import { IRepository } from '../../../../core/interfaces/IRepository';
import { 
  Reward, 
  RewardType, 
  RewardStatus, 
  RewardCalculationInput,
  RewardCalculationResult 
} from '../../types/reward.types';

export interface IRewardRepository extends IRepository<Reward> {
  // Basic CRUD operations inherited from IRepository
  
  // Reward-specific queries
  findByUserId(userId: string): Promise<Reward[]>;
  findByUserIdAndType(userId: string, type: RewardType): Promise<Reward[]>;
  findByUserIdAndStatus(userId: string, status: RewardStatus): Promise<Reward[]>;
  findByUserIdAndDateRange(
    userId: string, 
    startDate: Date, 
    endDate: Date
  ): Promise<Reward[]>;
  
  // Reward statistics
  getUserRewardStats(userId: string): Promise<{
    totalEarned: number;
    totalPending: number;
    totalPaid: number;
    rewardsByType: Record<RewardType, number>;
    rewardsByMonth: Record<string, number>;
  }>;
  
  // Batch operations
  createBatch(rewards: Omit<Reward, 'id' | 'createdAt' | 'updatedAt'>[]): Promise<Reward[]>;
  updateStatusBatch(rewardIds: string[], status: RewardStatus): Promise<void>;
  
  // Payroll integration
  findPendingRewardsForPayroll(
    startDate: Date, 
    endDate: Date
  ): Promise<Reward[]>;
  
  findRewardsByPayrollBatch(batchId: string): Promise<Reward[]>;
  
  // Performance queries
  findTopEarners(
    startDate: Date, 
    endDate: Date, 
    limit?: number
  ): Promise<Array<{
    userId: string;
    totalEarned: number;
    rewardCount: number;
  }>>;
  
  // Consistency tracking
  findUserConsistencyData(
    userId: string, 
    days: number
  ): Promise<Array<{
    date: Date;
    hasActivity: boolean;
    rewardEarned: number;
  }>>;
  
  // Audit and reporting
  getRewardTrends(
    startDate: Date, 
    endDate: Date, 
    groupBy: 'day' | 'week' | 'month'
  ): Promise<Array<{
    period: string;
    totalRewards: number;
    totalAmount: number;
    uniqueUsers: number;
  }>>;
}