Movie.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. /** @var FilmRepository $filmRepository */
  84. $filmRepository = app()->make(FilmRepository::class);
  85. return app('json')->success($filmRepository->getFilm($page, $limit, $type));
  86. }
  87. /**
  88. * 获取影片场次日期列表
  89. *
  90. * @return mixed
  91. */
  92. public function getFilmSchedDate()
  93. {
  94. $film_sign = $this->request->param('film_sign', '');
  95. if (empty($film_sign)) return app('json')->fail('请选择要观看的影片');
  96. /** @var CinemaSchedRepository $cinemaSchedRepository */
  97. $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
  98. return app('json')->success($cinemaSchedRepository->getFilmSchedDate($film_sign));
  99. }
  100. /**
  101. * 获取影片场次列表
  102. *
  103. * @return mixed
  104. */
  105. public function getFilmSched()
  106. {
  107. [$page, $limit] = $this->getPage();
  108. $film_sign = $this->request->param('film_sign', '');
  109. $longitude = $this->request->param('longitude', '');// 经度
  110. $latitude = $this->request->param('latitude', '');// 纬度
  111. $show_date = $this->request->param('show_date', '');
  112. if (empty($film_sign)) return app('json')->fail('请选择要观看的影片');
  113. if (empty($longitude) || empty($latitude)) return app('json')->fail('请授权应用开启定位');
  114. if (empty($show_date)) return app('json')->fail('请选择观影日期');
  115. /** @var CinemaSchedRepository $cinemaSchedRepository */
  116. $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
  117. return app('json')->success($cinemaSchedRepository->getFilmSched($page, $limit, $film_sign, $longitude, $latitude, $show_date));
  118. }
  119. /**
  120. * 影院影片场次列表
  121. *
  122. * @return mixed
  123. */
  124. public function getCinemaFilmSched()
  125. {
  126. [$page, $limit] = $this->getPage();
  127. $cinema_sign = $this->request->param('cinema_sign', '');
  128. $film_sign = $this->request->param('film_sign', '');
  129. // $longitude = $this->request->param('longitude', '');// 经度
  130. // $latitude = $this->request->param('latitude', '');// 纬度
  131. $show_date = $this->request->param('show_date', '');
  132. if (empty($cinema_sign)) return app('json')->fail('请选择观影影院');
  133. if (empty($film_sign)) return app('json')->fail('请选择观影影片');
  134. // if (empty($longitude) || empty($latitude)) return app('json')->fail('请授权应用开启定位');
  135. if (empty($show_date)) return app('json')->fail('请选择观影日期');
  136. /** @var CinemaSchedRepository $cinemaSchedRepository */
  137. $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
  138. return app('json')->success($cinemaSchedRepository->getCinemaFilmSched($page, $limit, $cinema_sign, $film_sign, date('Y') . '-' . $show_date));
  139. }
  140. /**
  141. * 获取场次座位
  142. *
  143. * @return mixed
  144. */
  145. public function getSchedSeat()
  146. {
  147. $relation_id = $this->request->param('relation_id', '');
  148. if (empty($relation_id)) return app('json')->fail('请选择观影场次');
  149. $sched_sign = $this->request->param('sched_sign', '');
  150. if (empty($sched_sign)) return app('json')->fail('请选择观影场次');
  151. return app('json')->success($this->repository->getSchedSeat($relation_id, $sched_sign));
  152. }
  153. /**
  154. * 锁座订单
  155. *
  156. * @return mixed
  157. */
  158. public function submitOrder()
  159. {
  160. $params = $this->request->params(
  161. ['relation_id', ''], // 场次ID
  162. ['sched_sign', ''], // 场次编码
  163. ['seat_no', ''], // 座位
  164. ['seat_sign', ''], // 座位编码
  165. ['channel_sn', ''] // 实际价格
  166. );
  167. if (empty($params['relation_id']) || empty($params['sched_sign']) || $params['channel_sn']) return app('json')->fail('请选择观影场次');
  168. if (empty($params['seat_no']) || empty($params['seat_sign'])) return app('json')->fail('请选择观影座位');
  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. }
  176. /**
  177. * 确认订单
  178. *
  179. * @return mixed
  180. */
  181. public function confirmOrder()
  182. {
  183. $order_sn = $this->request->param('order_sn', '');
  184. if (empty($order_sn)) return app('json')->fail('订单不存在');
  185. $pay_type = $this->request->param('pay_type', '');
  186. if (empty($pay_type) || !in_array($pay_type, ['wx', 'ali'])) return app('json')->fail('请选择支付方式');
  187. return app('json')->success($this->repository->confirmOrder($this->request->userInfo(), $order_sn, $pay_type));
  188. }
  189. /**
  190. * 订单列表
  191. *
  192. * @return mixed
  193. */
  194. public function getOrderList()
  195. {
  196. [$page, $limit] = $this->getPage();
  197. $type = $this->request->param('type', -1);//订单状态:-1:全部,0 待支付 1 已支付 2已超时 3已取消 4已成功
  198. return app('json')->success($this->repository->getOrderList($this->request->userInfo(), $page, $limit, $type));
  199. }
  200. /**
  201. * 查询订单信息
  202. *
  203. * @return mixed
  204. */
  205. public function getOrderInfo()
  206. {
  207. $order_sn = $this->request->param('order_sn', '');
  208. if (empty($order_sn)) return app('json')->fail('订单不存在');
  209. return app('json')->success($this->repository->getOrderInfo($this->request->userInfo(), $order_sn));
  210. }
  211. }