From 5d3d2bd973c202e4db6e28f701c87abb1bd4ca06 Mon Sep 17 00:00:00 2001 From: faezehzafarbakhsh Date: Mon, 15 Dec 2025 12:03:15 +0330 Subject: [PATCH] improve service --- .env.example | 4 +++- .../TransportaionUnit/AllocateRequest.php | 6 +++--- .../Cartables/Harim/HarimPaymentService.php | 18 ++++++++++-------- config/harim_web_services.php | 3 ++- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.env.example b/.env.example index 8daaa305..f9adb344 100644 --- a/.env.example +++ b/.env.example @@ -53,7 +53,9 @@ PAYMENT_LINK= HARIM_PAYMENT_USERNAME= HARIM_PAYMENT_PASSWORD= HARIM_PAYMENT_URL= -HARIM_PAYMENT_LINK= +HARIM_PAYMENT_SERIAL= +HARIM_PAYMENT_INSTANCE_ID= + RMS_VERSION=3.0 RMS_CTO_PHONE_NUMBER= diff --git a/app/Http/Requests/V3/Mission/TransportaionUnit/AllocateRequest.php b/app/Http/Requests/V3/Mission/TransportaionUnit/AllocateRequest.php index d5cc2956..de093022 100644 --- a/app/Http/Requests/V3/Mission/TransportaionUnit/AllocateRequest.php +++ b/app/Http/Requests/V3/Mission/TransportaionUnit/AllocateRequest.php @@ -36,13 +36,13 @@ class AllocateRequest extends FormRequest return [ function (Validator $validator) { $duplicateMission = Mission::query()->where('machine_id', '=', $this->machine_id) - ->whereBetween('start_date', [$this->mission->start_date, $this->mission->end_date]) - ->orWhereBetween('end_date', [$this->mission->start_date, $this->mission->end_date]) + ->where('start_date', '<=', $this->mission->end_date) + ->where('end_date', '>=', $this->mission->start_date) ->exists(); if ($duplicateMission) { $validator->errors()->add( - 'machine', + 'machine_id', 'خودروی مورد نظر در این زمان رزرو می باشد' ); } diff --git a/app/Services/Cartables/Harim/HarimPaymentService.php b/app/Services/Cartables/Harim/HarimPaymentService.php index 9b9a4f69..ef78b702 100644 --- a/app/Services/Cartables/Harim/HarimPaymentService.php +++ b/app/Services/Cartables/Harim/HarimPaymentService.php @@ -21,14 +21,16 @@ class HarimPaymentService 'username' => config('harim_web_services.Harim_Payment.username'), 'password' => config('harim_web_services.Harim_Payment.PASSWORD'), 'amount' => $payment_amount, - 'serial' => "12345", + 'serial' => config('harim_web_services.Harim_Payment.serial'), 'type' => 1, - 'instanceid' => 123, + 'instanceid' => config('harim_web_services.Harim_Payment.instanceid'), 'ownerid' => $national_id, 'calculationBox' => "{\"rows\":[{\"amount\":" . $payment_amount . ",\"code\":\"7070011026200593\"}]}" ); - $response = Http::retry(3, 100)->withBody(http_build_query($payload)) + $response = Http::withBody(http_build_query($payload)) + ->throw() + ->withoutVerifying() ->post(config('harim_web_services.Harim_Payment.url')); return $response->body(); @@ -52,12 +54,12 @@ class HarimPaymentService $result = "{$url}/{$username}/{$password}/{$bill_code}"; - $response = Http::timeout(10)->get($result); + return Http::get($result) + ->throw() + ->body(); - - return $response; - } catch (\Throwable $th) { - abort(500); + }catch (\Throwable $th) { + throw new ProhibitedAction('خطا در دریافت'); } } return json_encode(['isPayed' => 1]); diff --git a/config/harim_web_services.php b/config/harim_web_services.php index 6628fe54..8c377bf0 100644 --- a/config/harim_web_services.php +++ b/config/harim_web_services.php @@ -41,6 +41,7 @@ return [ 'username' => env('HARIM_ENCRYPTION_USERNAME'), 'password' => env('HARIM_ENCRYPTION_PASSWORD'), 'url' => env('HARIM_ENCRYPTION_URL'), - 'LINK' => env('HARIM_ENCRYPTION_LINK'), + 'serial' => env('HARIM_ENCRYPTION_SERIAL'), + 'instanceid' => env('HARIM_ENCRYPTION_INSTANCE_ID'), ] ];