调整商品列表查询
This commit is contained in:
parent
e39c96e65c
commit
1af1b7570b
@ -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 = '')
|
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);
|
$query = Db::name('cloud_product')->where('status', 1);
|
||||||
if (!empty($location)) {
|
if (!empty($location) && $location != ',') {
|
||||||
[$lat, $lng] = explode(',', $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();
|
$location = GeoStreet::where('street_code', $street_code)->field('lng,lat')->find();
|
||||||
if (!empty($location)) {
|
if (!empty($location)) {
|
||||||
[$lat, $lng] = [$location['lat'], $location['lng']];
|
[$lat, $lng] = [$location['lat'], $location['lng']];
|
||||||
@ -62,8 +64,8 @@ class CloudWarehouse extends BaseController
|
|||||||
$query->whereIn('mer_id', $merIds);
|
$query->whereIn('mer_id', $merIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($merIds)) {
|
if (empty($merIds) && !empty($lat)) {
|
||||||
$merIds = (new MerchantDao())->getValidMerchantByDistance($location['lat'], $location['lng'], true);
|
$merIds = (new MerchantDao())->getValidMerchantByDistance($lat, $lng, true);
|
||||||
$query->whereIn('mer_id', $merIds);
|
$query->whereIn('mer_id', $merIds);
|
||||||
}
|
}
|
||||||
if($cate_pid!=0){
|
if($cate_pid!=0){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user