refactor(types): 重构类型系统,统一共享类型定义
feat(types): 新增共享类型中心,包含用户、产品、订单等核心领域类型 fix(types): 修复类型定义错误,统一各模块类型引用 style(types): 优化类型文件格式和注释 docs(types): 更新类型文档和变更日志 test(types): 添加类型测试用例 build(types): 配置类型共享路径 chore(types): 清理重复类型定义文件
This commit is contained in:
@@ -12,11 +12,17 @@ export interface UserAsset {
|
||||
userId: string;
|
||||
userName: string;
|
||||
email: string;
|
||||
userEmail?: string; // 与 email 同义
|
||||
memberLevel: MemberLevel;
|
||||
points: number;
|
||||
memberScore?: number; // 与 points 同义
|
||||
totalSpent: number;
|
||||
availableBalance: number;
|
||||
availablePoints?: number; // 与 availableBalance 同义
|
||||
frozenBalance: number;
|
||||
frozenPoints?: number; // 与 frozenBalance 同义
|
||||
cashbackBalance?: number;
|
||||
couponCount?: number;
|
||||
totalOrders: number;
|
||||
joinDate: string;
|
||||
lastActiveDate: string;
|
||||
@@ -35,6 +41,18 @@ export interface MemberLevelConfig {
|
||||
icon: string;
|
||||
}
|
||||
|
||||
export type PointsSourceType =
|
||||
| 'PURCHASE'
|
||||
| 'REVIEW'
|
||||
| 'REFERRAL'
|
||||
| 'PROMOTION'
|
||||
| 'ADMIN_ADJUST'
|
||||
| 'EXPIRED'
|
||||
| 'REFUND'
|
||||
| 'MANUAL_DEDUCT';
|
||||
|
||||
export type PointsStatus = 'PENDING' | 'CONFIRMED' | 'FROZEN' | 'EXPIRED' | 'CANCELLED';
|
||||
|
||||
export interface PointsRecord {
|
||||
id: string;
|
||||
userId: string;
|
||||
@@ -45,6 +63,16 @@ export interface PointsRecord {
|
||||
source: string;
|
||||
description: string;
|
||||
createdAt: string;
|
||||
// 额外字段,用于 PointsManage 页面
|
||||
tenantId?: string;
|
||||
shopId?: string;
|
||||
traceId?: string;
|
||||
businessType?: 'TOC' | 'TOB';
|
||||
points?: number; // 与 amount 同义
|
||||
sourceType?: string; // 与 source 同义
|
||||
status?: 'PENDING' | 'CONFIRMED' | 'FROZEN' | 'EXPIRED' | 'CANCELLED';
|
||||
expiredAt?: string;
|
||||
sourceId?: string;
|
||||
}
|
||||
|
||||
export interface IUserAssetDataSource {
|
||||
@@ -103,8 +131,44 @@ class MockUserAssetDataSource implements IUserAssetDataSource {
|
||||
];
|
||||
|
||||
private pointsRecords: PointsRecord[] = [
|
||||
{ id: '1', userId: 'user_001', userName: 'John Doe', type: 'EARN', amount: 100, balance: 5000, source: 'Purchase', description: 'Order #ORD-001', createdAt: '2026-03-15' },
|
||||
{ id: '2', userId: 'user_001', userName: 'John Doe', type: 'REDEEM', amount: -50, balance: 4950, source: 'Redemption', description: 'Coupon redemption', createdAt: '2026-03-16' },
|
||||
{
|
||||
id: '1',
|
||||
userId: 'user_001',
|
||||
userName: 'John Doe',
|
||||
type: 'EARN',
|
||||
amount: 100,
|
||||
balance: 5000,
|
||||
source: 'Purchase',
|
||||
description: 'Order #ORD-001',
|
||||
createdAt: '2026-03-15',
|
||||
// 额外字段
|
||||
tenantId: 'T001',
|
||||
shopId: 'S001',
|
||||
traceId: 'TR001',
|
||||
businessType: 'TOC',
|
||||
points: 100,
|
||||
sourceType: 'PURCHASE',
|
||||
status: 'CONFIRMED'
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
userId: 'user_001',
|
||||
userName: 'John Doe',
|
||||
type: 'REDEEM',
|
||||
amount: -50,
|
||||
balance: 4950,
|
||||
source: 'Redemption',
|
||||
description: 'Coupon redemption',
|
||||
createdAt: '2026-03-16',
|
||||
// 额外字段
|
||||
tenantId: 'T001',
|
||||
shopId: 'S001',
|
||||
traceId: 'TR002',
|
||||
businessType: 'TOC',
|
||||
points: -50,
|
||||
sourceType: 'MANUAL_DEDUCT',
|
||||
status: 'CONFIRMED'
|
||||
},
|
||||
];
|
||||
|
||||
async fetchUserAssets(params?: { memberLevel?: string; status?: string; search?: string }): Promise<UserAsset[]> {
|
||||
|
||||
Reference in New Issue
Block a user