更新查询
This commit is contained in:
parent
c350d30893
commit
44aef5f3fa
@ -95,12 +95,12 @@ class CloudWarehouse extends BaseController
|
|||||||
* 云仓商品列表
|
* 云仓商品列表
|
||||||
* @return mixed
|
* @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) {
|
// if ($category_id == 0) {
|
||||||
// return app('json')->fail('分类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 = [
|
$where = [
|
||||||
'is_show' => 1,
|
'is_show' => 1,
|
||||||
'is_used' => 1,
|
'is_used' => 1,
|
||||||
@ -108,15 +108,17 @@ class CloudWarehouse extends BaseController
|
|||||||
'is_del' => 0,
|
'is_del' => 0,
|
||||||
'mer_status' => 1,
|
'mer_status' => 1,
|
||||||
];
|
];
|
||||||
if (!$cloud_product) {
|
if (!$cloud_product && $category_id==0) {
|
||||||
$list=[];
|
$list=[];
|
||||||
|
$count=0;
|
||||||
if($location){
|
if($location){
|
||||||
[$lon,$lat]=explode(',',$location);
|
[$lon,$lat]=explode(',',$location);
|
||||||
if($page_num==1){
|
if($page==1){
|
||||||
$limit=0;
|
$limit=0;
|
||||||
}else{
|
}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;");
|
$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) {
|
foreach ($select as $k => $v) {
|
||||||
$where['mer_id']=$v['mer_id'];
|
$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();
|
$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)
|
$select = Db::name('store_product')->whereIn('product_id', $cloud_product)->where($where)
|
||||||
@ -161,7 +163,7 @@ class CloudWarehouse extends BaseController
|
|||||||
public function town()
|
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 = [
|
$search = [
|
||||||
'street_id' => $params['street_code'],
|
'street_id' => $params['street_code'],
|
||||||
'type_id' => Merchant::TypeTownSupplyChain,
|
'type_id' => Merchant::TypeTownSupplyChain,
|
||||||
@ -174,8 +176,8 @@ class CloudWarehouse extends BaseController
|
|||||||
}
|
}
|
||||||
$merchantIds = $this->merchantDao->search($search)->column('mer_id');
|
$merchantIds = $this->merchantDao->search($search)->column('mer_id');
|
||||||
[$page, $limit] = $this->getPage();
|
[$page, $limit] = $this->getPage();
|
||||||
if (isset($params['page_num']) && $params['page_num'] != '') {
|
if (isset($params['page']) && $params['page'] != '') {
|
||||||
$page = $params['page_num'];
|
$page = $params['page'];
|
||||||
}
|
}
|
||||||
if (empty($merchantIds)) {
|
if (empty($merchantIds)) {
|
||||||
return app('json')->success(['count' => 0, 'list' => []]);
|
return app('json')->success(['count' => 0, 'list' => []]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user