From d0a2a1193ce843dfa9f0383f2393985a3ab11bcd Mon Sep 17 00:00:00 2001 From: Council Date: Wed, 15 Apr 2026 13:08:56 +0800 Subject: [PATCH] feat(Phase 2): add Base controller + extend all admin controllers, add BaseService --- .../vr_ticket/admin/controller/Base.php | 37 +++++++++++++ .../vr_ticket/admin/controller/Ticket.php | 7 ++- .../admin/controller/Verification.php | 7 ++- .../vr_ticket/admin/controller/Verifier.php | 7 ++- app/plugins/vr_ticket/service/BaseService.php | 55 +++++++++++++++++++ 5 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 app/plugins/vr_ticket/admin/controller/Base.php diff --git a/app/plugins/vr_ticket/admin/controller/Base.php b/app/plugins/vr_ticket/admin/controller/Base.php new file mode 100644 index 0000000..844b4c3 --- /dev/null +++ b/app/plugins/vr_ticket/admin/controller/Base.php @@ -0,0 +1,37 @@ +admin = AdminService::LoginInfo(); + if (empty($this->admin)) { + if (IS_AJAX) { + exit(json_encode([ + 'code' => -400, + 'msg' => '登录失效,请重新登录', + 'data' => [ + 'login' => MyUrl('admin/admin/logininfo'), + 'logout' => MyUrl('admin/admin/logout'), + ] + ])); + } else { + die(''); + } + } + } +} diff --git a/app/plugins/vr_ticket/admin/controller/Ticket.php b/app/plugins/vr_ticket/admin/controller/Ticket.php index 4d7d0c8..d82dc7c 100644 --- a/app/plugins/vr_ticket/admin/controller/Ticket.php +++ b/app/plugins/vr_ticket/admin/controller/Ticket.php @@ -7,8 +7,13 @@ namespace app\plugins\vr_ticket\admin\controller; -class Ticket +class Ticket extends Base { + public function __construct() + { + parent::__construct(); + } + /** * 电子票列表 */ diff --git a/app/plugins/vr_ticket/admin/controller/Verification.php b/app/plugins/vr_ticket/admin/controller/Verification.php index 8c54bf7..8aed144 100644 --- a/app/plugins/vr_ticket/admin/controller/Verification.php +++ b/app/plugins/vr_ticket/admin/controller/Verification.php @@ -7,8 +7,13 @@ namespace app\plugins\vr_ticket\admin\controller; -class Verification +class Verification extends Base { + public function __construct() + { + parent::__construct(); + } + /** * 核销记录列表 */ diff --git a/app/plugins/vr_ticket/admin/controller/Verifier.php b/app/plugins/vr_ticket/admin/controller/Verifier.php index 9c8d110..f71b41e 100644 --- a/app/plugins/vr_ticket/admin/controller/Verifier.php +++ b/app/plugins/vr_ticket/admin/controller/Verifier.php @@ -7,8 +7,13 @@ namespace app\plugins\vr_ticket\admin\controller; -class Verifier +class Verifier extends Base { + public function __construct() + { + parent::__construct(); + } + /** * 核销员列表 */ diff --git a/app/plugins/vr_ticket/service/BaseService.php b/app/plugins/vr_ticket/service/BaseService.php index d576e44..d8f6697 100644 --- a/app/plugins/vr_ticket/service/BaseService.php +++ b/app/plugins/vr_ticket/service/BaseService.php @@ -152,4 +152,59 @@ class BaseService $log_func($tag . $message . $ctx); } } + + /** + * 插件后台权限菜单 + * + * ShopXO 通过 PluginsService::PluginsAdminPowerMenu() 调用此方法 + * 返回格式:二维数组,每项代表一个菜单分组 + * + * @return array + */ + public static function AdminPowerMenu() + { + return [ + // 座位模板 + [ + 'name' => '座位模板', + 'control' => 'seat_template', + 'action' => 'list', + 'item' => [ + ['name' => '座位模板', 'action' => 'list'], + ['name' => '添加模板', 'action' => 'save'], + ], + ], + // 电子票 + [ + 'name' => '电子票', + 'control' => 'ticket', + 'action' => 'list', + 'item' => [ + ['name' => '电子票列表', 'action' => 'list'], + ['name' => '票详情', 'action' => 'detail'], + ['name' => '手动核销', 'action' => 'verify'], + ['name' => '导出票', 'action' => 'export'], + ], + ], + // 核销员 + [ + 'name' => '核销员', + 'control' => 'verifier', + 'action' => 'list', + 'item' => [ + ['name' => '核销员列表', 'action' => 'list'], + ['name' => '添加核销员', 'action' => 'save'], + ], + ], + // 核销记录 + [ + 'name' => '核销记录', + 'control' => 'verification', + 'action' => 'list', + 'item' => [ + ['name' => '核销记录', 'action' => 'list'], + ], + ], + ]; + } }