/**
 * 贡献值计算完成事件
 * 当用户的算力被计算或更新时发布
 */
export class ContributionCalculatedEvent {
  static readonly EVENT_TYPE = 'ContributionCalculated';
  static readonly TOPIC = 'contribution.contribution-calculated';

  constructor(
    public readonly eventId: string,
    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 calculatedAt: Date,
  ) {}

  toPayload(): Record<string, any> {
    return {
      eventId: this.eventId,
      eventType: ContributionCalculatedEvent.EVENT_TYPE,
      accountSequence: this.accountSequence,
      personalContribution: this.personalContribution,
      teamLevelContribution: this.teamLevelContribution,
      teamBonusContribution: this.teamBonusContribution,
      totalContribution: this.totalContribution,
      effectiveContribution: this.effectiveContribution,
      calculatedAt: this.calculatedAt.toISOString(),
    };
  }
}
