Commit eb278e9d authored by hujun's avatar hujun

获取两个经纬度距离

parent cb6b8320
...@@ -11,6 +11,7 @@ namespace app\index\controller; ...@@ -11,6 +11,7 @@ namespace app\index\controller;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\index\service\OfficeService; use app\index\service\OfficeService;
use app\index\service\PositionService;
use think\Request; use think\Request;
class OfficeManage extends Basic class OfficeManage extends Basic
...@@ -156,4 +157,37 @@ class OfficeManage extends Basic ...@@ -156,4 +157,37 @@ class OfficeManage extends Basic
return $this->response($code, $msg, $data); return $this->response($code, $msg, $data);
} }
/**
* 获得两个经纬度距离
*
* @return \think\Response
*/
public function getDistance()
{
$code = 200;
$msg = "";
$data = [];
$address_latitude = $this->params['address_latitude'];
$address_longitude = $this->params['address_longitude'];
$stations_latitude = $this->params['stations_latitude'];
$stations_longitude = $this->params['stations_longitude'];
if (empty($address_latitude) || empty($address_longitude) || empty($stations_latitude) || empty($stations_longitude)) {
return $this->response(101, '参数错误');
}
$first_position = $address_latitude . ',' . $address_longitude;
$end_position = $stations_latitude . ',' . $stations_longitude;
$position_service = new PositionService();
$distance = $position_service->getPositionDistance($first_position, $end_position);
if ($distance) {
$data['distance'] = $distance;
} else {
$data['distance'] = 0;
$code = 101;
$msg = '获取距离失败';
}
return $this->response($code, $msg, $data);
}
} }
\ No newline at end of file
...@@ -95,6 +95,7 @@ class Basic extends Controller ...@@ -95,6 +95,7 @@ class Basic extends Controller
'index/dailyBackImg', 'index/dailyBackImg',
'office_index/getLabelsList', 'office_index/getLabelsList',
'index/modifyAgentPassword', 'index/modifyAgentPassword',
'office_index/getDistance',
); );
/** /**
......
...@@ -1057,6 +1057,7 @@ Route::group('office_index', [ ...@@ -1057,6 +1057,7 @@ Route::group('office_index', [
'inspectionRecordStore/:check_status' => ['index/OfficeReport/inspectionRecordAll', ['method' => 'GET'], ['check_status' => 1]], //门店约带看 'inspectionRecordStore/:check_status' => ['index/OfficeReport/inspectionRecordAll', ['method' => 'GET'], ['check_status' => 1]], //门店约带看
'inspectionRecordDistrict/:check_status' => ['index/OfficeReport/inspectionRecordAll', ['method' => 'GET'], ['check_status' => 2]], //部门约带看 'inspectionRecordDistrict/:check_status' => ['index/OfficeReport/inspectionRecordAll', ['method' => 'GET'], ['check_status' => 2]], //部门约带看
'inspectionRecordAll/:check_status' => ['index/OfficeReport/inspectionRecordAll', ['method' => 'GET'], ['check_status' => 3]], //全部约带看 'inspectionRecordAll/:check_status' => ['index/OfficeReport/inspectionRecordAll', ['method' => 'GET'], ['check_status' => 3]], //全部约带看
'getDistance' => ['index/OfficeManage/getDistance', ['method' => 'GET']], //获取两个经纬度距离
]); ]);
Route::group('office_api', [ Route::group('office_api', [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment