瀏覽代碼

找出附近批发店修改

shizhongqi 4 月之前
父節點
當前提交
7297071438
共有 3 個文件被更改,包括 18 次插入20 次删除
  1. 11 7
      app-hd/controllers/GhsController.php
  2. 6 8
      app-hd/controllers/ShopController.php
  3. 1 5
      biz/ghs/classes/GhsClass.php

+ 11 - 7
app-hd/controllers/GhsController.php

@@ -444,19 +444,23 @@ class GhsController extends BaseController
     //寻找附近批发店
     public function actionSearchNearbyGhs()
     {
-        $shop = $this->shop;
-        $toLat = $shop['lat'] ?? '';
-        $toLnt = $shop['long'] ?? '';
+        $get = Yii::$app->request->get();
+        $toLat = $get['lat'] ?? '';
+        $toLnt = $get['long'] ?? '';
         if ($toLat == '' || $toLnt == '') {
-            util::fail('门店未定位');
+            util::fail('未获取到定位数据');
         }
 
-        if ($shop['province'] == '' || $shop['city'] == '') {
-            util::fail('门店未设置所在省市');
+        $where = [];
+        $where['ownShopId'] = $this->shopId;
+        $where['delStatus'] = 0;
+        $gs = GhsClass::getAllList('*', $where, 'inTurn DESC, addTime ASC');
+        if(!empty($gs)){
+            util::fail('已有批发商,不使用定位获取附近批发商');
         }
 
         // 找出附近批发店,之后自动给建立关系,然后补充二个店之间的距离
-        GhsClass::buildNearbyGhsRelations($shop['id'], $this->shop->pfShopId, $shop['province'], $shop['city'], $toLat, $toLnt);
+        GhsClass::buildNearbyGhsRelations($this->shop['id'], $this->shop->pfShopId, $toLat, $toLnt);
 
         util::complete();
     }

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

@@ -162,14 +162,12 @@ class ShopController extends BaseController
         try {
             ShopClass::updateShop($shop, $data);
 
-            // 找出附近批发店,之后自动给建立关系,然后补充二个店之间的距离(app-hd GhsController actionInfo),计算距离使用高德接口
-            if(isset($data['openLocation']) && $data['openLocation'] == 1){
-                $toLat = $data['lat'] ?? null;
-                $toLnt = $data['long'] ?? null;
-                $province = $data['province'] ?? '';
-                $city = $data['city'] ?? '';
-                \biz\ghs\classes\GhsClass::buildNearbyGhsRelations($id, $this->shop->pfShopId, $province, $city, $toLat, $toLnt);
-            }
+            // 找出附近批发店,之后自动给建立关系,然后补充二个店之间的距离(计算距离使用高德接口)
+            // if(isset($data['openLocation']) && $data['openLocation'] == 1){
+            //     $toLat = $data['lat'] ?? null;
+            //     $toLnt = $data['long'] ?? null;
+            //     \biz\ghs\classes\GhsClass::buildNearbyGhsRelations($id, $this->shop->pfShopId, $toLat, $toLnt);
+            // }
             $transaction->commit();
             util::complete();
         } catch (\Exception $exception) {

+ 1 - 5
biz/ghs/classes/GhsClass.php

@@ -330,16 +330,12 @@ class GhsClass extends BaseClass
     }
 
     // 建立附近批发店关系
-    public static function buildNearbyGhsRelations($shopId, $pfShopId, $province, $city, $toLat, $toLnt)
+    public static function buildNearbyGhsRelations($shopId, $pfShopId, $toLat, $toLnt)
     {
         if (empty($toLat) || empty($toLnt)) {
             util::fail('门店未定位');
         }
 
-        if (empty($province) || empty($city)) {
-            util::fail('门店未设置所在省市');
-        }
-
         // 获取除虚拟外的所有批发店
         $nearbyShops = ShopClass::getAllByCondition(['ptStyle'=>2, 'live'=>1, 'actTime>=' => strtotime('yesterday')], null, 'id, merchantName, lat, long');
         if (empty($nearbyShops)) {