|
|
@@ -26,6 +26,7 @@ class CinemaSchedCommand extends Command
|
|
26
|
26
|
|
|
27
|
27
|
protected function execute(Input $input, Output $output)
|
|
28
|
28
|
{
|
|
|
29
|
+ $date = strtotime(date('Y-m-d'));
|
|
29
|
30
|
try {
|
|
30
|
31
|
/** @var CinemaRepository $cinema */
|
|
31
|
32
|
$cinema = app()->make(CinemaRepository::class);
|
|
|
@@ -34,12 +35,15 @@ class CinemaSchedCommand extends Command
|
|
34
|
35
|
|
|
35
|
36
|
/** @var FilmRepository $filmRepository */
|
|
36
|
37
|
$filmRepository = app()->make(FilmRepository::class);
|
|
37
|
|
- // 获取已上映影片列表
|
|
38
|
|
- $filmResult = $filmRepository->getFilm($this->page, $this->limit);
|
|
|
38
|
+ // 获取{2个月内}已上映影片列表
|
|
|
39
|
+ $filmResult = $filmRepository->getFilmByStartEndDate($this->page, $this->limit, strtotime('-2 month', $date), $date);
|
|
39
|
40
|
|
|
40
|
|
- foreach ($filmResult['film_list'] as $key => $film) {
|
|
|
41
|
+ foreach ($filmResult as $key => $film) {
|
|
41
|
42
|
foreach ($result['cinema_list'] as $subKey => $cinema) {
|
|
42
|
|
- $this->doCinemaSched($film, $cinema);
|
|
|
43
|
+ // 是否未排片 @todo 影院未排片,不请求第三方接口获取排片场次
|
|
|
44
|
+ if (!($this->isUnscheduledFilm($film['film_sign'], $cinema['cinema_sign']))) {
|
|
|
45
|
+ $this->doCinemaSched($film, $cinema);
|
|
|
46
|
+ }
|
|
43
|
47
|
}
|
|
44
|
48
|
}
|
|
45
|
49
|
} catch (\Exception $exception) {
|
|
|
@@ -48,6 +52,19 @@ class CinemaSchedCommand extends Command
|
|
48
|
52
|
}
|
|
49
|
53
|
|
|
50
|
54
|
/**
|
|
|
55
|
+ * 是否未排片
|
|
|
56
|
+ *
|
|
|
57
|
+ * @param $film_sign
|
|
|
58
|
+ * @param $cinema_sign
|
|
|
59
|
+ * @return bool
|
|
|
60
|
+ */
|
|
|
61
|
+ private function isUnscheduledFilm($film_sign = '', $cinema_sign = '')
|
|
|
62
|
+ {
|
|
|
63
|
+ $count = Db::name('movie_cinema_unsched')->where(['film_sign' => $film_sign, 'cinema_sign' => $cinema_sign])->count();
|
|
|
64
|
+ return $count > 0;
|
|
|
65
|
+ }
|
|
|
66
|
+
|
|
|
67
|
+ /**
|
|
51
|
68
|
* 电影-获取影院场次列表
|
|
52
|
69
|
* @return void
|
|
53
|
70
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
@@ -60,9 +77,13 @@ class CinemaSchedCommand extends Command
|
|
60
|
77
|
$cinema_filmRepository = app()->make(MovieRepository::class);
|
|
61
|
78
|
// 获取排片场次
|
|
62
|
79
|
$cinema_sched = $cinema_filmRepository->getCinemaSched($film['film_sign'], $cinema['cinema_sign']);
|
|
63
|
|
-
|
|
64
|
|
- // 写入排片场次数据
|
|
65
|
|
- $this->createCinemaSched($cinema_sched, $cinema);
|
|
|
80
|
+ if (!empty($cinema_sched)) {
|
|
|
81
|
+ // 写入排片场次数据
|
|
|
82
|
+ $this->createCinemaSched($cinema_sched, $cinema);
|
|
|
83
|
+ } else {
|
|
|
84
|
+ // 写入未排片影院
|
|
|
85
|
+ $this->createUnschedCinema($film, $cinema);
|
|
|
86
|
+ }
|
|
66
|
87
|
}
|
|
67
|
88
|
|
|
68
|
89
|
/**
|
|
|
@@ -110,4 +131,23 @@ class CinemaSchedCommand extends Command
|
|
110
|
131
|
}
|
|
111
|
132
|
}
|
|
112
|
133
|
}
|
|
|
134
|
+
|
|
|
135
|
+ /**
|
|
|
136
|
+ * 记录未排片影院
|
|
|
137
|
+ *
|
|
|
138
|
+ * @param $film
|
|
|
139
|
+ * @param $cinema
|
|
|
140
|
+ * @return void
|
|
|
141
|
+ */
|
|
|
142
|
+ private function createUnschedCinema($film, $cinema)
|
|
|
143
|
+ {
|
|
|
144
|
+ $params = [
|
|
|
145
|
+ 'film_sign' => $film['film_sign'],
|
|
|
146
|
+ 'film_name' => $film['film_name'],
|
|
|
147
|
+ 'cinema_sign' => $cinema['cinema_sign'],
|
|
|
148
|
+ 'cinema_name' => $cinema['cinema_name'],
|
|
|
149
|
+ 'create_time' => time()
|
|
|
150
|
+ ];
|
|
|
151
|
+ Db::name('movie_cinema_unsched')->insert($params);
|
|
|
152
|
+ }
|
|
113
|
153
|
}
|