From ce6e6be2bfd3deca4257295a57dbfd86fce483b1 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 4 Jan 2022 20:50:04 +0800 Subject: [PATCH] fix yd fetch data --- .../FetchOrderListsFromYdPortalProcessor.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php index 6859cb21..a72a1cf1 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php @@ -202,14 +202,14 @@ class FetchOrderListsFromYdPortalProcessor continue; } - DB::beginTransaction(); + $packingListReference = $row->expressno; try{ $packingList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::SHIPPING_PACKING_LIST]); } catch (ResourceNotFoundException $exception){ - + DB::beginTransaction(); $warehouseReceiveObject = new PackingListObject($packingListReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id, PackingListType::WAREHOUSE_RECEIVE_LIST, ApprovalStatus::APPROVED); /** @var PackingList $warehouseReceiveList */ $warehouseReceiveList = $this->createPackingListProcessor->execute($warehouseReceiveObject, $order); @@ -250,9 +250,11 @@ class FetchOrderListsFromYdPortalProcessor $this->createPackageProcessor->execute($packageObject, $warehouseReceiveList); $this->createPackageProcessor->execute($packageObject, $packingList); } + DB::commit(); } if($containerReference) { + DB::beginTransaction(); try { $container = $this->fetchesContainer->execute(['reference' => $containerReference]); } catch (ResourceNotFoundException $exception){ @@ -264,7 +266,7 @@ class FetchOrderListsFromYdPortalProcessor $container->packingLists()->detach($packingList); $container->packingLists()->attach($packingList); -dump($container->packingLists); + $transport = $container->transports()->first(); if(!$transport){ @@ -274,7 +276,10 @@ dump($container->packingLists); $this->createsSchedule->execute($transport, new ScheduleObject($etd, $eta, ApprovalStatus::APPROVED)); } + DB::commit(); + if($unstuffingDate && $container->status !== ApprovalStatus::COMPLETED){ + DB::beginTransaction(); $container->update(['status' => ApprovalStatus::COMPLETED]); $container->transports()->first()->update(['drop_date' => $unstuffingDate, 'status' => ApprovalStatus::COMPLETED]); @@ -292,13 +297,12 @@ dump($container->packingLists); $step->update(['status' => ApprovalStatus::COMPLETED]); } } + DB::commit(); } } - DB::commit(); - } } catch (\Exception $exception) { Log::debug($exception);