package com.liquidnet.service.goblin.dto.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Map;

/**
 * 店铺退款列表 - 各 status 数量。
 * status 含义见 {@link GoblinBackOrderVo#getStatus()}，前端自行组合 Tab。
 */
@ApiModel("店铺退款列表-各审核状态数量")
@Data
public class GoblinStoreBackOrderStatusCountVo {

    @ApiModelProperty("全部")
    private long all;

    @ApiModelProperty("商铺发起退款[status=0]")
    private long storeInitiated;

    @ApiModelProperty("退款申请[status=1]")
    private long refundApply;

    @ApiModelProperty("退款成功[status=2]")
    private long refundSuccess;

    @ApiModelProperty("退款拒绝[status=3]")
    private long refundReject;

    @ApiModelProperty("退货申请[status=4]")
    private long returnApply;

    @ApiModelProperty("退货拒绝[status=5]")
    private long returnReject;

    @ApiModelProperty("退货审核通过待填物流[status=6]")
    private long returnWaitLogistics;

    @ApiModelProperty("待收货[status=7]")
    private long waitReceive;

    @ApiModelProperty("退货完成[status=8]")
    private long returnCompleted;

    @ApiModelProperty("退货失败[status=9]")
    private long returnFailed;

    /**
     * 从 Mongo 按 status 分组统计结果组装 VO。
     */
    public static GoblinStoreBackOrderStatusCountVo of(long all, Map<Integer, Long> grouped) {
        GoblinStoreBackOrderStatusCountVo vo = new GoblinStoreBackOrderStatusCountVo();
        vo.all = all;
        vo.storeInitiated = grouped.getOrDefault(0, 0L);
        vo.refundApply = grouped.getOrDefault(1, 0L);
        vo.refundSuccess = grouped.getOrDefault(2, 0L);
        vo.refundReject = grouped.getOrDefault(3, 0L);
        vo.returnApply = grouped.getOrDefault(4, 0L);
        vo.returnReject = grouped.getOrDefault(5, 0L);
        vo.returnWaitLogistics = grouped.getOrDefault(6, 0L);
        vo.waitReceive = grouped.getOrDefault(7, 0L);
        vo.returnCompleted = grouped.getOrDefault(8, 0L);
        vo.returnFailed = grouped.getOrDefault(9, 0L);
        return vo;
    }
}
