namespace WalletService.API.Application.Queries;

using MediatR;

#region Admin Wallet Queries

/// <summary>
/// EN: Query to get all wallets with pagination (Admin only).
/// VI: Query lấy tất cả ví với phân trang (Chỉ Admin).
/// </summary>
public record GetAllWalletsQuery(
    int Page,
    int PageSize,
    string? Status = null,
    string? Currency = null) : IRequest<AdminWalletsListDto>;

/// <summary>
/// EN: Query to get wallet by ID (Admin only).
/// VI: Query lấy ví theo ID (Chỉ Admin).
/// </summary>
public record GetWalletByIdQuery(Guid WalletId) : IRequest<AdminWalletDetailDto?>;

/// <summary>
/// EN: Query to search wallets (Admin only).
/// VI: Query tìm kiếm ví (Chỉ Admin).
/// </summary>
public record SearchWalletsQuery(
    Guid? UserId = null,
    Guid? WalletId = null,
    string? Status = null) : IRequest<List<AdminWalletDetailDto>>;

/// <summary>
/// EN: Query to get wallet statistics (Admin only).
/// VI: Query lấy thống kê ví (Chỉ Admin).
/// </summary>
public record GetWalletStatisticsQuery() : IRequest<WalletStatisticsDto>;

#endregion

#region Admin Points Queries

/// <summary>
/// EN: Query to get all point accounts with pagination (Admin only).
/// VI: Query lấy tất cả tài khoản điểm với phân trang (Chỉ Admin).
/// </summary>
public record GetAllPointAccountsQuery(
    int Page,
    int PageSize,
    long? MinPoints = null,
    long? MaxPoints = null) : IRequest<AdminPointAccountsListDto>;

/// <summary>
/// EN: Query to get point account by ID (Admin only).
/// VI: Query lấy tài khoản điểm theo ID (Chỉ Admin).
/// </summary>
public record GetPointAccountByIdQuery(Guid AccountId) : IRequest<AdminPointAccountDetailDto?>;

/// <summary>
/// EN: Query to search point accounts (Admin only).
/// VI: Query tìm kiếm tài khoản điểm (Chỉ Admin).
/// </summary>
public record SearchPointAccountsQuery(Guid? UserId = null) : IRequest<List<AdminPointAccountDetailDto>>;

/// <summary>
/// EN: Query to get points statistics (Admin only).
/// VI: Query lấy thống kê điểm (Chỉ Admin).
/// </summary>
public record GetPointsStatisticsQuery() : IRequest<PointsStatisticsDto>;

#endregion

#region Admin DTOs

/// <summary>
/// EN: DTO for admin wallets list with pagination.
/// VI: DTO cho danh sách ví Admin với phân trang.
/// </summary>
public record AdminWalletsListDto(
    List<AdminWalletSummaryDto> Wallets,
    int TotalCount,
    int Page,
    int PageSize);

public record AdminWalletSummaryDto(
    Guid Id,
    Guid UserId,
    string Status,
    List<BalanceItemDto> Balances,
    DateTime CreatedAt,
    DateTime UpdatedAt);

public record BalanceItemDto(
    string Currency,
    decimal Balance);

public record AdminWalletDetailDto(
    Guid Id,
    Guid UserId,
    string Status,
    List<BalanceItemDto> Balances,
    int TransactionCount,
    DateTime CreatedAt,
    DateTime UpdatedAt);

/// <summary>
/// EN: DTO for wallet statistics.
/// VI: DTO cho thống kê ví.
/// </summary>
public record WalletStatisticsDto(
    int TotalWallets,
    int ActiveWallets,
    int FrozenWallets,
    int ClosedWallets,
    Dictionary<string, decimal> TotalBalanceByCurrency,
    decimal TotalTransactionsToday,
    decimal TotalDepositsToday,
    decimal TotalWithdrawalsToday);

/// <summary>
/// EN: DTO for admin point accounts list with pagination.
/// VI: DTO cho danh sách tài khoản điểm Admin với phân trang.
/// </summary>
public record AdminPointAccountsListDto(
    List<AdminPointAccountSummaryDto> Accounts,
    int TotalCount,
    int Page,
    int PageSize);

public record AdminPointAccountSummaryDto(
    Guid Id,
    Guid UserId,
    long TotalPoints,
    long AvailablePoints,
    DateTime CreatedAt);

public record AdminPointAccountDetailDto(
    Guid Id,
    Guid UserId,
    long TotalPoints,
    long AvailablePoints,
    int TransactionCount,
    DateTime CreatedAt,
    DateTime UpdatedAt);

/// <summary>
/// EN: DTO for points statistics.
/// VI: DTO cho thống kê điểm.
/// </summary>
public record PointsStatisticsDto(
    int TotalAccounts,
    long TotalPointsIssued,
    long TotalPointsAvailable,
    long TotalPointsSpent,
    long TotalPointsExpired,
    long PointsEarnedToday,
    long PointsSpentToday);

#endregion
