Movie.php 5.7 KB

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