chore: remove debug logging from AdminGoodsSaveHandle
All debugging code (vr_debug.log writes) removed. Template snapshot rebuild is now stable and verified.council/ProductManager
parent
c03737308b
commit
05b69588f5
|
|
@ -11,9 +11,6 @@ class AdminGoodsSaveHandle
|
|||
*/
|
||||
public function handle($params = [])
|
||||
{
|
||||
$debugPath = '/tmp/vr_debug.log';
|
||||
@file_put_contents($debugPath, "[HOOK_FIRED] hook_name=" . ($params['hook_name'] ?? 'NULL') . ", goods_id=" . ($params['goods_id'] ?? 'NULL') . ", item_type=" . ($params['data']['item_type'] ?? 'NULL') . "\n", FILE_APPEND);
|
||||
|
||||
$hookName = $params['hook_name'] ?? '';
|
||||
|
||||
// ──────────────────────────────────────────────────────
|
||||
|
|
@ -68,9 +65,6 @@ class AdminGoodsSaveHandle
|
|||
$rawConfig = $data['vr_goods_config'] ?? '';
|
||||
}
|
||||
|
||||
// DEBUG: 记录关键值
|
||||
$debugPath = defined('RUNTIME_PATH') ? RUNTIME_PATH . 'vr_debug.log' : '/tmp/vr_debug.log';
|
||||
$debugInfo = ["[" . date('H:i:s') . "] goodsId=$goodsId, rawConfig_len=" . strlen($rawConfig) . ", rawConfig_preview=" . substr($rawConfig, 0, 200)];
|
||||
if (!empty($rawConfig)) {
|
||||
$configs = json_decode($rawConfig, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
|
|
@ -89,11 +83,9 @@ class AdminGoodsSaveHandle
|
|||
$template = Db::name('vr_seat_templates')->find($templateId);
|
||||
$seatMap = json_decode($template['seat_map'] ?? '{}', true);
|
||||
$allRooms = $seatMap['rooms'] ?? [];
|
||||
// DEBUG
|
||||
$debugInfo[] = "templateId=$templateId, selectedRooms=" . json_encode($selectedRooms) . ", template_found=" . ($template ? 'YES' : 'NO') . ", seatMap_keys=" . (is_array($seatMap) ? implode(',', array_keys($seatMap)) : 'NOT_ARRAY') . ", allRooms_count=" . count($allRooms) . ", allRooms_ids=" . json_encode(array_column($allRooms, 'id'));
|
||||
|
||||
// 注意:v3 格式 room.id 可能为空(用数组索引代替 id),
|
||||
// 此时 room_0 对应 rooms[0],room_1 对应 rooms[1],以此类推
|
||||
// ── v1→v3 兼容迁移 ──
|
||||
// v1 旧格式没有 rooms 嵌套,只有 sections+map 扁平结构
|
||||
if (empty($allRooms) && !empty($seatMap['sections'])) {
|
||||
$v1Sections = $seatMap['sections'] ?? [];
|
||||
$v1Map = $seatMap['map'] ?? [];
|
||||
|
|
@ -112,7 +104,7 @@ class AdminGoodsSaveHandle
|
|||
// 注意:v3 格式 room.id 可能为空(用数组索引代替 id),
|
||||
// 此时 room_0 对应 rooms[0],room_1 对应 rooms[1],以此类推
|
||||
$selectedRoomIds = array_column(
|
||||
array_filter($allRooms, function ($r) use ($selectedRooms, &$roomIdx) {
|
||||
array_filter($allRooms, function ($r) use ($selectedRooms) {
|
||||
$rid = $r['id'] ?? '';
|
||||
// 直接匹配
|
||||
if (in_array($rid, $selectedRooms)) {
|
||||
|
|
@ -134,8 +126,6 @@ class AdminGoodsSaveHandle
|
|||
return false;
|
||||
}), null
|
||||
);
|
||||
// 重置静态索引(避免跨模板污染)
|
||||
unset($roomIndex);
|
||||
|
||||
$config['template_snapshot'] = [
|
||||
'venue' => $seatMap['venue'] ?? [],
|
||||
|
|
@ -145,9 +135,6 @@ class AdminGoodsSaveHandle
|
|||
}
|
||||
unset($config); // 解除引用,避免后续误改
|
||||
|
||||
// 写入调试日志
|
||||
@file_put_contents($debugPath, implode("\n", $debugInfo) . "\n", FILE_APPEND);
|
||||
|
||||
// 将填充后的完整 config 写回 goods 表
|
||||
Db::name('Goods')->where('id', $goodsId)->update([
|
||||
'vr_goods_config' => json_encode($configs, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
|
|
|
|||
Loading…
Reference in New Issue