package com.slodon.b2b2c.vo.statistics;

import com.slodon.b2b2c.core.util.TimeUtil;
import com.slodon.b2b2c.statistics.pojo.PlatformDay;
import com.slodon.b2b2c.statistics.pojo.base.StoreBase;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;

import static com.slodon.b2b2c.vo.statistics.FlowOverviewVO.dealSubmitPayRate;

/**
 *
 * 封装交易分析-交易报表Vo对象
 * @author wuxy
 */
@Data
public class TradeReportVO {

    @ApiModelProperty("统计时间")
    private String statsTime;

    @ApiModelProperty("下单数")
    private Integer orderSubmitNum;

    @ApiModelProperty("下单人数")
    private Integer orderSubmitMemberNum;

    @ApiModelProperty("下单金额")
    private BigDecimal orderSubmitAmount;

    @ApiModelProperty("支付订单数")
    private Integer orderPayNum;

    @ApiModelProperty("支付人数")
    private Integer orderPayMemberNum;

    @ApiModelProperty("支付金额")
    private BigDecimal orderPayAmount;

    @ApiModelProperty("下单-支付转化率，支付订单人数/下单人数*100%")
    private String submitPayRate;

    public TradeReportVO(PlatformDay platformDay) {
        this.statsTime = TimeUtil.getZDDay(platformDay.getStatsTime());
        this.orderSubmitNum = platformDay.getOrderSubmitNum();
        this.orderSubmitMemberNum = platformDay.getOrderSubmitMemberNum();
        this.orderSubmitAmount = platformDay.getOrderSubmitAmount();
        this.orderPayNum = platformDay.getOrderPayNum();
        this.orderPayMemberNum = platformDay.getOrderPayMemberNum();
        this.orderPayAmount = platformDay.getOrderPayAmount();
        this.submitPayRate = dealSubmitPayRate(platformDay.getOrderPayMemberNum(), platformDay.getOrderSubmitMemberNum());
    }

    public TradeReportVO(StoreBase storeBase) {
        this.statsTime = TimeUtil.getZDDay(storeBase.getStatsTime());
        this.orderSubmitNum = storeBase.getOrderSubmitNum();
        this.orderSubmitMemberNum = storeBase.getOrderSubmitMemberNum();
        this.orderSubmitAmount = storeBase.getOrderSubmitAmount();
        this.orderPayNum = storeBase.getOrderPayNum();
        this.orderPayMemberNum = storeBase.getOrderPayMemberNum();
        this.orderPayAmount = storeBase.getOrderPayAmount();
        this.submitPayRate = dealSubmitPayRate(storeBase.getOrderPayMemberNum(), storeBase.getOrderSubmitMemberNum());
    }
}
