-- ════════════════════════════════════════════════════════════════════
-- 消息通知中心 - Bug 修复脚本
-- 修复内容:
--   1. 注册 Quartz 定时任务（报价到期检查）
--   2. 将现有待审批的 CLIENT_QUOTE(quote_id=6) 状态重置为 draft
-- ════════════════════════════════════════════════════════════════════
SET NAMES utf8mb4;

-- 1. 注册 Quartz 定时任务（报价到期检查，每天上午9点执行）
-- 如果已通过 UI 注册则跳过
DELETE FROM sys_job WHERE job_name = '报价到期检查' AND job_group = 'DEFAULT';
INSERT INTO sys_job (job_id, job_name, job_group, invoke_target, cron_expression,
                     misfire_policy, concurrent, status, create_by, create_time, remark)
VALUES (100, '报价到期检查', 'DEFAULT',
        'quotationExpireTask.checkQuotationExpire()',
        '0 0 9 * * ?',
        '3', '1', '0', 'admin', sysdate(), '报价到期提醒，每天检查即将到期和已过期的报价单');

-- 2. 将 quote_id=6 的测试数据重置为 draft 方便重新测试审批提交通知
UPDATE biz_client_quote SET status = 'draft', update_time = sysdate() WHERE quote_id = 6 AND status = '10';
