import { PendingReward, PendingRewardStatus } from '@/domain/aggregates';

export interface IPendingRewardRepository {
  save(reward: PendingReward): Promise<PendingReward>;
  saveAll(rewards: PendingReward[]): Promise<void>;
  update(reward: PendingReward): Promise<void>;
  updateAll(rewards: PendingReward[]): Promise<void>;

  findById(id: bigint): Promise<PendingReward | null>;
  findByAccountSequence(accountSequence: string, status?: PendingRewardStatus): Promise<PendingReward[]>;
  findByUserId(userId: bigint, status?: PendingRewardStatus): Promise<PendingReward[]>;
  findBySourceOrderId(sourceOrderId: string): Promise<PendingReward[]>;

  /**
   * 查找所有已过期但状态仍为 PENDING 的奖励
   * 用于定时任务批量处理过期
   */
  findExpiredPending(now: Date, limit?: number): Promise<PendingReward[]>;

  /**
   * 统计用户的待领取奖励总额
   */
  sumPendingByAccountSequence(accountSequence: string): Promise<{ usdtTotal: number; hashpowerTotal: number }>;
}

export const PENDING_REWARD_REPOSITORY = Symbol('IPendingRewardRepository');
