最近店铺修改逻辑
This commit is contained in:
parent
479de5cc41
commit
f00ca73aa9
@ -366,12 +366,18 @@ class OrderController extends BaseApiController
|
|||||||
public function detail()
|
public function detail()
|
||||||
{
|
{
|
||||||
$order_id = (int)$this->request->get('order_id');
|
$order_id = (int)$this->request->get('order_id');
|
||||||
|
$lat = $this->request->get('lat','');
|
||||||
|
$lng = $this->request->get('long','');
|
||||||
$where = [
|
$where = [
|
||||||
'id' => $order_id,
|
'id' => $order_id,
|
||||||
'uid' => $this->userId,
|
'uid' => $this->userId,
|
||||||
];
|
];
|
||||||
$url = 'https://'.$this->request->host(true);
|
$url = 'https://'.$this->request->host(true);
|
||||||
$order = OrderLogic::detail($where,$url);
|
$parm = [
|
||||||
|
'lat'=>$lat,
|
||||||
|
'long'=>$lng
|
||||||
|
];
|
||||||
|
$order = OrderLogic::detail($where,$url,$parm);
|
||||||
if ($order) {
|
if ($order) {
|
||||||
return $this->data($order);
|
return $this->data($order);
|
||||||
} else {
|
} else {
|
||||||
|
@ -338,7 +338,7 @@ class OrderLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function detail($params,$url=''): array
|
public static function detail($params,$url='',$param=[]): array
|
||||||
{
|
{
|
||||||
$find = StoreOrder::where($params)->findOrEmpty()->toArray();
|
$find = StoreOrder::where($params)->findOrEmpty()->toArray();
|
||||||
if ($find) {
|
if ($find) {
|
||||||
@ -360,6 +360,24 @@ class OrderLogic extends BaseLogic
|
|||||||
if($find['verify_img']){
|
if($find['verify_img']){
|
||||||
$find['verify_img'] = $url.$find['verify_img'];
|
$find['verify_img'] = $url.$find['verify_img'];
|
||||||
}
|
}
|
||||||
|
//处理返回最近的店铺
|
||||||
|
if($param['lat'] && $param['long']){
|
||||||
|
$storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray();
|
||||||
|
$nearestStore = null;
|
||||||
|
$minDistance = PHP_FLOAT_MAX;
|
||||||
|
foreach ($storeAll as $value){
|
||||||
|
$value['distance'] = haversineDistance($value['latitude'],$value['longitude'],$param['lat'] ,$param['long']);
|
||||||
|
if ($value['distance'] < $minDistance) {
|
||||||
|
$minDistance = $value['distance'];
|
||||||
|
$nearestStore = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($nearestStore) {
|
||||||
|
$find['near_store'] =$nearestStore;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $find;
|
return $find;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user