package com.haha.entity.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 补货单创建DTO
 */
@Data
public class ReplenishmentOrderCreateDTO {

    /**
     * 设备SN号
     */
    @NotBlank(message = "设备ID不能为空")
    private String deviceId;

    /**
     * 门店ID
     */
    private Long shopId;

    /**
     * 供应商名称
     */
    private String supplierName;

    /**
     * ERP仓库名称
     */
    private String warehouseName;

    /**
     * 预计到货时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private LocalDateTime expectedArrivalTime;

    /**
     * 备注
     */
    private String remark;

    /**
     * 补货商品列表
     */
    @NotEmpty(message = "补货商品列表不能为空")
    @Valid
    private List<ReplenishmentOrderItemDTO> items;

    @Data
    public static class ReplenishmentOrderItemDTO {

        /**
         * 商品ID
         */
        @NotNull(message = "商品ID不能为空")
        private Long productId;

        /**
         * 商品编码
         */
        private String productCode;

        /**
         * 商品名称
         */
        private String productName;

        /**
         * 计划补货数量
         */
        @NotNull(message = "计划补货数量不能为空")
        @Min(value = 1, message = "计划补货数量至少为1")
        private Integer plannedQuantity;

        /**
         * 单价
         */
        private BigDecimal unitPrice;

        /**
         * 货架层号
         */
        private Integer shelfNum;

        /**
         * 货道位置
         */
        private String position;
    }
}
