package com.erp.reconciliation.dto;

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

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

/**
 * 对账统计DTO
 * 
 * @author ERP Migration
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ReconciliationStatisticsDTO {

    /** 统计时间范围 */
    private LocalDateTime startTime;
    private LocalDateTime endTime;
    
    // ==================== 对账单统计 ====================
    
    /** 总对账单数 */
    private Long totalBillCount;
    
    /** 待对账数 */
    private Long pendingBillCount;
    
    /** 已完成数 */
    private Long completedBillCount;
    
    /** 失败数 */
    private Long failedBillCount;
    
    // ==================== 金额统计 ====================
    
    /** 平台账单总金额 */
    private BigDecimal platformTotalAmount;
    
    /** 内部订单总金额 */
    private BigDecimal internalTotalAmount;
    
    /** 差异总金额 */
    private BigDecimal totalDifferenceAmount;
    
    /** 已匹配金额 */
    private BigDecimal matchedAmount;
    
    // ==================== 差异统计 ====================
    
    /** 差异记录总数 */
    private Long totalDifferenceCount;
    
    /** 待处理差异数 */
    private Long pendingDifferenceCount;
    
    /** 已解决差异数 */
    private Long resolvedDifferenceCount;
    
    /** 金额差异数 */
    private Long amountDifferenceCount;
    
    /** 缺失差异数 */
    private Long missingDifferenceCount;
    
    /** 状态不匹配数 */
    private Long statusMismatchCount;
    
    // ==================== 匹配率 ====================
    
    /** 总订单匹配率 */
    private BigDecimal overallMatchRate;
    
    /** 已匹配订单数 */
    private Long matchedOrderCount;
    
    /** 差异订单数 */
    private Long differenceOrderCount;
    
    // ==================== 按平台统计 ====================
    
    private List<PlatformStatistics> platformStatistics;
    
    // ==================== 按店铺统计 ====================
    
    private List<ShopStatistics> shopStatistics;
    
    // ==================== 内部类 ====================
    
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class PlatformStatistics {
        private String platform;
        private Long billCount;
        private Long orderCount;
        private BigDecimal platformAmount;
        private BigDecimal internalAmount;
        private BigDecimal differenceAmount;
        private BigDecimal matchRate;
    }
    
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class ShopStatistics {
        private Long shopId;
        private String shopName;
        private String platform;
        private Long billCount;
        private Long orderCount;
        private BigDecimal platformAmount;
        private BigDecimal internalAmount;
        private BigDecimal differenceAmount;
        private BigDecimal matchRate;
    }
}
