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

/**
 * Reward service interface
 */
export interface IRewardService extends IService {
  /**
   * Calculate reward based on input parameters
   */
  calculateReward(input: RewardCalculationInput): Promise<RewardCalculationResult>;

  /**
   * Create a new reward
   */
  createReward(reward: Omit<Reward, 'id' | 'createdAt' | 'updatedAt'>): Promise<Reward>;

  /**
   * Get reward by ID
   */
  getRewardById(id: string): Promise<Reward | null>;

  /**
   * Get rewards by user ID
   */
  getRewardsByUserId(userId: string, filters?: {
    type?: RewardType;
    status?: RewardStatus;
    dateFrom?: Date;
    dateTo?: Date;
    limit?: number;
    offset?: number;
  }): Promise<Reward[]>;

  /**
   * Get rewards by status
   */
  getRewardsByStatus(status: RewardStatus, limit?: number, offset?: number): Promise<Reward[]>;

  /**
   * Update reward status
   */
  updateRewardStatus(id: string, status: RewardStatus, approvedBy?: string): Promise<Reward>;

  /**
   * Approve reward
   */
  approveReward(id: string, approvedBy: string): Promise<Reward>;

  /**
   * Reject reward
   */
  rejectReward(id: string, reason: string, rejectedBy: string): Promise<Reward>;

  /**
   * Mark reward as paid
   */
  markRewardAsPaid(id: string, transactionId: string): Promise<Reward>;

  /**
   * Get reward statistics for user
   */
  getUserRewardStatistics(userId: string, dateFrom?: Date, dateTo?: Date): Promise<{
    totalEarned: number;
    totalPending: number;
    totalApproved: number;
    totalPaid: number;
    rewardBreakdown: Array<{
      type: RewardType;
      count: number;
      totalAmount: number;
    }>;
  }>;

  /**
   * Get reward configuration
   */
  getRewardConfig(): Promise<RewardConfig>;

  /**
   * Update reward configuration
   */
  updateRewardConfig(config: Partial<RewardConfig>): Promise<RewardConfig>;

  /**
   * Calculate learning hours reward
   */
  calculateLearningHoursReward(userId: string, hoursLogged: number, sessionIds: string[]): Promise<RewardCalculationResult>;

  /**
   * Calculate performance bonus reward
   */
  calculatePerformanceBonusReward(userId: string, performanceScore: number, achievementId: string): Promise<RewardCalculationResult>;

  /**
   * Calculate completion reward
   */
  calculateCompletionReward(userId: string, completedItemId: string, completedItemType: 'course' | 'exam' | 'module', score?: number): Promise<RewardCalculationResult>;

  /**
   * Calculate consistency reward
   */
  calculateConsistencyReward(userId: string, streakDays: number, streakType: 'daily_login' | 'daily_learning' | 'weekly_goals'): Promise<RewardCalculationResult>;

  /**
   * Bulk create rewards
   */
  bulkCreateRewards(rewards: Array<Omit<Reward, 'id' | 'createdAt' | 'updatedAt'>>): Promise<Reward[]>;

  /**
   * Get pending rewards count
   */
  getPendingRewardsCount(): Promise<number>;

  /**
   * Get total rewards amount by period
   */
  getTotalRewardsByPeriod(startDate: Date, endDate: Date, status?: RewardStatus): Promise<{
    totalAmount: number;
    count: number;
    currency: string;
  }>;
}