From f0a6491adbc8039a1ffee0f50b10a43546f095fa Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 14 Jun 2024 10:54:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=9B=B8=E5=85=B3=E5=85=BC?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreBranchProductLists.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/app/admin/lists/store_branch_product/StoreBranchProductLists.php b/app/admin/lists/store_branch_product/StoreBranchProductLists.php index 59bb61b77..a15a4e13a 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']); })