import { RightType } from './right-type.enum';

export class RewardSource {
  private constructor(
    public readonly rightType: RightType,
    public readonly sourceOrderNo: string,  // 订单号是字符串格式如 PLT1765391584505Q0Q6QD
    public readonly sourceUserId: bigint,
    public readonly sourceAccountSequence: string | null,  // 触发奖励的用户账户序列号
  ) {}

  static create(
    rightType: RightType,
    sourceOrderNo: string,
    sourceUserId: bigint,
    sourceAccountSequence?: string | null,
  ): RewardSource {
    return new RewardSource(rightType, sourceOrderNo, sourceUserId, sourceAccountSequence ?? null);
  }

  equals(other: RewardSource): boolean {
    return (
      this.rightType === other.rightType &&
      this.sourceOrderNo === other.sourceOrderNo &&
      this.sourceUserId === other.sourceUserId
    );
  }
}
