shish 3 yıl önce
ebeveyn
işleme
99278568ae

+ 5 - 4
app-mall/controllers/ExpressController.php

@@ -15,6 +15,7 @@ class ExpressController extends BaseController
         $get = Yii::$app->request->get();
         $lng = $get['lng'] ?? '';
         $lat = $get['lat'] ?? '';
+        //花束重量默认1.5
         $weight = 1.5;
         if (empty($lng) || empty($lat)) {
             util::fail('请填写收花地址');
@@ -25,10 +26,10 @@ class ExpressController extends BaseController
         if (empty($shopLong) || empty($shopLat)) {
             util::fail('门店地址有问题');
         }
-        $respond = OrderClass::getDistanceFee($lat, $lng, $shop, $weight);
-        $distance = $respond['distance']??0;
-        $showDistance = $respond['showDistance']??0;
-        $fee = $respond['fee']??0;
+        $respond = OrderClass::getDistanceFee($lat, $lng, $shopLat, $shopLong, $weight);
+        $distance = $respond['distance'] ?? 0;
+        $showDistance = $respond['showDistance'] ?? 0;
+        $fee = $respond['fee'] ?? 0;
         util::success(['distance' => $distance, 'showDistance' => $showDistance, 'fee' => $fee]);
     }
 

+ 6 - 1
app-mall/controllers/OrderController.php

@@ -172,9 +172,14 @@ class OrderController extends BaseController
                 if (empty($lat) || empty($lng)) {
                     util::fail('请填写收花地址');
                 }
+                $shopLat = $shop->lat ?? '';
+                $shopLong = $shop->long ?? '';
+                if (empty($shopLat) || empty($shopLong)) {
+                    util::fail('请完成门店地址');
+                }
                 //花束重量默认1.5
                 $weight = 1.5;
-                $disRespond = OrderClass::getDistanceFee($lat, $lng, $shop, $weight);
+                $disRespond = OrderClass::getDistanceFee($lat, $lng, $shopLat, $shopLong, $weight);
                 $sendCost = $disRespond['fee'] ?? 0;
                 $sendDistance = $disRespond['distance'] ?? 0;
             }

+ 1 - 7
biz-mall/order/classes/OrderClass.php

@@ -59,14 +59,8 @@ class OrderClass extends BaseClass
     ];
 
     //计算运费,请搜索关键词calc_freight,二个方法要合一起 ssh 20221014
-    public static function getDistanceFee($userLat,$userLong, $shop, $weight)
+    public static function getDistanceFee($userLat, $userLong, $shopLat, $shopLong, $weight)
     {
-        $shopLat = isset($shop->lat) ? $shop->lat : '';
-        $shopLong = isset($shop->long) ? $shop->long : '';
-        if (empty($shopLat) || empty($shopLong)) {
-            util::fail('商家地址有问题');
-        }
-
         //基础配送费8元,0-5公里,每公里+1元,5-100公里,6元起,每公里+2元
         //5-10公斤,2元起,每公斤+2元,10-15公斤,+12元,超过15公斤,+20元
         //00:00 - 06:00 +6元,22:00-24:00 +4元