|
|
@@ -0,0 +1,71 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+namespace app\api\controller\v1\taxiUser;
|
|
|
+
|
|
|
+
|
|
|
+use app\api\controller\ApiController;
|
|
|
+use app\common\model\Users;
|
|
|
+use app\http\IResponse;
|
|
|
+use EasyWeChat\Factory;
|
|
|
+use Lettered\Support\Upload;
|
|
|
+use think\App;
|
|
|
+use app\api\service\JWTAuth as IAuth;
|
|
|
+use think\Db;
|
|
|
+use think\Exception;
|
|
|
+
|
|
|
+class Order extends ApiController
|
|
|
+{
|
|
|
+ protected $model;
|
|
|
+
|
|
|
+ public function __construct(App $app = null, IAuth $auth)
|
|
|
+ {
|
|
|
+ parent::__construct($app, $auth);
|
|
|
+ $this->model = new \app\common\model\TaxiOrder();
|
|
|
+ $this->taxiUserModel = new \app\api\model\taxi\User();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function index()
|
|
|
+ {
|
|
|
+ // 1. 传入用户位置
|
|
|
+ $param = $this->request->param();
|
|
|
+ // 数据校验
|
|
|
+ $valid = $this->validate($param, [
|
|
|
+ 'lng' => ['require','regex|-?((0|1?[0-7]?[0-9]?)(([.][0-9]{1,4})?)|180(([.][0]{1,4})?))'],
|
|
|
+ 'lat' => ['require','regex|-?((0|1?[0-7]?[0-9]?)(([.][0-9]{1,4})?)|180(([.][0]{1,4})?))'],
|
|
|
+ 'page' => 'require',
|
|
|
+ ],[
|
|
|
+ 'lng.require' => '缺少经度参数',
|
|
|
+ 'lng.regex' => '经度参数有误',
|
|
|
+ 'lat.require' => '缺少维度参数',
|
|
|
+ 'lat.regex' => '维度参数有误'
|
|
|
+ ]);
|
|
|
+ // 错误
|
|
|
+ if (true !== $valid){
|
|
|
+ return $this->ApiJson(-1,$valid);
|
|
|
+ }
|
|
|
+
|
|
|
+ $limit = 20;
|
|
|
+ $taxiUser = $this->auth->guard('taxi_user')->user();
|
|
|
+// $carType =
|
|
|
+
|
|
|
+ // 经纬度升序
|
|
|
+ $lists = $this->model
|
|
|
+ ->fieldRaw("* , TRUNCATE(( 6371 * acos (
|
|
|
+ cos ( radians(".$param['lat'].") )
|
|
|
+ * cos( radians( latitude ) )
|
|
|
+ * cos( radians( longitude ) - radians(".$param['lng'].") )
|
|
|
+ + sin ( radians(".$param['lat'].") )
|
|
|
+ * sin( radians( latitude ) )
|
|
|
+ )
|
|
|
+ ), 2) AS distance")
|
|
|
+ ->having('distance < 10')
|
|
|
+ ->where(['status' => 2])
|
|
|
+ ->where(['status' => 2])
|
|
|
+ ->order(['distance' => 'ASC'])
|
|
|
+ ->limit((($param['page'] - 1) * $limit) . "," . $limit)
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ return $this->ApiJson(0,'', $lists);
|
|
|
+ }
|
|
|
+}
|