whitefang 1 tahun lalu
induk
melakukan
a243dd8529
1 mengubah file dengan 7 tambahan dan 3 penghapusan
  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) {
             if ($result['status'] === 0) {
                 //获取城市id
                 //获取城市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) {
         } catch (\Exception $e) {
             self::$error = $e->getMessage();
             self::$error = $e->getMessage();