package com.erp.purchase.dto;

import com.erp.purchase.entity.PurchaseReturn;
import jakarta.validation.constraints.NotEmpty;
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 PurchaseReturnDTO {

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class CreateRequest {
        @NotNull(message = "采购单ID不能为空")
        private Long purchaseOrderId;
        private Long supplierId;
        private Long warehouseId;
        @NotEmpty(message = "退货明细不能为空")
        private List<ReturnItemRequest> items;
        private String returnReason;
        private String returnType;
        private String remark;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class ReturnItemRequest {
        private String skuCode;
        private String skuName;
        private String unit;
        private Integer purchaseQuantity;
        private Integer returnQuantity;
        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 returnQuantity;
        }
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class QueryRequest {
        private String returnNo;
        private Long purchaseOrderId;
        private Long supplierId;
        private String status;
        private String returnType;
        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 returnNo;
        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 BigDecimal totalAmount;
        private BigDecimal refundedAmount;
        private String returnReason;
        private String returnType;
        private LocalDateTime outboundTime;
        private String remark;
        private String warehouseOutboundNo;
        private Long operatorId;
        private String operatorName;
        private java.time.LocalDateTime createTime;
        private List<PurchaseReturn.PurchaseReturnItem> items;
    }
}
