// EN: DTOs for Order Service.
// VI: DTOs cho Order Service.

namespace OrderService.API.Application.DTOs;

/// <summary>
/// EN: Complete order details with items.
/// VI: Chi tiết order đầy đủ với items.
/// </summary>
public record OrderDto(
    Guid Id,
    Guid ShopId,
    Guid? CustomerId,
    string Status,
    decimal TotalAmount,
    DateTime CreatedAt,
    DateTime? UpdatedAt,
    List<OrderItemDto> Items
);

/// <summary>
/// EN: Order item details.
/// VI: Chi tiết order item.
/// </summary>
public record OrderItemDto(
    Guid Id,
    Guid ProductId,
    string ProductName,
    string ProductType,
    int Quantity,
    decimal UnitPrice,
    decimal TotalPrice,
    string Status
);

/// <summary>
/// EN: Order summary for list views.
/// VI: Tóm tắt order cho danh sách.
/// </summary>
public record OrderSummaryDto(
    Guid Id,
    Guid ShopId,
    Guid? CustomerId,
    string Status,
    decimal TotalAmount,
    int ItemCount,
    DateTime CreatedAt
);

/// <summary>
/// EN: Paged result wrapper.
/// VI: Wrapper kết quả phân trang.
/// </summary>
public record PagedResult<T>(
    List<T> Items,
    int TotalCount,
    int PageSize,
    int CurrentPage
)
{
    /// <summary>
    /// EN: Total number of pages.
    /// VI: Tổng số trang.
    /// </summary>
    public int TotalPages => (int)Math.Ceiling((double)TotalCount / PageSize);

    /// <summary>
    /// EN: Whether there are more pages.
    /// VI: Có thêm trang hay không.
    /// </summary>
    public bool HasNextPage => CurrentPage < TotalPages;

    /// <summary>
    /// EN: Whether there are previous pages.
    /// VI: Có trang trước hay không.
    /// </summary>
    public bool HasPreviousPage => CurrentPage > 1;
}
