From 0555b4a536c66133c2d394a49be16beb3b0ea576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Fri, 25 Aug 2023 18:38:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20#10000=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Shop/ShipController.php | 2 +- app/Services/Ship/WayBillService.php | 26 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/Shop/ShipController.php b/app/Http/Controllers/Shop/ShipController.php index db69a30..c043d02 100644 --- a/app/Http/Controllers/Shop/ShipController.php +++ b/app/Http/Controllers/Shop/ShipController.php @@ -60,6 +60,6 @@ class ShipController extends Controller $sender->save(); } - return response(['message' =>'保存成功']); + return response(['message' => '保存成功']); } } diff --git a/app/Services/Ship/WayBillService.php b/app/Services/Ship/WayBillService.php index 8f17a3e..a42a081 100644 --- a/app/Services/Ship/WayBillService.php +++ b/app/Services/Ship/WayBillService.php @@ -29,12 +29,12 @@ class WayBillService $contents = []; foreach ($this->orders as $shopId => $order) { // 订单取消的情况暂不处理 - $shop = $this->getShop($shopId); + $shopShip = $this->getShopShip($shopId); $faceSheet = new FaceSheet(); - $faceSheet->setShop($shop); + $faceSheet->setShop($shopShip); foreach ($order as $item) { - [$sender, $orderInfo, $wpCode] = $this->prepareRequest($item, $shop); - $waybill = $this->saveWayBill($item, $shop); + [$sender, $orderInfo, $wpCode] = $this->prepareRequest($item, $shopShip); + $waybill = $this->saveWayBill($item, $shopShip); if (empty($waybill->id)) { $resp = $faceSheet->getWayBill($sender, $orderInfo, $wpCode); @@ -150,7 +150,7 @@ class WayBillService return $waybill; } - private function timedDelivery($order) + private function getTimedDelivery($orderItem) { $this->timedDeliveryCode = Waybill::$BUSINESS_EXPRESS_CODE; $address = [ @@ -166,20 +166,20 @@ class WayBillService '西宁市', '海东市', '海北藏族自治州', '黄南藏族自治州', '海南藏族自治州', '玉树藏族自治州' ], ]; - if (isset($address[$order['recipient_province']])) { - if (empty($address[$order['recipient_province']])) { + if (isset($address[$orderItem['recipient_province']])) { + if (empty($address[$orderItem['recipient_province']])) { $this->timedDeliveryCode = Waybill::$AIR_FREIGHT_CODE; } - if ($address[$order['recipient_province']] && in_array($order['recipient_city'], $address[$order['recipient_province']], true)) { + if ($address[$orderItem['recipient_province']] && in_array($orderItem['recipient_city'], $address[$orderItem['recipient_province']], true)) { $this->timedDeliveryCode = Waybill::$AIR_FREIGHT_CODE; } } } - private function prepareRequest($order, $shop) + private function prepareRequest($order, $shopShip) { - $this->timedDelivery($order); - $senderConfig = $shop->senders[0]; + $this->getTimedDelivery($order); + $senderConfig = $shopShip->senders[0]; $sender = [ 'address' => [ 'city' => $senderConfig['city'], @@ -234,7 +234,7 @@ class WayBillService 'mobile' => $order['recipient_mobile'], ], 'template_url' => $this->sfOne, - 'user_id' => $shop->owner_id, + 'user_id' => $shopShip->owner_id, ]; return [$sender, $orderInfo, $senderConfig['wp_code']]; @@ -329,7 +329,7 @@ class WayBillService return $this; } - private function getShop($shopId) + private function getShopShip($shopId) { return ShopShip::query() ->select(['id', 'shop_id', 'access_token', 'owner_id'])