更新
This commit is contained in:
parent
07d3b2ce98
commit
2c72112def
@ -92,14 +92,11 @@ class CloudWarehouse extends BaseController
|
||||
// }
|
||||
|
||||
/**
|
||||
* 云仓商品列表
|
||||
* type_id 13云仓商品列表
|
||||
* @return mixed
|
||||
*/
|
||||
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)->column('product_id');
|
||||
$where = [
|
||||
'is_show' => 1,
|
||||
@ -118,23 +115,32 @@ class CloudWarehouse extends BaseController
|
||||
}else{
|
||||
$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'];
|
||||
$product_list = Db::name('store_product')->where($where)
|
||||
->limit(3)
|
||||
$where=[
|
||||
'type_id'=>13,
|
||||
'is_de'=>0,
|
||||
'mer_state'=>1
|
||||
];
|
||||
$mer_id=Db::name('merchant')->where($where)->column('mer_id');
|
||||
// $select=Db::query("select mer_id,mer_name ,ST_Distance(coordinates, POINT($lon,$lat)) AS distance from eb_merchant where coordinates !='' and type_id= 13 and is_del=0 and mer_state=1 ORDER BY distance LIMIT 100;");
|
||||
// halt($select);
|
||||
if ($mer_id) {
|
||||
$where['mer_id']=$mer_id;
|
||||
$select = Db::name('store_product')->where($where)
|
||||
->withAttr('sku', function ($value, $data) {
|
||||
$find = Db::name('store_product_attr_value')->where('mer_id', $data['mer_id'])->where('product_id', $data['product_id'])->find();
|
||||
return ['' => $find];
|
||||
})
|
||||
->withAttr('merchant', function ($value, $data) {
|
||||
$find= Db::name('merchant')->where('mer_id', $data['mer_id'])->field('mer_id,mer_name')->find();
|
||||
return $find;
|
||||
})
|
||||
->select();
|
||||
foreach ($product_list as $k1 => $v1){
|
||||
$arr=$v1;
|
||||
$v['distance']=round($v['distance'],2).'km';
|
||||
$arr['merchant']=$v;
|
||||
$list[]=$arr;
|
||||
}
|
||||
// foreach ($product_list as $k1 => $v1){
|
||||
// $arr=$v1;
|
||||
// $v['distance']=round($v['distance'],2).'km';
|
||||
// $arr['merchant']=$v;
|
||||
// $list[]=$arr;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
@ -170,6 +170,7 @@ class StoreSpu extends BaseController
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$where = $this->request->params(['common','mer_id']);
|
||||
$params = $this->request->params(['location']);
|
||||
$typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
|
||||
$where['is_gift_bag'] = 0;
|
||||
//1:星级
|
||||
@ -196,8 +197,18 @@ class StoreSpu extends BaseController
|
||||
}
|
||||
$where['product_type'] = 0;
|
||||
$where['is_stock'] = 1;
|
||||
$where['mer_ids'] = Merchant::getInstance()->whereIn('type_id', implode(',', $typeIdArray ??[]))
|
||||
->where(['status' => 1, 'mer_state' => 1, 'is_del' => 0])->column('mer_id');
|
||||
if($params['location']!=''){
|
||||
[$lon,$lat]=explode(',',$params['location']);
|
||||
$select=Db::query("select mer_id,ST_Distance(coordinates, POINT($lon,$lat)) AS distance from eb_merchant where coordinates !='' and type_id IN ('10', '17') and is_del=0 and mer_state=1 ORDER BY distance LIMIT 100;");
|
||||
$arr=[];
|
||||
foreach($select as $k=>$v){
|
||||
$arr[]=$v['mer_id'];
|
||||
}
|
||||
if($arr){
|
||||
$where['mer_ids'] =$arr;
|
||||
|
||||
}
|
||||
}
|
||||
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user