Movie.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?php
  2. /**
  3. * @package merchant
  4. * @Author: Qinii
  5. * @Date: 2020/5/27
  6. */
  7. namespace app\controller\api\movie;
  8. use app\common\repositories\movie\CinemaRepository;
  9. use app\common\repositories\movie\CinemaSchedRepository;
  10. use app\common\repositories\movie\FilmRepository;
  11. use app\common\repositories\movie\MovieRepository;
  12. use app\common\repositories\system\groupData\GroupDataRepository;
  13. use app\controller\merchant\user\User;
  14. use crmeb\basic\BaseController;
  15. use think\App;
  16. class Movie extends BaseController
  17. {
  18. /**
  19. * @var repository
  20. */
  21. protected $repository;
  22. protected $userInfo;
  23. private $source;
  24. private $merId;
  25. /**
  26. * StoreProduct constructor.
  27. * @param App $app
  28. * @param repository $repository
  29. */
  30. public function __construct(App $app, MovieRepository $repository)
  31. {
  32. parent::__construct($app);
  33. $this->repository = $repository;
  34. }
  35. /**
  36. * 获取城市列表
  37. *
  38. * @return mixed
  39. */
  40. public function getMovieCity()
  41. {
  42. return app('json')->success($this->repository->getLocalMovieCity());
  43. }
  44. /**
  45. * 获取城市分区列表
  46. *
  47. * @return mixed
  48. */
  49. public function getArea()
  50. {
  51. $city_sign = $this->request->param('city_sign', '');
  52. if (empty($city_sign)) return app('json')->fail('请选择城市');
  53. return app('json')->success($this->repository->getMovieArea($city_sign));
  54. }
  55. /**
  56. * 获取影院列表
  57. *
  58. * @return mixed
  59. */
  60. public function getCinema()
  61. {
  62. [$page, $limit] = $this->getPage();
  63. $cinema_name = $this->request->param('cinema_name', '');// 影院名称
  64. $longitude = $this->request->param('longitude', '');// 经度
  65. $latitude = $this->request->param('latitude', '');// 纬度
  66. if (empty($longitude)) return app('json')->fail('请授权应用开启定位');
  67. if (empty($latitude)) return app('json')->fail('请授权应用开启定位');
  68. $where = !empty($cinema_name) ? ['cinema_name' => $cinema_name] : [];
  69. /** @var CinemaRepository $cinemaRepository */
  70. $cinemaRepository = app()->make(CinemaRepository::class);
  71. return app('json')->success($cinemaRepository->getLocalCinema($page, $limit, $longitude, $latitude, $where));
  72. }
  73. /**
  74. * 获取影片列表
  75. *
  76. * @return mixed
  77. */
  78. public function getFilm()
  79. {
  80. [$page, $limit] = $this->getPage();
  81. $type = $this->request->param('type', 0);//热映:0:正在热映,1:即将上映
  82. /** @var FilmRepository $filmRepository */
  83. $filmRepository = app()->make(FilmRepository::class);
  84. return app('json')->success($filmRepository->getFilm($page, $limit, $type));
  85. }
  86. /**
  87. * 获取影片场次日期列表
  88. *
  89. * @return mixed
  90. */
  91. public function getFilmSchedDate()
  92. {
  93. $film_sign = $this->request->param('film_sign', '');
  94. if (empty($film_sign)) return app('json')->fail('请选择要观看的影片');
  95. /** @var CinemaSchedRepository $cinemaSchedRepository */
  96. $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
  97. return app('json')->success($cinemaSchedRepository->getFilmSchedDate($film_sign));
  98. }
  99. /**
  100. * 获取影片场次列表
  101. *
  102. * @return mixed
  103. */
  104. public function getFilmSched()
  105. {
  106. [$page, $limit] = $this->getPage();
  107. $film_sign = $this->request->param('film_sign', '');
  108. $longitude = $this->request->param('longitude', '');// 经度
  109. $latitude = $this->request->param('latitude', '');// 纬度
  110. $show_date = $this->request->param('show_date', '');
  111. if (empty($film_sign)) return app('json')->fail('请选择要观看的影片');
  112. if (empty($longitude) || empty($latitude)) return app('json')->fail('请授权应用开启定位');
  113. if (empty($show_date)) return app('json')->fail('请选择观影日期');
  114. /** @var CinemaSchedRepository $cinemaSchedRepository */
  115. $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
  116. return app('json')->success($cinemaSchedRepository->getFilmSched($page, $limit, $film_sign, $longitude, $latitude, $show_date));
  117. }
  118. /**
  119. * 影院影片场次列表
  120. *
  121. * @return mixed
  122. */
  123. public function getCinemaFilmSched()
  124. {
  125. [$page, $limit] = $this->getPage();
  126. $cinema_sign = $this->request->param('cinema_sign', '');
  127. $film_sign = $this->request->param('film_sign', '');
  128. // $longitude = $this->request->param('longitude', '');// 经度
  129. // $latitude = $this->request->param('latitude', '');// 纬度
  130. $show_date = $this->request->param('show_date', '');
  131. if (empty($cinema_sign)) return app('json')->fail('请选择观影影院');
  132. if (empty($film_sign)) return app('json')->fail('请选择观影影片');
  133. // if (empty($longitude) || empty($latitude)) return app('json')->fail('请授权应用开启定位');
  134. if (empty($show_date)) return app('json')->fail('请选择观影日期');
  135. /** @var CinemaSchedRepository $cinemaSchedRepository */
  136. $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
  137. return app('json')->success($cinemaSchedRepository->getCinemaFilmSched($page, $limit, $cinema_sign, $film_sign, date('Y') . '-' . $show_date));
  138. }
  139. /**
  140. * 获取场次座位
  141. *
  142. * @return mixed
  143. */
  144. public function getSchedSeat()
  145. {
  146. $relation_id = $this->request->param('relation_id', '');
  147. if (empty($relation_id)) return app('json')->fail('请选择观影场次');
  148. $sched_sign = $this->request->param('sched_sign', '');
  149. if (empty($sched_sign)) return app('json')->fail('请选择观影场次');
  150. return app('json')->success($this->repository->getSchedSeat($relation_id, $sched_sign));
  151. }
  152. /**
  153. * 锁座订单
  154. *
  155. * @return mixed
  156. */
  157. public function submitOrder()
  158. {
  159. $params = $this->request->params(
  160. ['price', 0.00],
  161. ['number', 0],
  162. ['channel_type', ''],
  163. ['pay_type', ''],
  164. ['city_sign', ''],
  165. ['city_name', ''],
  166. ['area_code', ''],
  167. ['area_name', ''],
  168. ['cinema_sign', ''],
  169. ['cinema_name', ''],
  170. ['address', ''],
  171. ['longitude', ''],
  172. ['latitude', ''],
  173. ['hall_sign', ''],
  174. ['hall_name', ''],
  175. ['relation_id', ''],
  176. ['sched_sign', ''],
  177. ['film_sign', ''],
  178. ['film_name', ''],
  179. ['show_date', ''],
  180. ['show_time', ''],
  181. ['sched_seat', '']
  182. );
  183. if (empty($params['sched_sign'])) return app('json')->fail('请选择场次');
  184. if (empty($params['seat_sign'])) return app('json')->fail('请选择座位');
  185. if (empty($params['channel_type'])) return app('json')->fail('请选择购票类型');
  186. $result = $this->repository->submitOrder($this->request->userInfo(), $params);
  187. if ($result['code'] == 200) {
  188. return app('json')->success($result);
  189. } else {
  190. return app('json')->fail($result);
  191. }
  192. }
  193. /**
  194. * 确认订单
  195. *
  196. * @return mixed
  197. */
  198. public function confirmOrder()
  199. {
  200. $order_sn = $this->request->param(['order_sn']);
  201. if (empty($order_sn)) return app('json')->fail('订单不存在');
  202. return app('json')->success($this->repository->confirmOrder($this->request->userInfo(), $order_sn));
  203. }
  204. /**
  205. * 查询订单信息
  206. *
  207. * @return mixed
  208. */
  209. public function getOrderInfo()
  210. {
  211. $order_sn = $this->request->param('order_sn', '');
  212. if (empty($order_sn)) return app('json')->fail('订单不存在');
  213. return app('json')->success($this->repository->getOrderInfo($this->request->userInfo(), $order_sn));
  214. }
  215. }