From 630ef10fd6220b5095e887fadd207558f9cdcddb Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 25 Jun 2024 09:43:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2=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 | 33 +++++++++++++++----------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index a8826a48b..85efb1ae4 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -4,6 +4,7 @@ namespace app\api\lists\product; use app\admin\lists\BaseAdminDataLists; +use app\common\lists\ListsExtendInterface; use app\common\lists\ListsSortInterface; use app\common\model\dict\DictType; use app\common\model\store_branch_product\StoreBranchProduct; @@ -19,7 +20,7 @@ use think\facade\Db; * Class goods * @package app\api\goods */ -class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface +class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface,ListsExtendInterface { @@ -64,7 +65,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L */ public function setDefaultOrder(): array { - return [ 'price' => 'asc','id' => 'desc']; + return ['price' => 'asc', 'id' => 'desc']; } /** @@ -99,16 +100,13 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L 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]; + } else { + $this->searchWhere[] = ['cate_id', '=', $class_all]; } } - $off_activity=Config::where('name','off_activity')->value('value'); - if($off_activity==1){ - $field='id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,cost price,bar_code,image,sales,store_info,delete_time,unit,batch'; - }else{ - $field='id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch'; - } + + $field = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch'; + $this->searchWhere[] = ['status', '=', 1]; $this->searchWhere[] = ['stock', '>', 0]; return StoreBranchProduct::where($this->searchWhere) @@ -116,9 +114,8 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L ->with(['className', 'unitName']) ->limit($this->limitOffset, $this->limitLength) ->order($this->sortOrder) -// ->page($this->limitOffset +1,$this->limitLength) + // ->page($this->limitOffset +1,$this->limitLength) ->select()->toArray(); - } @@ -150,8 +147,8 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L 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]; + } else { + $this->searchWhere[] = ['cate_id', '=', $class_all]; } } @@ -160,4 +157,12 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L return StoreBranchProduct::where($this->searchWhere) ->count(); } + public function extend(){ + $off_activity = Config::where('name', 'off_activity')->value('value'); + return [ + 'off_activity'=>$off_activity, + 'price'=>'cost', + 'op_price'=>'price', + ]; + } }