Просмотр исходного кода

Wesmiler 人人车 初始化项目 0816

APPLE 3 лет назад
Родитель
Сommit
caf5cb67aa

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

@@ -79,7 +79,7 @@ class Taxi extends ApiController
         $params = $this->request->param();
         // 参数校验
         $valid = $this->validate($params, [
-//            'taxi_id|关联车辆' => 'require',
+            'taxi_id|关联车辆' => 'require',
             'mobile|联系方式' => 'require',
             'count|乘车人数' => 'require',
             'depart|起始位置' => 'require',
@@ -143,6 +143,108 @@ class Taxi extends ApiController
     }
 
     /**
+     * 用车,新的地图下单方式
+     */
+    public function newCallTaxi()
+    {
+        $params = $this->request->param();
+        // 参数校验
+        $valid = $this->validate($params, [
+            'mobile|联系方式' => 'require',
+            'count|乘车人数' => 'require',
+            'depart|起始位置' => 'require',
+            'arrive|送达位置' => 'require',
+            'km|公里数' => 'require',
+            'price|价格' => 'require',
+        ]);
+        // 错误返回
+        if(true !== $valid){
+            return $this->ApiJson(-1, $valid);
+        };
+        $user = $this->auth->user();
+        // 统计订单
+        $count = model('common/TaxiOrder')->where('status','>=','2')->where(['is_free' => '1','user_id' =>  $user['id']])->count('id');
+
+        // 创建订单
+        $params['order_no'] = get_order_no();
+        $params['user_id'] = $user['id'];
+
+        $order = model('common/TaxiOrder')::create($params,true);
+        //
+        if ($order){
+            // 创建对应支付记录
+            $trade_no = get_order_no();
+            $logID = model('common/OrderPaylog')->storeBy([
+                'out_trade_no' => $trade_no,
+                'total_price' => $params['price'],
+                'order_idx' =>  $order['id'],
+                'ascription' => 'motor' // 归属订单
+            ]);
+            // 免单优惠 20201201 添加条件  仅限xx 公里以下 不包含 xx 公里
+            if ($count < sys_config('taxi_order_free_num','store') && $params['km'] < sys_config('taxi_order_free_km','store')){
+
+                model('common/OrderPaylog')->updateBy($logID,[
+                    'pay_price' => $params['price'],
+                    'is_pay' => 1
+                ]);
+                model('common/TaxiOrder')->updateBy($order['id'], [
+                    'is_free' => 1, // 免单
+                    'status' => 2
+                ]);
+                // 后台推送
+//                push_socket_data('motor',[
+//                    'id' => $order['id'],
+//                    'msg' => '有新的(免费)摩的订单等待处理哟,点击前往!'
+//                ]);
+                return $this->ApiJson(0,"本单免费,等待师傅接驾", [
+                    'type' => 'free',
+                    'success' => "ok!"
+                ]);
+            }
+            // 返回支付单号
+            return $this->ApiJson(0,'订单提交成功', [
+                'type' => 'wx',
+                'success' => "ok!",
+                'trade_no' => $trade_no
+            ]);
+        }
+
+        return $this->ApiJson(-1,'发生异常,请骚后重试...');
+    }
+
+
+    /**
+     * 订单详情
+     *
+     * @author 许祖兴 < zuxing.xu@lettered.cn>
+     * @date 2020/7/6 11:09
+     *
+     * @return \think\response\Json
+     * @throws \Lettered\Support\Exceptions\FailedException
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function orderInfo()
+    {
+        $param = $this->request->param();
+        // 数据校验
+        $valid = $this->validate($param, [
+            'order_no' => 'require',
+        ]);
+        // 错误
+        if (true !== $valid) {
+            return $this->ApiJson(-1, $valid);
+        }
+
+        $info = model('common/TaxiOrder')
+            ->with(['paylog','taxi','user'])
+            ->where(['user_id' => $this->auth->user()['id'], 'order_no'=> $param['order_no']])
+            ->findOrFail();
+        return $this->ApiJson(0,'获取成功', $info);
+    }
+
+    /**
      * 订单
      *
      * @author 许祖兴 < zuxing.xu@lettered.cn>

+ 1 - 1
application/common/model/TaxiOrder.php

@@ -43,7 +43,7 @@ class TaxiOrder extends BaseModel
      */
     public function taxi()
     {
-        return $this->belongsTo('Taxi','taxi_id','id');
+        return $this->belongsTo('Taxi','taxi_id','id')->with(['user']);
     }
 
     /**

+ 2 - 0
route/route.php

@@ -228,7 +228,9 @@ Route::group('api',function (){
                 // 摩的订单
                 Route::group('my',function (){
                     Route::get('order', 'api/:ver.Taxi/order'); // 我的车单
+                    Route::get('orderInfo', 'api/:ver.Taxi/orderInfo'); // 我的车单详情
                     Route::post('call', 'api/:ver.Taxi/callTaxi');  // 呼叫车辆
+                    Route::post('newCall', 'api/:ver.Taxi/newCallTaxi');  // 呼叫车辆
                     Route::get('cancel', 'api/:ver.Taxi/cancelOrder');  // 取消订单
                 });
 

+ 0 - 53
vendor/lcobucci/jwt/test/functional/Keys.php

@@ -1,53 +0,0 @@
-<?php
-namespace Lcobucci\JWT;
-
-use Lcobucci\JWT\Signer\Keychain;
-
-/**
- * @author Luís Otávio Cobucci Oblonczyk <lcobucci@gmail.com>
- */
-trait Keys
-{
-    /**
-     * @var array
-     */
-    protected static $rsaKeys;
-
-    /**
-     * @var array
-     */
-    protected static $ecdsaKeys;
-
-    /**
-     * @beforeClass
-     */
-    public static function createRsaKeys()
-    {
-        $keychain = new Keychain();
-        $dir = 'file://' . __DIR__;
-
-        static::$rsaKeys = [
-            'private' => $keychain->getPrivateKey($dir . '/rsa/private.key'),
-            'public' => $keychain->getPublicKey($dir . '/rsa/public.key'),
-            'encrypted-private' => $keychain->getPrivateKey($dir . '/rsa/encrypted-private.key', 'testing'),
-            'encrypted-public' => $keychain->getPublicKey($dir . '/rsa/encrypted-public.key')
-        ];
-    }
-
-    /**
-     * @beforeClass
-     */
-    public static function createEcdsaKeys()
-    {
-        $keychain = new Keychain();
-        $dir = 'file://' . __DIR__;
-
-        static::$ecdsaKeys = [
-            'private' => $keychain->getPrivateKey($dir . '/ecdsa/private.key'),
-            'private-params' => $keychain->getPrivateKey($dir . '/ecdsa/private2.key'),
-            'public1' => $keychain->getPublicKey($dir . '/ecdsa/public1.key'),
-            'public2' => $keychain->getPublicKey($dir . '/ecdsa/public2.key'),
-            'public-params' => $keychain->getPublicKey($dir . '/ecdsa/public3.key'),
-        ];
-    }
-}

+ 154 - 0
vendor/qeq66/jwt/test/functional/RFC6978VectorTest.php

@@ -0,0 +1,154 @@
+<?php
+namespace Lcobucci\JWT\FunctionalTests;
+
+use Lcobucci\JWT\Signer\Ecdsa;
+use Lcobucci\JWT\Signer\Ecdsa\Sha256;
+use Lcobucci\JWT\Signer\Ecdsa\Sha384;
+use Lcobucci\JWT\Signer\Ecdsa\Sha512;
+use Lcobucci\JWT\Signer\Key;
+use PHPUnit\Framework\TestCase;
+use const PHP_EOL;
+use function assert;
+use function hex2bin;
+use function is_string;
+
+final class RFC6978VectorTest extends TestCase
+{
+    /**
+     * @see https://tools.ietf.org/html/rfc6979#appendix-A.2.5
+     * @see https://tools.ietf.org/html/rfc6979#appendix-A.2.6
+     * @see https://tools.ietf.org/html/rfc6979#appendix-A.2.7
+     *
+     * @test
+     * @dataProvider dataRFC6979
+     *
+     * @covers \Lcobucci\JWT\Signer\Key
+     * @covers \Lcobucci\JWT\Signer\Ecdsa
+     * @covers \Lcobucci\JWT\Signer\Ecdsa\MultibyteStringConverter
+     * @covers \Lcobucci\JWT\Signer\Ecdsa\Sha256
+     * @covers \Lcobucci\JWT\Signer\Ecdsa\Sha384
+     * @covers \Lcobucci\JWT\Signer\Ecdsa\Sha512
+     * @covers \Lcobucci\JWT\Signer\OpenSSL
+     * @covers \Lcobucci\JWT\Signer\BaseSigner
+     */
+    public function theVectorsFromRFC6978CanBeVerified(
+        Ecdsa $signer,
+        Key $key,
+        $payload,
+        $expectedR,
+        $expectedS
+    ) {
+        $signature = hex2bin($expectedR . $expectedS);
+        assert(is_string($signature));
+
+        static::assertTrue($signer->verify($signature, $payload, $key));
+    }
+
+    /**
+     * @return mixed[]
+     */
+    public function dataRFC6979()
+    {
+        return $this->sha256Data() + $this->sha384Data() + $this->sha512Data();
+    }
+
+    /**
+     * @return mixed[]
+     */
+    public function sha256Data()
+    {
+        $signer = new Sha256();
+        $key    = new Key(
+            '-----BEGIN PUBLIC KEY-----' . PHP_EOL
+            . 'MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEYP7UuiVanTHJYet0xjVtaMBJuJI7' . PHP_EOL
+            . 'Yfps5mliLmDyn7Z5A/4QCLi8maQa6elWKLxk8vGyDC1+n1F3o8KU1EYimQ==' . PHP_EOL
+            . '-----END PUBLIC KEY-----'
+        );
+
+        return [
+            'SHA-256 (sample)' => [
+                $signer,
+                $key,
+                'sample',
+                'EFD48B2AACB6A8FD1140DD9CD45E81D69D2C877B56AAF991C34D0EA84EAF3716',
+                'F7CB1C942D657C41D436C7A1B6E29F65F3E900DBB9AFF4064DC4AB2F843ACDA8',
+            ],
+            'SHA-256 (test)' => [
+                $signer,
+                $key,
+                'test',
+                'F1ABB023518351CD71D881567B1EA663ED3EFCF6C5132B354F28D3B0B7D38367',
+                '019F4113742A2B14BD25926B49C649155F267E60D3814B4C0CC84250E46F0083',
+            ]
+        ];
+    }
+
+    /**
+     * @return mixed[]
+     */
+    public function sha384Data()
+    {
+        $signer = new Sha384();
+        $key    = new Key(
+            '-----BEGIN PUBLIC KEY-----' . PHP_EOL
+            . 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE7DpOQVtOGaRWhhgCn0J/pdqai8SukuAu' . PHP_EOL
+            . 'BqrlKGswDGTe+PDqkFWGYGSiVFFUgLwTgBXZty19VyROqO+awMYhiWcIpZNn+d+5' . PHP_EOL
+            . '9UyoSz8cnbEoiyMcOuDU/nNE/SUzJkcg' . PHP_EOL
+            . '-----END PUBLIC KEY-----'
+        );
+
+        return [
+            'SHA-384 (sample)' => [
+                $signer,
+                $key,
+                'sample',
+                '94EDBB92A5ECB8AAD4736E56C691916B3F88140666CE9FA73D64C4EA95AD133C81A648152E44ACF96E36DD1E80FABE46',
+                '99EF4AEB15F178CEA1FE40DB2603138F130E740A19624526203B6351D0A3A94FA329C145786E679E7B82C71A38628AC8',
+            ],
+            'SHA-384 (test)' => [
+                $signer,
+                $key,
+                'test',
+                '8203B63D3C853E8D77227FB377BCF7B7B772E97892A80F36AB775D509D7A5FEB0542A7F0812998DA8F1DD3CA3CF023DB',
+                'DDD0760448D42D8A43AF45AF836FCE4DE8BE06B485E9B61B827C2F13173923E06A739F040649A667BF3B828246BAA5A5',
+            ]
+        ];
+    }
+
+    /**
+     * @return mixed[]
+     */
+    public function sha512Data()
+    {
+        $signer = new Sha512();
+        $key    = new Key(
+            '-----BEGIN PUBLIC KEY-----' . PHP_EOL
+            . 'MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBiUVQ0HhZMuAOqiO2lPIT+MMSH4bc' . PHP_EOL
+            . 'l6BOWnFn205bzTcRI9RuRdtrXVNwp/IPtjMVXTj/oW0r12HcrEdLmi9QI6QASTEB' . PHP_EOL
+            . 'yWLNTS/d94IoXmRYQTnC+RtH+H/4I1TWYw90aiig2yV0G1s0qCgAiyKswj+ST6r7' . PHP_EOL
+            . '1NM/gepmlW3+qiv9/PU=' . PHP_EOL
+            . '-----END PUBLIC KEY-----'
+        );
+
+        return [
+            'SHA-512 (sample)' => [
+                $signer,
+                $key,
+                'sample',
+                '00C328FAFCBD79DD77850370C46325D987CB525569FB63C5D3BC53950E6D4C5F174E25A1EE9017B5D450606ADD152B534931D7D4E8'
+                . '455CC91F9B15BF05EC36E377FA',
+                '00617CCE7CF5064806C467F678D3B4080D6F1CC50AF26CA209417308281B68AF282623EAA63E5B5C0723D8B8C37FF0777B1A20F8CC'
+                . 'B1DCCC43997F1EE0E44DA4A67A',
+            ],
+            'SHA-512 (test)' => [
+                $signer,
+                $key,
+                'test',
+                '013E99020ABF5CEE7525D16B69B229652AB6BDF2AFFCAEF38773B4B7D08725F10CDB93482FDCC54EDCEE91ECA4166B2A7C6265EF0C'
+                . 'E2BD7051B7CEF945BABD47EE6D',
+                '01FBD0013C674AA79CB39849527916CE301C66EA7CE8B80682786AD60F98F7E78A19CA69EFF5C57400E3B3A0AD66CE0978214D13BA'
+                . 'F4E9AC60752F7B155E2DE4DCE3',
+            ],
+        ];
+    }
+}