From bbb2e653303c546219dd4c9113ee43835906cee5 Mon Sep 17 00:00:00 2001 From: Council Date: Sun, 19 Apr 2026 15:54:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20vr=5Fticket=20?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=96=87=E4=BB=B6=E8=A2=AB=20gitignore=20?= =?UTF-8?q?=E5=BF=BD=E7=95=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 强制追踪 vr_ticket/Event.php(被 shopxo/app/.gitignore 的 event.php 规则遮蔽) - 强制追踪 vr_ticket/database/migrations/*.sql(被全局 gitignore 的 database 规则遮蔽) - 删除 shopxo/app/.gitignore(规则过宽,影响插件文件) - 追踪 shopxo/app/event.php(ShopXO 源码,被上条 .gitignore 遮蔽) - 更新项目 .gitignore(vendor/upload/adminufgeyw/强制追踪database) --- .gitignore | 3 ++ shopxo/app/.gitignore | 1 - shopxo/app/event.php | 50 +++++++++++++++++++ shopxo/app/plugins/vr_ticket/Event.php | 32 ++++++++++++ .../database/migrations/001_vr_tables.sql | 10 ++++ .../database/migrations/fix_garbled_name.sql | 37 ++++++++++++++ 6 files changed, 132 insertions(+), 1 deletion(-) delete mode 100644 shopxo/app/.gitignore create mode 100644 shopxo/app/event.php create mode 100644 shopxo/app/plugins/vr_ticket/Event.php create mode 100755 shopxo/app/plugins/vr_ticket/database/migrations/001_vr_tables.sql create mode 100755 shopxo/app/plugins/vr_ticket/database/migrations/fix_garbled_name.sql diff --git a/.gitignore b/.gitignore index 6fcae24..b70e211 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ shopxo/data.db # ShopXO installation files (auto-generated during install, do not track) shopxo/adminufgeyw.php shopxo/public/adminufgeyw.php + +# 强制追踪 vr_ticket 插件的 database 目录(全局 gitignore 的 database 规则过宽) +!shopxo/app/plugins/vr_ticket/database/ diff --git a/shopxo/app/.gitignore b/shopxo/app/.gitignore deleted file mode 100644 index 49f588f..0000000 --- a/shopxo/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -event.php \ No newline at end of file diff --git a/shopxo/app/event.php b/shopxo/app/event.php new file mode 100644 index 0000000..52c935e --- /dev/null +++ b/shopxo/app/event.php @@ -0,0 +1,50 @@ + + array ( + 'plugins_css' => + array ( + 0 => 'app\\plugins\\my_test_plugin\\Hook', + ), + 'plugins_js' => + array ( + 0 => 'app\\plugins\\my_test_plugin\\Hook', + ), + 'plugins_service_admin_menu_data' => + array ( + 0 => 'app\\plugins\\vr_ticket\\Hook', + ), + 'plugins_service_order_pay_success_handle_end' => + array ( + 0 => 'app\\plugins\\vr_ticket\\Hook', + ), + 'plugins_service_order_delete_success' => + array ( + 0 => 'app\\plugins\\vr_ticket\\Hook', + ), + 'plugins_view_admin_goods_save' => + array ( + 0 => 'app\\plugins\\vr_ticket\\hook\\AdminGoodsSave', + ), + 'plugins_service_goods_save_handle' => + array ( + 0 => 'app\\plugins\\vr_ticket\\hook\\AdminGoodsSaveHandle', + ), + 'plugins_service_goods_save_thing_end' => + array ( + 0 => 'app\\plugins\\vr_ticket\\hook\\AdminGoodsSaveHandle', + ), + ), +); +?> \ No newline at end of file diff --git a/shopxo/app/plugins/vr_ticket/Event.php b/shopxo/app/plugins/vr_ticket/Event.php new file mode 100644 index 0000000..02d1ad2 --- /dev/null +++ b/shopxo/app/plugins/vr_ticket/Event.php @@ -0,0 +1,32 @@ +query("SHOW COLUMNS FROM `{$prefix}goods` LIKE 'item_type'"); + if (count($query) == 0) { + $db->execute("ALTER TABLE `{$prefix}goods` ADD COLUMN `item_type` VARCHAR(20) NOT NULL DEFAULT 'normal' COMMENT '商品类型:normal=普通 goods ticket=票务 physical=周边' AFTER `is_shelves`"); + } + + $queryConfig = $db->query("SHOW COLUMNS FROM `{$prefix}goods` LIKE 'vr_goods_config'"); + if (count($queryConfig) == 0) { + $db->execute("ALTER TABLE `{$prefix}goods` ADD COLUMN `vr_goods_config` LONGTEXT COMMENT '票务配置' AFTER `item_type`"); + } + } + + public function Uninstall($params = []) + { + // 卸载操作通常由 uninstall.sql 完成 + } + + public function Upgrade($params = []) + { + } +} +?> \ No newline at end of file diff --git a/shopxo/app/plugins/vr_ticket/database/migrations/001_vr_tables.sql b/shopxo/app/plugins/vr_ticket/database/migrations/001_vr_tables.sql new file mode 100755 index 0000000..5d92c1c --- /dev/null +++ b/shopxo/app/plugins/vr_ticket/database/migrations/001_vr_tables.sql @@ -0,0 +1,10 @@ +-- ===================================================== +-- VR票务插件 - 数据库迁移(一次性创建全部表) +-- ShopXO 表前缀:vrt_(安装时动态获取实际前缀) +-- 执行方式:ShopXO 后台安装时自动执行 EventListener.php +-- AI 参与度:100% +-- ===================================================== + +-- 以下 SQL 由 EventListener.php 在安装时自动执行 +-- 此文件仅作为备份参考,实际以 EventListener.php 中为准 + diff --git a/shopxo/app/plugins/vr_ticket/database/migrations/fix_garbled_name.sql b/shopxo/app/plugins/vr_ticket/database/migrations/fix_garbled_name.sql new file mode 100755 index 0000000..b14e3c7 --- /dev/null +++ b/shopxo/app/plugins/vr_ticket/database/migrations/fix_garbled_name.sql @@ -0,0 +1,37 @@ +-- ===================================================== +-- VR票务插件 - 乱码修复 SQL +-- 症状:侧边栏显示 `VR票务`(应为 `VR票务`) +-- 根因:plugins 表的 name 字段存储了 UTF-8 字节序列被当作 Latin1 编码 +-- `VR票务` 的 UTF-8 字节 \xE5\xA5\x96\xE5\x8A\xA1 被 Latin1 解码为 `票务` +-- +-- 执行方式:在 phpMyAdmin 或 MySQL CLI 中执行 +-- 注意:请先备份数据库再执行 +-- ===================================================== + +-- Step 1: 确认乱码状态(应看到 `VR票务`) +-- SELECT `name` FROM `{前缀}plugins` WHERE `identifier` LIKE '%vr_ticket%'; + +-- Step 2: 修复 plugins 表的 name 字段 +-- 使用 BINARY 强制以二进制读取,然后正确转换编码 +UPDATE `{前缀}plugins` +SET `name` = CONVERT(BINARY CONVERT(`name` USING latin1) USING utf8mb4) +WHERE `identifier` LIKE '%vr_ticket%' + AND `name` != 'VR票务'; + +-- Step 3: 确认修复结果(应显示 `VR票务`) +-- SELECT `name` FROM `{前缀}plugins` WHERE `identifier` LIKE '%vr_ticket%'; + +-- 同时检查 vrt_power 表(如果有权限配置) +-- Step 4: 检查并修复 vrt_power 表的 name 字段(如果存在且有乱码) +-- UPDATE `{前缀}vrt_power` +-- SET `name` = CONVERT(BINARY CONVERT(`name` USING latin1) USING utf8mb4) +-- WHERE `name` LIKE '%票%'; + +-- ===================================================== +-- 原理说明: +-- UTF-8 → Latin1 双重编码的修复: +-- 1. BINARY CONVERT(... USING latin1) — 以 Latin1 重新解读乱码字节 +-- `票务` 的 Latin1 字节 = \xE5\xA5\x96\xE5\x8A\xA1 +-- 2. CONVERT(... USING utf8mb4) — 将字节以 UTF-8 解码 +-- \xE5\xA5\x96\xE5\x8A\xA1 → `票务` ✓ +-- =====================================================