whitefang 1 год назад
Родитель
Сommit
a243dd8529
1 измененных файлов с 7 добавлено и 3 удалено
  1. 7 3
      app/api/logic/RegionLogic.php

+ 7 - 3
app/api/logic/RegionLogic.php

@@ -58,9 +58,13 @@ class RegionLogic extends BaseLogic
             }
             if ($result['status'] === 0) {
                 //获取城市id
-                $city_id = Area::where(['name'=>['like',"%".$result['result']['address_component']['city']."%"]])->value('id');
-                $result['result']['address_component']['city_id'] = $city_id;
-                return $result['result']['address_component'];
+                if(empty($result['result']['address_component']['city'])){
+                    throw new Exception('定位获取shibai');
+                }
+                $city_id = PostageRegion::where('name','like',"%".$result['result']['address_component']['city']."%")->value('id');
+                $result = $result['result']['address_component'];
+                $result['city_id'] = $city_id;
+                return $result;
             }
         } catch (\Exception $e) {
             self::$error = $e->getMessage();