fix(seed): 更新 disputes + audit_logs 种子数据匹配新 schema

- disputes: buyer_id/seller_id → plaintiff_id/defendant_id, 移除已删除列
- audit_logs: actor_id/actor_role/resource_type → admin_id/admin_name/resource
- 枚举值对齐: buyer_complaint → buyer_claim, evidence_collection → processing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-23 22:04:31 -08:00
parent 686bf6c395
commit 4651edae35
1 changed files with 29 additions and 39 deletions

View File

@ -791,39 +791,29 @@ ON CONFLICT (id) DO NOTHING;
-- ---------------------------------------------------------------------------
-- 14. DISPUTES (2 disputes)
-- ---------------------------------------------------------------------------
INSERT INTO disputes (id, type, status, buyer_id, seller_id, order_id, coupon_id, description, evidence, chain_evidence, resolution, refund_approved, sla_deadline, resolved_by, resolved_at, created_at) VALUES
INSERT INTO disputes (id, type, status, plaintiff_id, defendant_id, order_id, description, amount, resolution, resolved_at, created_at, updated_at) VALUES
-- D01: Pending buyer complaint - coupon not usable
('a4000000-0001-4000-8000-000000000001',
'buyer_complaint', 'evidence_collection',
'a0000000-0006-4000-8000-000000000006', -- buyer: 李娜
'a0000000-0010-4000-8000-000000000010', -- seller: 赵雪
'buyer_claim', 'processing',
'a0000000-0006-4000-8000-000000000006', -- plaintiff: 李娜
'a0000000-0010-4000-8000-000000000010', -- defendant: 赵雪
'80000000-0003-4000-8000-000000000003',
'f0000000-0004-4000-8000-000000000004',
'购买的IMAX电影通票在到店使用时被拒商户称券已被核销。请求退款。',
'[{"type": "screenshot", "url": "https://cdn.gogenex.com/disputes/d01_screenshot.png", "uploaded_at": "2025-01-20T10:30:00Z"}]',
'[{"tx_hash": "0xdef789abc012345678901234567890abcdef1234567890abcdef1234567890ab", "block": 12345678}]',
NULL, NULL,
NOW() + INTERVAL '3 days',
NULL, NULL,
NOW() - INTERVAL '5 days'),
96.00, NULL, NULL,
NOW() - INTERVAL '5 days', NOW() - INTERVAL '5 days'),
-- D02: Resolved refund request
('a4000000-0002-4000-8000-000000000002',
'refund_request', 'resolved',
'a0000000-0005-4000-8000-000000000005', -- buyer: 张伟
'a0000000-0004-4000-8000-000000000004', -- seller: Market Maker
'a0000000-0005-4000-8000-000000000005', -- plaintiff: 张伟
'a0000000-0004-4000-8000-000000000004', -- defendant: Market Maker
'80000000-0001-4000-8000-000000000001',
'f0000000-0001-4000-8000-000000000001',
'咖啡畅饮券在门店使用时发现已过活动期,实际可用期限与描述不符。',
'[{"type": "receipt", "url": "https://cdn.gogenex.com/disputes/d02_receipt.png", "uploaded_at": "2025-01-10T14:00:00Z"}]',
'[]',
42.50,
'经核实该券活动描述确实存在歧义已为买方全额退款并补偿10元代金券。',
true,
NOW() - INTERVAL '10 days',
'a0000000-0001-4000-8000-000000000001',
NOW() - INTERVAL '12 days',
NOW() - INTERVAL '18 days')
NOW() - INTERVAL '18 days', NOW() - INTERVAL '12 days')
ON CONFLICT (id) DO NOTHING;
@ -831,55 +821,55 @@ ON CONFLICT (id) DO NOTHING;
-- ---------------------------------------------------------------------------
-- 15. AUDIT LOGS (6 entries)
-- ---------------------------------------------------------------------------
INSERT INTO audit_logs (id, actor_id, actor_role, action, resource_type, resource_id, details, ip_address, user_agent, created_at) VALUES
INSERT INTO audit_logs (id, admin_id, admin_name, action, resource, resource_id, details, ip_address, result, created_at, updated_at) VALUES
-- Audit: Admin approved KYC for U05
('a5000000-0001-4000-8000-000000000001',
'a0000000-0001-4000-8000-000000000001', 'admin',
'a0000000-0001-4000-8000-000000000001', '系统管理员',
'kyc.approve', 'kyc_submission', 'b0000000-0001-4000-8000-000000000001',
'{"user_id": "a0000000-0005-4000-8000-000000000005", "target_level": 3, "full_name": "张伟"}',
'10.0.1.100', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)',
NOW() - INTERVAL '85 days'),
'10.0.1.100', 'success',
NOW() - INTERVAL '85 days', NOW() - INTERVAL '85 days'),
-- Audit: Admin froze U09 account
('a5000000-0002-4000-8000-000000000002',
'a0000000-0001-4000-8000-000000000001', 'admin',
'a0000000-0001-4000-8000-000000000001', '系统管理员',
'user.freeze', 'user', 'a0000000-0009-4000-8000-000000000009',
'{"reason": "AML alert - structuring pattern detected", "alert_id": "a3000000-0001-4000-8000-000000000001"}',
'10.0.1.100', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)',
NOW() - INTERVAL '15 days'),
'10.0.1.100', 'success',
NOW() - INTERVAL '15 days', NOW() - INTERVAL '15 days'),
-- Audit: Issuer created coupon C01
('a5000000-0003-4000-8000-000000000003',
'a0000000-0002-4000-8000-000000000002', 'issuer',
'a0000000-0002-4000-8000-000000000002', '星享咖啡官方',
'coupon.create', 'coupon', 'f0000000-0001-4000-8000-000000000001',
'{"name": "咖啡畅饮券", "face_value": 50.00, "total_supply": 1000}',
'192.168.1.50', 'GenexApp/2.1.0 (iOS 17.2)',
NOW() - INTERVAL '130 days'),
'192.168.1.50', 'success',
NOW() - INTERVAL '130 days', NOW() - INTERVAL '130 days'),
-- Audit: Admin resolved dispute D02
('a5000000-0004-4000-8000-000000000004',
'a0000000-0001-4000-8000-000000000001', 'admin',
'a0000000-0001-4000-8000-000000000001', '系统管理员',
'dispute.resolve', 'dispute', 'a4000000-0002-4000-8000-000000000002',
'{"resolution": "refund_approved", "refund_amount": 42.50, "compensation": 10.00}',
'10.0.1.100', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
NOW() - INTERVAL '12 days'),
'10.0.1.100', 'success',
NOW() - INTERVAL '12 days', NOW() - INTERVAL '12 days'),
-- Audit: Admin dismissed AML alert
('a5000000-0005-4000-8000-000000000005',
'a0000000-0001-4000-8000-000000000001', 'admin',
'a0000000-0001-4000-8000-000000000001', '系统管理员',
'aml_alert.dismiss', 'aml_alert', 'a3000000-0002-4000-8000-000000000002',
'{"reason": "False positive - user is a small business owner with normal transaction pattern"}',
'10.0.1.100', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)',
NOW() - INTERVAL '22 days'),
'10.0.1.100', 'success',
NOW() - INTERVAL '22 days', NOW() - INTERVAL '22 days'),
-- Audit: Admin rejected KYC for U07
('a5000000-0006-4000-8000-000000000006',
'a0000000-0001-4000-8000-000000000001', 'admin',
'a0000000-0001-4000-8000-000000000001', '系统管理员',
'kyc.reject', 'kyc_submission', 'b0000000-0003-4000-8000-000000000003',
'{"user_id": "a0000000-0007-4000-8000-000000000007", "target_level": 2, "reason": "证件照片模糊"}',
'10.0.1.100', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)',
NOW() - INTERVAL '55 days')
'10.0.1.100', 'success',
NOW() - INTERVAL '55 days', NOW() - INTERVAL '55 days')
ON CONFLICT (id) DO NOTHING;