1.获取距离
This commit is contained in:
parent
8b297a6a31
commit
4bddbf2c80
@ -49,6 +49,13 @@ class LocalStore extends Api
|
||||
$result = $model->getLocalUserOrderList($data);
|
||||
return JsonServer::success('查询成功',$result);
|
||||
}
|
||||
// 查询距离
|
||||
public function getLocalDistance(){
|
||||
$model = new LocalStoreLogic;
|
||||
$data = $this->request->param();
|
||||
$result = $model->getLocalDistance($data);
|
||||
return JsonServer::success('查询成功',$result);
|
||||
}
|
||||
public function addLocalStore()
|
||||
{
|
||||
$user_id = $this->user_id;
|
||||
|
||||
@ -104,6 +104,10 @@ class LocalStoreLogic extends Logic
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
public function getLocalDistance($data){
|
||||
$result = Db::name("local_store")->where("lstore_id",$data['id'])->find();
|
||||
return round($this->distance($data['latitude'], $data['longitude'], $result['latitude'], $result['longitude'])/1000,2)."公里";
|
||||
}
|
||||
function distance($lat1, $lon1, $lat2, $lon2) {
|
||||
$earthRadius = 6371000; // 地球平均半径,单位为米
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user