From 17963150e59d76cfa45b986c6451c68c6a7c5ab4 Mon Sep 17 00:00:00 2001 From: hantao Date: Tue, 29 Jul 2025 13:47:35 +0800 Subject: [PATCH] api --- application/admin/controller/wechat/Api.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/application/admin/controller/wechat/Api.php b/application/admin/controller/wechat/Api.php index 1b50281..27ca094 100644 --- a/application/admin/controller/wechat/Api.php +++ b/application/admin/controller/wechat/Api.php @@ -77,6 +77,8 @@ class Api extends Backend $attr = $data['attr'] ?? null; $brand = $data['brand'] ?? null; $type = $data['type'] ?? 1; + $price = $data['price'] ?? null; + $sort = $data['sort'] ?? 1; if ($attr){ $ids = $this->getAttrIds($attr); $build->whereIn('id',$ids); @@ -88,12 +90,23 @@ class Api extends Backend $build->whereIn('series_id',$brand); } } - + if (!empty($price)){ + $prices = explode('-',$price); + $build->whereBetween('price',$prices); + } + if (!empty($sort)){ + $sort = explode('-',$sort); + $build->order($sort[0],$sort[1]); + }else{ + $build->order('id','desc'); + } $build->where('car_type',$type); + $list = $build->paginate(); $res = []; $car_ids = []; + foreach ($list->items() as $item){ $out = $item->toArray(); $car_ids [] = $item['id'];