From ca7bee5494d2f3aa4761720b5e9a0ffc63acca72 Mon Sep 17 00:00:00 2001 From: Council Date: Mon, 20 Apr 2026 11:28:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(AdminGoodsSaveHandle):=20save=5Fthing=5Fend?= =?UTF-8?q?=20=E6=94=B9=E4=B8=BA=E7=9B=B4=E6=8E=A5=E8=AF=BB=20DB=20?= =?UTF-8?q?=E8=80=8C=E9=9D=9E=20=20=E5=80=BC=E6=8B=B7=E8=B4=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 确保 template_snapshot 兜底逻辑在正确的数据上执行: 1. ShopXO save_thing_end 传入的 $data 是值拷贝,改用 Db::find() 直接从DB读 2. 加 json_last_error() 检查,防止损坏的 JSON 静默失败 --- shopxo/app/plugins/vr_ticket/hook/AdminGoodsSaveHandle.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shopxo/app/plugins/vr_ticket/hook/AdminGoodsSaveHandle.php b/shopxo/app/plugins/vr_ticket/hook/AdminGoodsSaveHandle.php index 3c6c44e..d96477b 100644 --- a/shopxo/app/plugins/vr_ticket/hook/AdminGoodsSaveHandle.php +++ b/shopxo/app/plugins/vr_ticket/hook/AdminGoodsSaveHandle.php @@ -57,9 +57,14 @@ class AdminGoodsSaveHandle $goodsId = $params['goods_id'] ?? 0; if ($goodsId > 0 && ($data['item_type'] ?? '') === 'ticket') { - $rawConfig = $data['vr_goods_config'] ?? ''; + // 直接从数据库读 vr_goods_config(避免 $params['data'] 值拷贝的引用链问题) + $goodsRow = Db::name('Goods')->field('vr_goods_config')->find($goodsId); + $rawConfig = $goodsRow['vr_goods_config'] ?? ''; if (!empty($rawConfig)) { $configs = json_decode($rawConfig, true); + if (json_last_error() !== JSON_ERROR_NONE) { + $configs = null; + } if (is_array($configs) && !empty($configs)) { // 0) 填充 template_snapshot(前端没传、或 rooms 为空时兜底从 vr_seat_templates 读)