package com.slodon.b2b2c.vo.statistics;

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

import java.math.BigDecimal;

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

/**
 *
 * 封装近30天变化趋势Vo对象
 * @author wuxy
 */
@NoArgsConstructor
@Data
public class ChangeTrendVO {

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

    @ApiModelProperty("访客数")
    private Integer visitorNum;

    @ApiModelProperty("新访客数")
    private Integer newVisitorNum;

    @ApiModelProperty("浏览量")
    private Integer viewNum;

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

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

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

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

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

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

    @ApiModelProperty("下单客单价")
    private BigDecimal orderSubmitAtv;

    @ApiModelProperty("支付客单价")
    private BigDecimal orderPayAtv;

    @ApiModelProperty("访问-支付转化率")
    private String pvPayRate;

    public ChangeTrendVO(PlatformBase platformBase) {
        this.statsTime = TimeUtil.getZDDay(platformBase.getStatsTime());
        this.visitorNum = platformBase.getVisitorNum();
        this.newVisitorNum = platformBase.getNewVisitorNum();
        this.viewNum = platformBase.getViewNum();
        this.orderSubmitAmount = platformBase.getOrderSubmitAmount();
        this.orderPayAmount = platformBase.getOrderPayAmount();
        this.orderSubmitNum = platformBase.getOrderSubmitNum();
        this.orderSubmitMemberNum = platformBase.getOrderSubmitMemberNum();
        this.orderPayNum = platformBase.getOrderPayNum();
        this.orderPayMemberNum = platformBase.getOrderPayMemberNum();
        this.orderSubmitAtv = platformBase.getOrderSubmitAtv();
        this.orderPayAtv = platformBase.getOrderPayAtv();
        this.pvPayRate = dealPvPayRate(platformBase.getOrderPayMemberNum(), platformBase.getVisitorNum());
    }

    public ChangeTrendVO(StoreBase storeBase) {
        this.statsTime = TimeUtil.getZDDay(storeBase.getStatsTime());
        this.visitorNum = storeBase.getVisitorNum();
        this.viewNum = storeBase.getViewNum();
        this.orderSubmitAmount = storeBase.getOrderSubmitAmount();
        this.orderPayAmount = storeBase.getOrderPayAmount();
        this.orderSubmitNum = storeBase.getOrderSubmitNum();
        this.orderSubmitMemberNum = storeBase.getOrderSubmitMemberNum();
        this.orderPayNum = storeBase.getOrderPayNum();
        this.orderPayMemberNum = storeBase.getOrderPayMemberNum();
        this.orderSubmitAtv = storeBase.getOrderSubmitAtv();
        this.orderPayAtv = storeBase.getOrderPayAtv();
        this.pvPayRate = dealPvPayRate(storeBase.getOrderPayMemberNum(), storeBase.getVisitorNum());
    }

}
