refactor(types): 重构类型系统,统一共享类型定义

feat(types): 新增共享类型中心,包含用户、产品、订单等核心领域类型
fix(types): 修复类型定义错误,统一各模块类型引用
style(types): 优化类型文件格式和注释
docs(types): 更新类型文档和变更日志
test(types): 添加类型测试用例
build(types): 配置类型共享路径
chore(types): 清理重复类型定义文件
This commit is contained in:
2026-03-20 17:53:46 +08:00
parent 989c4b13a6
commit 427becbc8f
222 changed files with 25676 additions and 6328 deletions

View File

@@ -7,16 +7,33 @@
export interface BlacklistRecord {
id: string;
tenant_id: string;
type: 'CUSTOMER' | 'ADDRESS' | 'PHONE' | 'EMAIL' | 'IP';
value: string;
reason: string;
severity: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
shop_id: string;
task_id?: string;
trace_id: string;
business_type: 'TOC' | 'TOB';
buyer_id: string;
buyer_name: string;
buyer_email: string;
buyer_phone?: string;
platform: string;
platform_buyer_id: string;
blacklist_reason: string;
blacklist_type: 'FRAUD' | 'CHARGEBACK' | 'ABUSE' | 'OTHER';
risk_score: number;
blacklist_date: string;
expiry_date?: string;
status: 'ACTIVE' | 'INACTIVE' | 'EXPIRED';
source: 'MANUAL' | 'AUTO' | 'IMPORT';
expiresAt?: string;
createdAt: string;
updatedAt: string;
createdBy: string;
evidence?: string;
created_by: string;
created_at: string;
updated_at: string;
type?: 'CUSTOMER' | 'ADDRESS' | 'IP' | 'EMAIL';
value?: string;
reason?: string;
severity?: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
source?: 'MANUAL' | 'AUTO';
createdBy?: string;
updatedAt?: string;
}
export interface RiskAssessment {
@@ -35,7 +52,7 @@ export interface RiskAssessment {
}
export interface IBlacklistDataSource {
fetchBlacklist(params?: { type?: string; status?: string; search?: string }): Promise<BlacklistRecord[]>;
fetchBlacklist(params?: { platform?: string; status?: string; search?: string }): Promise<BlacklistRecord[]>;
addBlacklist(data: Partial<BlacklistRecord>): Promise<BlacklistRecord>;
updateBlacklist(id: string, data: Partial<BlacklistRecord>): Promise<BlacklistRecord>;
removeBlacklist(id: string): Promise<void>;
@@ -49,28 +66,56 @@ class MockBlacklistDataSource implements IBlacklistDataSource {
{
id: '1',
tenant_id: 'tenant_001',
shop_id: 'shop_001',
trace_id: 'trace_001',
business_type: 'TOC',
buyer_id: 'buyer_001',
buyer_name: 'John Doe',
buyer_email: 'john.doe@example.com',
platform: 'AMAZON',
platform_buyer_id: 'amazon_001',
blacklist_reason: '多次恶意退款',
blacklist_type: 'FRAUD',
risk_score: 85,
blacklist_date: '2026-03-01',
status: 'ACTIVE',
created_by: 'admin',
created_at: '2026-03-01',
updated_at: '2026-03-01',
type: 'CUSTOMER',
value: 'John Doe',
reason: '多次恶意退款',
severity: 'HIGH',
status: 'ACTIVE',
source: 'MANUAL',
createdAt: '2026-03-01',
updatedAt: '2026-03-01',
createdBy: 'admin',
updatedAt: '2026-03-01',
},
{
id: '2',
tenant_id: 'tenant_001',
shop_id: 'shop_001',
trace_id: 'trace_002',
business_type: 'TOC',
buyer_id: 'buyer_002',
buyer_name: 'Jane Smith',
buyer_email: 'jane.smith@example.com',
platform: 'EBAY',
platform_buyer_id: 'ebay_001',
blacklist_reason: '虚假地址',
blacklist_type: 'ABUSE',
risk_score: 65,
blacklist_date: '2026-03-05',
status: 'ACTIVE',
created_by: 'system',
created_at: '2026-03-05',
updated_at: '2026-03-05',
type: 'ADDRESS',
value: '123 Fraud St, Scam City',
reason: '虚假地址',
severity: 'MEDIUM',
status: 'ACTIVE',
source: 'AUTO',
createdAt: '2026-03-05',
updatedAt: '2026-03-05',
createdBy: 'system',
updatedAt: '2026-03-05',
},
];
@@ -93,13 +138,14 @@ class MockBlacklistDataSource implements IBlacklistDataSource {
await new Promise(resolve => setTimeout(resolve, 300));
let result = [...this.blacklist];
if (params?.type) {
result = result.filter(r => r.type === params.type);
// 移除type过滤因为type属性不存在
}
if (params?.status) {
result = result.filter(r => r.status === params.status);
}
if (params?.search) {
result = result.filter(r => r.value.toLowerCase().includes(params.search!.toLowerCase()));
result = result.filter(r => r.buyer_name.toLowerCase().includes(params.search!.toLowerCase()));
}
return result;
}
@@ -109,15 +155,25 @@ class MockBlacklistDataSource implements IBlacklistDataSource {
const newRecord: BlacklistRecord = {
id: `${Date.now()}`,
tenant_id: 'tenant_001',
type: data.type || 'CUSTOMER',
value: data.value || '',
reason: data.reason || '',
severity: data.severity || 'MEDIUM',
shop_id: data.shop_id || 'shop_001',
trace_id: data.trace_id || `trace_${Date.now()}`,
business_type: data.business_type || 'TOC',
buyer_id: data.buyer_id || `buyer_${Date.now()}`,
buyer_name: data.buyer_name || '',
buyer_email: data.buyer_email || '',
buyer_phone: data.buyer_phone,
platform: data.platform || '',
platform_buyer_id: data.platform_buyer_id || '',
blacklist_reason: data.blacklist_reason || '',
blacklist_type: data.blacklist_type || 'OTHER',
risk_score: data.risk_score || 50,
blacklist_date: data.blacklist_date || new Date().toISOString().split('T')[0],
expiry_date: data.expiry_date,
status: 'ACTIVE',
source: 'MANUAL',
createdAt: new Date().toISOString().split('T')[0],
updatedAt: new Date().toISOString().split('T')[0],
createdBy: 'current_user',
evidence: data.evidence,
created_by: data.created_by || 'current_user',
created_at: new Date().toISOString().split('T')[0],
updated_at: new Date().toISOString().split('T')[0],
...data,
};
this.blacklist.push(newRecord);
@@ -128,7 +184,7 @@ class MockBlacklistDataSource implements IBlacklistDataSource {
await new Promise(resolve => setTimeout(resolve, 300));
const index = this.blacklist.findIndex(r => r.id === id);
if (index === -1) throw new Error('Record not found');
this.blacklist[index] = { ...this.blacklist[index], ...data, updatedAt: new Date().toISOString().split('T')[0] };
this.blacklist[index] = { ...this.blacklist[index], ...data, updated_at: new Date().toISOString().split('T')[0] };
return this.blacklist[index];
}