Selaa lähdekoodia

调整下单支付接口

family 1 vuosi sitten
vanhempi
commit
cb32005513

+ 10 - 6
app/common/repositories/movie/MovieRepository.php

@@ -268,7 +268,7 @@ class MovieRepository extends BaseRepository
268
         if ($orderinfo['paid'] == 0 && $orderinfo['status'] == 3) throw new ValidateException('订单已取消');
268
         if ($orderinfo['paid'] == 0 && $orderinfo['status'] == 3) throw new ValidateException('订单已取消');
269
         if ($orderinfo['paid'] == 1) throw new ValidateException('订单已支付');
269
         if ($orderinfo['paid'] == 1) throw new ValidateException('订单已支付');
270
 
270
 
271
-        $res = $this->movie_pay(strtolower($pay_type), $code, $userinfo['wechat_user_id'], $orderinfo, $orderinfo['film_name'], env('APP_URL') . "/api/hf_notify/movie", 'delay');
271
+        $res = $this->movie_pay(strtolower($pay_type), $code, '', $orderinfo, $orderinfo['film_name'], env('APP_URL') . "/api/hf_notify/movie", 'delay');
272
         Db::name('log')->insert(['data' => '汇付电影票订单支付--- 返回参数' . json_encode($res)]);
272
         Db::name('log')->insert(['data' => '汇付电影票订单支付--- 返回参数' . json_encode($res)]);
273
         if (isset($res['id'])) {
273
         if (isset($res['id'])) {
274
             $type = 0;
274
             $type = 0;
@@ -574,10 +574,15 @@ class MovieRepository extends BaseRepository
574
         $time = time();
574
         $time = time();
575
         // 订单状态 0:待支付;1:已出票;3:已取消
575
         // 订单状态 0:待支付;1:已出票;3:已取消
576
         $create_time = $create_time + self::tenMinute;
576
         $create_time = $create_time + self::tenMinute;
577
-        if ($plat_status == 1 && ($create_time < $time)) {
578
-            $status = 0;
579
-            $state = '待付款';
580
-            $time_remaining = $time - $create_time;
577
+        if (($plat_status == 0) || ($plat_status == 1)) {
578
+            if ($create_time < $time) {
579
+                $status = 3;
580
+                $state = '支付超时,已取消';
581
+            } else {
582
+                $status = 0;
583
+                $state = '待付款';
584
+                $time_remaining = $time - $create_time;
585
+            }
581
         } elseif ($plat_status == 5) {
586
         } elseif ($plat_status == 5) {
582
             $status = 3;
587
             $status = 3;
583
             $state = '支付超时,已取消';
588
             $state = '支付超时,已取消';
@@ -590,7 +595,6 @@ class MovieRepository extends BaseRepository
590
         }
595
         }
591
 
596
 
592
         return compact('status', 'state', 'time_remaining');
597
         return compact('status', 'state', 'time_remaining');
593
-
594
     }
598
     }
595
 
599
 
596
     /**
600
     /**

+ 25 - 1
app/controller/api/merchant/sxy/Access.php

@@ -3,10 +3,12 @@ namespace app\controller\api\merchant\sxy;
3
 
3
 
4
 use alipay\aop\AopClient;
4
 use alipay\aop\AopClient;
5
 use alipay\aop\request\AlipaySystemOauthTokenRequest;
5
 use alipay\aop\request\AlipaySystemOauthTokenRequest;
6
+use app\common\dao\movie\order\MovieOrderDao;
6
 use app\common\model\store\order\StoreOrder;
7
 use app\common\model\store\order\StoreOrder;
7
 use app\common\model\user\UserCertification;
8
 use app\common\model\user\UserCertification;
8
 use app\common\repositories\merchant\order\OrderGzcRepository;
9
 use app\common\repositories\merchant\order\OrderGzcRepository;
9
 use app\common\repositories\merchant\order\OrderMerchantRepository;
10
 use app\common\repositories\merchant\order\OrderMerchantRepository;
11
+use app\common\repositories\movie\MovieRepository;
10
 use app\common\repositories\store\order\StoreGroupOrderRepository;
12
 use app\common\repositories\store\order\StoreGroupOrderRepository;
11
 use app\common\repositories\store\order\StoreOrderRepository;
13
 use app\common\repositories\store\order\StoreOrderRepository;
12
 use app\controller\Aes;
14
 use app\controller\Aes;
@@ -787,7 +789,7 @@ class Access
787
             }
789
             }
788
             //b2 精彩生活区的现金+积分支付
790
             //b2 精彩生活区的现金+积分支付
789
             if($array_fzone_paytype['type'] == 'b2'){
791
             if($array_fzone_paytype['type'] == 'b2'){
790
-                
792
+
791
                 $userdata = Db::name('user')->where('uid',$store_order_data['uid'])->find();
793
                 $userdata = Db::name('user')->where('uid',$store_order_data['uid'])->find();
792
                 //查询用户的积分是否足够
794
                 //查询用户的积分是否足够
793
                 $score_pri = $userdata['score'] - $array_fzone_paytype['other'];
795
                 $score_pri = $userdata['score'] - $array_fzone_paytype['other'];
@@ -2310,4 +2312,26 @@ class Access
2310
         }
2312
         }
2311
 
2313
 
2312
     }
2314
     }
2315
+
2316
+    /**
2317
+     * 电影票支付
2318
+     *
2319
+     * @return mixed
2320
+     */
2321
+    public function dy_pay_wechat_mp()
2322
+    {
2323
+        $order_id = Request::param('oid', '');
2324
+        $code = Request::param('code', '');
2325
+        $pay_type = Request::param('type', '');
2326
+        if (empty($order_id)) return app('json')->fail('订单不存在');
2327
+        if (empty($pay_type) || !in_array(strtolower($pay_type), ['wx', 'ali'])) return app('json')->fail('请选择支付方式');
2328
+
2329
+        try {
2330
+            /** @var MovieRepository $movieRepository */
2331
+            $movieRepository = new MovieRepository(new MovieOrderDao());
2332
+            return app('json')->success($movieRepository->confirmOrder(null, $order_id, $pay_type, $code));
2333
+        } catch (\Exception $exception) {
2334
+            return app('json')->fail($exception->getMessage());
2335
+        }
2336
+    }
2313
 }
2337
 }

+ 2 - 1
route/api.php

@@ -1168,6 +1168,8 @@ Route::group('api/', function () {
1168
     //首信易回调
1168
     //首信易回调
1169
     Route::any('notify/:type', 'api.merchant.sxy.Access/notify');//回调
1169
     Route::any('notify/:type', 'api.merchant.sxy.Access/notify');//回调
1170
     Route::any('test1111', 'api.merchant.sxy.Access/test1111');//回调
1170
     Route::any('test1111', 'api.merchant.sxy.Access/test1111');//回调
1171
+    ////app小程序电影票支付
1172
+    Route::get('dy_pay_wechat_mp', 'api.merchant.sxy.Access/dy_pay_wechat_mp');
1171
     //app小程序支付
1173
     //app小程序支付
1172
     Route::get('sxy_pay_wechat_mp', 'api.merchant.sxy.Access/pay_wechat_mp');
1174
     Route::get('sxy_pay_wechat_mp', 'api.merchant.sxy.Access/pay_wechat_mp');
1173
     //app小程序话费支付
1175
     //app小程序话费支付
@@ -1290,7 +1292,6 @@ Route::group('api/', function () {
1290
     Route::group('movie', function () {
1292
     Route::group('movie', function () {
1291
         Route::post('submit_order', '/submitOrder');
1293
         Route::post('submit_order', '/submitOrder');
1292
         Route::post('confirm_order', '/confirmOrder');
1294
         Route::post('confirm_order', '/confirmOrder');
1293
-        Route::post('dy_pay_wechat_mp', '/confirmOrder');
1294
         Route::get('order_list', '/getOrderList'); // 订单列表
1295
         Route::get('order_list', '/getOrderList'); // 订单列表
1295
         Route::get('order_info', '/getOrderInfo');
1296
         Route::get('order_info', '/getOrderInfo');
1296
     })->prefix('api.movie.Movie')->middleware(\app\common\middleware\UserTokenMiddleware::class, false);
1297
     })->prefix('api.movie.Movie')->middleware(\app\common\middleware\UserTokenMiddleware::class, false);