123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <?php
- namespace app\store\controller;
- use library\Controller;
- use think\Db;
- /**
- * 电影场次管理
- * Class FilmList
- * @package app\store\controller
- */
- class FilmScreen extends Controller
- {
- protected $table = 'FilmInfo';
- /**
- * 电影场次列表
- * @auth true
- * @menu true
- */
- public function index(){
- $this->title = '电影场次';
- $f_id = input('f_id');
- $this->film = Db::table('film_list')->find($f_id);
- $query = $this->_query($this->table)->where(['f_id'=>$f_id]);
- $query->order('day_time desc ,point_time desc,id desc')->page();
- }
- /**
- * 数据列表处理
- * @auth true
- * @menu true
- * @param array $data
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- protected function _index_page_filter(&$data)
- {
- foreach ($data as &$vo) {
- $vo['show_time'] = $vo['day_time'].' ' . $vo['point_time'];
- $vo['sell_rate'] = bcdiv( $vo['num'] - $vo['surplus_num'],$vo['num'] ? : 1,4) * 100 . '%';
- $sell_num = Db::table('ticket_order')
- ->field('total_num,children_num')
- ->where(['f_id'=>$vo['id'],'pay_state'=>1])
- ->select();
- $children_num = empty($sell_num) ? 0: array_sum(array_column($sell_num,'children_num'));
- $total = empty($sell_num) ? 0: array_sum(array_column($sell_num,'total_num'));
- $adu_num = $total - $children_num;
- $vo['s_num'] = $total;
- $vo['adu_rate'] = empty($sell_num)? '0%' :bcdiv($adu_num,$vo['num'],4)*100 . '%';
- $vo['children_rate'] = empty($sell_num)? '0%':bcdiv($children_num,$vo['num'],4) * 100 . '%';
- }
- }
- /**
- * 添加场次
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function add()
- {
- $this->title = '添加场次';
- $f_id = input('f_id');
- $this->film_detail = Db::table('film_list')->find($f_id);
- $this->_form($this->table, 'form');
- }
- /**
- * 编辑场次
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function edit()
- {
- $this->title = '编辑场次';
- $f_id = input('f_id');
- $this->film_detail = Db::table('film_list')->find($f_id);
- $this->_form($this->table, 'form');
- }
- /**
- * 取消场次
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function cancel()
- {
- $this->_save($this->table, ['status' => '0']);
- }
- /**
- * 上映场次
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function up()
- {
- $this->_save($this->table, ['status' => '1']);
- }
- /**
- * 表单数据处理
- * @auth true
- * @menu true
- * @param array $data
- */
- protected function _form_filter(&$data)
- {
- if ($this->request->isPost()) {
- $f_id = input('f_id');
- $show_time = strtotime( input('show_time'));
- $data['day_time'] = date("Y-m-d",$show_time);
- $data['point_time'] = date("H:i",$show_time);
- $data['surplus_num'] = input('num');
- $sel_id = isset($data['id']) ? $data['id'] : 0;
- $check = Db::table('film_info')
- ->where(['f_id'=>$f_id,'day_time' =>$data['day_time'],'point_time'=>$data['point_time'] ])
- ->where('id !='.$sel_id)
- ->count();
- if($check) $this->error('该电影在此时间段已有场次');
- }
- }
- function copy_screen()
- {
- $ids = input('ids');// 所选择的id
- $limit_date =date("Y-m-d", strtotime('-1 day'));// 昨天日期
- $sel_screen = Db::table('film_info')
- ->where(['id'=>$ids])
- ->where('day_time','>= time',$limit_date)
- ->select();
- $copy_num= 0;
- foreach ($sel_screen as $sv)
- {
- $check = Db::table('film_info')
- ->where(['f_id'=>$sv['f_id'],'point_time'=>$sv['point_time'],'day_time'=>date("Y-m-d",strtotime($sv['day_time']) + 86400)])
- ->value('id');
- if($check) continue;
- $copy_data = [
- 'f_id'=>$sv['f_id'],
- 'status'=>$sv['status'],
- 'create_at'=>date('Y-m-d H:i:s'),
- 's_price'=>$sv['s_price'],
- 'sort'=>$sv['sort'],
- 'num'=>$sv['num'],
- 'surplus_num'=>$sv['surplus_num'],
- 'point_time'=>$sv['point_time'],
- 'day_time'=>date("Y-m-d",strtotime($sv['day_time']) + 86400),
- 'show_time'=>date("Y-m-d H:i:s",strtotime($sv['show_time'])+86400),
- ];
- $copy_num++;
- }
- }
- }
|