namespace WalletService.API.Application.Commands;

using MediatR;

/// <summary>
/// EN: Command to create an escrow hold on a wallet.
/// VI: Command để tạo escrow hold trên ví.
/// </summary>
public record CreateHoldCommand(
    Guid UserId,
    decimal Amount,
    string CurrencyCode,
    string ReferenceType,
    Guid ReferenceId,
    string Description,
    DateTime? ExpiresAt = null
) : IRequest<HoldResult>;

/// <summary>
/// EN: Command to execute (commit) an escrow hold.
/// VI: Command để thực thi (cam kết) escrow hold.
/// </summary>
public record ExecuteHoldCommand(
    Guid WalletId,
    Guid HoldId,
    decimal Amount,
    string? ExecutionRef = null
) : IRequest<HoldResult>;

/// <summary>
/// EN: Command to release (return) an escrow hold.
/// VI: Command để giải phóng (trả lại) escrow hold.
/// </summary>
public record ReleaseHoldCommand(
    Guid WalletId,
    Guid HoldId,
    decimal? Amount = null  // null = release all remaining
) : IRequest<HoldResult>;

/// <summary>
/// EN: Command to cancel an escrow hold.
/// VI: Command để hủy escrow hold.
/// </summary>
public record CancelHoldCommand(
    Guid WalletId,
    Guid HoldId
) : IRequest<HoldResult>;

/// <summary>
/// EN: Result of hold operations.
/// VI: Kết quả của các thao tác hold.
/// </summary>
public record HoldResult(
    Guid HoldId,
    Guid WalletId,
    decimal OriginalAmount,
    decimal RemainingAmount,
    decimal ExecutedAmount,
    decimal ReleasedAmount,
    string Status,
    string CurrencyCode,
    string ReferenceType,
    Guid ReferenceId,
    DateTime CreatedAt,
    DateTime UpdatedAt
);
