-- 2025-12-22
ALTER TABLE cc_call_task ADD COLUMN auto_stop SMALLINT DEFAULT 1 COMMENT '是否自动停止（1:自动停止，0:实时任务不自动停止）';
-- update cc_call_task set auto_stop = 0;


-- 2025-12-24
UPDATE sys_config SET config_value = 'aliyun_tts' WHERE config_key = 'config_tts_provider_aliyun' AND config_value = 'aliyun';
UPDATE sys_config SET config_value = 'doubao_vcl_tts' WHERE config_key = 'config_tts_provider_doubao' AND config_value = 'doubao';
UPDATE sys_config SET config_value = 'chinatelecom_tts' WHERE config_key = 'config_tts_provider_chinatelecom' AND config_value = 'chinatelecom';

ALTER TABLE cc_call_task ADD COLUMN ivr_id VARCHAR(32) DEFAULT '' COMMENT 'IVR id';


DROP TABLE IF EXISTS `cc_ivr`;
CREATE TABLE `cc_ivr` (
                          `id` VARCHAR(32) COLLATE utf8mb4_general_ci NOT NULL,
                          `root_id` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
                          `digit` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'DTMF digit key',
                          `node_name` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'node name',
                          `parent_node_id` VARCHAR(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT 'id of parent node. ',
                          `tts_text` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT 'The path of the audio file, or the speech-to-text',
                          `action` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'acd、extension、hangup、gateway、play、playAndGetDigits、upaction、 function',
                          `ai_transfer_data` VARCHAR(255) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT 'Data of specific manual transfer methods',
                          `wait_key_timeout` INT NOT NULL COMMENT 'Wait for the key press timeout',
                          `max_press_key_failures` INT NOT NULL COMMENT 'The maximum number of attempts to press a key',
                          `press_key_invalid_tips` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'invalid text tips or wav path.',
                          `failed_action` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'hangup、upaction',
                          `digit_range` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '数字按键的可选范围',
                          `enabled` SMALLINT NOT NULL DEFAULT '1' COMMENT 'Whether to enable.',
                          `tts_provider` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'tts_provider',
                          `voice_code` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'name of tts speaker',
                          `max_len` INT DEFAULT '1' COMMENT 'max length of input digits',
                          `min_len` INT DEFAULT '1' COMMENT 'min length of input digits',
                          `user_input_var_name` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'Variable name, store the value entered by the user to this variable.',
                          PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

insert  into `sys_menu`(`menu_id`,`menu_name`,`menu_code`,`parent_id`,`order_num`,`url`,`target`,`menu_type`,`visible`,`is_refresh`,`perms`,`icon`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`) values (3071,'IVR配置','ivr',3065,1,'/cc/ivr','','C','0','1','cc:ivr:view','#','admin','2025-12-30 01:46:20','',NULL,'IVR配置菜单');
insert  into `sys_menu`(`menu_id`,`menu_name`,`menu_code`,`parent_id`,`order_num`,`url`,`target`,`menu_type`,`visible`,`is_refresh`,`perms`,`icon`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`) values (3072,'IVR配置查询','ivrList',3071,1,'#','','F','0','1','cc:ivr:list','#','admin','2025-12-30 01:46:20','',NULL,'');
insert  into `sys_menu`(`menu_id`,`menu_name`,`menu_code`,`parent_id`,`order_num`,`url`,`target`,`menu_type`,`visible`,`is_refresh`,`perms`,`icon`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`) values (3073,'IVR配置新增','ivrAdd',3071,2,'#','','F','0','1','cc:ivr:add','#','admin','2025-12-30 01:46:20','',NULL,'');
insert  into `sys_menu`(`menu_id`,`menu_name`,`menu_code`,`parent_id`,`order_num`,`url`,`target`,`menu_type`,`visible`,`is_refresh`,`perms`,`icon`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`) values (3074,'IVR配置修改','ivrEdit',3071,3,'#','','F','0','1','cc:ivr:edit','#','admin','2025-12-30 01:46:20','',NULL,'');
insert  into `sys_menu`(`menu_id`,`menu_name`,`menu_code`,`parent_id`,`order_num`,`url`,`target`,`menu_type`,`visible`,`is_refresh`,`perms`,`icon`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`) values (3075,'IVR配置删除','ivrDel',3071,4,'#','','F','0','1','cc:ivr:remove','#','admin','2025-12-30 01:46:20','',NULL,'');

-- 删除过时菜单
DELETE FROM `sys_menu` WHERE menu_id IN('3','114','115','116','1057','1058','1059','1060','1061','110','111','1050','1051','1052','1053','1054','1055','1056','2120');

-- 电信ASR、TTS配置菜单
-- DELETE FROM `sys_menu` WHERE menu_id IN('3069','3070');
-- 豆包语音克隆、豆包tts配置菜单
-- DELETE FROM `sys_menu` WHERE menu_id IN('3068','3067');

ALTER TABLE cc_call_phone ADD COLUMN  ivr_dtmf_digits VARCHAR(255) DEFAULT '' COMMENT '整个ivr通话中的有效按键';
ALTER TABLE cc_inbound_cdr ADD COLUMN  ivr_dtmf_digits VARCHAR(255) DEFAULT '' COMMENT '整个ivr通话中的有效按键';

ALTER TABLE cc_ivr ADD COLUMN hangup_tips VARCHAR(255) DEFAULT '' COMMENT '挂机提示';

-- INSERT INTO `cc_params` VALUES ('96', '话术中涉及到的变量', 'tts_content_variables', '{"custName":"姓名", "custAddress":"地址", "age":"年龄", "idTail":"身份证后四位"}', 'sys', '0');

UPDATE sys_config SET config_value = 'v20260103' WHERE config_key = 'sys.version';

