|
|
@@ -16,6 +16,7 @@ namespace app\adminapi\lists\reviews;
|
|
|
|
|
|
|
|
|
use app\adminapi\lists\BaseAdminDataLists;
|
|
|
+use app\common\model\goods_category\GoodsCategory;
|
|
|
use app\common\model\reviews\GoodsReviews;
|
|
|
use app\common\lists\ListsSearchInterface;
|
|
|
|
|
|
@@ -38,12 +39,24 @@ class GoodsReviewsLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|
|
public function setSearch(): array
|
|
|
{
|
|
|
return [
|
|
|
- '=' => ['goods_id', 'goods_category_id', 'user_id', 'rating', 'comment', 'review_image', 'review_status', 'create_time', 'update_time'],
|
|
|
+ '=' => ['goods_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
|
|
|
@@ -56,6 +69,7 @@ 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'])
|
|
|
@@ -72,7 +86,7 @@ class GoodsReviewsLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|
|
*/
|
|
|
public function count(): int
|
|
|
{
|
|
|
- return GoodsReviews::where($this->searchWhere)->count();
|
|
|
+ return GoodsReviews::where($this->searchWhere)->where($this->queryWhere())->count();
|
|
|
}
|
|
|
|
|
|
}
|