Explorar el Código

锁座订单接口返回订单编码

family hace 1 año
padre
commit
11ceb8264e

+ 1 - 1
app/command/MovieOrderCommand.php

@@ -31,7 +31,7 @@ class MovieOrderCommand extends Command
31
      */
31
      */
32
     private function doMovieOrder()
32
     private function doMovieOrder()
33
     {
33
     {
34
-        $tenMinute = 600; // 10分钟
34
+        $tenMinute = MovieRepository::tenMinute; // 10分钟
35
         $time = time();
35
         $time = time();
36
 
36
 
37
         /** @var MovieRepository $movieOrderRepository */
37
         /** @var MovieRepository $movieOrderRepository */

+ 13 - 2
app/common/repositories/movie/MovieRepository.php

@@ -33,6 +33,7 @@ class MovieRepository extends BaseRepository
33
     const yanglaojin_ratio = 0.3;
33
     const yanglaojin_ratio = 0.3;
34
 
34
 
35
     const pv_ratio = 0.7;
35
     const pv_ratio = 0.7;
36
+    const tenMinute = 600;
36
 
37
 
37
     /**
38
     /**
38
      * ProductRepository constructor.
39
      * ProductRepository constructor.
@@ -249,7 +250,7 @@ class MovieRepository extends BaseRepository
249
                 if ($orderModel) return $orderModel['order_id'];
250
                 if ($orderModel) return $orderModel['order_id'];
250
                 throw new ValidateException('锁座下单失败');
251
                 throw new ValidateException('锁座下单失败');
251
             });
252
             });
252
-            return $order_id;
253
+            return compact('order_id', 'order_sn');
253
         } else {
254
         } else {
254
             throw new ValidateException($submitOrder['msg']);
255
             throw new ValidateException($submitOrder['msg']);
255
         }
256
         }
@@ -519,6 +520,7 @@ class MovieRepository extends BaseRepository
519
         $orderinfo = $this->dao->search(['order_sn' => $order_sn, 'uid' => $userinfo['uid']])->find();
520
         $orderinfo = $this->dao->search(['order_sn' => $order_sn, 'uid' => $userinfo['uid']])->find();
520
         if (empty($orderinfo)) throw new ValidateException('订单不存在');
521
         if (empty($orderinfo)) throw new ValidateException('订单不存在');
521
 
522
 
523
+        $time = time();
522
         $result = DouHuoMallFilmApiRequest::getOrderInfo($order_sn);
524
         $result = DouHuoMallFilmApiRequest::getOrderInfo($order_sn);
523
         if (!empty($result) && ($result['code'] == ApiResponseService::DEFAULT_SUCCESS_CODE)) {
525
         if (!empty($result) && ($result['code'] == ApiResponseService::DEFAULT_SUCCESS_CODE)) {
524
             $plat_orderinfo = $result['data'];
526
             $plat_orderinfo = $result['data'];
@@ -549,9 +551,18 @@ class MovieRepository extends BaseRepository
549
             ];
551
             ];
550
             $plat_orderinfo['sched_time'] = date('Y-m-d H:i', strtotime($result['data']['sched_time']));
552
             $plat_orderinfo['sched_time'] = date('Y-m-d H:i', strtotime($result['data']['sched_time']));
551
             $plat_orderinfo['schedend_time'] = date('m-d H:i', strtotime($result['data']['sched_time']) + $film['duration'] * 60);
553
             $plat_orderinfo['schedend_time'] = date('m-d H:i', strtotime($result['data']['sched_time']) + $film['duration'] * 60);
552
-            if ($plat_orderinfo['status'] == 1) {
554
+            $plat_orderinfo['time_remaining'] = 0;// 剩余时间
555
+            // 0 待支付 1 已支付 2已超时 3已取消 4已成功
556
+            $create_time = $plat_orderinfo['create_time'] + self::tenMinute;
557
+            if ($orderinfo['status'] == 0 && ($create_time < $time)) {
553
                 $plat_orderinfo['status'] = 0;
558
                 $plat_orderinfo['status'] = 0;
554
                 $plat_orderinfo['state'] = '待付款';
559
                 $plat_orderinfo['state'] = '待付款';
560
+            } elseif ($orderinfo['status'] == 1) {
561
+                $plat_orderinfo['status'] = 1;
562
+                $plat_orderinfo['state'] = '已支付';
563
+            } else {
564
+                $plat_orderinfo['status'] = 3;
565
+                $plat_orderinfo['state'] = '支付超时,已取消';
555
             }
566
             }
556
 
567
 
557
             unset($plat_orderinfo['plat_order']);
568
             unset($plat_orderinfo['plat_order']);

+ 3 - 3
app/controller/api/movie/Movie.php

@@ -203,9 +203,9 @@ class Movie extends BaseController
203
         if (empty($params['sched_seat'])) return app('json')->fail('请选择观影座位');
203
         if (empty($params['sched_seat'])) return app('json')->fail('请选择观影座位');
204
 
204
 
205
         try {
205
         try {
206
-            $order_id = $this->repository->submitOrder($this->request->userInfo(), $params);
207
-            if (!empty($order_id)) {
208
-                return app('json')->success(['oid' => $order_id, 'code' => '', 'type' => 'wx']);
206
+            $order = $this->repository->submitOrder($this->request->userInfo(), $params);
207
+            if (!empty($order)) {
208
+                return app('json')->success(['order_sn' => $order['order_sn'], 'oid' => $order['order_id'], 'code' => '', 'type' => 'wx']);
209
             } else {
209
             } else {
210
                 return app('json')->fail('锁座下单失败');
210
                 return app('json')->fail('锁座下单失败');
211
             }
211
             }