From ed637739cc06d8591e058ec7cd27f3a997ac89b1 Mon Sep 17 00:00:00 2001 From: Fairuz Date: Mon, 27 Sep 2021 09:48:00 +0800 Subject: [PATCH] Inbound custom cleared --- .../Processors/CreateOrderRolesProcessor.php | 1 + .../Containers/InboundCustomClearedLogic.php | 66 +++++++++++ .../FetchInboundCustomClearedProcessor.php | 105 ++++++++++++++++++ .../InboundCustomClearedController.php | 20 ++++ resources/views/swagger/json.blade.php | 50 ++++++++- routes/packing_list.php | 2 + 6 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 app/Classes/Modules/PackingLists/ControllersLogic/Containers/InboundCustomClearedLogic.php create mode 100644 app/Classes/Modules/PackingLists/Processors/FetchInboundCustomClearedProcessor.php create mode 100644 app/Http/Controllers/PackingLists/Containers/InboundCustomClearedController.php diff --git a/app/Classes/Modules/Orders/Processors/CreateOrderRolesProcessor.php b/app/Classes/Modules/Orders/Processors/CreateOrderRolesProcessor.php index 0d4b1860..24495752 100644 --- a/app/Classes/Modules/Orders/Processors/CreateOrderRolesProcessor.php +++ b/app/Classes/Modules/Orders/Processors/CreateOrderRolesProcessor.php @@ -79,6 +79,7 @@ class CreateOrderRolesProcessor $roleObject = new OrderRoleObject($order, $destinationWarehouse, OrderRoleTypes::DESTINATION_WAREHOUSE); $this->createsOrderRole->execute($roleObject); + $roleObject = new OrderRoleObject($order, $freightForwarder, OrderRoleTypes::LAST_MILE_DELIVERY_DRIVER); $this->createsOrderRole->execute($roleObject); diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/Containers/InboundCustomClearedLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/InboundCustomClearedLogic.php new file mode 100644 index 00000000..1df92ffa --- /dev/null +++ b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/InboundCustomClearedLogic.php @@ -0,0 +1,66 @@ + 'Retrieved Containers', + 'message' => 'You have successfully retrieved a list of Containers' + ]; + } + + /** @var CanListContainers */ + private $canListContainers; + + /** @var ListsContainers */ + private $listsContainers; + + private $fetchInboundCustomCleared; + + /** + * ListContainersLogic constructor. + * @param CanListContainers $canListContainers + * @param ListsContainers $listsContainers + */ + public function __construct(CanListContainers $canListContainers, ListsContainers $listsContainers, FetchInboundCustomClearedProcessor $fetchInboundCustomCleared) + { + $this->canListContainers = $canListContainers; + $this->listsContainers = $listsContainers; + $this->fetchInboundCustomCleared = $fetchInboundCustomCleared; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + //$this->canListOrders->passes(); + + //$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true])); + + $d = $this->fetchInboundCustomCleared->execute(); + + return response()->json($d); + + } +} diff --git a/app/Classes/Modules/PackingLists/Processors/FetchInboundCustomClearedProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchInboundCustomClearedProcessor.php new file mode 100644 index 00000000..b4ea6395 --- /dev/null +++ b/app/Classes/Modules/PackingLists/Processors/FetchInboundCustomClearedProcessor.php @@ -0,0 +1,105 @@ +fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal; + $this->createsTransport = $createsTransport; + $this->createsSchedule = $createsSchedule; + $this->updatesContractObligations = $updatesContractObligations; + } + + + /** + * @return array + */ + public function execute(){ + + $packingLists = PackingList::query()->with(['steps' => function ($query) { + $query->where('steps.status', '<>', 3); + }])->first(); + dd($packingLists); + /* + $packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST) + ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::SUSPENDED])->get(); + + foreach($packingLists as $packingList){ + try { + $filter = '["PoNumber:=%js%\"'.$packingList->reference.'\"\u0000"]'; + + $shippingPackingListsRequest = $this->fetchesDataFRomVTPortal->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), ''); + + $shippingPackingLists = $this->fetchesDataFRomVTPortal->getResponseBody($shippingPackingListsRequest); + + $shippingPackingList = $shippingPackingLists->Rows[0]; + + if(!$shippingPackingList[9] && !$shippingPackingList[10]) { + continue; + } + + $packingList->status = ApprovalStatus::COMPLETED; + $packingList->save(); + + $deliveryDate = Carbon::parse($shippingPackingList[9] ? $shippingPackingList[9]:$shippingPackingList[10]); + $transportObject = new TransportObject(TransportType::LAND, null, null, $deliveryDate, $deliveryDate, ApprovalStatus::APPROVED); + $transport = $this->createsTransport->execute($transportObject, $packingList); + $this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED)); + + $deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first(); + $signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture; + $this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id); + $deliveryStep->update(['status' => ApprovalStatus::COMPLETED]); + + } catch (GuzzleException $exception) { + continue; + } + + }*/ + + + return []; + + } + + +} diff --git a/app/Http/Controllers/PackingLists/Containers/InboundCustomClearedController.php b/app/Http/Controllers/PackingLists/Containers/InboundCustomClearedController.php new file mode 100644 index 00000000..303ea5dc --- /dev/null +++ b/app/Http/Controllers/PackingLists/Containers/InboundCustomClearedController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} diff --git a/resources/views/swagger/json.blade.php b/resources/views/swagger/json.blade.php index 4fa056ef..cd4df686 100644 --- a/resources/views/swagger/json.blade.php +++ b/resources/views/swagger/json.blade.php @@ -107,6 +107,54 @@ } } }, + "/packing_list/container/inbound-custom-cleared": { + "get": { + "tags": [ + "Packing" + ], + "produces": [ + "application/json" + ], + "operationId": "listPackingIn", + "summary": "List packing", + "description": "", + "parameters": [ + { + "name": "filter", + "in": "query", + "description": "Filters", + "required": false, + "type": "array", + "items": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "headers": { + "X-Expires-After": { + "type": "string", + "format": "date-time", + "description": "date in UTC when token expires" + }, + "X-Rate-Limit": { + "type": "integer", + "format": "int32", + "description": "calls per hour allowed by the user" + } + }, + "schema": { + "type": "string" + } + }, + "422": { + "description": "Invalid input supplied" + } + } + } + }, "/packing_list/list": { "get": { "tags": [ @@ -2982,7 +3030,7 @@ } } }, - "/account/registration/registration": { + "/account/registration": { "post": { "tags": [ "Account", diff --git a/routes/packing_list.php b/routes/packing_list.php index ea64c7e1..11fc87ec 100644 --- a/routes/packing_list.php +++ b/routes/packing_list.php @@ -16,6 +16,8 @@ Route::group(['namespace' => 'PackingLists', 'as' => 'packing_list.', 'prefix' = Route::post('/create', 'CreateContainerController@create')->name('create'); Route::put('/update/{id}', 'UpdateContainerController@update')->name('update'); Route::delete('/delete/{id}', 'DeleteContainerController@delete')->name('delete'); + + Route::get('/inbound-custom-cleared', 'InboundCustomClearedController@list')->name('list.inbound.custom.cleared'); }); Route::group(['namespace' => 'Packages', 'as' => 'package.', 'prefix' => 'package'], function () {