/**
 * 推荐关系同步事件
 * 用于同步到 mining-admin-service
 */
export class ReferralSyncedEvent {
  static readonly EVENT_TYPE = 'ReferralSynced';
  static readonly AGGREGATE_TYPE = 'Referral';

  constructor(
    public readonly accountSequence: string,
    public readonly referrerAccountSequence: string | null,
    public readonly referrerUserId: bigint | null,
    public readonly originalUserId: bigint | null,
    public readonly ancestorPath: string | null,
    public readonly depth: number,
  ) {}

  toPayload(): Record<string, any> {
    return {
      eventType: ReferralSyncedEvent.EVENT_TYPE,
      accountSequence: this.accountSequence,
      referrerAccountSequence: this.referrerAccountSequence,
      referrerUserId: this.referrerUserId?.toString() ?? null,
      originalUserId: this.originalUserId?.toString() ?? null,
      ancestorPath: this.ancestorPath,
      depth: this.depth,
    };
  }
}
