From 1854ca24de2adcbf91e10d46cb0f0b27177a7a8d Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 19 Jan 2022 13:29:26 +0800 Subject: [PATCH] fix yd order number bug --- .../FetchOrderListsFromYdPortalProcessor.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php index f3f239d3..11ee4454 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php @@ -153,7 +153,6 @@ class FetchOrderListsFromYdPortalProcessor ]); $rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest); - foreach($rows->data as $row){ $containerReference = null; @@ -166,6 +165,7 @@ class FetchOrderListsFromYdPortalProcessor 'trakingno' => $row->expressno ]); $rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest); + foreach ($rows->data as $trackingRow) { if($trackingRow->tracking === '货物已送达仓库准备入库中'){ $receiveDate = Carbon::parse($trackingRow->trackingtime); @@ -186,20 +186,16 @@ class FetchOrderListsFromYdPortalProcessor $customerno = preg_split('(-|\(|\)|\/)', $row->customerno); - if (!array_key_exists(2, $customerno)){ - if (!array_key_exists(1, $customerno)){ - continue; - } - $customerno[2] = substr($customerno[1], -9); - } - - - $orderNumber = $customerno[2]; + $orderNumber = $customerno[array_key_last($customerno)]; try { $order = $this->fetchesOrder->execute(['reference' => $orderNumber]); } catch (ResourceNotFoundException $exception) { - continue; + try { + $order = $this->fetchesOrder->execute(['reference' => substr($orderNumber, -9)]); + } catch (ResourceNotFoundException $exception) { + continue; + } } $packingListReference = $row->expressno;