From da38902072f625a6cea6592e08aa4248333ae855 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 25 Jun 2024 14:26:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A4=84=E7=90=86=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=9A=84=E5=88=86=E7=B1=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/product/ProductLists.php | 29 ++------------------------ 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index f8e219939..5ad85ef03 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -35,6 +35,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L if ($name) { if (preg_match('/[\x{4e00}-\x{9fff}]+/u', $name) == 1) { $where['%like%'] = ['store_name' => 'store_name']; + $where['='] = ['store_id', 'bar_code', 'cate_id']; } else { $where['='] = ['bar_code', 'cate_id']; } @@ -77,20 +78,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L */ public function lists(): array { - - $found = false; - if ($this->searchWhere) { - foreach ($this->searchWhere as $subArray) { - if (in_array('store_id', $subArray)) { - $found = true; - break; // 找到后退出循环 - } - } - } - if (!$found) { - $store_id = DictType::where('type', 'store')->value('remark') ?? 5; - $this->searchWhere[] = ['store_id', '=', $store_id]; - } $class_all = $this->request->get('class_all'); if ($class_all) { //查3级别的 @@ -124,19 +111,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L */ public function count(): int { - $found = false; - if ($this->searchWhere) { - foreach ($this->searchWhere as $subArray) { - if (in_array('store_id', $subArray)) { - $found = true; - break; // 找到后退出循环 - } - } - } - if (!$found) { - $store_id = DictType::where('type', 'store')->value('remark') ?? 5; - $this->searchWhere[] = ['store_id', '=', $store_id]; - } + $class_all = $this->request->get('class_all'); if ($class_all) { //查3级别的 From bcef6451d69c22843e4a82f6f9aa3e0c6f30981f Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 25 Jun 2024 14:36:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/product/ProductLists.php | 33 ++++---------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index 5ad85ef03..357cedda3 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -30,20 +30,10 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L */ public function setSearch(): array { - $name = $this->request->get('store_name', ''); - // $where['%pipe_like%'] =['name'=>'store_name|bar_code']; - if ($name) { - if (preg_match('/[\x{4e00}-\x{9fff}]+/u', $name) == 1) { - $where['%like%'] = ['store_name' => 'store_name']; - $where['='] = ['store_id', 'bar_code', 'cate_id']; - } else { - $where['='] = ['bar_code', 'cate_id']; - } - } else { - $where['='] = ['store_id', 'bar_code', 'cate_id']; - } - - return $where; + return [ + '=' => ['store_id', 'cate_id'], + '%pipe_like%' => ['store_name' => 'store_name|bar_code'], + ]; } /** * @notes 设置支持排序字段 @@ -111,21 +101,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L */ public function count(): int { - - $class_all = $this->request->get('class_all'); - if ($class_all) { - //查3级别的 - $arr = Cate::where('pid', $class_all)->column('id'); - if ($arr) { - $arr2 = Cate::where('pid', 'in', $arr)->column('id'); - $this->searchWhere[] = ['cate_id', 'in', array_merge($arr, $arr2)]; - }else{ - $this->searchWhere[] = ['cate_id','=',$class_all]; - } - } - - $this->searchWhere[] = ['status', '=', 1]; - $this->searchWhere[] = ['stock', '>', 0]; return StoreBranchProduct::where($this->searchWhere) ->count(); }