作者 王晓刚
1 个管道 的构建 通过 耗费 0 秒

商品搜索

... ... @@ -170,7 +170,6 @@ class Goods extends Frontend
}
public function get_all(){
// dump($this->auth->id);
$param = $this->request->param();
$where['g.status'] = ['eq','1'];
if(!empty($param['province_id'])){
... ... @@ -203,7 +202,7 @@ class Goods extends Frontend
if(!empty($param['store_id'])){
$where['g.store_id'] = ['eq',$param['store_id']];
}
$order = 'g.weigh desc';
$order = 'distance asc';//'g.weigh desc';
if(!empty($param['sort'])){
if($param['sort'] == 1){
//销量降序
... ... @@ -256,7 +255,10 @@ class Goods extends Frontend
}
$data = $goodsModel
->alias('g')
->field('g.*,t.name as goodstype_name,s.lng,s.lat,s.name as store_name,s.phone as store_phone,s.address as store_address,s.property,s.type,s.content as store_content,s.thumbnail as store_thumbnail,s.money as store_money')
->field([
'g.*,t.name as goodstype_name,s.lng,s.lat,s.name as store_name,s.phone as store_phone,s.address as store_address,s.property,s.type,s.content as store_content,s.thumbnail as store_thumbnail,s.money as store_money',
"round((6378.138 * 2 * asin(sqrt(pow(sin((s.latitude * pi() / 180 - ".$param['lat']." * pi() / 180) / 2),2) + cos(s.latitude * pi() / 180) * cos(".$param['lat']." * pi() / 180) * pow(sin((s.longitude * pi() / 180 - ".$param['lng']." * pi() / 180) / 2),2)))),2) as distance",
])
->join('sto_goodstype t','t.id = g.goodstype_id')
->join('sto_store s','s.id = g.store_id')
->where($where)
... ... @@ -303,7 +305,6 @@ class Goods extends Frontend
$insurance = '1';
}
}
// dump($insurance);
$data[$key]['insurance'] = $insurance;
if(empty($user_id)){
$text = "(请您先登录)";
... ...