From 3f42f3935246bdaf2ac853f1438bedcd9b13ff21 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 7 Aug 2023 18:54:30 +0800 Subject: [PATCH] 1 --- doc/Mall.py | 1 + third_party/phpcommon | 2 +- webapp/controller/MallController.class.php | 34 +++++++++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/doc/Mall.py b/doc/Mall.py index 2805003b..1281902a 100644 --- a/doc/Mall.py +++ b/doc/Mall.py @@ -16,6 +16,7 @@ class Mall(object): ['page', 0, '第几页数据'], ['seller', '', '查询指定钱包 为空的化查询所有人'], ['order_method', 0, '排序方式 0:默认排序(当前指向1) 1:上架时间 2:价格'], + ['order_asc', 0, '排序方向, 0:从小到大 1:从大到小'], ['price_filter', '', '价格过滤(用|分割)'], ], 'response': [ diff --git a/third_party/phpcommon b/third_party/phpcommon index 7b9d2492..9f75ccab 160000 --- a/third_party/phpcommon +++ b/third_party/phpcommon @@ -1 +1 @@ -Subproject commit 7b9d24921cb7a2d2cd6d793604b8d69f3d2786b3 +Subproject commit 9f75ccab850c1681c405a496c57acf4b0cca4343 diff --git a/webapp/controller/MallController.class.php b/webapp/controller/MallController.class.php index 98a6c5de..95baa1bb 100644 --- a/webapp/controller/MallController.class.php +++ b/webapp/controller/MallController.class.php @@ -29,6 +29,24 @@ class MallController extends BaseAuthedController { if (!empty($seller)) { $queryData['seller'] = $seller; } + $queryData['price_filter'] = getReqVal('price_filter', ''); + $orderBy = ''; + $orderAsc = 'ASC'; + if (getReqVal('order_asc', '') == 1) { + $orderAsc = 'DESC'; + } + switch (getReqVal('order_method', '')) { + case 1: + { + $orderBy = 'ORDER BY createtime ' . $orderAsc; + } + break; + case 2: + { + $orderBy = 'ORDER BY price ' . $orderAsc; + } + break; + } $out = array( 'pagination' => array(), @@ -52,9 +70,23 @@ class MallController extends BaseAuthedController { 'cond' => '=', 'ignore_empty' => true, ), + array( + 'name' => 'price_filter', + 'field_name' => '', + 'cond' => 'custom', + 'ignore_empty' => true, + 'custom_func' => function () use ($queryData) { + $priceFilters = $queryData['price_filter']; + error_log($priceFilters); + $arrPriceFilter = explode('|', $priceFilters); + $priceLow = $arrPriceFilter[0]; + $priceHigh = $arrPriceFilter[1]; + return "AND (price >= ${priceLow} AND price <= ${priceHigh})"; + } + ), ) ), - //'orderBy' => $orderBy, + 'orderBy' => $orderBy, 'handle' => function ($row) use(&$out) { array_push($out['rows'], Mall::toDto($row)); }