| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php
- namespace app\admin\controller;
- use app\admin\AdminBaseController;
- use app\common\model\SeatApplyModel;
- use app\common\model\SeatModel;
- use app\common\service\QrcodeService;
- use app\common\validate\SeatValidate;
- use think\exception\ValidateException;
- class Seat extends AdminBaseController
- {
- /**
- * 列表
- */
- public function index()
- {
- return view('',[
- 'status_list' => SeatModel::STATUS,
- ]);
- }
- public function listSeat()
- {
- $map = $this->dealEqualInput(['status']);
- $list = SeatModel::where($map)->limit(input('limit'))->page(input('page'))->append(['status_text'])->select();
- $count = SeatModel::where($map)->count();
- if ($count == 0) {
- ajax_return(1, '未查询到数据');
- }
- list_return($list, $count);
- }
- /**
- * 编辑
- */
- public function seatForm()
- {
- $id = input('id/d, 0');
- $info = SeatModel::find($id);
- return view('', [
- 'info' => $info,
- 'status_list' => SeatModel::STATUS,
- 'seat_list' => empty($info['seat_list']) ? '[]' : json_encode($info['seat_list']),
- ]);
- }
- public function editSeat()
- {
- $data = input('post.');
- try {
- validate(SeatValidate::class)->check($data);
- } catch (ValidateException $e) {
- ajax_return(1, $e->getError());
- }
- $data['total'] = array_sum($data['seat_list']);
- if (empty($data['id'])) {
- SeatModel::create($data);
- } else {
- SeatModel::update($data, ['id' => $data['id']]);
- }
- ajax_return();
- }
- public function delSeat()
- {
- $id = input('id/d');
- $check = SeatApplyModel::where('seat_id', $id)->find();
- if (!empty($check)) {
- ajax_return(1, '已有投票的活动无法删除!');
- }
- SeatModel::destroy($id);
- ajax_return();
- }
- /**
- * 二维码
- */
- public function qrcodeSeat()
- {
- $id = input('id/d', 0);
- $file_name = "/seat_{$id}.png";
- $link = url('/mobile/seat/apply') . '?id=' . $id;
- $file_url = QrcodeService::getQrcode($file_name, $link, 600);
- ajax_return(0, '', $file_url);
- }
- /**
- * 座位明细
- */
- public function apply()
- {
- return view('', [
- 'id' => input('id/d', 0),
- ]);
- }
- public function listApply()
- {
- $map = $this->dealEqualInput(['seat_id']);
- $list = SeatApplyModel::where($map)->limit(input('limit'))->page(input('page'))->select();
- $count = SeatApplyModel::where($map)->count();
- if ($count == 0) {
- ajax_return(1, '未查询到数据');
- }
- list_return($list, $count);
- }
- public function exportApply()
- {
- $map = $this->dealEqualInput(['seat_id']);
- $list = SeatApplyModel::where($map)->select();
- $xlsCell = [
- ['name', '姓名'],
- ['mobile', '手机号'],
- ['no', '号数'],
- ['seat', '座位'],
- ['create_time', '选座时间'],
- ];
- export_exl("座位明细表", $xlsCell, $list, ['mobile', 'no']);
- }
- }
|