package cn.ysk.cashier.vo;


import lombok.Data;

import java.math.BigDecimal;

@Data
public class TbOrderSalesCountByDayVo {
    private String productName;
    private String productSkuName;
    private String cateName;
    private String unitName;
    private BigDecimal price;
    private BigDecimal salesNum;
    private BigDecimal refNum;
    private BigDecimal salesAmount;
    private BigDecimal refAmount;
    private BigDecimal num;
    private Integer productId;
    private Integer productSkuId;

    public TbOrderSalesCountByDayVo(BigDecimal salesNum, BigDecimal refNum) {
        this.salesNum = salesNum;
        this.refNum = refNum;
    }

    public TbOrderSalesCountByDayVo(String productName, String productSkuName, String cateName,String unitName,BigDecimal price,
                                    BigDecimal salesNum, BigDecimal refNum, BigDecimal num, BigDecimal salesAmount, BigDecimal refAmount) {
        this.productName = productName;
        this.productSkuName = productSkuName;
        this.cateName = cateName;
        this.unitName = unitName;
        this.price = price;
        this.salesNum = salesNum;
        this.refNum = refNum;
        this.salesAmount = salesAmount;
        this.refAmount = refAmount;
        this.num = num;
        count();
    }

    public TbOrderSalesCountByDayVo(String productName, String productSkuName,
                                    String cateName,String unitName,BigDecimal price,
                                    BigDecimal salesNum, BigDecimal refNum, BigDecimal num, BigDecimal salesAmount, BigDecimal refAmount, Integer productId, Integer productSkuId) {
        this.productName = productName;
        this.productSkuName = productSkuName;
        this.cateName = cateName;
        this.unitName = unitName;
        this.price = price;
        this.salesNum = salesNum;
        this.refNum = refNum;
        this.salesAmount = salesAmount;
        this.refAmount = refAmount;
        this.num = num;
        this.productId = productId;
        this.productSkuId = productSkuId;
        count();
    }

    public TbOrderSalesCountByDayVo(BigDecimal salesNum, BigDecimal refNum, BigDecimal num, BigDecimal salesAmount, BigDecimal refAmount) {
        this.salesNum = salesNum;
        this.refNum = refNum;
        this.salesAmount =  salesAmount;
        this.refAmount = refAmount;
        this.num = num;
        count();
    }

    public void count(){
        if (salesNum == null) salesNum = BigDecimal.ZERO;
        if (refNum == null) refNum = BigDecimal.ZERO;
        salesNum = salesNum.subtract(refNum);
        if (salesAmount == null) salesAmount = BigDecimal.ZERO;
        if (refAmount == null) refAmount = BigDecimal.ZERO;
        salesAmount = salesAmount.subtract(refAmount);
    }
}
