family 1 rok temu
rodzic
commit
d835d0313b

+ 23 - 8
app/common/repositories/movie/MovieRepository.php

@@ -16,8 +16,6 @@ use app\traits\HuiPay;
16
 use crmeb\services\ApiResponseService;
16
 use crmeb\services\ApiResponseService;
17
 use think\exception\ValidateException;
17
 use think\exception\ValidateException;
18
 use think\facade\Db;
18
 use think\facade\Db;
19
-use think\facade\Log;
20
-use function Symfony\Component\String\b;
21
 
19
 
22
 /**
20
 /**
23
  * Class MovieRepository
21
  * Class MovieRepository
@@ -175,7 +173,7 @@ class MovieRepository extends BaseRepository
175
     {
173
     {
176
         /** @var StoreOrderRepository $storeOrder */
174
         /** @var StoreOrderRepository $storeOrder */
177
         $storeOrder = app()->make(StoreOrderRepository::class);
175
         $storeOrder = app()->make(StoreOrderRepository::class);
178
-        $order_sn = $storeOrder->getNewOrderId() . '0';
176
+        $order_sn = substr($storeOrder->getNewOrderId(), 0, 20);
179
 
177
 
180
         /** @var CinemaSchedRepository $cinemaSchedRepository */
178
         /** @var CinemaSchedRepository $cinemaSchedRepository */
181
         $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
179
         $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
@@ -249,13 +247,13 @@ class MovieRepository extends BaseRepository
249
      */
247
      */
250
     public function confirmOrder($userinfo, $order_sn, $pay_type)
248
     public function confirmOrder($userinfo, $order_sn, $pay_type)
251
     {
249
     {
252
-        $orderinfo = $this->dao->getWhere(['order_sn' => $order_sn, 'uid' => $userinfo->uid])->find();
250
+        $orderinfo = $this->dao->search(['order_sn' => $order_sn, 'uid' => $userinfo['uid']])->find();
253
         if (empty($orderinfo)) throw new ValidateException('订单不存在');
251
         if (empty($orderinfo)) throw new ValidateException('订单不存在');
254
         if ($orderinfo['paid'] == 0 && $orderinfo['status'] == 2) throw new ValidateException('订单已超时');
252
         if ($orderinfo['paid'] == 0 && $orderinfo['status'] == 2) throw new ValidateException('订单已超时');
255
         if ($orderinfo['paid'] == 0 && $orderinfo['status'] == 3) throw new ValidateException('订单已取消');
253
         if ($orderinfo['paid'] == 0 && $orderinfo['status'] == 3) throw new ValidateException('订单已取消');
256
         if ($orderinfo['paid'] == 1) throw new ValidateException('订单已支付');
254
         if ($orderinfo['paid'] == 1) throw new ValidateException('订单已支付');
257
 
255
 
258
-        $res = $this->pay($pay_type, $userinfo->wechat_user_id, $orderinfo, $orderinfo['film_name'], env('APP_URL') . "/api/hf_notify/movie", 'delay');
256
+        $res = $this->pay($pay_type, $userinfo['wechat_user_id'], $orderinfo, $orderinfo['film_name'], env('APP_URL') . "/api/hf_notify/movie", 'delay');
259
         Db::name('log')->insert(['data' => '汇付电影票订单支付--- 返回参数' . json_encode($res)]);
257
         Db::name('log')->insert(['data' => '汇付电影票订单支付--- 返回参数' . json_encode($res)]);
260
         if (isset($res['id'])) {
258
         if (isset($res['id'])) {
261
             $type = 0;
259
             $type = 0;
@@ -355,11 +353,28 @@ class MovieRepository extends BaseRepository
355
      */
353
      */
356
     public function getOrderInfo($userinfo, $order_sn)
354
     public function getOrderInfo($userinfo, $order_sn)
357
     {
355
     {
358
-        $orderinfo = $this->dao->getWhere(['order_sn' => $order_sn, 'uid' => $userinfo->uid])->find();
356
+        $orderinfo = $this->dao->search(['order_sn' => $order_sn, 'uid' => $userinfo['uid']])->find();
359
         if (empty($orderinfo)) throw new ValidateException('订单不存在');
357
         if (empty($orderinfo)) throw new ValidateException('订单不存在');
360
 
358
 
361
         $result = DouHuoMallFilmApiRequest::getOrderInfo($order_sn);
359
         $result = DouHuoMallFilmApiRequest::getOrderInfo($order_sn);
362
-        if (!empty($result) && ($result['code'] == ApiResponseService::DEFAULT_SUCCESS_CODE)) return $result['data'];
360
+        if (!empty($result) && ($result['code'] == ApiResponseService::DEFAULT_SUCCESS_CODE)) {
361
+            $plat_orderinfo = $result['data'];
362
+            $plat_orderinfo['order_sn'] = $plat_orderinfo['third_order'];
363
+            $plat_orderinfo['sched_seat'] = base64_encode(json_encode($plat_orderinfo['sched_seat'], JSON_FORCE_OBJECT));
364
+            $plat_orderinfo['order_price'] = $orderinfo['order_price'];
365
+            $plat_orderinfo['sched_seat'] = json_decode($orderinfo['sched_seat'], true);
366
+            $plat_orderinfo['cinema_film'] = Db::name('movie_cinema_sched')
367
+                ->where('film_sign', $orderinfo['film_sign'])
368
+                ->where(['relation_id' => $orderinfo['relation_id'], 'sched_sign' => $orderinfo['sched_sign']])
369
+                ->field('cinema_sign,cinema_name,address,longitude,latitude,hall_sign,hall_name,film_sign,film_name,show_date,show_time')
370
+                ->find();
371
+            $plat_orderinfo['cinema_film']['show_date'] = date('Y-m-d', $plat_orderinfo['cinema_film']['show_date']);
372
+            $plat_orderinfo['cinema_film']['cover_img'] = Db::name('movie_film')->where('film_sign', $orderinfo['film_sign'])->value('cover_img');
373
+
374
+            unset($plat_orderinfo['plat_order']);
375
+            unset($plat_orderinfo['third_order']);
376
+            return $plat_orderinfo;
377
+        }
363
         throw new ValidateException('订单不存在');
378
         throw new ValidateException('订单不存在');
364
     }
379
     }
365
 
380
 
@@ -412,7 +427,7 @@ class MovieRepository extends BaseRepository
412
      */
427
      */
413
     public function updateMovieOrderAndcalculationCommissionDividendAward($pay_type, $order_sn, $post_data)
428
     public function updateMovieOrderAndcalculationCommissionDividendAward($pay_type, $order_sn, $post_data)
414
     {
429
     {
415
-        $orderinfo = $this->dao->getWhere(['order_sn' => $order_sn])->find();
430
+        $orderinfo = $this->dao->search(['order_sn' => $order_sn])->find();
416
         if ($orderinfo) throw new ValidateException('订单不存在');
431
         if ($orderinfo) throw new ValidateException('订单不存在');
417
         Db::startTrans();
432
         Db::startTrans();
418
         $orderinfo->paid = 1;
433
         $orderinfo->paid = 1;

+ 1 - 1
route/api.php

@@ -1279,13 +1279,13 @@ Route::group('api/', function () {
1279
         Route::get('film_sched', '/getFilmSched'); // 根据影片排片日期查询排片影院
1279
         Route::get('film_sched', '/getFilmSched'); // 根据影片排片日期查询排片影院
1280
         Route::get('cinemafilm_sched', '/getCinemaFilmSched'); // 根据影院影片场次日期查询场次列表
1280
         Route::get('cinemafilm_sched', '/getCinemaFilmSched'); // 根据影院影片场次日期查询场次列表
1281
         Route::get('sched_seat', '/getSchedSeat'); // 获取场次座位
1281
         Route::get('sched_seat', '/getSchedSeat'); // 获取场次座位
1282
-        Route::get('order_list', '/getOrderList'); // 订单列表
1283
     })->prefix('api.movie.Movie');
1282
     })->prefix('api.movie.Movie');
1284
 
1283
 
1285
     //电影 - 下单业务
1284
     //电影 - 下单业务
1286
     Route::group('movie', function () {
1285
     Route::group('movie', function () {
1287
         Route::post('submit_order', '/submitOrder');
1286
         Route::post('submit_order', '/submitOrder');
1288
         Route::post('confirm_order', '/confirmOrder');
1287
         Route::post('confirm_order', '/confirmOrder');
1288
+        Route::get('order_list', '/getOrderList'); // 订单列表
1289
         Route::get('order_info', '/getOrderInfo');
1289
         Route::get('order_info', '/getOrderInfo');
1290
     })->prefix('api.movie.Movie')->middleware(\app\common\middleware\UserTokenMiddleware::class, false);
1290
     })->prefix('api.movie.Movie')->middleware(\app\common\middleware\UserTokenMiddleware::class, false);
1291
 })
1291
 })