From 1af1b7570b0d12b149fee17e83b7aed18b60d2ba Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Mon, 22 Jan 2024 16:42:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/store/product/CloudWarehouse.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index 7a8da07e..f8acf07f 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -47,10 +47,12 @@ class CloudWarehouse extends BaseController public function index($street_code, $page = 1, $category_id = 0, $cate_pid = 0,$cate_id = 0,$location = '') { $query = Db::name('cloud_product')->where('status', 1); - if (!empty($location)) { + if (!empty($location) && $location != ',') { [$lat, $lng] = explode(',', $location); } - if (!empty($street_code) && empty($location)) { + if (!empty($street_code) && (empty($location) || $location == ',')) { + + $location = GeoStreet::where('street_code', $street_code)->field('lng,lat')->find(); if (!empty($location)) { [$lat, $lng] = [$location['lat'], $location['lng']]; @@ -62,8 +64,8 @@ class CloudWarehouse extends BaseController $query->whereIn('mer_id', $merIds); } } - if (empty($merIds)) { - $merIds = (new MerchantDao())->getValidMerchantByDistance($location['lat'], $location['lng'], true); + if (empty($merIds) && !empty($lat)) { + $merIds = (new MerchantDao())->getValidMerchantByDistance($lat, $lng, true); $query->whereIn('mer_id', $merIds); } if($cate_pid!=0){