From 68f32cc0d0e009ace396823b64f3217226b97d3c Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Mon, 6 May 2024 18:03:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=95=86=E5=93=81=E6=8C=89?= =?UTF-8?q?=E9=94=80=E9=87=8F=E4=BB=B7=E6=A0=BC=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/goods/GoodsLists.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/api/lists/goods/GoodsLists.php b/app/api/lists/goods/GoodsLists.php index bf2fcba..5bd6ab3 100644 --- a/app/api/lists/goods/GoodsLists.php +++ b/app/api/lists/goods/GoodsLists.php @@ -65,7 +65,9 @@ class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface public function lists(): array { $class_all=$this->request->get('class_all'); + $order_param = $this->request->get('order'); $where=[]; + $order = []; if($class_all){ $arr=[]; $arr2=[]; @@ -77,11 +79,22 @@ class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface $where[]=['class','=',$class_all]; } } + if(!empty($order_param)){ + if($order_param == 'asc'){ + $order['sell'] = 'asc'; + }elseif ($order_param == 'desc') { + $order['sell'] = 'desc'; + }elseif ($order_param=='sales') { + $order['sales'] = 'desc'; + }else{ + $order['id'] = 'desc'; + } + } return Goods::where($this->searchWhere)->where($where) - ->field(['id', 'name','brand','class','unit', 'sell', 'code','imgs',]) + ->field(['id', 'name','brand','class','unit', 'sell', 'code','imgs','sales']) ->limit($this->limitOffset, $this->limitLength) ->with(['className','brandName','unitName']) - ->order(['id' => 'desc']) + ->order($order) ->select() ->toArray(); }