shish %!s(int64=2) %!d(string=hai) anos
pai
achega
bd1a4c1985

+ 8 - 0
app-hd/controllers/PurchaseController.php

@@ -215,6 +215,14 @@ class PurchaseController extends BaseController
                 util::fail('本店已休息,请选择其它门店');
             }
 
+            if (isset($ghsShopInfo->pfLevel) && $ghsShopInfo->pfLevel == 1) {
+                $notSameCity = PurchaseClass::notSameCity($this->shop, $ghsShopInfo);
+                if ($notSameCity == false) {
+                    util::fail('不是同城买货,不能选择同城配送');
+                }
+            }
+
+
             if ($book == 1) {
                 $sendTimeWant = isset($post['sendTimeWant']) && !empty($post['sendTimeWant']) ? $post['sendTimeWant'] : date("Y-m-d");
                 $future = date("Y-m-d", strtotime('+2 day'));

+ 22 - 0
biz-hd/purchase/classes/PurchaseClass.php

@@ -36,6 +36,7 @@ use Yii;
 class PurchaseClass extends BaseClass
 {
     use OrderTrait;
+
     public static $baseFile = '\bizHd\purchase\models\Purchase';
 
     //订单状态 1待付款,待确认,2待配送,3配送中,4已完成,5取消,失败
@@ -60,6 +61,27 @@ class PurchaseClass extends BaseClass
     const REFUND_NO = 1;
     const REFUND_YES = 2;
 
+    public static function notSameCity($shop, $ghsShop)
+    {
+        $shopLat = $shop->lat ?? '';
+        $shopLong = $shop->long ?? '';
+        if (empty($shopLat) || empty($shopLong)) {
+            util::fail('请完善门店地址');
+        }
+        $ghsShopLat = $ghsShop->lat ?? '';
+        $ghsShopLong = $ghsShop->long ?? '';
+        if (empty($ghsShopLat) || empty($ghsShopLong)) {
+            util::fail('商家地址有问题');
+        }
+        $distance = mapUtil::calculateDistance($shopLong, $shopLat, $ghsShopLong, $ghsShopLat);
+        $formatDistance = ceil($distance / 1000);
+        noticeUtil::push("同城距离:" . $formatDistance, '15280215347');
+        if($formatDistance > 200){
+            return false;
+        }
+        return true;
+    }
+
     //计算距离和运费【另外还有个地方要同步修改,关键词calc_freight_distance】 ssh 20221003
     public static function getDistanceFee($shop, $ghsShop, $weight)
     {