package com.erp.purchase.dto;

import com.erp.purchase.entity.PurchaseInbound;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.Builder;

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

/**
 * 采购入库DTO
 */
public class PurchaseInboundDTO {

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class CreateRequest {
        /** 采购单ID */
        @NotNull(message = "采购单ID不能为空")
        private Long purchaseOrderId;

        private Long warehouseId;
        private LocalDateTime expectedTime;
        private String remark;

        @NotNull(message = "入库明细不能为空")
        private List<InboundItemRequest> items;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class InboundItemRequest {
        private String skuCode;
        private String skuName;
        private String unit;
        /** 到货数量 */
        private Integer arrivedQuantity;
        /** 验收合格数量 */
        private Integer acceptedQuantity;
        /** 残次品数量 */
        private Integer defectiveQuantity;
        private BigDecimal price;
        private String remark;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class ConfirmRequest {
        private String remark;
        private List<ConfirmItem> items;

        @Data
        @NoArgsConstructor
        @AllArgsConstructor
        @Builder
        public static class ConfirmItem {
            private Long itemId;
            private String skuCode;
            private Integer acceptedQuantity;
            private Integer defectiveQuantity;
        }
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class QueryRequest {
        private String inboundNo;
        private Long purchaseOrderId;
        private Long supplierId;
        private Long warehouseId;
        private String status;
        private LocalDateTime startTime;
        private LocalDateTime endTime;
        private int page = 1;
        private int limit = 20;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class VO {
        private Long id;
        private String inboundNo;
        private Long purchaseOrderId;
        private String purchaseOrderNo;
        private Long supplierId;
        private String supplierName;
        private Long warehouseId;
        private String warehouseName;
        private String status;
        private String statusDesc;
        private Integer totalQuantity;
        private Integer acceptedQuantity;
        private Integer defectiveQuantity;
        private BigDecimal totalAmount;
        private LocalDateTime inboundTime;
        private LocalDateTime expectedTime;
        private String remark;
        private String warehouseInboundNo;
        private Long operatorId;
        private String operatorName;
        private java.time.LocalDateTime createTime;
        private List<PurchaseInbound.PurchaseInboundItem> items;
    }
}
