From 37c328a722d890c3a395d6032d6c2dcd44f12e50 Mon Sep 17 00:00:00 2001 From: lqmac Date: Fri, 17 May 2024 12:15:21 +0800 Subject: [PATCH] 1 --- app/common/model/Goods.php | 69 +++++++++++++++++++--------------- app/store/controller/Goods.php | 2 +- app/store/controller/Store.php | 4 +- 3 files changed, 42 insertions(+), 33 deletions(-) diff --git a/app/common/model/Goods.php b/app/common/model/Goods.php index 6a132a23..271ca05d 100644 --- a/app/common/model/Goods.php +++ b/app/common/model/Goods.php @@ -274,37 +274,46 @@ class Goods extends BaseModel // 排序条件 $sort = $this->setQuerySort($param); $order = request()->get()['order'] ?? ''; - - if (!empty($order)) { - if ($order == 1) { - $sort = ['goods_price_min' => 'asc']; - } - if ($order == 2) { - $sort = ['goods_price_min' => 'desc']; - } - - if ($order == 3) { - $sort = ['discount' => 'asc']; - } - if ($order == 4) { - $sort = ['discount' => 'desc']; - } - - if ($order == 5) { - $sort = ['goods_sales' => 'asc']; - - } - if ($order == 6) { - $sort = ['goods_sales' => 'desc']; - } - - if ($order == 7) { - $sort = ['goods_sales' => 'asc']; - } - if ($order == 8) { - $sort = ['goods_sales' => 'desc']; - } + $sort = request()->get()['sort'] ?? ''; + if ($order && $sort) { + $sort = [ + $sort => $order, + ]; + } else { + $sort = [ + $this->getPk() => 'desc', + ]; } + // if (!empty($order)) { + // if ($order == 1) { + // $sort = ['goods_price_min' => 'asc']; + // } + // if ($order == 2) { + // $sort = ['goods_price_min' => 'desc']; + // } + + // if ($order == 3) { + // $sort = ['discount' => 'asc']; + // } + // if ($order == 4) { + // $sort = ['discount' => 'desc']; + // } + + // if ($order == 5) { + // $sort = ['goods_sales' => 'asc']; + + // } + // if ($order == 6) { + // $sort = ['goods_sales' => 'desc']; + // } + + // if ($order == 7) { + // $sort = ['goods_sales' => 'asc']; + // } + // if ($order == 8) { + // $sort = ['goods_sales' => 'desc']; + // } + // } $field = $this->getAliasFields($this->name, ['content']); diff --git a/app/store/controller/Goods.php b/app/store/controller/Goods.php index 3bb3a95d..194130b5 100644 --- a/app/store/controller/Goods.php +++ b/app/store/controller/Goods.php @@ -35,7 +35,7 @@ class Goods extends Controller // 获取列表记录 $model = new GoodsModel; $params = $this->request->param(); - //$params['channel'] = 'zy'; + $params['channel'] = 'zy'; $list= $model->getList($params, (int)$this->request->param('pageSize', 15)); return $this->renderSuccess(compact('list')); } diff --git a/app/store/controller/Store.php b/app/store/controller/Store.php index 498f3c85..6b95f8f1 100644 --- a/app/store/controller/Store.php +++ b/app/store/controller/Store.php @@ -75,8 +75,8 @@ class Store extends Controller */ public function platformList(): Json { - $list = Channel::withoutGlobalScope()->where('status', 1)->whereIn('code',['jd','sn','zy','xqtx'])->select(); - //$list = Channel::withoutGlobalScope()->where('status', 1)->whereIn('code',['zy'])->select(); + //$list = Channel::withoutGlobalScope()->where('status', 1)->whereIn('code',['jd','sn','zy','xqtx'])->select(); + $list = Channel::withoutGlobalScope()->where('status', 1)->whereIn('code',['zy'])->select(); $platformList = []; foreach ($list as $key => $value) { $platformList[$value['code']] = $value['name'];