Kaynağa Gözat

地址查询

moonsflyer 8 ay önce
ebeveyn
işleme
7c41425634
1 değiştirilmiş dosya ile 21 ekleme ve 22 silme
  1. 21 22
      app/api/lists/service/ServiceLists.php

+ 21 - 22
app/api/lists/service/ServiceLists.php

@@ -61,16 +61,6 @@ class ServiceLists extends BaseApiDataLists implements ListsSearchInterface
             $where[] = ['cate_id', 'like', '%' . ',' .$this->params['cate_id'].',' . '%'];
         }
 
-        if (!empty($this->params['area_id'])) {
-            $cwhere=[];
-//            $cwhere[]=['pid','=',$this->params['area_id']];
-//            $cate_list = AssetArea::where($cwhere)->select()->toArray();
-//            $cate_ids = array_column($cate_list,'id');
-//            $cate_ids = array_push($cate_ids,$this->params['area_id']);
-//            $where[] = ['area_id', 'in', $cate_ids];
-            $where[] = ['area_id', 'like', '%' . ',' .$this->params['area_id'].',' . '%'];
-        }
-
         return $where;
     }
 
@@ -86,26 +76,35 @@ class ServiceLists extends BaseApiDataLists implements ListsSearchInterface
      */
     public function lists(): array
     {
-        $orderRaw = 'expiration_time desc';
+        $wheres = [] ;
+        if (!empty($this->params['area_id'])) {
+            $cwhere=[];
+            $cwhere[]=['pid','=',$this->params['area_id']];
+
+            $cate_list = AssetArea::where($cwhere)->select() ->toArray();
+
+            $cate_ids = array_column($cate_list,'id');
+            array_push($cate_ids,(int)$this->params['area_id']);
+
+
+            $ccs = [];
+            foreach ($cate_ids as &$v){
+                $ccs[]='%,'.$v.',%';
+
+            }
+            $wheres[] = ['area_id', 'like', $ccs, 'or'];
+
+        }
 
         $field = 'id,user_id,name,mobile,type,agricultural_machinery_model,images,cate_id,area_id,money,content,status,expiration_time,create_time';
         $result = UserService::field($field)
             ->where($this->queryWhere())
             ->where($this->searchWhere)
-            ->orderRaw($orderRaw)
+            ->where($wheres)
             ->append(['type_desc','cate_desc','area_desc','images','user'])
             ->limit($this->limitOffset, $this->limitLength)
             ->select()->toArray();
-
-//        $articleIds = array_column($result, 'id');
-//
-//        $collectIds = ArticleCollect::where(['user_id' => $this->userId, 'status' => YesNoEnum::YES])
-//            ->whereIn('article_id', $articleIds)
-//            ->column('article_id');
-
-//        foreach ($result as &$item) {
-//            $item['collect'] = in_array($item['id'], $collectIds);
-//        }
+        
 
         return $result;
     }