moonsflyer 7 miesięcy temu
rodzic
commit
dfd786c1d9
1 zmienionych plików z 13 dodań i 5 usunięć
  1. 13 5
      app/api/lists/service/ServiceLists.php

+ 13 - 5
app/api/lists/service/ServiceLists.php

@@ -56,10 +56,6 @@ class ServiceLists extends BaseApiDataLists implements ListsSearchInterface
     {
         $where[] = ['status', '=', 1];
         $where[] = ['expiration_time', '>=', time()];
-        if (!empty($this->params['cate_id'])) {
-
-            $where[] = ['cate_id', 'like', '%' . ',' .$this->params['cate_id'].',' . '%'];
-        }
 
         return $where;
     }
@@ -95,16 +91,28 @@ class ServiceLists extends BaseApiDataLists implements ListsSearchInterface
             $wheres[] = ['area_id', 'like', $ccs, 'or'];
 
         }
+        $catwhere=[];
+        if (!empty($this->params['cate_id'])) {
+            $cate_id_arr = explode(',',$this->params['cate_id']);
+
+            $cats = [];
+            foreach ($cate_id_arr as &$v){
+                $cats[]='%,'.$v.',%';
+
+            }
+            $catwhere[] = ['cate_id', 'like', $cats, '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)
             ->where($wheres)
+            ->where($catwhere)
             ->append(['type_desc','cate_desc','area_desc','images','user'])
             ->limit($this->limitOffset, $this->limitLength)
             ->select()->toArray();
-        
+
 
         return $result;
     }