/**
 * 贡献值账户同步事件
 * 用于初始同步到 mining-admin-service
 */
export class ContributionAccountSyncedEvent {
  static readonly EVENT_TYPE = 'ContributionAccountSynced';
  static readonly AGGREGATE_TYPE = 'ContributionAccount';

  constructor(
    public readonly accountSequence: string,
    public readonly personalContribution: string,
    public readonly teamLevelContribution: string,
    public readonly teamBonusContribution: string,
    public readonly totalContribution: string,
    public readonly effectiveContribution: string,
    public readonly hasAdopted: boolean,
    public readonly directReferralAdoptedCount: number,
    public readonly unlockedLevelDepth: number,
    public readonly unlockedBonusTiers: number,
    public readonly createdAt: Date,
  ) {}

  toPayload(): Record<string, any> {
    return {
      eventType: ContributionAccountSyncedEvent.EVENT_TYPE,
      accountSequence: this.accountSequence,
      personalContribution: this.personalContribution,
      teamLevelContribution: this.teamLevelContribution,
      teamBonusContribution: this.teamBonusContribution,
      totalContribution: this.totalContribution,
      effectiveContribution: this.effectiveContribution,
      hasAdopted: this.hasAdopted,
      directReferralAdoptedCount: this.directReferralAdoptedCount,
      unlockedLevelDepth: this.unlockedLevelDepth,
      unlockedBonusTiers: this.unlockedBonusTiers,
      createdAt: this.createdAt.toISOString(),
    };
  }
}
