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']); } }