package com.erp.order.settlement.dto;

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

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

/**
 * 结算统计数据传输对象
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class SettlementStatisticsDTO {

    /** 总订单数 */
    private Long totalOrderCount;

    /** 总订单金额 */
    private BigDecimal totalOrderAmount;

    /** 总优惠金额 */
    private BigDecimal totalDiscountAmount;

    /** 总运费 */
    private BigDecimal totalFreight;

    /** 总平台佣金 */
    private BigDecimal totalPlatformFee;

    /** 总结算金额 */
    private BigDecimal totalSettlementAmount;

    /** 已结算金额 */
    private BigDecimal settledAmount;

    /** 待结算金额 */
    private BigDecimal pendingSettlementAmount;

    /** 已冻结金额 */
    private BigDecimal frozenAmount;

    /** 各状态数量统计 */
    private Map<String, Long> statusCountMap;

    /** 各平台统计 */
    private List<PlatformStatistics> platformStatistics;

    /** 各店铺统计 */
    private List<ShopStatistics> shopStatistics;

    /** 统计时间范围 */
    private LocalDateTime startTime;
    private LocalDateTime endTime;

    /**
     * 平台维度统计
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class PlatformStatistics {
        private String platform;
        private Long orderCount;
        private BigDecimal orderAmount;
        private BigDecimal platformFee;
        private BigDecimal settlementAmount;
    }

    /**
     * 店铺维度统计
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class ShopStatistics {
        private Long shopId;
        private String shopName;
        private String platform;
        private Long orderCount;
        private BigDecimal orderAmount;
        private BigDecimal platformFee;
        private BigDecimal settlementAmount;
    }
}
