From 593875f7519e5c853c9f421cfaf685c31f0b9bb3 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Tue, 23 Jan 2024 15:55:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BA=91=E4=BB=93=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=97=E8=A1=A8=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/store/product/CloudWarehouse.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index d6fcf60b..eb1cb8d4 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -47,6 +47,7 @@ class CloudWarehouse extends BaseController public function index($street_code, $page = 1, $category_id = 0, $cate_pid = 0,$cate_id = 0,$location = '') { $keyword = $this->request->get('keyword'); + $order = $this->request->get('order'); [$lat, $lng] = (new CityAreaDao())->getLngAndLat($location, $street_code); $query = Db::name('cloud_product')->where('status', 1); $productIds = (new MerchantDao())->getProductByDistance($lat, $lng,false,50000); @@ -63,6 +64,15 @@ class CloudWarehouse extends BaseController if (!empty($keyword)) { $query->where('store_name', 'like', '%'. $keyword . '%'); } + if (!empty($order)) { + if ($order == 'sales') { + $query->order($order, 'desc'); + } elseif ($order == 'price_desc') { + $query->order('price', 'desc'); + } else { + $query->order('price', 'asc'); + } + } $cloud_product_arr = $query->where(function($query){ $query->where('mer_labels', '') ->whereOr('mer_labels',',5,'); @@ -77,7 +87,8 @@ class CloudWarehouse extends BaseController 'status' => 1, 'is_del' => 0, 'mer_status' => 1, - 'product_id' => $cloud_product + 'product_id' => $cloud_product, + 'order' => $order ]; if (!$cloud_product) { return app('json')->success(['count' => 0, 'list' => []]);