Movie.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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 crmeb\services\ApiResponseService;
  16. use think\App;
  17. class Movie extends BaseController
  18. {
  19. /**
  20. * @var repository
  21. */
  22. protected $repository;
  23. protected $userInfo;
  24. private $source;
  25. private $merId;
  26. /**
  27. * StoreProduct constructor.
  28. * @param App $app
  29. * @param repository $repository
  30. */
  31. public function __construct(App $app, MovieRepository $repository)
  32. {
  33. parent::__construct($app);
  34. $this->repository = $repository;
  35. }
  36. /**
  37. * 获取城市列表
  38. *
  39. * @return mixed
  40. */
  41. public function getMovieCity()
  42. {
  43. return app('json')->success($this->repository->getLocalMovieCity());
  44. }
  45. /**
  46. * 获取城市分区列表
  47. *
  48. * @return mixed
  49. */
  50. public function getArea()
  51. {
  52. $city_sign = $this->request->param('city_sign', '');
  53. if (empty($city_sign)) return app('json')->fail('请选择城市');
  54. return app('json')->success($this->repository->getMovieArea($city_sign));
  55. }
  56. /**
  57. * 获取影院列表
  58. *
  59. * @return mixed
  60. */
  61. public function getCinema()
  62. {
  63. [$page, $limit] = $this->getPage();
  64. $cinema_name = $this->request->param('cinema_name', '');// 影院名称
  65. $longitude = $this->request->param('longitude', '');// 经度
  66. $latitude = $this->request->param('latitude', '');// 纬度
  67. if (empty($longitude)) return app('json')->fail('请授权应用开启定位');
  68. if (empty($latitude)) return app('json')->fail('请授权应用开启定位');
  69. $where = !empty($cinema_name) ? ['cinema_name' => $cinema_name] : [];
  70. /** @var CinemaRepository $cinemaRepository */
  71. $cinemaRepository = app()->make(CinemaRepository::class);
  72. return app('json')->success($cinemaRepository->getLocalCinema($page, $limit, $longitude, $latitude, $where));
  73. }
  74. /**
  75. * 获取影片列表
  76. *
  77. * @return mixed
  78. */
  79. public function getFilm()
  80. {
  81. [$page, $limit] = $this->getPage();
  82. $type = $this->request->param('type', 0);//热映:0:正在热映,1:即将上映
  83. $film_name = $this->request->param('film_name', '');
  84. /** @var FilmRepository $filmRepository */
  85. $filmRepository = app()->make(FilmRepository::class);
  86. return app('json')->success($filmRepository->getFilm($page, $limit, $type, $film_name));
  87. }
  88. /**
  89. * 获取影片场次日期列表
  90. *
  91. * @return mixed
  92. */
  93. public function getFilmSchedDate()
  94. {
  95. $film_sign = $this->request->param('film_sign', '');
  96. if (empty($film_sign)) return app('json')->fail('请选择要观看的影片');
  97. /** @var CinemaSchedRepository $cinemaSchedRepository */
  98. $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
  99. return app('json')->success($cinemaSchedRepository->getFilmSchedDate($film_sign));
  100. }
  101. /**
  102. * 根据影片、排片日期-获取影院列表
  103. *
  104. * @return mixed
  105. */
  106. public function getFilmSched()
  107. {
  108. [$page, $limit] = $this->getPage();
  109. $film_sign = $this->request->param('film_sign', '');
  110. $longitude = $this->request->param('longitude', '');// 经度
  111. $latitude = $this->request->param('latitude', '');// 纬度
  112. $show_date = $this->request->param('show_date', '');
  113. if (empty($film_sign)) return app('json')->fail('请选择要观看的影片');
  114. if (empty($longitude) || empty($latitude)) return app('json')->fail('请授权应用开启定位');
  115. if (empty($show_date)) return app('json')->fail('请选择观影日期');
  116. /** @var CinemaSchedRepository $cinemaSchedRepository */
  117. $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
  118. return app('json')->success($cinemaSchedRepository->getFilmSched($page, $limit, $film_sign, $longitude, $latitude, $show_date, date('H:i')));
  119. }
  120. /**
  121. * 根据影片、影院、排片日期-获取场次列表
  122. *
  123. * @return mixed
  124. */
  125. public function getCinemaFilmSched()
  126. {
  127. [$page, $limit] = $this->getPage();
  128. $cinema_sign = $this->request->param('cinema_sign', '');
  129. $film_sign = $this->request->param('film_sign', '');
  130. // $longitude = $this->request->param('longitude', '');// 经度
  131. // $latitude = $this->request->param('latitude', '');// 纬度
  132. $show_date = $this->request->param('show_date', '');
  133. if (empty($cinema_sign)) return app('json')->fail('请选择观影影院');
  134. if (empty($film_sign)) return app('json')->fail('请选择观影影片');
  135. // if (empty($longitude) || empty($latitude)) return app('json')->fail('请授权应用开启定位');
  136. if (empty($show_date)) return app('json')->fail('请选择观影日期');
  137. /** @var CinemaSchedRepository $cinemaSchedRepository */
  138. $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
  139. return app('json')->success($cinemaSchedRepository->getCinemaFilmSched($page, $limit, $cinema_sign, $film_sign, $show_date, date('H:i')));
  140. }
  141. /**
  142. * 获取场次座位
  143. *
  144. * @return mixed
  145. */
  146. public function getSchedSeat()
  147. {
  148. $relation_id = $this->request->param('relation_id', '');
  149. if (empty($relation_id)) return app('json')->fail('请选择观影场次');
  150. $sched_sign = $this->request->param('sched_sign', '');
  151. if (empty($sched_sign)) return app('json')->fail('请选择观影场次');
  152. return app('json')->success($this->repository->getSchedSeat($relation_id, $sched_sign));
  153. }
  154. /**
  155. * 锁座订单
  156. *
  157. * @return mixed
  158. */
  159. public function submitOrder()
  160. {
  161. $params['relation_id'] = $this->request->param('relation_id', '');// 场次ID
  162. $params['sched_sign'] = $this->request->param('sched_sign', '');// 场次编码
  163. $params['sched_seat'] = $this->request->param('sched_seat', '');// 座位编码
  164. $params['channel_sn'] = $this->request->param('channel_sn', '');// 实际价格
  165. $params['phone'] = $this->request->param('phone', '');// 联系电话
  166. if (empty($params['relation_id']) || empty($params['sched_sign']) || empty($params['channel_sn'])) return app('json')->fail('请选择观影场次');
  167. if (empty($params['sched_seat'])) return app('json')->fail('请选择观影座位');
  168. try {
  169. $result = $this->repository->submitOrder($this->request->userInfo(), $params);
  170. if (!empty($result)) {
  171. return app('json')->success(['order_sn' => $result]);
  172. } else {
  173. return app('json')->fail('锁座下单失败');
  174. }
  175. } catch (\Exception $exception) {
  176. return app('json')->fail($exception->getMessage());
  177. }
  178. }
  179. /**
  180. * 确认订单
  181. *
  182. * @return mixed
  183. */
  184. public function confirmOrder()
  185. {
  186. $order_sn = $this->request->param('order_sn', '');
  187. if (empty($order_sn)) return app('json')->fail('订单不存在');
  188. $pay_type = $this->request->param('pay_type', '');
  189. if (empty($pay_type) || !in_array($pay_type, ['wx', 'ali'])) return app('json')->fail('请选择支付方式');
  190. try {
  191. return app('json')->success($this->repository->confirmOrder($this->request->userInfo(), $order_sn, $pay_type));
  192. } catch (\Exception $exception) {
  193. return app('json')->fail($exception->getMessage());
  194. }
  195. }
  196. /**
  197. * 订单列表
  198. *
  199. * @return mixed
  200. */
  201. public function getOrderList()
  202. {
  203. [$page, $limit] = $this->getPage();
  204. $type = $this->request->param('type', -1);//订单状态:-1:全部,0 待支付 1 已支付 2已超时 3已取消 4已成功
  205. return app('json')->success($this->repository->getOrderList($this->request->userInfo(), $page, $limit, $type));
  206. }
  207. /**
  208. * 查询订单信息
  209. *
  210. * @return mixed
  211. */
  212. public function getOrderInfo()
  213. {
  214. $order_sn = $this->request->param('order_sn', '');
  215. if (empty($order_sn)) return app('json')->fail('订单不存在');
  216. return app('json')->success($this->repository->getOrderInfo($this->request->userInfo(), $order_sn));
  217. }
  218. }