shish 3 лет назад
Родитель
Сommit
7e7dc03373

+ 13 - 1
app-hd/controllers/PurchaseController.php

@@ -105,7 +105,19 @@ class PurchaseController extends BaseController
             $ghsInfo['miniKilo'] = $ghsShopInfo->miniKilo ?? 0;
 
             $post['product'] = $productList;
-            $post['sendCost'] = isset($post['sendCost']) && is_numeric($post['sendCost']) ? $post['sendCost'] : 0;
+
+            $sendType = $post['sendType'] ?? 1;
+            $sendCost = 0;
+            if ($sendType == 3) {
+                $weight = 0;
+                foreach ($productList as $itemData) {
+                    $currentWeight = $itemData['weight'] ?? 0;
+                    $weight = bcadd($currentWeight, $weight, 2);
+                }
+                $result = PurchaseClass::getDistanceFee($this->shop, $ghsShopInfo, $weight);
+                $sendCost = $result['fee'] ?? 0;
+            }
+            $post['sendCost'] = $sendCost;
 
             $respond = PurchaseService::createPurchase($post, $ghsInfo);
             $transaction->commit();

+ 1 - 6
biz-hd/purchase/services/PurchaseService.php

@@ -56,12 +56,7 @@ class PurchaseService extends BaseService
         $purchaseId = $respond->id ?? 0;
         $shopAdminId = $data['shopAdminId'] ?? 0;
         $shopAdminName = $data['shopAdminName'] ?? '';
-        //客户采购时选了自取,则供货商的销售单就是自取
-        $sendType = OrderClass::SEND_TYPE_UNKNOWN;
-        $getType = $data['getType'] ?? PurchaseClass::GET_TYPE_SELF_GET;
-        if ($getType == PurchaseClass::GET_TYPE_SELF_GET) {
-            $sendType = OrderClass::SEND_TYPE_NO;
-        }
+        $sendType = $data['sendType'] ?? 1;
         $couponId = $data['couponId'] ?? 0;
         $discountType = $respond->discountType ?? dict::getDict('discountType', 'noDiscount');
         $discountAmount = $respond->discountAmount ?? 0;