liugc 1 год назад
Родитель
Сommit
9a14e92f7b

+ 2 - 17
app/adminapi/lists/reviews/GoodsReviewsLists.php

@@ -39,24 +39,10 @@ class GoodsReviewsLists extends BaseAdminDataLists implements ListsSearchInterfa
     public function setSearch(): array
     {
         return [
-            '=' => ['goods_id', 'user_id', 'rating', 'comment', 'review_image', 'review_status', 'create_time', 'update_time'],
+            '=' => ['goods_id','goods_category_id', 'user_id', 'rating', 'comment', 'review_image', 'review_status', 'create_time', 'update_time'],
 
         ];
     }
-
-    public function queryWhere()
-    {
-        $where = [];
-        if (!empty($this->params['goods_category_id'])) {
-            $goodsCategoryId = end($this->params['goods_category_id']);
-            $goodsCategoryData = GoodsCategory::where(['status'=>1])->order(['pid' => 'asc','weigh' => 'desc', 'id' => 'desc'])
-                ->select()->toArray();
-            $ids =get_tree_ids($goodsCategoryData,$goodsCategoryId);
-            $ids[] = $goodsCategoryId;
-            $where[] = ['goods_category_id','in' ,$ids];
-        }
-        return $where;
-    }
     /**
      * @notes 获取列表
      * @return array
@@ -69,7 +55,6 @@ class GoodsReviewsLists extends BaseAdminDataLists implements ListsSearchInterfa
     public function lists(): array
     {
         return GoodsReviews::where($this->searchWhere)
-            ->where($this->queryWhere())
             ->field(['id', 'goods_id', 'goods_category_id', 'user_id', 'rating', 'comment', 'review_image', 'review_status', 'create_time', 'update_time'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
@@ -86,7 +71,7 @@ class GoodsReviewsLists extends BaseAdminDataLists implements ListsSearchInterfa
      */
     public function count(): int
     {
-        return GoodsReviews::where($this->searchWhere)->where($this->queryWhere())->count();
+        return GoodsReviews::where($this->searchWhere)->count();
     }
 
 }

+ 3 - 11
app/common/model/reviews/GoodsReviews.php

@@ -28,15 +28,7 @@ class GoodsReviews extends BaseModel
 {
     protected $name = 'goods_reviews';
 
-    public function getReviewImageAttr($value,$data)
-    {
-        if(!empty($value)){
-            $arr = json_decode($value,true);
-            if(empty($arr)){
-                return [$value];
-            }
-        }else{
-            return [];
-        }
-    }
+    protected $type = [
+        'review_image' => 'array'
+    ];
 }