From a5b2d00c8ecc7b722cb963d9255e8460d4de66d3 Mon Sep 17 00:00:00 2001 From: Council Date: Sat, 25 Apr 2026 20:02:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(admin):=20visitor=5Fname=E2=86=92real=5Fnam?= =?UTF-8?q?e,=20verify=5Fstatus,=20TicketVerify=20GET=20handler,=20input?= =?UTF-8?q?=20filter=20null=E2=86=92s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - list.html: visitor_name→real_name, status→verify_status, 修复搜索字段名 - verify.html: visitor_name→real_name in JS showResult(), 移除form-validation class - Admin.php TicketList: 搜索字段从keywords改为逐字段搜索(real_name/phone/order_no/ticket_code) - Admin.php TicketVerify: 添加GET分支显示核销页面,POST分支保持原逻辑 - Admin.php TicketVerify: input() filter null→'s' 避免variable type error --- shopxo/app/plugins/vr_ticket/admin/Admin.php | 63 ++++++++++++------- .../vr_ticket/view/admin/ticket/list.html | 34 +++++----- .../vr_ticket/view/admin/ticket/verify.html | 8 +-- 3 files changed, 62 insertions(+), 43 deletions(-) diff --git a/shopxo/app/plugins/vr_ticket/admin/Admin.php b/shopxo/app/plugins/vr_ticket/admin/Admin.php index 1ba5dbb..6b2c97a 100644 --- a/shopxo/app/plugins/vr_ticket/admin/Admin.php +++ b/shopxo/app/plugins/vr_ticket/admin/Admin.php @@ -316,20 +316,36 @@ class Admin extends Common { $where = []; - $keywords = input('keywords', '', null, 'trim'); - if (!empty($keywords)) { - $where[] = ['order_no|ticket_code|real_name|phone', 'like', "%{$keywords}%"]; + // 逐字段精确搜索(对应视图的独立搜索框) + $order_no = input('order_no', '', null, 'trim'); + if ($order_no !== '') { + $where[] = ['order_no', 'like', "%{$order_no}%"]; + } + $ticket_code = input('ticket_code', '', 's', 'trim'); + if ($ticket_code !== '') { + $where[] = ['ticket_code', 'like', "%{$ticket_code}%"]; + } + $real_name = input('real_name', '', null, 'trim'); + if ($real_name !== '') { + $where[] = ['real_name', 'like', "%{$real_name}%"]; + } + $phone = input('phone', '', null, 'trim'); + if ($phone !== '') { + $where[] = ['phone', 'like', "%{$phone}%"]; } - $verify_status = input('verify_status', '', null); if ($verify_status !== '' && $verify_status !== null) { $where[] = ['verify_status', '=', intval($verify_status)]; } - $goods_id = input('goods_id', 0, 'intval'); - if ($goods_id > 0) { - $where[] = ['goods_id', '=', $goods_id]; - } + // 搜索参数回传(用于表单值保持) + $params = [ + 'order_no' => $order_no, + 'ticket_code' => $ticket_code, + 'real_name' => $real_name, + 'phone' => $phone, + 'verify_status' => $verify_status, + ]; $list = \think\facade\Db::name('vr_tickets') ->where($where) @@ -350,17 +366,11 @@ class Admin extends Common unset($item); } - $status_map = [ - 0 => ['text' => '未核销', 'color' => 'blue'], - 1 => ['text' => '已核销', 'color' => 'green'], - 2 => ['text' => '已退款', 'color' => 'red'], - ]; - return MyView('../../../plugins/vr_ticket/view/admin/ticket/list', [ - 'list' => $list_data['data'], - 'page' => $list->render() ?: '', - 'count' => $list_data['total'], - 'status_map' => $status_map, + 'list' => $list_data['data'], + 'page' => $list->render() ?: '', + 'count' => $list_data['total'], + 'params'=> $params, ]); } @@ -404,13 +414,24 @@ class Admin extends Common /** * 手动核销票(JSON API) */ + /** + * 扫码核销页面(GET)和核销处理(AJAX POST) + * GET: 显示核销表单 + * POST: 处理核销 AJAX 请求 + */ public function TicketVerify() { - if (!(request()->isAjax() && request()->isPost())) { - return DataReturn('非法请求', -1); + // GET 请求 — 显示核销表单页面 + if (!request()->isAjax()) { + return MyView('../../../plugins/vr_ticket/view/admin/ticket/verify', []); } - $ticket_code = input('ticket_code', '', null, 'trim'); + // AJAX POST — 处理核销 + if (!request()->isPost()) { + return json(['code' => -1, 'msg' => '非法请求']); + } + + $ticket_code = input('ticket_code', '', 's', 'trim'); // M-05: verifier_id 从 session 获取,禁止客户端伪造 // $this->admin 来自父类构造函数:AdminService::LoginInfo() diff --git a/shopxo/app/plugins/vr_ticket/view/admin/ticket/list.html b/shopxo/app/plugins/vr_ticket/view/admin/ticket/list.html index 55568d7..a0ccb90 100644 --- a/shopxo/app/plugins/vr_ticket/view/admin/ticket/list.html +++ b/shopxo/app/plugins/vr_ticket/view/admin/ticket/list.html @@ -11,7 +11,7 @@
-
+
@@ -28,26 +28,26 @@
观演人 - +
手机号 - +
- +
状态 - - - - + + +
@@ -66,7 +66,7 @@
-
电子票列表
+
电子票列表 共 {{$count|default=0}} 条
@@ -85,19 +85,19 @@ {{volist name="list" id="ticket"}} - + - + - +
{{$ticket.ticket_code}}{{$ticket.visitor_name}}{{$ticket.real_name|default='—'}} {{if !empty($ticket.seat_info)}}{{$ticket.seat_info}}{{else}}无{{/if}}{{$ticket.goods_name}}{{$ticket.goods_title|default='已删除商品'}} - {{if $ticket.status == 0}} + {{if $ticket.verify_status == 0}} 未核销 - {{elseif $ticket.status == 1}} + {{elseif $ticket.verify_status == 1}} 已核销 - {{elseif $ticket.status == 2}} + {{elseif $ticket.verify_status == 2}} 已退款 {{/if}} {{$ticket.create_time}}{{if !empty($ticket.issued_at)}}{{:date('Y-m-d H:i', $ticket.issued_at)}}{{else}}—{{/if}} 查看详情 @@ -112,7 +112,7 @@ {{/if}}
- + {{if !empty($page)}}
@@ -123,4 +123,4 @@
-{{:ModuleInclude('public/footer')}} \ No newline at end of file +{{:ModuleInclude('public/footer')}} diff --git a/shopxo/app/plugins/vr_ticket/view/admin/ticket/verify.html b/shopxo/app/plugins/vr_ticket/view/admin/ticket/verify.html index 963b4a3..ab7f43e 100644 --- a/shopxo/app/plugins/vr_ticket/view/admin/ticket/verify.html +++ b/shopxo/app/plugins/vr_ticket/view/admin/ticket/verify.html @@ -34,7 +34,7 @@
扫码/输入核销
- +
@@ -126,11 +126,9 @@ function showResult(res) { var ticket = res.data; html = '
' + '

核销成功

' + - '

票码:' + ticket.ticket_code + '

' + - '

观演人:' + ticket.visitor_name + '

' + + '

观演人:' + (ticket.real_name || '—') + '

' + '

座位:' + (ticket.seat_info || '无') + '

' + - '

商品名:' + ticket.goods_name + '

' + - '

核销时间:' + ticket.verify_time + '

' + + '

商品名:' + (ticket.goods_name || '—') + '

' + '
'; // 清空输入框