فهرست منبع

Merge branch 'web_sannong_fr'

15313670163 3 هفته پیش
والد
کامیت
154e148d72
1فایلهای تغییر یافته به همراه12 افزوده شده و 48 حذف شده
  1. 12 48
      app/JsonRpc/WebsiteService.php

+ 12 - 48
app/JsonRpc/WebsiteService.php

@@ -571,56 +571,20 @@ class WebsiteService implements WebsiteServiceInterface
 
     /**
      * 搜索地区
-     * @param array $data
-     * @return array
-     */
-    public function selectWebsiteArea(array $data): array
-    {
-        $provinces = District::where('pid', 0)->where('status', 1)->orderBy('code')->get();
+     * @param array $data 
+     * @return array 
+     */ 
+    public function selectWebsiteArea(array $data): array 
+    { 
 
-        if (isset($data['province'])) {
-            $province = District::where('pid', 0)->where('status', 1)->where('id', $data['province'])->orderBy('code')->get();
-            $province = $province->toArray();
-            if (!empty($province)) {
-                $citys = District::where('pid', $data['province'])->where('status', 1)->orderBy('code')->get();
-                if (!empty($citys) && isset($data['city']) && !empty($data['city'])) {
-                    // $province = $province->toArray();
-                    $province_id = [];
-                    foreach ($province as $val) {
-                        array_push($province_id, $val['id']);
-                    }
-                    // var_dump($province_id);
-                    $city = District::whereIn('pid', $province_id)->where('status', 1)->where('id', $data['city'])->orderBy('code')->get();
-                    if (!empty($city)) {
-                        $city_id = [];
-                        foreach ($city as $val) {
-                            array_push($city_id, $val['id']);
-                        }
-                        $regions = District::whereIn('pid', $city_id)->where('status', 1)->orderBy('code')->get();
-
-                        $result = [
-                            'province' => $province,
-                            'city' => $city,
-                            'region' => $regions,
-                        ];
-                    } else {
-                        return Result::error("未查询到此城市", 0);
-                    }
-                } else {
-                    $result = [
-                        'province' => $province,
-                        'city' => $citys,
-                        'region' => null,
-                    ];
-                }
-            } else {
-                return Result::error("未查询到此省份", 0);
-            }
-        } else {
-            // $keys = array('data');
-            $result = $provinces;
+        // return Result::success($data);
+        $pid = $data['pid'] ?? 0;
+        $result = District::where('pid',$pid)->where('status',1)->orderBy('code')->get();
+        if(empty($result)){
+            return Result::error("未查询到此地区",0);
+        }else{
+            return Result::success($result);
         }
-        return Result::success($result);
     }
 
     /**