using MediatR;
using TakeoutSaaS.Application.App.Orders.Dto;
using TakeoutSaaS.Domain.Orders.Enums;
using TakeoutSaaS.Domain.Payments.Enums;

namespace TakeoutSaaS.Application.App.Orders.Commands;

/// <summary>
/// 创建订单命令。
/// </summary>
public sealed class CreateOrderCommand : IRequest<OrderDto>
{
    /// <summary>
    /// 订单号。
    /// </summary>
    public string OrderNo { get; set; } = string.Empty;

    /// <summary>
    /// 门店 ID。
    /// </summary>
    public long StoreId { get; set; }

    /// <summary>
    /// 渠道。
    /// </summary>
    public OrderChannel Channel { get; set; } = OrderChannel.MiniProgram;

    /// <summary>
    /// 履约方式。
    /// </summary>
    public DeliveryType DeliveryType { get; set; } = DeliveryType.DineIn;

    /// <summary>
    /// 状态。
    /// </summary>
    public OrderStatus Status { get; set; } = OrderStatus.PendingPayment;

    /// <summary>
    /// 支付状态。
    /// </summary>
    public PaymentStatus PaymentStatus { get; set; } = PaymentStatus.Unpaid;

    /// <summary>
    /// 顾客姓名。
    /// </summary>
    public string? CustomerName { get; set; }

    /// <summary>
    /// 顾客手机号。
    /// </summary>
    public string? CustomerPhone { get; set; }

    /// <summary>
    /// 桌号。
    /// </summary>
    public string? TableNo { get; set; }

    /// <summary>
    /// 排队号。
    /// </summary>
    public string? QueueNumber { get; set; }

    /// <summary>
    /// 预约 ID。
    /// </summary>
    public long? ReservationId { get; set; }

    /// <summary>
    /// 商品金额。
    /// </summary>
    public decimal ItemsAmount { get; set; }

    /// <summary>
    /// 优惠金额。
    /// </summary>
    public decimal DiscountAmount { get; set; }

    /// <summary>
    /// 应付金额。
    /// </summary>
    public decimal PayableAmount { get; set; }

    /// <summary>
    /// 实付金额。
    /// </summary>
    public decimal PaidAmount { get; set; }

    /// <summary>
    /// 支付时间。
    /// </summary>
    public DateTime? PaidAt { get; set; }

    /// <summary>
    /// 完成时间。
    /// </summary>
    public DateTime? FinishedAt { get; set; }

    /// <summary>
    /// 取消时间。
    /// </summary>
    public DateTime? CancelledAt { get; set; }

    /// <summary>
    /// 取消原因。
    /// </summary>
    public string? CancelReason { get; set; }

    /// <summary>
    /// 备注。
    /// </summary>
    public string? Remark { get; set; }

    /// <summary>
    /// 明细。
    /// </summary>
    public IReadOnlyList<OrderItemRequest> Items { get; set; } = Array.Empty<OrderItemRequest>();
}
