正在显示
1 个修改的文件
包含
5 行增加
和
4 行删除
@@ -170,7 +170,6 @@ class Goods extends Frontend | @@ -170,7 +170,6 @@ class Goods extends Frontend | ||
170 | } | 170 | } |
171 | 171 | ||
172 | public function get_all(){ | 172 | public function get_all(){ |
173 | -// dump($this->auth->id); | ||
174 | $param = $this->request->param(); | 173 | $param = $this->request->param(); |
175 | $where['g.status'] = ['eq','1']; | 174 | $where['g.status'] = ['eq','1']; |
176 | if(!empty($param['province_id'])){ | 175 | if(!empty($param['province_id'])){ |
@@ -203,7 +202,7 @@ class Goods extends Frontend | @@ -203,7 +202,7 @@ class Goods extends Frontend | ||
203 | if(!empty($param['store_id'])){ | 202 | if(!empty($param['store_id'])){ |
204 | $where['g.store_id'] = ['eq',$param['store_id']]; | 203 | $where['g.store_id'] = ['eq',$param['store_id']]; |
205 | } | 204 | } |
206 | - $order = 'g.weigh desc'; | 205 | + $order = 'distance asc';//'g.weigh desc'; |
207 | if(!empty($param['sort'])){ | 206 | if(!empty($param['sort'])){ |
208 | if($param['sort'] == 1){ | 207 | if($param['sort'] == 1){ |
209 | //销量降序 | 208 | //销量降序 |
@@ -256,7 +255,10 @@ class Goods extends Frontend | @@ -256,7 +255,10 @@ class Goods extends Frontend | ||
256 | } | 255 | } |
257 | $data = $goodsModel | 256 | $data = $goodsModel |
258 | ->alias('g') | 257 | ->alias('g') |
259 | - ->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') | 258 | + ->field([ |
259 | + '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', | ||
260 | + "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", | ||
261 | + ]) | ||
260 | ->join('sto_goodstype t','t.id = g.goodstype_id') | 262 | ->join('sto_goodstype t','t.id = g.goodstype_id') |
261 | ->join('sto_store s','s.id = g.store_id') | 263 | ->join('sto_store s','s.id = g.store_id') |
262 | ->where($where) | 264 | ->where($where) |
@@ -303,7 +305,6 @@ class Goods extends Frontend | @@ -303,7 +305,6 @@ class Goods extends Frontend | ||
303 | $insurance = '1'; | 305 | $insurance = '1'; |
304 | } | 306 | } |
305 | } | 307 | } |
306 | -// dump($insurance); | ||
307 | $data[$key]['insurance'] = $insurance; | 308 | $data[$key]['insurance'] = $insurance; |
308 | if(empty($user_id)){ | 309 | if(empty($user_id)){ |
309 | $text = "(请您先登录)"; | 310 | $text = "(请您先登录)"; |
-
请 注册 或 登录 后发表评论