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

根据影片、影院、排片日期-获取场次列表:返回影片基本信息

family 1 год назад
Родитель
Сommit
6edbe28853
2 измененных файлов с 19 добавлено и 2 удалено
  1. 18 1
      app/common/repositories/movie/CinemaSchedRepository.php
  2. 1 1
      app/controller/api/movie/Movie.php

+ 18 - 1
app/common/repositories/movie/CinemaSchedRepository.php

@@ -105,20 +105,33 @@ class CinemaSchedRepository extends BaseRepository
105
      * @param $cinema_sign
105
      * @param $cinema_sign
106
      * @param $film_sign
106
      * @param $film_sign
107
      * @param $show_date
107
      * @param $show_date
108
+     * @param $show_time
108
      * @return array
109
      * @return array
109
      * @throws \think\db\exception\DataNotFoundException
110
      * @throws \think\db\exception\DataNotFoundException
110
      * @throws \think\db\exception\DbException
111
      * @throws \think\db\exception\DbException
111
      * @throws \think\db\exception\ModelNotFoundException
112
      * @throws \think\db\exception\ModelNotFoundException
112
      */
113
      */
113
-    public function getCinemaFilmSched($page, $limit, $cinema_sign, $film_sign, $show_date)
114
+    public function getCinemaFilmSched($page, $limit, $cinema_sign, $film_sign, $show_date, $show_time)
114
     {
115
     {
115
         $field = 'relation_id,sched_sign,film_sign,film_name,show_date,show_time,cinema_sign,cinema_name,hall_sign,hall_name,price';
116
         $field = 'relation_id,sched_sign,film_sign,film_name,show_date,show_time,cinema_sign,cinema_name,hall_sign,hall_name,price';
116
         $where = ['cinema_sign' => $cinema_sign, 'film_sign' => $film_sign, 'show_date' => $show_date];
117
         $where = ['cinema_sign' => $cinema_sign, 'film_sign' => $film_sign, 'show_date' => $show_date];
118
+        if ($show_date == strtotime(date('Y-m-d'))) $where['show_time'] = $show_time;
117
 
119
 
118
         $cinema_sched = $this->dao->search(null, $where)
120
         $cinema_sched = $this->dao->search(null, $where)
119
             ->when($page && $limit, function ($query) use ($page, $limit) {
121
             ->when($page && $limit, function ($query) use ($page, $limit) {
120
                 $query->page($page, $limit);
122
                 $query->page($page, $limit);
121
             })->order('show_time asc')->field([$field])->select()->toArray();
123
             })->order('show_time asc')->field([$field])->select()->toArray();
124
+
125
+        $filmList = [];
126
+        $film_sign_list = array_column($cinema_sched, 'film_sign');
127
+        if (!empty($film_sign_list)) {
128
+            $tmpFilmList = Db::name('movie_film')->whereIn('film_sign', $film_sign_list)->field('film_sign,publish_date,language,type,duration,version')->select()->toArray();
129
+            foreach ($tmpFilmList as $fKey => $fValue) {
130
+                $fValue['publish_date'] = date('Y-m-d', $fValue['publish_date']);
131
+                $filmList[$fValue['film_sign']] = $fValue;
132
+            }
133
+        }
134
+
122
         foreach ($cinema_sched as $key => $value) {
135
         foreach ($cinema_sched as $key => $value) {
123
             $pcYanglaojinGongxian = MovieRepository::getPvYanglaojinScore($value['price']);
136
             $pcYanglaojinGongxian = MovieRepository::getPvYanglaojinScore($value['price']);
124
 
137
 
@@ -127,6 +140,10 @@ class CinemaSchedRepository extends BaseRepository
127
             $cinema_sched[$key]['pv'] = $pcYanglaojinGongxian['pv'];
140
             $cinema_sched[$key]['pv'] = $pcYanglaojinGongxian['pv'];
128
             $cinema_sched[$key]['score'] = $pcYanglaojinGongxian['score'];
141
             $cinema_sched[$key]['score'] = $pcYanglaojinGongxian['score'];
129
             $cinema_sched[$key]['gongxian'] = $pcYanglaojinGongxian['gongxian'];
142
             $cinema_sched[$key]['gongxian'] = $pcYanglaojinGongxian['gongxian'];
143
+
144
+            $film = $filmList[$value['film_sign']] ?? [];
145
+            $cinema_sched[$key]['end_time'] = !empty($film) ? date('H:i', (strtotime($value['show_time']) + $film['duration'] * 60)) : '';
146
+            $cinema_sched[$key]['film'] = $film;
130
         }
147
         }
131
 
148
 
132
         $count = $this->dao->search(null, $where)->count();
149
         $count = $this->dao->search(null, $where)->count();

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

@@ -155,7 +155,7 @@ class Movie extends BaseController
155
 
155
 
156
         /** @var CinemaSchedRepository $cinemaSchedRepository */
156
         /** @var CinemaSchedRepository $cinemaSchedRepository */
157
         $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
157
         $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
158
-        return app('json')->success($cinemaSchedRepository->getCinemaFilmSched($page, $limit, $cinema_sign, $film_sign, $show_date));
158
+        return app('json')->success($cinemaSchedRepository->getCinemaFilmSched($page, $limit, $cinema_sign, $film_sign, $show_date, date('H:i')));
159
     }
159
     }
160
 
160
 
161
     /**
161
     /**