| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- <?php
- /**
- * @package merchant
- * @Author: Qinii
- * @Date: 2020/5/27
- */
- namespace app\controller\api\movie;
- use app\common\repositories\movie\CinemaRepository;
- use app\common\repositories\movie\CinemaSchedRepository;
- use app\common\repositories\movie\FilmRepository;
- use app\common\repositories\movie\MovieRepository;
- use app\common\repositories\system\groupData\GroupDataRepository;
- use app\controller\merchant\user\User;
- use crmeb\basic\BaseController;
- use think\App;
- class Movie extends BaseController
- {
- /**
- * @var repository
- */
- protected $repository;
- protected $userInfo;
- private $source;
- private $merId;
- /**
- * StoreProduct constructor.
- * @param App $app
- * @param repository $repository
- */
- public function __construct(App $app, MovieRepository $repository)
- {
- parent::__construct($app);
- $this->repository = $repository;
- }
- /**
- * 获取城市列表
- *
- * @return mixed
- */
- public function getMovieCity()
- {
- return app('json')->success($this->repository->getLocalMovieCity());
- }
- /**
- * 获取城市分区列表
- *
- * @return mixed
- */
- public function getArea()
- {
- $city_sign = $this->request->param('city_sign', '');
- if (empty($city_sign)) return app('json')->fail('请选择城市');
- return app('json')->success($this->repository->getMovieArea($city_sign));
- }
- /**
- * 获取影院列表
- *
- * @return mixed
- */
- public function getCinema()
- {
- [$page, $limit] = $this->getPage();
- $cinema_name = $this->request->param('cinema_name', '');// 影院名称
- $longitude = $this->request->param('longitude', '');// 经度
- $latitude = $this->request->param('latitude', '');// 纬度
- if (empty($longitude)) return app('json')->fail('请授权应用开启定位');
- if (empty($latitude)) return app('json')->fail('请授权应用开启定位');
- $where = !empty($cinema_name) ? ['cinema_name' => $cinema_name] : [];
- /** @var CinemaRepository $cinemaRepository */
- $cinemaRepository = app()->make(CinemaRepository::class);
- return app('json')->success($cinemaRepository->getLocalCinema($page, $limit, $longitude, $latitude, $where));
- }
- /**
- * 获取影片列表
- *
- * @return mixed
- */
- public function getFilm()
- {
- [$page, $limit] = $this->getPage();
- $type = $this->request->param('type', 0);//热映:0:正在热映,1:即将上映
- /** @var FilmRepository $filmRepository */
- $filmRepository = app()->make(FilmRepository::class);
- return app('json')->success($filmRepository->getFilm($page, $limit, $type));
- }
- /**
- * 获取影片场次日期列表
- *
- * @return mixed
- */
- public function getFilmSchedDate()
- {
- $film_sign = $this->request->param('film_sign', '');
- if (empty($film_sign)) return app('json')->fail('请选择要观看的影片');
- /** @var CinemaSchedRepository $cinemaSchedRepository */
- $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
- return app('json')->success($cinemaSchedRepository->getFilmSchedDate($film_sign));
- }
- /**
- * 获取影片场次列表
- *
- * @return mixed
- */
- public function getFilmSched()
- {
- [$page, $limit] = $this->getPage();
- $film_sign = $this->request->param('film_sign', '');
- $longitude = $this->request->param('longitude', '');// 经度
- $latitude = $this->request->param('latitude', '');// 纬度
- $show_date = $this->request->param('show_date', '');
- if (empty($film_sign)) return app('json')->fail('请选择要观看的影片');
- if (empty($longitude) || empty($latitude)) return app('json')->fail('请授权应用开启定位');
- if (empty($show_date)) return app('json')->fail('请选择观影日期');
- /** @var CinemaSchedRepository $cinemaSchedRepository */
- $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
- return app('json')->success($cinemaSchedRepository->getFilmSched($page, $limit, $film_sign, $longitude, $latitude, $show_date));
- }
- /**
- * 影院影片场次列表
- *
- * @return mixed
- */
- public function getCinemaFilmSched()
- {
- [$page, $limit] = $this->getPage();
- $cinema_sign = $this->request->param('cinema_sign', '');
- $film_sign = $this->request->param('film_sign', '');
- // $longitude = $this->request->param('longitude', '');// 经度
- // $latitude = $this->request->param('latitude', '');// 纬度
- $show_date = $this->request->param('show_date', '');
- if (empty($cinema_sign)) return app('json')->fail('请选择观影影院');
- if (empty($film_sign)) return app('json')->fail('请选择观影影片');
- // if (empty($longitude) || empty($latitude)) return app('json')->fail('请授权应用开启定位');
- if (empty($show_date)) return app('json')->fail('请选择观影日期');
- /** @var CinemaSchedRepository $cinemaSchedRepository */
- $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
- return app('json')->success($cinemaSchedRepository->getCinemaFilmSched($page, $limit, $cinema_sign, $film_sign, date('Y') . '-' . $show_date));
- }
- /**
- * 获取场次座位
- *
- * @return mixed
- */
- public function getSchedSeat()
- {
- $relation_id = $this->request->param('relation_id', '');
- if (empty($relation_id)) return app('json')->fail('请选择观影场次');
- $sched_sign = $this->request->param('sched_sign', '');
- if (empty($sched_sign)) return app('json')->fail('请选择观影场次');
- return app('json')->success($this->repository->getSchedSeat($relation_id, $sched_sign));
- }
- /**
- * 锁座订单
- *
- * @return mixed
- */
- public function submitOrder()
- {
- $params = $this->request->params(
- ['price', 0.00],
- ['number', 0],
- ['channel_type', ''],
- ['pay_type', ''],
- ['city_sign', ''],
- ['city_name', ''],
- ['area_code', ''],
- ['area_name', ''],
- ['cinema_sign', ''],
- ['cinema_name', ''],
- ['address', ''],
- ['longitude', ''],
- ['latitude', ''],
- ['hall_sign', ''],
- ['hall_name', ''],
- ['relation_id', ''],
- ['sched_sign', ''],
- ['film_sign', ''],
- ['film_name', ''],
- ['show_date', ''],
- ['show_time', ''],
- ['sched_seat', '']
- );
- if (empty($params['sched_sign'])) return app('json')->fail('请选择场次');
- if (empty($params['seat_sign'])) return app('json')->fail('请选择座位');
- if (empty($params['channel_type'])) return app('json')->fail('请选择购票类型');
- $result = $this->repository->submitOrder($this->request->userInfo(), $params);
- if ($result['code'] == 200) {
- return app('json')->success($result);
- } else {
- return app('json')->fail($result);
- }
- }
- /**
- * 确认订单
- *
- * @return mixed
- */
- public function confirmOrder()
- {
- $order_sn = $this->request->param(['order_sn']);
- if (empty($order_sn)) return app('json')->fail('订单不存在');
- return app('json')->success($this->repository->confirmOrder($this->request->userInfo(), $order_sn));
- }
- /**
- * 查询订单信息
- *
- * @return mixed
- */
- public function getOrderInfo()
- {
- $order_sn = $this->request->param('order_sn', '');
- if (empty($order_sn)) return app('json')->fail('订单不存在');
- return app('json')->success($this->repository->getOrderInfo($this->request->userInfo(), $order_sn));
- }
- }
|