更新查询
This commit is contained in:
parent
c350d30893
commit
44aef5f3fa
@ -95,12 +95,12 @@ class CloudWarehouse extends BaseController
|
||||
* 云仓商品列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function index($street_code, $page_num = 1, $category_id = 0,$location='')
|
||||
public function index($street_code, $page = 1, $category_id = 0,$location='')
|
||||
{
|
||||
// if ($category_id == 0) {
|
||||
// return app('json')->fail('分类id不能为0');
|
||||
// }
|
||||
$cloud_product = Db::name('cloud_product')->where('street_code', $street_code)->where('status', 1)->page($page_num)->column('product_id');
|
||||
$cloud_product = Db::name('cloud_product')->where('street_code', $street_code)->where('status', 1)->page($page)->column('product_id');
|
||||
$where = [
|
||||
'is_show' => 1,
|
||||
'is_used' => 1,
|
||||
@ -108,15 +108,17 @@ class CloudWarehouse extends BaseController
|
||||
'is_del' => 0,
|
||||
'mer_status' => 1,
|
||||
];
|
||||
if (!$cloud_product) {
|
||||
if (!$cloud_product && $category_id==0) {
|
||||
$list=[];
|
||||
$count=0;
|
||||
if($location){
|
||||
[$lon,$lat]=explode(',',$location);
|
||||
if($page_num==1){
|
||||
if($page==1){
|
||||
$limit=0;
|
||||
}else{
|
||||
$limit=$page_num*10;
|
||||
$limit=$page*10;
|
||||
}
|
||||
$count=Db::name('merchant')->where('coordinates','<>','')->count();
|
||||
$select=Db::query("select mer_id,mer_name ,ST_Distance(coordinates, POINT($lon,$lat)) AS distance from eb_merchant where coordinates !='' ORDER BY distance LIMIT $limit, 10;");
|
||||
foreach ($select as $k => $v) {
|
||||
$where['mer_id']=$v['mer_id'];
|
||||
@ -137,7 +139,7 @@ class CloudWarehouse extends BaseController
|
||||
}
|
||||
|
||||
}
|
||||
return app('json')->success(['count' => 0, 'list' => $list]);
|
||||
return app('json')->success(['count' => $count, 'list' => $list]);
|
||||
}
|
||||
$count = Db::name('cloud_product')->where('street_code', $street_code)->where('status', 1)->count();
|
||||
$select = Db::name('store_product')->whereIn('product_id', $cloud_product)->where($where)
|
||||
@ -161,7 +163,7 @@ class CloudWarehouse extends BaseController
|
||||
public function town()
|
||||
{
|
||||
// 除了市级供应链都可以查询
|
||||
$params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword', 'page_num']);
|
||||
$params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword', 'page']);
|
||||
$search = [
|
||||
'street_id' => $params['street_code'],
|
||||
'type_id' => Merchant::TypeTownSupplyChain,
|
||||
@ -174,8 +176,8 @@ class CloudWarehouse extends BaseController
|
||||
}
|
||||
$merchantIds = $this->merchantDao->search($search)->column('mer_id');
|
||||
[$page, $limit] = $this->getPage();
|
||||
if (isset($params['page_num']) && $params['page_num'] != '') {
|
||||
$page = $params['page_num'];
|
||||
if (isset($params['page']) && $params['page'] != '') {
|
||||
$page = $params['page'];
|
||||
}
|
||||
if (empty($merchantIds)) {
|
||||
return app('json')->success(['count' => 0, 'list' => []]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user