Przeglądaj źródła

Merge branch 'web_sannong_fr'

15313670163 1 miesiąc temu
rodzic
commit
ba15e1b464
1 zmienionych plików z 34 dodań i 34 usunięć
  1. 34 34
      app/JsonRpc/WebsiteService.php

+ 34 - 34
app/JsonRpc/WebsiteService.php

@@ -540,13 +540,13 @@ class WebsiteService implements WebsiteServiceInterface
     public function selectWebsiteDepartment(array $data): array
     {
 
-        $depart = Department::where('pid', 0)->orderBy('id', 'asc')->limit(10)->get();
-        if (isset($data['keyword']) && !empty($data['keyword'])) {
-            $departments = Department::where('name', 'like', '%' . $data['keyword'] . '%')->get();
-            if (empty($departments)) {
-                $result['message'] = "未查询到与此相关职能部门";
-            } else {
-                $count = Department::where('name', 'like', "%{$data['keyword']}%")->count();
+        $depart = Department::where('pid',0)->orderBy('id','asc')->get(); 
+        if(isset($data['keyword']) && !empty($data['keyword'])){ 
+            $departments= Department::where('name', 'like', '%' . $data['keyword'] . '%')->get();
+            if(empty($departments)){
+                $result['message']="未查询到与此相关职能部门"; 
+            }else{ 
+                $count = Department::where('name','like',"%{$data['keyword']}%")->count();
                 $m = [
                     'department' => $depart,
                     'type' => $departments,
@@ -564,40 +564,40 @@ class WebsiteService implements WebsiteServiceInterface
 
     /**
      * 搜索地区
-     * @param array $data
-     * @return array
-     */
-    public function selectWebsiteArea(array $data): array
-    {
-        $provinces = District::where('pid', 0)->where('status', 1)->get();
-
-        if (isset($data['province'])) {
-            $province = District::where('pid', 0)->where('status', 1)->where('id', $data['province'])->orderBy('id')->get();
-            $province = $province->toArray();
-            if (!empty($province)) {
-                $citys = District::where('pid', $data['province'])->where('status', 1)->orderBy('id')->get();
-                if (!empty($citys) && isset($data['city']) && !empty($data['city'])) {
+     * @param array $data 
+     * @return array 
+     */ 
+    public function selectWebsiteArea(array $data): array 
+    { 
+        $provinces=District::where('pid',0)->where('status',1)->get();
+       
+        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('id')->get();
-                    if (!empty($city)) {
-                        $city_id = [];
-                        foreach ($city as $val) {
-                            array_push($city_id, $val['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('id')->get();
-
-                        $result = [
-                            'province' => $province,
-                            'city' => $city,
-                            'region' => $regions,
-                        ];
-                    } else {
-                        return Result::error("未查询到此城市", 0);
+                        $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 = [