diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index 2c779e82..7a8da07e 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -47,13 +47,19 @@ 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($street_code)) { + if (!empty($location)) { + [$lat, $lng] = explode(',', $location); + } + if (!empty($street_code) && empty($location)) { $location = GeoStreet::where('street_code', $street_code)->field('lng,lat')->find(); if (!empty($location)) { - $merIds = (new MerchantDao())->getValidMerchantByDistance($location['lat'], $location['lng']); - if (!empty($merIds)) { - $query->whereIn('mer_id', $merIds); - } + [$lat, $lng] = [$location['lat'], $location['lng']]; + } + } + if (!empty($lat)) { + $merIds = (new MerchantDao())->getValidMerchantByDistance($lat, $lng); + if (!empty($merIds)) { + $query->whereIn('mer_id', $merIds); } } if (empty($merIds)) {