diff --git a/app/admin/lists/store_branch_product/StoreBranchProductLists.php b/app/admin/lists/store_branch_product/StoreBranchProductLists.php index 59bb61b7..a15a4e13 100644 --- a/app/admin/lists/store_branch_product/StoreBranchProductLists.php +++ b/app/admin/lists/store_branch_product/StoreBranchProductLists.php @@ -4,6 +4,7 @@ namespace app\admin\lists\store_branch_product; use app\admin\lists\BaseAdminDataLists; +use app\common\model\cate\Cate; use app\common\model\store_category\StoreCategory; use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\system_store\SystemStore; @@ -47,7 +48,16 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI public function lists(): array { $status = $this->params['status'] ?? ''; - return StoreBranchProduct::where($this->searchWhere) + $class_all=$this->request->get('class_all'); + $where=[]; + if($class_all){ + $arr=Cate::where('pid',$class_all)->column('id'); + if($arr){ + $arr2=Cate::where('pid','in',$arr)->column('id'); + $where[]=['cate_id','in',array_merge($arr,$arr2)]; + } + } + return StoreBranchProduct::where($this->searchWhere)->where($where) ->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'status']) ->when(!empty($this->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->adminInfo['store_id']); @@ -85,7 +95,16 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI public function count(): int { $status = $this->params['status'] ?? ''; - return StoreBranchProduct::where($this->searchWhere) + $class_all=$this->request->get('class_all'); + $where=[]; + if($class_all){ + $arr=Cate::where('pid',$class_all)->column('id'); + if($arr){ + $arr2=Cate::where('pid','in',$arr)->column('id'); + $where[]=['cate_id','in',array_merge($arr,$arr2)]; + } + } + return StoreBranchProduct::where($this->searchWhere)->where($where) ->when(!empty($this->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->adminInfo['store_id']); })