Files
group_xinghuo_jinrong/scripts/core/02-seed-base.sql
T
GaoYiYuan_0626 90d0660b44 feat: C5 FR-9 预警处置时效升级(RISK-007,P0)
- 仓储:新增 list_pending_alerts_all / update_alert_escalation(统一读改写 payload,
  升级标记独占写入,status/handler_* 列不碰;_parse_alert 补 created_at/handled_at
  字符串→datetime 解析,兼容 sqlite 原生 DDL)
- escalation_service.scan_and_escalate:扫描判级(普通 4h/24h、AML 1h/4h 短通道)、
  幂等闸门(仅升不降)、先持久化再推送、按 (customer_id,level) 降噪合并一次推送、
  通知链累积(L1 含 risk_manager / L2 含 compliance)、逐单+任务级审计
- scripts/cron/escalation_scan.py:15min 定时扫描壳(sys.path 引导 + new_trace + JSON 摘要)
- 对话线 query_overdue_alerts Tool + 注册表 + 意图词(置于 alert_query 之前)+ summarize 分支
- C5 前置:seed STAFF-31001/31002(risk_manager) + deps 矩阵放行 + chat.py 显式 deny +
  risk.py 台账全量只读分支;JWT 手册 §5.3/§5.4/§6.1 增补 risk_manager
- 测试:conftest 回拨 fixture + test_escalation_service(9) + risk_api/manager(5) +
  chat deny(1) + chat_tools overdue(2);全量 470 绿(453+17)
2026-09-07 19:28:04 +08:00

84 lines
5.2 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
USE jinrong_core;
-- 客户风险等级 C1~C5(对齐《适当性管理指南》第六条)
INSERT INTO core_risk_grade (code, grade_type, display_name, sort_order) VALUES
('C1', 'customer', '保守型 C1', 1),
('C2', 'customer', '稳健型 C2', 2),
('C3', 'customer', '平衡型 C3', 3),
('C4', 'customer', '进取型 C4', 4),
('C5', 'customer', '激进型 C5', 5);
-- 产品风险等级 R1~R5(对齐《适当性管理指南》第十一条)
INSERT INTO core_risk_grade (code, grade_type, display_name, sort_order) VALUES
('R1', 'product', '低风险 R1', 1),
('R2', 'product', '中低风险 R2', 2),
('R3', 'product', '中风险 R3', 3),
('R4', 'product', '中高风险 R4', 4),
('R5', 'product', '高风险 R5', 5);
-- C×R 匹配矩阵(第十二条)
INSERT INTO core_suitability_rule (customer_risk_code, product_risk_code, match_result) VALUES
('C1', 'R1', 'allowed'), ('C1', 'R2', 'allowed'), ('C1', 'R3', 'forbidden'), ('C1', 'R4', 'forbidden'), ('C1', 'R5', 'forbidden'),
('C2', 'R1', 'allowed'), ('C2', 'R2', 'allowed'), ('C2', 'R3', 'allowed'), ('C2', 'R4', 'forbidden'), ('C2', 'R5', 'forbidden'),
('C3', 'R1', 'allowed'), ('C3', 'R2', 'allowed'), ('C3', 'R3', 'allowed'), ('C3', 'R4', 'allowed_with_disclosure'), ('C3', 'R5', 'forbidden'),
('C4', 'R1', 'allowed'), ('C4', 'R2', 'allowed'), ('C4', 'R3', 'allowed'), ('C4', 'R4', 'allowed'), ('C4', 'R5', 'allowed_with_disclosure'),
('C5', 'R1', 'allowed'), ('C5', 'R2', 'allowed'), ('C5', 'R3', 'allowed'), ('C5', 'R4', 'allowed'), ('C5', 'R5', 'allowed');
INSERT INTO core_industry (industry_code, industry_name) VALUES
('IND-BOND', '债券固收'),
('IND-MIX', '混合平衡'),
('IND-TECH', '科技成长'),
('IND-CONS', '消费'),
('IND-MED', '医药健康'),
('IND-INDEX', '宽基指数'),
('IND-MONEY', '货币现金'),
('IND-WMGMT', '银行理财'),
('IND-PRIV', '私募证券');
-- ========== 内部员工 · RBAC 种子 ==========
INSERT INTO core_staff (staff_id, display_name, staff_type, roles) VALUES
('STAFF-10086', '张理财', 'advisor', '["advisor"]'),
('STAFF-10087', '李顾问', 'advisor', '["advisor"]'),
('STAFF-10088', '王经理', 'advisor', '["advisor"]'),
('STAFF-10089', '赵专员', 'advisor', '["advisor"]'),
('STAFF-10090', '刘助理', 'advisor', '["advisor"]'),
('STAFF-20001', '陈分析', 'analyst', '["analyst"]'),
('STAFF-20002', '周数据', 'analyst', '["analyst"]'),
('STAFF-30001', '吴风控', 'risk_officer', '["risk_officer"]'),
('STAFF-30002', '郑监测', 'risk_officer', '["risk_officer"]'),
('STAFF-40001', '孙合规', 'compliance', '["compliance"]'),
('STAFF-40002', '钱监察', 'compliance', '["compliance"]'),
('STAFF-50001', '冯运营', 'ops', '["ops"]'),
('STAFF-10091', '双角色顾问', 'advisor', '["advisor", "compliance"]');
-- 1 风控演示账号(网关演示用,roles 含 risk_demo · 见 docs/PRD/PRD-风控监测Agent.md §10.1)
-- 我方分支独有种子(main 侧无此账号),对齐 main 时保留
INSERT INTO core_staff (staff_id, display_name, staff_type, roles) VALUES
('STAFF-90001', '风控演示账号', 'risk_officer', '["risk_officer", "risk_demo"]');
-- 2 风控经理(C5 前置 · PRD 4A.1:risk_manager 可看台账全量,无处置权)
-- staff_type 仍为 risk_officer(同岗位序列),roles 标 risk_manager 用于权限区分
INSERT INTO core_staff (staff_id, display_name, staff_type, roles) VALUES
('STAFF-31001', '风控经理甲', 'risk_officer', '["risk_manager"]'),
('STAFF-31002', '风控经理乙', 'risk_officer', '["risk_manager"]');
-- ========== 产品 14 只(含起购/期限 · C-11) ==========
INSERT INTO core_product (
product_id, product_name, product_type, min_risk_code,
min_subscribe_amount, term_days, requires_disclosure, industry_code, fee_rate
) VALUES
('PROD-110022', '稳健债基 A', 'bond', 'R1', 100.00, NULL, 0, 'IND-BOND', 0.0030),
('PROD-110023', '信用债精选', 'bond', 'R2', 100.00, NULL, 0, 'IND-BOND', 0.0040),
('PROD-005827', '平衡混合一号', 'mixed', 'R3', 100.00, NULL, 0, 'IND-MIX', 0.0150),
('PROD-005828', '稳健增利混合', 'mixed', 'R2', 100.00, NULL, 0, 'IND-MIX', 0.0120),
('PROD-161725', '科技成长主题', 'stock', 'R4', 100.00, NULL, 1, 'IND-TECH', 0.0150),
('PROD-161726', '消费升级主题', 'stock', 'R4', 100.00, NULL, 1, 'IND-CONS', 0.0150),
('PROD-003095', '医药健康精选', 'stock', 'R4', 100.00, NULL, 1, 'IND-MED', 0.0120),
('PROD-510300', '沪深300指数', 'index', 'R3', 100.00, NULL, 0, 'IND-INDEX', 0.0050),
('PROD-510500', '中证500指数', 'index', 'R4', 100.00, NULL, 1, 'IND-INDEX', 0.0060),
('PROD-XYZ999', '进取成长五号', 'stock', 'R5', 100.00, NULL, 1, 'IND-TECH', 0.0180),
('PROD-000001', '现金宝货币', 'money', 'R1', 1.00, NULL, 0, 'IND-MONEY', 0.0010),
('PROD-000002', '同业存单基金', 'bond', 'R1', 100.00, NULL, 0, 'IND-BOND', 0.0020),
('PROD-WMG001', '稳享180天理财', 'wealth_mgmt', 'R2', 200000.00, 180, 0, 'IND-WMGMT', 0.0035),
('PROD-PRIV01', '量化中性私募一号', 'private_fund','R4', 1000000.00, NULL, 1, 'IND-PRIV', 0.0200);