|
|
@@ -190,11 +190,6 @@ class MovieRepository extends BaseRepository
|
|
190
|
190
|
$storeOrder = app()->make(StoreOrderRepository::class);
|
|
191
|
191
|
$order_sn = substr($storeOrder->getNewOrderId(), 0, 20);
|
|
192
|
192
|
|
|
193
|
|
- /** @var CinemaSchedRepository $cinemaSchedRepository */
|
|
194
|
|
-// $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
|
|
195
|
|
-// $sched = $cinemaSchedRepository->getCinemaSchedInfo($params['relation_id'], $params['sched_sign']);
|
|
196
|
|
-// if (empty($sched)) throw new ValidateException('观影场次不存在');
|
|
197
|
|
-
|
|
198
|
193
|
$channel_sn = json_decode(base64_decode($params['channel_sn']), true);
|
|
199
|
194
|
if (empty($channel_sn) || !isset($channel_sn['channel_type']) || empty($channel_sn['channel_type']) || !isset($channel_sn['price'])
|
|
200
|
195
|
|| empty($channel_sn['price']) || json_last_error()) {
|
|
|
@@ -528,7 +523,7 @@ class MovieRepository extends BaseRepository
|
|
528
|
523
|
$plat_orderinfo['type'] = ($orderinfo['pay_type'] == 1) ? 'wx' : ($orderinfo['pay_type'] == 2 ? 'ali' : 'wx');
|
|
529
|
524
|
$plat_orderinfo['order_price'] = $orderinfo['order_price'];
|
|
530
|
525
|
$plat_orderinfo['order_sn'] = $order_sn;
|
|
531
|
|
- $plat_orderinfo['create_time'] = strtotime($orderinfo['create_time']);
|
|
|
526
|
+ $plat_orderinfo['create_time'] = strtotime($orderinfo['create_time']);// 下单时间戳
|
|
532
|
527
|
$plat_orderinfo['phone'] = $orderinfo['mobile'];
|
|
533
|
528
|
$plat_orderinfo['sched_seat'] = json_decode($orderinfo['sched_seat'], true);
|
|
534
|
529
|
$plat_orderinfo['cinema'] = [
|
|
|
@@ -551,20 +546,12 @@ class MovieRepository extends BaseRepository
|
|
551
|
546
|
];
|
|
552
|
547
|
$plat_orderinfo['sched_time'] = date('Y-m-d H:i', strtotime($result['data']['sched_time']));
|
|
553
|
548
|
$plat_orderinfo['schedend_time'] = date('m-d H:i', strtotime($result['data']['sched_time']) + $film['duration'] * 60);
|
|
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)) {
|
|
558
|
|
- $plat_orderinfo['status'] = 0;
|
|
559
|
|
- $plat_orderinfo['state'] = '待付款';
|
|
560
|
|
- $plat_orderinfo['time_remaining'] = $time - $plat_orderinfo['create_time'];
|
|
561
|
|
- } elseif ($orderinfo['status'] == 1) {
|
|
562
|
|
- $plat_orderinfo['status'] = 1;
|
|
563
|
|
- $plat_orderinfo['state'] = '已支付';
|
|
564
|
|
- } else {
|
|
565
|
|
- $plat_orderinfo['status'] = 3;
|
|
566
|
|
- $plat_orderinfo['state'] = '支付超时,已取消';
|
|
567
|
|
- }
|
|
|
549
|
+
|
|
|
550
|
+ // 订单状态 0:待支付;1:已出票;3:已取消
|
|
|
551
|
+ $statuspayinfo = $this->getOrderStatus($plat_orderinfo['create_time'], $plat_orderinfo['status']);
|
|
|
552
|
+ $plat_orderinfo['status'] = $statuspayinfo['status'];
|
|
|
553
|
+ $plat_orderinfo['state'] = $statuspayinfo['state'];
|
|
|
554
|
+ $plat_orderinfo['time_remaining'] = $statuspayinfo['time_remaining'];// 支付倒计时
|
|
568
|
555
|
|
|
569
|
556
|
unset($plat_orderinfo['plat_order']);
|
|
570
|
557
|
unset($plat_orderinfo['third_order']);
|
|
|
@@ -574,6 +561,39 @@ class MovieRepository extends BaseRepository
|
|
574
|
561
|
}
|
|
575
|
562
|
|
|
576
|
563
|
/**
|
|
|
564
|
+ * 获取订单状态
|
|
|
565
|
+ *
|
|
|
566
|
+ * @param $create_time
|
|
|
567
|
+ * @param $plat_status
|
|
|
568
|
+ * @return array
|
|
|
569
|
+ */
|
|
|
570
|
+ private function getOrderStatus($create_time, $plat_status = 0)
|
|
|
571
|
+ {
|
|
|
572
|
+ $time_remaining = 0;
|
|
|
573
|
+
|
|
|
574
|
+ $time = time();
|
|
|
575
|
+ // 订单状态 0:待支付;1:已出票;3:已取消
|
|
|
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;
|
|
|
581
|
+ } elseif ($plat_status == 5) {
|
|
|
582
|
+ $status = 3;
|
|
|
583
|
+ $state = '支付超时,已取消';
|
|
|
584
|
+ } elseif ($plat_status == 6) {
|
|
|
585
|
+ $status = 1;
|
|
|
586
|
+ $state = '已出票';
|
|
|
587
|
+ } else {
|
|
|
588
|
+ $status = 3;
|
|
|
589
|
+ $state = '支付超时,已取消';
|
|
|
590
|
+ }
|
|
|
591
|
+
|
|
|
592
|
+ return compact('status', 'state', 'time_remaining');
|
|
|
593
|
+
|
|
|
594
|
+ }
|
|
|
595
|
+
|
|
|
596
|
+ /**
|
|
577
|
597
|
* @return array
|
|
578
|
598
|
* @throws \think\db\exception\DataNotFoundException
|
|
579
|
599
|
* @throws \think\db\exception\DbException
|
|
|
@@ -845,7 +865,7 @@ class MovieRepository extends BaseRepository
|
|
845
|
865
|
default:
|
|
846
|
866
|
break;
|
|
847
|
867
|
}
|
|
848
|
|
- $time = time();
|
|
|
868
|
+ $film = [];
|
|
849
|
869
|
|
|
850
|
870
|
$field = 'order_sn,order_price,city_name,area_name,cinema_name,address,hall_name,film_sign,film_name,show_date,show_time,sched_seat,number,status,create_time';
|
|
851
|
871
|
$movie_order = $this->dao->search($where)
|
|
|
@@ -853,23 +873,16 @@ class MovieRepository extends BaseRepository
|
|
853
|
873
|
$query->page($page, $limit);
|
|
854
|
874
|
})->order('order_id desc')->field([$field])->select()->toArray();
|
|
855
|
875
|
foreach ($movie_order as $key => $value) {
|
|
|
876
|
+ if (!isset($film[$value['film_sign']])) $film[$value['film_sign']] = Db::name('movie_film')->where('film_sign', $value['film_sign'])->value('cover_img');
|
|
856
|
877
|
$movie_order[$key]['sched_seat'] = json_decode($value['sched_seat'], true);
|
|
857
|
|
- $movie_order[$key]['cover_img'] = Db::name('movie_film')->where('film_sign', $value['film_sign'])->value('cover_img');
|
|
858
|
|
- $movie_order[$key]['time_remaining']= 0;
|
|
859
|
|
-
|
|
860
|
|
- // 0 待支付 1 已支付 2已超时 3已取消 4已成功
|
|
861
|
|
- $create_time = strtotime($value['create_time']) + self::tenMinute;
|
|
862
|
|
- if ($value['status'] == 0 && ($create_time < $time)) {
|
|
863
|
|
- $movie_order[$key]['status'] = 0;
|
|
864
|
|
- $movie_order[$key]['state'] = '待付款';
|
|
865
|
|
- $movie_order[$key]['time_remaining'] = $time - strtotime($value['create_time']);
|
|
866
|
|
- } elseif ($value['status'] == 1) {
|
|
867
|
|
- $movie_order[$key]['status'] = 1;
|
|
868
|
|
- $movie_order[$key]['state'] = '已支付';
|
|
869
|
|
- } else {
|
|
870
|
|
- $movie_order[$key]['status'] = 3;
|
|
871
|
|
- $movie_order[$key]['state'] = '支付超时,已取消';
|
|
872
|
|
- }
|
|
|
878
|
+ $movie_order[$key]['cover_img'] = $film[$value['film_sign']];
|
|
|
879
|
+ $movie_order[$key]['time_remaining'] = 0;
|
|
|
880
|
+
|
|
|
881
|
+ // 订单状态 0:待支付;1:已出票;3:已取消
|
|
|
882
|
+ $statuspayinfo = $this->getOrderStatus(strtotime($value['create_time']), $value['status']);
|
|
|
883
|
+ $movie_order[$key]['status'] = $statuspayinfo['status'];
|
|
|
884
|
+ $movie_order[$key]['state'] = $statuspayinfo['state'];
|
|
|
885
|
+ $movie_order[$key]['time_remaining'] = $statuspayinfo['time_remaining'];// 支付倒计时
|
|
873
|
886
|
}
|
|
874
|
887
|
|
|
875
|
888
|
$count = $this->dao->search($where)->count();
|