package com.erp.warehouse.dto;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.Builder;

import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

/**
 * 库存操作请求DTO
 */
public class StockOpDTO {

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class InboundRequest {
        @NotBlank(message = "SKU编码不能为空")
        private String skuCode;

        @NotNull(message = "仓库ID不能为空")
        private Long warehouseId;

        @NotNull(message = "数量不能为空")
        @Min(value = 1, message = "数量必须大于0")
        private Integer quantity;

        private String relatedNo;
        private String remark;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class OutboundRequest {
        @NotBlank(message = "SKU编码不能为空")
        private String skuCode;

        @NotNull(message = "仓库ID不能为空")
        private Long warehouseId;

        @NotNull(message = "数量不能为空")
        @Min(value = 1, message = "数量必须大于0")
        private Integer quantity;

        private String relatedNo;
        private String remark;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class LockRequest {
        @NotBlank(message = "SKU编码不能为空")
        private String skuCode;

        @NotNull(message = "仓库ID不能为空")
        private Long warehouseId;

        @NotNull(message = "数量不能为空")
        @Min(value = 1, message = "数量必须大于0")
        private Integer quantity;

        @NotNull(message = "订单ID不能为空")
        private Long orderId;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class UnlockRequest {
        @NotBlank(message = "SKU编码不能为空")
        private String skuCode;

        @NotNull(message = "仓库ID不能为空")
        private Long warehouseId;

        @NotNull(message = "数量不能为空")
        @Min(value = 1, message = "数量必须大于0")
        private Integer quantity;

        @NotNull(message = "订单ID不能为空")
        private Long orderId;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class ReserveRequest {
        @NotBlank(message = "SKU编码不能为空")
        private String skuCode;

        @NotNull(message = "仓库ID不能为空")
        private Long warehouseId;

        @NotNull(message = "数量不能为空")
        @Min(value = 1, message = "数量必须大于0")
        private Integer quantity;

        @NotNull(message = "订单ID不能为空")
        private Long orderId;

        private String reserveToken;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class ConfirmReserveRequest {
        @NotBlank(message = "预扣凭证不能为空")
        private String reserveToken;

        @NotNull(message = "订单ID不能为空")
        private Long orderId;

        private String trackingNo;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class ShipRequest {
        @NotBlank(message = "SKU编码不能为空")
        private String skuCode;

        @NotNull(message = "仓库ID不能为空")
        private Long warehouseId;

        @NotNull(message = "数量不能为空")
        @Min(value = 1, message = "数量必须大于0")
        private Integer quantity;

        @NotNull(message = "订单ID不能为空")
        private Long orderId;

        private String trackingNo;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class AdjustRequest {
        @NotBlank(message = "SKU编码不能为空")
        private String skuCode;

        @NotNull(message = "仓库ID不能为空")
        private Long warehouseId;

        private Integer quantity;
        private Integer lockedQuantity;
        private Integer defectiveQuantity;
        private String remark;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class ThresholdRequest {
        @NotBlank(message = "SKU编码不能为空")
        private String skuCode;

        @NotNull(message = "仓库ID不能为空")
        private Long warehouseId;

        @NotNull(message = "预警阈值不能为空")
        @Min(value = 0, message = "预警阈值不能为负数")
        private Integer warningThreshold;
    }
}
