Parcourir la source

Wesmiler 人人车 初始化项目 0816

APPLE il y a 3 ans
Parent
commit
b8ae1794bb

+ 1 - 0
application/api/controller/v1/Taxi.php

@@ -169,6 +169,7 @@ class Taxi extends ApiController
         // 创建订单
         $params = [
             'user_id'=> $user['id'],
+            'category_id'=> isset($datas['category_id'])? $datas['category_id'] : 0,
             'order_no'=> get_order_no(),
             'price'=> isset($datas['price'])? $datas['price'] : 0.00,
             'count'=> isset($datas['count'])? $datas['count'] : 0,

+ 71 - 0
application/api/controller/v1/taxiUser/Order.php

@@ -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);
+    }
+}

+ 6 - 6
application/api/controller/v1/taxiUser/User.php

@@ -126,7 +126,7 @@ class User extends ApiController
             return IResponse::failure('用户不存在,或已被冻结');
         }
         if(!$taxiUser['user_id']){
-            return IResponse::failure('司机未绑定用户账号');
+            return IResponse::failure( "司机未绑定用户账号");
         }
 
         $user = $this->model->where(['id'=> $taxiUser['user_id']])
@@ -135,17 +135,17 @@ class User extends ApiController
 
         // 司机资产限制
         if ($user['partnership'] <= sys_config('user_withdraw_limit','user')){
-            return $this->ApiJson(-1, "当前可提现金额不满足!司机资产:【". $user['partnership'] . "】");
+            return IResponse::failure("当前可提现金额不满足!司机资产:【". $user['partnership'] . "】");
         }
 
         // 最低限制
         if ($params['amount'] <= ($limit = sys_config('user_withdraw_limit','user'))){
-            //return $this->ApiJson(-1, "申请提现金额不满足最低提现!最低:【" . $limit . "】");
+            //return IResponse::failure("申请提现金额不满足最低提现!最低:【" . $limit . "】");
         }
 
         // 最高限制
         if ($user['partnership'] <= $params['amount']){
-            return $this->ApiJson(-1, "当前可提现金额不满足!资产:【". $user['partnership'] . "】");
+            return IResponse::failure("当前可提现金额不满足!资产:【". $user['partnership'] . "】");
         }
         // 写入用户ID
         $params['user_id'] = $user['id'];
@@ -164,11 +164,11 @@ class User extends ApiController
             $Users->changePartnership($user['id'], $ret['amount'], '资产提现', 20);
             Db::commit();
 
-            return $this->ApiJson(0, '提现申请成功,请等候审核');
+            return IResponse::success('提现申请成功,请等候审核');
         }
         catch(Exception $e) {
             Db::rollback();
-            return $this->ApiJson(-1, '提现失败,请稍后重试');
+            return IResponse::failure( '提现失败,请稍后重试');
         }
     }