package com.snack.server.module.order.dto.req;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 提交订单请求
 */
@Data
@Schema(description = "提交订单请求")
public class OrderSubmitReq implements Serializable {

    @NotEmpty(message = "订单项不能为空")
    @Valid
    @Schema(description = "订单项列表（来自购物车）")
    private List<OrderItemReq> items;

    @NotNull(message = "收货地址不能为空")
    @Schema(description = "收货地址 ID", example = "1")
    private Long addressId;

    @Schema(description = "优惠券 ID（可选）")
    private Long couponId;

    @Schema(description = "订单备注")
    private String remark;

    @Data
    public static class OrderItemReq implements Serializable {
        @NotNull(message = "SKU ID 不能为空")
        @Schema(description = "SKU ID")
        private Long skuId;

        @NotNull(message = "数量不能为空")
        @Schema(description = "购买数量")
        private Integer quantity;
    }
}
