shish hace 4 meses
padre
commit
d4f8efeb41
Se han modificado 1 ficheros con 7 adiciones y 6 borrados
  1. 7 6
      biz/ghs/classes/GhsClass.php

+ 7 - 6
biz/ghs/classes/GhsClass.php

@@ -333,13 +333,13 @@ class GhsClass extends BaseClass
     public static function buildNearbyGhsRelations($shopId, $pfShopId, $toLat, $toLnt)
     public static function buildNearbyGhsRelations($shopId, $pfShopId, $toLat, $toLnt)
     {
     {
         if (empty($toLat) || empty($toLnt)) {
         if (empty($toLat) || empty($toLnt)) {
-            util::fail('门店未定位');
+            return false;
         }
         }
 
 
         // 获取除虚拟外的所有批发店
         // 获取除虚拟外的所有批发店
-        $nearbyShops = ShopClass::getAllByCondition(['ptStyle'=>2, 'live'=>1, 'actTime>=' => strtotime('yesterday')], null, 'id, merchantName, lat, long');
+        $nearbyShops = ShopClass::getAllByCondition(['ptStyle' => 2, 'live' => 1, 'actTime>=' => strtotime('yesterday')], null, 'id, merchantName, lat, long');
         if (empty($nearbyShops)) {
         if (empty($nearbyShops)) {
-            return;
+            return false;
         }
         }
 
 
         $origins = [];
         $origins = [];
@@ -348,7 +348,7 @@ class GhsClass extends BaseClass
             if ($nearbyShop['id'] == $pfShopId) {
             if ($nearbyShop['id'] == $pfShopId) {
                 continue;
                 continue;
             }
             }
-            if ($nearbyShop['lat'] && $nearbyShop['long']) {
+            if (!empty($nearbyShop['lat']) && !empty($nearbyShop['long'])) {
                 $origins[] = [
                 $origins[] = [
                     'lat' => $nearbyShop['lat'],
                     'lat' => $nearbyShop['lat'],
                     'lng' => $nearbyShop['long'],
                     'lng' => $nearbyShop['long'],
@@ -361,7 +361,7 @@ class GhsClass extends BaseClass
         }
         }
 
 
         if (empty($origins)) {
         if (empty($origins)) {
-            return;
+            return false;
         }
         }
 
 
         // 高德批量测距接口最多支持 100 个起点,需分批处理
         // 高德批量测距接口最多支持 100 个起点,需分批处理
@@ -387,7 +387,7 @@ class GhsClass extends BaseClass
             $ghsShopId = $nearbyShop['id'];
             $ghsShopId = $nearbyShop['id'];
             $distance = $allDistances[$index] ?? 0;
             $distance = $allDistances[$index] ?? 0;
             // 距离大于60公里不建立关系
             // 距离大于60公里不建立关系
-            if ($distance > 60*1000) {
+            if ($distance > 60 * 1000) {
                 continue;
                 continue;
             }
             }
 
 
@@ -398,5 +398,6 @@ class GhsClass extends BaseClass
                 self::updateById($ghsId, ['distance' => $distance]);
                 self::updateById($ghsId, ['distance' => $distance]);
             }
             }
         }
         }
+        return true;
     }
     }
 }
 }