-- ============================================================
-- KTV服务 数据模板修复 Part 5
-- 匹配GPU实际参数名：audio_path/images/embedding/lyrics/video_url/image_url/model
-- ============================================================

-- asr: audio_file → audio_path
UPDATE uapi SET data='{"audio_path":"{{audio_file}}"{%if language%},"language":"{{language}}"{%endif%}}' WHERE id='uapi_ktv_asr_transcribe';

-- demucs: audio_file → audio_path  
UPDATE uapi SET data='{"audio_path":"{{audio_file}}"}' WHERE id='uapi_ktv_demucs_separate';

-- face-detect: image_file → images list
UPDATE uapi SET data='{"images":["{{image_file}}"]}' WHERE id='uapi_ktv_face_detect';

-- face-recognize: image_file → images list
UPDATE uapi SET data='{"images":["{{image_file}}"]{%if face_id%},"face_id":"{{face_id}}"{%endif%}}' WHERE id='uapi_ktv_face_recognize';

-- face-compare: image_file1→embedding1, image_file2→embedding2
UPDATE uapi SET data='{"embedding1":"{{image_file1}}","embedding2":"{{image_file2}}"}' WHERE id='uapi_ktv_face_compare';

-- subtitle: lyrics_json → lyrics
UPDATE uapi SET data='{"lyrics":{{lyrics_json}}{%if width%},"width":{{width}}{%endif%}{%if height%},"height":{{height}}{%endif%}}' WHERE id='uapi_ktv_subtitle_render';

-- merge: video_file→video_url, audio_file→audio_path
UPDATE uapi SET data='{%set c=joiner(",")%}{{%if video_file%}{{c()}}"video_url":"{{video_file}}"{%endif%}{%if audio_file%}{{c()}}"audio_path":"{{audio_file}}"{%endif%}{%if subtitle_file%}{{c()}}"subtitle_url":"{{subtitle_file}}"{%endif%}{%if output_format%}{{c()}}"output_format":"{{output_format}}"{%endif%}}' WHERE id='uapi_ktv_merge_video';

-- songrate: audio_file→audio_path
UPDATE uapi SET data='{"audio_path":"{{audio_file}}"{%if scene%},"scene":"{{scene}}"{%endif%}}' WHERE id='uapi_ktv_songrate_evaluate';

-- synth-gen: audio_file→audio_path
UPDATE uapi SET data='{"lyrics":"{{lyrics}}"{%if style%},"style":"{{style}}"{%endif%}{%if audio_file%},"audio_path":"{{audio_file}}"{%endif%}}' WHERE id='uapi_ktv_synth_generate';

-- synth-status: GET, params in query string, no body
UPDATE uapi SET httpmethod='GET', data=NULL, path='/synth/api/synth-status?task_id={{task_id}}' WHERE id='uapi_ktv_synth_status';

-- realesrgan-upscale: image_file→image_url
UPDATE uapi SET data='{"image_url":"{{image_file}}"{%if scale%},"scale":{{scale}}{%endif%}}' WHERE id='uapi_ktv_realesrgan_upscale';

-- realesrgan-status: GET, params in query string, no body
UPDATE uapi SET httpmethod='GET', data=NULL, path='/realesrgan/api/realesrgan-status?task_id={{task_id}}' WHERE id='uapi_ktv_realesrgan_status';

-- rvc: audio_file→audio_path, voice_model→model
UPDATE uapi SET data='{"audio_path":"{{audio_file}}","model":"{{voice_model}}"}' WHERE id='uapi_ktv_rvc_convert';

-- video-eval: video_file→video_url
UPDATE uapi SET data='{"video_url":"{{video_file}}"}' WHERE id='uapi_ktv_video_eval_evaluate';

-- ============================================================
-- 补充缺失的 pricing_program_timing 记录 (tokentest发现3个缺失)
-- ============================================================
INSERT INTO pricing_program_timing (id,ppid,name,pricing_data,enabled_date,expired_date) VALUES 
('pt_ktv_face_compare','pp_ktv_face_compare','KTV人脸比对','unit_values:\n  compare_count: 1\nfields:\n  price_factors:\n    type: string\n    role: factor\n    label: 计价因子\n  unit_prices:\n    type: float\n    role: factor\n    label: 单位定价\n  unit:\n    type: string\n    role: factor\n    label: 计价单位\npricings:\n- price_factors: compare_count\n  unit_prices: 0.10\n  unit: compare_count','2025-01-01','9999-12-31'),
('pt_ktv_synth_status','pp_ktv_synth_status','KTV合成状态','unit_values:\n  次: 1\nfields:\n  price_factors:\n    type: string\n    role: factor\n    label: 计价因子\n  unit_prices:\n    type: float\n    role: factor\n    label: 单位定价\n  unit:\n    type: string\n    role: factor\n    label: 计价单位\npricings:\n- price_factors: flat\n  unit_prices: 0.01\n  unit: 次','2025-01-01','9999-12-31'),
('pt_ktv_realesrgan_status','pp_ktv_realesrgan_status','KTV超分状态','unit_values:\n  次: 1\nfields:\n  price_factors:\n    type: string\n    role: factor\n    label: 计价因子\n  unit_prices:\n    type: float\n    role: factor\n    label: 单位定价\n  unit:\n    type: string\n    role: factor\n    label: 计价单位\npricings:\n- price_factors: flat\n  unit_prices: 0.01\n  unit: 次','2025-01-01','9999-12-31')
ON DUPLICATE KEY UPDATE ppid=VALUES(ppid), pricing_data=VALUES(pricing_data);
