feat: #10000 更新

This commit is contained in:
赵世界 2023-08-25 18:38:07 +08:00
parent 7baa81ec71
commit 0555b4a536
2 changed files with 14 additions and 14 deletions

View File

@ -29,12 +29,12 @@ class WayBillService
$contents = []; $contents = [];
foreach ($this->orders as $shopId => $order) { foreach ($this->orders as $shopId => $order) {
// 订单取消的情况暂不处理 // 订单取消的情况暂不处理
$shop = $this->getShop($shopId); $shopShip = $this->getShopShip($shopId);
$faceSheet = new FaceSheet(); $faceSheet = new FaceSheet();
$faceSheet->setShop($shop); $faceSheet->setShop($shopShip);
foreach ($order as $item) { foreach ($order as $item) {
[$sender, $orderInfo, $wpCode] = $this->prepareRequest($item, $shop); [$sender, $orderInfo, $wpCode] = $this->prepareRequest($item, $shopShip);
$waybill = $this->saveWayBill($item, $shop); $waybill = $this->saveWayBill($item, $shopShip);
if (empty($waybill->id)) { if (empty($waybill->id)) {
$resp = $faceSheet->getWayBill($sender, $orderInfo, $wpCode); $resp = $faceSheet->getWayBill($sender, $orderInfo, $wpCode);
@ -150,7 +150,7 @@ class WayBillService
return $waybill; return $waybill;
} }
private function timedDelivery($order) private function getTimedDelivery($orderItem)
{ {
$this->timedDeliveryCode = Waybill::$BUSINESS_EXPRESS_CODE; $this->timedDeliveryCode = Waybill::$BUSINESS_EXPRESS_CODE;
$address = [ $address = [
@ -166,20 +166,20 @@ class WayBillService
'西宁市', '海东市', '海北藏族自治州', '黄南藏族自治州', '海南藏族自治州', '玉树藏族自治州' '西宁市', '海东市', '海北藏族自治州', '黄南藏族自治州', '海南藏族自治州', '玉树藏族自治州'
], ],
]; ];
if (isset($address[$order['recipient_province']])) { if (isset($address[$orderItem['recipient_province']])) {
if (empty($address[$order['recipient_province']])) { if (empty($address[$orderItem['recipient_province']])) {
$this->timedDeliveryCode = Waybill::$AIR_FREIGHT_CODE; $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; $this->timedDeliveryCode = Waybill::$AIR_FREIGHT_CODE;
} }
} }
} }
private function prepareRequest($order, $shop) private function prepareRequest($order, $shopShip)
{ {
$this->timedDelivery($order); $this->getTimedDelivery($order);
$senderConfig = $shop->senders[0]; $senderConfig = $shopShip->senders[0];
$sender = [ $sender = [
'address' => [ 'address' => [
'city' => $senderConfig['city'], 'city' => $senderConfig['city'],
@ -234,7 +234,7 @@ class WayBillService
'mobile' => $order['recipient_mobile'], 'mobile' => $order['recipient_mobile'],
], ],
'template_url' => $this->sfOne, 'template_url' => $this->sfOne,
'user_id' => $shop->owner_id, 'user_id' => $shopShip->owner_id,
]; ];
return [$sender, $orderInfo, $senderConfig['wp_code']]; return [$sender, $orderInfo, $senderConfig['wp_code']];
@ -329,7 +329,7 @@ class WayBillService
return $this; return $this;
} }
private function getShop($shopId) private function getShopShip($shopId)
{ {
return ShopShip::query() return ShopShip::query()
->select(['id', 'shop_id', 'access_token', 'owner_id']) ->select(['id', 'shop_id', 'access_token', 'owner_id'])