package com.erp.report.dto;

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

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

/**
 * 库存统计响应DTO
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class StockReportResponse {

    // overview类型
    private Long totalStocks;
    private Long totalQuantity;
    private Long totalAvailable;
    private Long lowStockCount;
    private Long outOfStockCount;
    private Long slowMovingCount;

    // slow_moving / turnover类型
    private String type;
    private Integer slowDays;
    private Integer period;       // 周转率统计周期(天)
    private BigDecimal overallTurnoverRate; // 整体周转率

    private List<StockStatItem> list;

    private PaginationInfo pagination;

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class StockStatItem {
        // 通用字段
        private String skuCode;
        private String skuName;
        private Long warehouseId;
        private String warehouseName;
        private Integer quantity;
        private Integer available;

        // 呆滞库存特有
        private LocalDateTime lastMoveAt;
        private Integer daysSinceMove;
        private Boolean isSlow;

        // 周转率特有
        private Integer out30d;
        private BigDecimal turnoverRate;
        private BigDecimal turnoverDays;
    }

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class PaginationInfo {
        private Integer currentPage;
        private Integer perPage;
        private Long total;
        private Integer lastPage;
    }
}
