Ver código fonte

修复业务逻辑不全面与接口实现补充

shizhongqi 8 meses atrás
pai
commit
f35dc59b24

+ 6 - 8
app-hd/controllers/DeliveryController.php

@@ -45,7 +45,7 @@ class DeliveryController extends BaseController
         util::success(['platformList'=>$platformList]);
         util::success(['platformList'=>$platformList]);
     }
     }
 
 
-    // 花店发货 -- 获取多个平台报价
+    // 花店发货 -- 获取多个平台报价
     public function actionHdAllDeliveryQuotes()
     public function actionHdAllDeliveryQuotes()
     {
     {
         $post = Yii::$app->request->post();
         $post = Yii::$app->request->post();
@@ -67,7 +67,6 @@ class DeliveryController extends BaseController
         if(isset($platformQuotes['error'])){
         if(isset($platformQuotes['error'])){
             util::fail($platformQuotes['error']);
             util::fail($platformQuotes['error']);
         }
         }
-
         // 格式化各平台报价为前端展示格式
         // 格式化各平台报价为前端展示格式
         $deliveryList = $ds->formatPlatformQuotesForDisplay($platformQuotes);
         $deliveryList = $ds->formatPlatformQuotesForDisplay($platformQuotes);
         // 按 price 从低到高排序
         // 按 price 从低到高排序
@@ -77,7 +76,7 @@ class DeliveryController extends BaseController
         util::success($ret, "success");
         util::success($ret, "success");
     }
     }
 
 
-    // 花店向批发买花 -- 获取多个平台报价
+    // 花店向批发买花 -- 获取多个平台报价
     public function actionAllDeliveryQuotes()
     public function actionAllDeliveryQuotes()
     {
     {
         $post = Yii::$app->request->post();
         $post = Yii::$app->request->post();
@@ -92,11 +91,10 @@ class DeliveryController extends BaseController
 
 
         // --------- $customId
         // --------- $customId
         $customId = $ghs->customId ?? 0;
         $customId = $ghs->customId ?? 0;
-        $custom = CustomClass::getById($customId, true);
+        $custom = CustomClass::getById($customId, true); // 批发的 custom
         if (empty($custom)) {
         if (empty($custom)) {
             util::fail('获取custom数据失败');
             util::fail('获取custom数据失败');
         }
         }
-        $weight = $post['weight'] ?? 1;
 
 
         // 生成随机订单号
         // 生成随机订单号
         $prefix = 'XSD_CS-' . $ghs->mainId . '-';
         $prefix = 'XSD_CS-' . $ghs->mainId . '-';
@@ -114,10 +112,10 @@ class DeliveryController extends BaseController
             'long' => $custom['long'],
             'long' => $custom['long'],
             'address' => $custom['address'], //'toAddress' => $order['address'],
             'address' => $custom['address'], //'toAddress' => $order['address'],
             'city' => $custom['city'],
             'city' => $custom['city'],
-            'weight' => $weight,
+            'weight' =>  $post['weight'] ?? 1,
             'remark' => $post['remark'] ?? '',
             'remark' => $post['remark'] ?? '',
-            'prePrice' => 10, // TODO 要从前端获取
-            'actPrice' => 10, // TODO
+            'prePrice' => floatval($post['totalPrice'] ?? 0),
+            'actPrice' => floatval($post['totalPrice'] ?? 0),
         ];
         ];
         $ghsShop = ShopClass::getById($ghsShopId);
         $ghsShop = ShopClass::getById($ghsShopId);
         $ds = new DispatchService($ghs->mainId);
         $ds = new DispatchService($ghs->mainId);

+ 2 - 0
app-mall/controllers/ExpressController.php

@@ -43,6 +43,8 @@ class ExpressController extends BaseController
         $shop['openIntraCity'] = $intraCityRet['openIntraCity'];
         $shop['openIntraCity'] = $intraCityRet['openIntraCity'];
         $shop['hcFreeKm'] = $intraCityRet['hcFreeKm'];
         $shop['hcFreeKm'] = $intraCityRet['hcFreeKm'];
         $shop['hcMap'] = $intraCityRet['hcMap'];
         $shop['hcMap'] = $intraCityRet['hcMap'];
+        $shop['hsFreeKm'] = $intraCityRet['hsFreeKm'];
+        $shop['hsAddFee'] = $intraCityRet['hsAddFee'];
         util::success(['hasMap' => dict::getDict('hasMap'), 'shop'=>$shop]);
         util::success(['hasMap' => dict::getDict('hasMap'), 'shop'=>$shop]);
     }
     }
 }
 }

+ 3 - 3
app-mall/controllers/OrderController.php

@@ -524,7 +524,7 @@ class OrderController extends BaseController
             $sendDistance = 0;
             $sendDistance = 0;
             $sendCost = 0;
             $sendCost = 0;
 
 
-            if ($sendType == dict::getDict('sendType', 'thirdSend')) {
+            if ($goodsData['freightType'] == 0 && $sendType == dict::getDict('sendType', 'thirdSend')) {
                 // if (dict::getDict('hasMap') == 0) {
                 // if (dict::getDict('hasMap') == 0) {
                 //     util::fail('不能使用跑腿,请选其它方式');
                 //     util::fail('不能使用跑腿,请选其它方式');
                 // }
                 // }
@@ -619,8 +619,8 @@ class OrderController extends BaseController
                 ];
                 ];
                 $cutomInfo = (object)$cutomInfo;
                 $cutomInfo = (object)$cutomInfo;
 
 
-                // 生成随机订单号
-                $prefix = 'XSD_CS-' . $this->mainId . '-';
+                // 生成随机花束订单号
+                $prefix = 'KD_CS-' . $this->mainId . '-';
                 $orderSn = $prefix . round(microtime(true) * 1000);
                 $orderSn = $prefix . round(microtime(true) * 1000);
 
 
                 // 使用 DeliveryQuoteUtil 获取配送报价
                 // 使用 DeliveryQuoteUtil 获取配送报价

+ 8 - 2
biz/shop/classes/ShopClass.php

@@ -29,7 +29,7 @@ class ShopClass extends BaseClass
         $long = $shop->long ?? '';
         $long = $shop->long ?? '';
         $address = $shop->address ?? '';
         $address = $shop->address ?? '';
         $hasMap = dict::getDict('hasMap');
         $hasMap = dict::getDict('hasMap');
-        $ext = ShopExtClass::getByCondition(['shopId' => $shop->id], true, null, 'id,shopId,thirdSendFee,hcFreeKm, hcMap');
+        $ext = ShopExtClass::getByCondition(['shopId' => $shop->id], true, null, 'id,shopId,thirdSend,thirdSendFee,hcFreeKm,hcMap,hsFreeKm,hsAddFee');
         $openIntraCity = 0;
         $openIntraCity = 0;
         //有地图功能
         //有地图功能
         if ($hasMap == 1) {
         if ($hasMap == 1) {
@@ -40,7 +40,13 @@ class ShopClass extends BaseClass
                 }
                 }
             }
             }
         }
         }
-        return ['openIntraCity' => $openIntraCity, 'hcFreeKm'=>$ext->hcFreeKm, 'hcMap'=>$ext->hcMap];
+        return [
+            'openIntraCity' => $openIntraCity,
+            'hcFreeKm'=>$ext->hcFreeKm,
+            'hcMap'=>$ext->hcMap,
+            'hsFreeKm'=>$ext->hsFreeKm,
+            'hsAddFee'=>$ext->hsAddFee
+        ];
     }
     }
 
 
     //营业状态
     //营业状态

+ 49 - 32
common/components/delivery/util/DeliveryQuoteUtil.php

@@ -197,44 +197,61 @@ class DeliveryQuoteUtil
         $orderSn
         $orderSn
     ) {
     ) {
         // 获取店铺扩展信息(免费配送设置)
         // 获取店铺扩展信息(免费配送设置)
-        $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, null, 'id,hcFreeKm,hcMap');
+        $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, null, 'id,hcFreeKm,hcMap,hsFreeKm,hsAddFee');
         if (empty($shopExt)) {
         if (empty($shopExt)) {
             return $sendCost;
             return $sendCost;
         }
         }
-        
-        // 获取花材的免费配送设置
-        $hcFreeKm = ($shopExt['hcFreeKm'] ?? 0) * 1000; // 转换为米
-        $hcMapString = $shopExt['hcMap'] ?? '';
-        $hcMap = [];
-        
-        if (!empty($hcMapString)) {
-            $hcMap = json_decode($hcMapString, true);
-        }
-        
-        // 判断是否免跑腿费
-        if ($sendDistance > $hcFreeKm) {
-            // 超过免费距离,检查是否满足其他免费条件
-            if (count($hcMap) > 0) {
-                foreach ($hcMap as $rule) {
-                    $ruleNum = $rule['num'] ?? 0;
-                    $rulePrice = $rule['price'] ?? 0;
-                    $ruleDistance = ($rule['distance'] ?? 0) * 1000;
-                    
-                    if ($productCount >= $ruleNum 
-                        && $itemTotalAmount >= $rulePrice 
-                        && $sendDistance <= $ruleDistance
-                    ) {
-                        noticeUtil::push(
-                            "ghsMainId={$ghsMainId}, orderSn={$orderSn}, 免跑腿费,满足条件:" 
-                            . json_encode($rule)
-                        );
-                        return 0;
+
+        // XSD_CS-    KD_CS-
+        if(strstr($orderSn, 'XSD_CS')){//花材
+            // 获取花材的免费配送设置
+            $hcFreeKm = ($shopExt['hcFreeKm'] ?? 0) * 1000; // 转换为米
+            $hcMapString = $shopExt['hcMap'] ?? '';
+            $hcMap = [];
+            
+            if (!empty($hcMapString)) {
+                $hcMap = json_decode($hcMapString, true);
+            }
+            
+            // 判断是否免跑腿费
+            if ($sendDistance > $hcFreeKm) {
+                // 超过免费距离,检查是否满足其他免费条件
+                if (count($hcMap) > 0) {
+                    foreach ($hcMap as $rule) {
+                        $ruleNum = $rule['num'] ?? 0;
+                        $rulePrice = $rule['price'] ?? 0;
+                        $ruleDistance = ($rule['distance'] ?? 0) * 1000;
+                        
+                        if ($productCount >= $ruleNum 
+                            && $itemTotalAmount >= $rulePrice 
+                            && $sendDistance <= $ruleDistance
+                        ) {
+                            noticeUtil::push(
+                                "ghsMainId={$ghsMainId}, orderSn={$orderSn}, 免跑腿费,满足条件:" 
+                                . json_encode($rule)
+                            );
+                            return 0;
+                        }
                     }
                     }
                 }
                 }
+            } else {
+                // 在免费配送距离内
+                return 0;
             }
             }
-        } else {
-            // 在免费配送距离内
-            return 0;
+        }else if(strstr($orderSn, 'KD_CS')){//花束
+            // 获取花材的免费配送设置
+            $hsFreeKm = ($shopExt['hsFreeKm'] ?? 0) * 1000; // 转换为米
+            $hsAddFee = $shopExt['hsAddFee'] ?? 0;
+            
+            // 判断是否免跑腿费
+            if ($sendDistance > $hsFreeKm) {
+                return ($sendDistance - $hsFreeKm)/1000 * $hsAddFee;
+            } else {
+                // 在免费配送距离内
+                return 0;
+            }
+        }else{
+            new \Exception('不支持的订单类型');
         }
         }
         
         
         return $sendCost;
         return $sendCost;