export type MemberLevel = 'BRONZE' | 'SILVER' | 'GOLD' | 'PLATINUM' | 'DIAMOND';

export type PointsSourceType = 
  | 'PURCHASE'
  | 'REVIEW'
  | 'REFERRAL'
  | 'SIGN_IN'
  | 'PROMOTION'
  | 'ADMIN_ADJUST'
  | 'EXPIRED'
  | 'REDEEM';

export type PointsStatus = 'PENDING' | 'CONFIRMED' | 'EXPIRED' | 'REDEEMED' | 'CANCELLED';

export interface UserAsset {
  id?: string;
  tenantId: string;
  shopId: string;
  userId: string;
  totalPoints: number;
  availablePoints: number;
  frozenPoints: number;
  totalSpent: number;
  totalOrders: number;
  memberLevel: MemberLevel;
  memberScore: number;
  cashbackBalance: number;
  couponCount: number;
  lastActiveAt?: Date;
  createdAt?: Date;
  updatedAt?: Date;
}

export interface UserAssetCreateInput {
  tenantId: string;
  shopId: string;
  userId: string;
  traceId: string;
}

export interface PointsRecord {
  id?: string;
  tenantId: string;
  shopId: string;
  userId: string;
  taskId?: string;
  traceId: string;
  businessType: 'TOC' | 'TOB';
  points: number;
  balance: number;
  sourceType: PointsSourceType;
  sourceId?: string;
  description: string;
  status: PointsStatus;
  expiredAt?: Date;
  createdAt?: Date;
}

export interface PointsOperationInput {
  tenantId: string;
  shopId: string;
  userId: string;
  taskId?: string;
  traceId: string;
  businessType: 'TOC' | 'TOB';
  points: number;
  sourceType: PointsSourceType;
  sourceId?: string;
  description: string;
  expiredAt?: Date;
}

export interface MemberLevelRule {
  id?: string;
  tenantId?: string;
  level: MemberLevel;
  minScore: number;
  maxScore: number;
  discount: number;
  pointsMultiplier: number;
  benefits: string[];
  isActive: boolean;
  createdAt?: Date;
  updatedAt?: Date;
}

export interface MemberLevelRuleCreateInput {
  tenantId?: string;
  level: MemberLevel;
  minScore: number;
  maxScore: number;
  discount: number;
  pointsMultiplier: number;
  benefits: string[];
  isActive?: boolean;
}

export interface UserAssetQueryOptions {
  tenantId: string;
  shopId?: string;
  userId?: string;
  memberLevel?: MemberLevel;
  minPoints?: number;
  maxPoints?: number;
  page?: number;
  pageSize?: number;
}

export interface PointsQueryOptions {
  tenantId: string;
  shopId?: string;
  userId?: string;
  sourceType?: PointsSourceType;
  status?: PointsStatus;
  startDate?: Date;
  endDate?: Date;
  page?: number;
  pageSize?: number;
}
