fix yd fetch data

This commit is contained in:
omair saleh
2022-01-04 20:50:04 +08:00
parent f608bb54f0
commit ce6e6be2bf
@@ -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);