-- =====================================================================
-- 预警功能验证数据
-- 构造三类预警场景: 课时不足 / 即将到期 / 已过期
-- =====================================================================

SET NAMES utf8mb4;

-- 清理旧验证数据
DELETE FROM `edu_contract` WHERE id BETWEEN 4200 AND 4299;

-- 场景1: 课时不足 WARN — 钱小红, 总40课时剩8(20%), 触发课时不足警告
INSERT INTO `edu_contract`(`id`,`tenant_id`,`contract_no`,`student_id`,`contract_type`,`sign_date`,`effective_date`,`expire_date`,`total_amount`,`discount_amount`,`paid_amount`,`refund_amount`,`total_hours`,`used_hours`,`remain_hours`,`gift_hours`,`payment_method`,`payment_status`,`status`,`sales_id`,`housekeeper_id`,`remark`,`create_by`,`create_time`) VALUES
(4201,'000000','EDUCT-ALERT-001',2002,'ENROLL','2026-02-10','2026-02-10','2027-02-10',9600.00,0.00,9600.00,0.00,40.00,32.00,8.00,0.00,'WECHAT','2','2',1002,1003,'验证: 课时不足(剩8/40=20%→WARN)',1,NOW()),

-- 场景2: 课时不足 URGENT — 孙小刚, 总20课时剩1.5(7.5%), 触发紧急
(4202,'000000','EDUCT-ALERT-002',2003,'ENROLL','2026-03-01','2026-03-01','2027-03-01',4800.00,0.00,4800.00,0.00,20.00,18.50,1.50,0.00,'ALIPAY','2','2',1001,1003,'验证: 课时不足紧急(剩1.5/20=7.5%→URGENT)',1,NOW()),

-- 场景3: 即将到期 — 钱小红, 剩余课时充足但15天后到期, 触发到期警告
(4203,'000000','EDUCT-ALERT-003',2002,'ENROLL','2025-12-01','2025-12-01',DATE_ADD(CURDATE(),INTERVAL 15 DAY),8000.00,0.00,8000.00,0.00,30.00,5.00,25.00,0.00,'WECHAT','2','2',1002,1003,'验证: 即将到期(15天后→WARN)',1,NOW()),

-- 场景4: 已过期 URGENT — 孙小刚, 到期日已过但仍执行中(异常状态)
(4204,'000000','EDUCT-ALERT-004',2003,'ENROLL','2025-06-01','2025-06-01',DATE_SUB(CURDATE(),INTERVAL 10 DAY),6000.00,0.00,6000.00,0.00,30.00,12.00,18.00,0.00,'CASH','2','2',1001,1003,'验证: 已过期(10天前到期但仍执行中→URGENT)',1,NOW());
