diff --git a/app/Events/V3/Dashboard/Harim/PaymentExecutedEvent.php b/app/Events/V3/Dashboard/Harim/PaymentExecutedEvent.php new file mode 100644 index 00000000..36cd5c8c --- /dev/null +++ b/app/Events/V3/Dashboard/Harim/PaymentExecutedEvent.php @@ -0,0 +1,18 @@ +successResponse(); } } diff --git a/app/Http/Controllers/V3/Dashboard/RoadMaintenanceStationController.php b/app/Http/Controllers/V3/Dashboard/RoadMaintenanceStationController.php index 01f05b43..e9de71e6 100644 --- a/app/Http/Controllers/V3/Dashboard/RoadMaintenanceStationController.php +++ b/app/Http/Controllers/V3/Dashboard/RoadMaintenanceStationController.php @@ -223,4 +223,9 @@ class RoadMaintenanceStationController extends Controller allowedSelects: ['id', 'lat', 'lng', 'status', 'type'], )); } + + public function giveListToFms() + { + return $this->successResponse(RahdariPoint::all(['id', 'name', 'lat', 'lng', 'area'])); + } } diff --git a/app/Listeners/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedListener.php b/app/Listeners/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedListener.php index 9a11afc0..69dd473d 100644 --- a/app/Listeners/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedListener.php +++ b/app/Listeners/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedListener.php @@ -3,9 +3,9 @@ namespace App\Listeners\V3\Dashboard\Harim; use App\Events\V3\Dashboard\Harim\ConfirmGuaranteeLetterNeedEvent; +use App\Services\PanjarehVahed\SendAccessRoadStatusService; +use Exception; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Http\Client\RequestException; -use Illuminate\Support\Facades\Http; class ConfirmGuaranteeLetterNeedListener implements ShouldQueue { @@ -16,38 +16,14 @@ class ConfirmGuaranteeLetterNeedListener implements ShouldQueue */ public ?string $queue = 'harim'; - protected string $url; - protected string $password; - protected string $username; - - public function __construct() - { - $this->url = config('harim_web_services.Guarantee_Letter_Need.url'); - $this->username = config('harim_web_services.Guarantee_Letter_Need.username'); - $this->password = config('harim_web_services.Guarantee_Letter_Need.password'); - } + public function __construct(){} /** - * @throws RequestException + * @throws Exception */ - public function handle(ConfirmGuaranteeLetterNeedEvent $event): void + public function handle(ConfirmGuaranteeLetterNeedEvent $event, SendAccessRoadStatusService $sendAccessRoadStatusService): void { - $encodedData = openssl_decrypt($event->harim->data); - - $data = [ - 'data' => [ - 'actionId' => $encodedData['actionId'], - 'ruleId' => $encodedData['ruleId'], - 'activityId' => $encodedData['activityId'], - 'requestId' => $encodedData['requestId'], - 'taskId' => $encodedData['taskId'], - 'code' => $encodedData['code'], - 'warrantStatus' => $encodedData['warrantStatus'], - 'amountPaid' => $encodedData['amountPaid'], - ], - 'token' => $encodedData['token'] - ]; - - Http::post($this->url, json_encode($data))->throw(); + $sendAccessRoadStatusService->makeInputParameters($event->harim->data); + $sendAccessRoadStatusService->run(); } } diff --git a/app/Listeners/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedListener.php b/app/Listeners/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedListener.php index 74ec1676..6161f4bc 100644 --- a/app/Listeners/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedListener.php +++ b/app/Listeners/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedListener.php @@ -3,9 +3,9 @@ namespace App\Listeners\V3\Dashboard\Harim; use App\Events\V3\Dashboard\Harim\ConfirmNoRoadAccessNeedEvent; +use App\Services\PanjarehVahed\SendAccessRoadStatusService; +use Exception; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Http\Client\RequestException; -use Illuminate\Support\Facades\Http; class ConfirmNoRoadAccessNeedListener implements ShouldQueue { @@ -16,38 +16,14 @@ class ConfirmNoRoadAccessNeedListener implements ShouldQueue */ public ?string $queue = 'harim'; - protected string $url; - protected string $password; - protected string $username; - - public function __construct() - { - $this->url = config('harim_web_services.No_Need_Access.url'); - $this->username = config('harim_web_services.No_Need_Access.username'); - $this->password = config('harim_web_services.No_Need_Access.password'); - } + public function __construct(){} /** - * @throws RequestException + * @throws Exception */ - public function handle(ConfirmNoRoadAccessNeedEvent $event): void + public function handle(ConfirmNoRoadAccessNeedEvent $event, SendAccessRoadStatusService $sendAccessRoadStatusService): void { - $encodedData = openssl_decrypt($event->harim->data); - - $data = [ - 'data' => [ - 'actionId' => $encodedData['actionId'], - 'ruleId' => $encodedData['ruleId'], - 'activityId' => $encodedData['activityId'], - 'requestId' => $encodedData['requestId'], - 'taskId' => $encodedData['taskId'], - 'code' => $encodedData['code'], - 'resultStatus' => $encodedData['resultStatus'], - 'Description' => $encodedData['Description'], - ], - 'token' => $encodedData['token'] - ]; - - Http::post($this->url, json_encode($data))->throw(); + $sendAccessRoadStatusService->makeInputParameters($event->harim->data); + $sendAccessRoadStatusService->run(); } } diff --git a/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedListener.php b/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedListener.php index cf77c02f..81844a0b 100644 --- a/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedListener.php +++ b/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedListener.php @@ -3,9 +3,9 @@ namespace App\Listeners\V3\Dashboard\Harim; use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessEditNeedEvent; +use App\Services\PanjarehVahed\SendAccessRoadStatusService; +use Exception; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Http\Client\RequestException; -use Illuminate\Support\Facades\Http; class ConfirmRoadAccessEditNeedListener implements ShouldQueue { @@ -16,38 +16,14 @@ class ConfirmRoadAccessEditNeedListener implements ShouldQueue */ public ?string $queue = 'harim'; - protected string $url; - protected string $password; - protected string $username; - - public function __construct() - { - $this->url = config('harim_web_services.Edit_Need_Access.url'); - $this->username = config('harim_web_services.Edit_Need_Access.username'); - $this->password = config('harim_web_services.Edit_Need_Access.password'); - } + public function __construct(){} /** - * @throws RequestException + * @throws Exception */ - public function handle(ConfirmRoadAccessEditNeedEvent $event): void + public function handle(ConfirmRoadAccessEditNeedEvent $event, SendAccessRoadStatusService $sendAccessRoadStatusService): void { - $encodedData = openssl_decrypt($event->harim->data); - - $data = [ - 'data' => [ - 'actionId' => $encodedData['actionId'], - 'ruleId' => $encodedData['ruleId'], - 'activityId' => $encodedData['activityId'], - 'requestId' => $encodedData['requestId'], - 'taskId' => $encodedData['taskId'], - 'code' => $encodedData['code'], - 'resultStatus' => $encodedData['resultStatus'], - 'Description' => $encodedData['Description'], - ], - 'token' => $encodedData['token'] - ]; - - Http::post($this->url, json_encode($data))->throw(); + $sendAccessRoadStatusService->makeInputParameters($event->harim->data); + $sendAccessRoadStatusService->run(); } } diff --git a/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessNeedListener.php b/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessNeedListener.php index ce54b281..60104829 100644 --- a/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessNeedListener.php +++ b/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessNeedListener.php @@ -3,9 +3,9 @@ namespace App\Listeners\V3\Dashboard\Harim; use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessNeedEvent; +use App\Services\PanjarehVahed\SendAccessRoadStatusService; +use Exception; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Http\Client\RequestException; -use Illuminate\Support\Facades\Http; class ConfirmRoadAccessNeedListener implements ShouldQueue { @@ -16,40 +16,16 @@ class ConfirmRoadAccessNeedListener implements ShouldQueue */ public ?string $queue = 'harim'; - protected string $url; - protected string $password; - protected string $username; - - public function __construct() - { - $this->url = config('harim_web_services.Need_Access.url'); - $this->username = config('harim_web_services.Need_Access.username'); - $this->password = config('harim_web_services.Need_Access.password'); - } + public function __construct(){} /** * Handle the event. - * @throws RequestException + * @throws Exception */ - public function handle(ConfirmRoadAccessNeedEvent $event): void + public function handle(ConfirmRoadAccessNeedEvent $event, SendAccessRoadStatusService $sendAccessRoadStatusService): void { - $encodedData = openssl_decrypt($event->harim->data); - - $data = [ - 'data' => [ - 'actionId' => $encodedData['actionId'], - 'ruleId' => $encodedData['ruleId'], - 'activityId' => $encodedData['activityId'], - 'requestId' => $encodedData['requestId'], - 'taskId' => $encodedData['taskId'], - 'code' => $encodedData['code'], - 'resultStatus' => $encodedData['resultStatus'], - 'Description' => $encodedData['Description'], - ], - 'token' => $encodedData['token'] - ]; - - Http::post($this->url, json_encode($data))->throw(); + $sendAccessRoadStatusService->makeInputParameters($event->harim->data); + $sendAccessRoadStatusService->run(); } } diff --git a/app/Listeners/V3/Dashboard/Harim/PaymentExecutedListener.php b/app/Listeners/V3/Dashboard/Harim/PaymentExecutedListener.php new file mode 100644 index 00000000..69a5234c --- /dev/null +++ b/app/Listeners/V3/Dashboard/Harim/PaymentExecutedListener.php @@ -0,0 +1,30 @@ +makeInputParameters($event->harim->data); + $sendPaymentInfoService->run(); + } +} diff --git a/app/Listeners/V3/Dashboard/Harim/RejectRequestListener.php b/app/Listeners/V3/Dashboard/Harim/RejectRequestListener.php index 0d5a1da7..84534c51 100644 --- a/app/Listeners/V3/Dashboard/Harim/RejectRequestListener.php +++ b/app/Listeners/V3/Dashboard/Harim/RejectRequestListener.php @@ -3,9 +3,9 @@ namespace App\Listeners\V3\Dashboard\Harim; use App\Events\V3\Dashboard\Harim\RejectRequestEvent; +use App\Services\PanjarehVahed\SendAccessRoadStatusService; +use Exception; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Http\Client\RequestException; -use Illuminate\Support\Facades\Http; class RejectRequestListener implements ShouldQueue { @@ -16,38 +16,14 @@ class RejectRequestListener implements ShouldQueue */ public ?string $queue = 'harim'; - protected string $url; - protected string $password; - protected string $username; - - public function __construct() - { - $this->url = config('harim_web_services.Reject.url'); - $this->username = config('harim_web_services.Reject.username'); - $this->password = config('harim_web_services.Reject.password'); - } + public function __construct(){} /** - * @throws RequestException + * @throws Exception */ - public function handle(RejectRequestEvent $event): void + public function handle(RejectRequestEvent $event, SendAccessRoadStatusService $sendAccessRoadStatusService): void { - $encodedData = openssl_decrypt($event->harim->data); - - $data = [ - 'data' => [ - 'actionId' => $encodedData['actionId'], - 'ruleId' => $encodedData['ruleId'], - 'activityId' => $encodedData['activityId'], - 'requestId' => $encodedData['requestId'], - 'taskId' => $encodedData['taskId'], - 'code' => $encodedData['code'], - 'resultStatus' => $encodedData['resultStatus'], - 'Description' => $encodedData['Description'], - ], - 'token' => $encodedData['token'] - ]; - - Http::post($this->url, json_encode($data))->throw(); + $sendAccessRoadStatusService->makeInputParameters($event->harim->data); + $sendAccessRoadStatusService->run(); } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 16c73d00..ff703422 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -6,12 +6,14 @@ use App\Events\V3\Dashboard\Harim\ConfirmGuaranteeLetterNeedEvent; use App\Events\V3\Dashboard\Harim\ConfirmNoRoadAccessNeedEvent; use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessEditNeedEvent; use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessNeedEvent; +use App\Events\V3\Dashboard\Harim\PaymentExecutedEvent; use App\Events\V3\Dashboard\Harim\RejectRequestEvent; use App\Events\V3\Dashboard\Mission\SendDataToFMSEvent; use App\Listeners\V3\Dashboard\Harim\ConfirmGuaranteeLetterNeedListener; use App\Listeners\V3\Dashboard\Harim\ConfirmNoRoadAccessNeedListener; use App\Listeners\V3\Dashboard\Harim\ConfirmRoadAccessEditNeedListener; use App\Listeners\V3\Dashboard\Harim\ConfirmRoadAccessNeedListener; +use App\Listeners\V3\Dashboard\Harim\PaymentExecutedListener; use App\Listeners\V3\Dashboard\Harim\RejectRequestListener; use App\Listeners\V3\Dashboard\Mission\SendDataToFMSListener; use Illuminate\Auth\Events\Registered; @@ -55,7 +57,10 @@ class EventServiceProvider extends ServiceProvider ], SendDataToFMSEvent::class => [ SendDataToFMSListener::class - ] + ], + PaymentExecutedEvent::class => [ + PaymentExecutedListener::class + ], ]; /** diff --git a/app/Services/PanjarehVahed/SendAccessRoadStatusService.php b/app/Services/PanjarehVahed/SendAccessRoadStatusService.php new file mode 100644 index 00000000..c9704dcd --- /dev/null +++ b/app/Services/PanjarehVahed/SendAccessRoadStatusService.php @@ -0,0 +1,74 @@ +url = config('harim_web_services.Reject.url'); + $this->channelName = ''; + } + + /** + * @throws Exception + */ + public function run(): array + { + try { + return $this->sendRequest(); + } + catch (Exception $e) { + Log::channel($this->channelName) + ->error(get_class($this), + [ + 'message' => $e->getMessage(), + ] + ); + + throw $e; + } + } + + private function sendRequest(): array + { + return Http::withHeaders(['Content-Type' => 'application/json']) + ->withBody($this->inputParameters) + ->throw() + ->withoutVerifying() + ->post($this->url) + ->json(); + } + + public function makeInputParameters($data): void + { + $arrayData = json_decode($data, true); + + $inputParameters = [ + 'data' => [ + 'actionId' => $arrayData['actionId'], + 'ruleId' => $arrayData['ruleId'], + 'activityId' => $arrayData['activityId'], + 'requestId' => $arrayData['requestId'], + 'taskId' => $arrayData['taskId'], + 'code' => $arrayData['code'], + 'resultStatus' => $arrayData['resultStatus'], + 'Description' => $arrayData['Description'], + ], + 'token' => $arrayData['token'], + ]; + + $key = config('harim_web_services.Harim_Info.key'); + $iv = config('harim_web_services.Harim_Info.iv'); + + $this->inputParameters = openssl_encrypt(json_encode($inputParameters), 'aes-256-cbc', $key, false, $iv); + } +} \ No newline at end of file diff --git a/app/Services/PanjarehVahed/SendPaymentInfoService.php b/app/Services/PanjarehVahed/SendPaymentInfoService.php new file mode 100644 index 00000000..cfd09b97 --- /dev/null +++ b/app/Services/PanjarehVahed/SendPaymentInfoService.php @@ -0,0 +1,74 @@ +url = config('harim_web_services.Reject.url'); + $this->channelName = ''; + } + + /** + * @throws Exception + */ + public function run(): array + { + try { + return $this->sendRequest(); + } + catch (Exception $e) { + Log::channel($this->channelName) + ->error(get_class($this), + [ + 'message' => $e->getMessage(), + ] + ); + + throw $e; + } + } + + private function sendRequest(): array + { + return Http::withHeaders(['Content-Type' => 'application/json']) + ->withBody($this->inputParameters) + ->throw() + ->withoutVerifying() + ->post($this->url) + ->json(); + } + + public function makeInputParameters($data): void + { + $arrayData = json_decode($data, true); + + $inputParameters = [ + 'data' => [ + 'actionId' => $arrayData['actionId'], + 'ruleId' => $arrayData['ruleId'], + 'activityId' => $arrayData['activityId'], + 'requestId' => $arrayData['requestId'], + 'taskId' => $arrayData['taskId'], + 'code' => $arrayData['code'], + 'warrantStatus' => $arrayData['warrantStatus'], + 'amountPaid' => $arrayData['amountPaid'], + ], + 'token' => $arrayData['token'], + ]; + + $key = config('harim_web_services.Harim_Info.key'); + $iv = config('harim_web_services.Harim_Info.iv'); + + $this->inputParameters = openssl_encrypt(json_encode($inputParameters), 'aes-256-cbc', $key, false, $iv); + } +} \ No newline at end of file diff --git a/routes/v3.php b/routes/v3.php index a06507fa..9fde0fa9 100644 --- a/routes/v3.php +++ b/routes/v3.php @@ -472,6 +472,7 @@ Route::prefix('road_maintenance_station') Route::get('/', 'index')->name('index')->middleware('permission:show-tollhouse|show-tollhouse-province'); Route::post('/', 'store')->name('store'); Route::get('/map', 'map')->name('map'); + Route::get('/list', 'giveListToFms')->name('giveListToFms'); Route::get('/images/{rahdariPoint}', 'images')->name('images'); Route::get('/{rahdariPoint}', 'show')->name('show')->middleware('permission:show-tollhouse|show-tollhouse-province'); Route::post('/{rahdariPoint}', 'update')->name('update')->middleware('permission:edit-tollhouse|edit-tollhouse-province');