From 5d5b2a28cacacb27b525f20390364af18f97248e Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 25 Jun 2024 14:34:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9ProductLists=E7=B1=BB?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=90=9C=E7=B4=A2=E3=80=81=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E5=92=8C=E6=89=A9=E5=B1=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/product/ProductLists.php | 43 ++++++-------------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index 2644ed0bd..8ccab3a48 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -20,7 +20,7 @@ use think\facade\Db; * Class goods * @package app\api\goods */ -class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface,ListsExtendInterface +class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface, ListsExtendInterface { @@ -32,20 +32,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 设置支持排序字段 @@ -114,29 +104,16 @@ 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(); } - public function extend(){ + public function extend() + { $off_activity = Config::where('name', 'off_activity')->value('value'); return [ - 'off_activity'=>$off_activity, - 'price'=>'cost', - 'op_price'=>'price', + 'off_activity' => $off_activity, + 'price' => 'cost', + 'op_price' => 'price', ]; } }