package com.pusong.business.domain.vo.home;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;

@Data
public class MakeAmountVo {

    /**
     * 当前时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date currentDate = new Date();
    /**
     * 统计范围
     */
    private String dateStr;
    /**
     * 成交总金额
     */
    private BigDecimal all;
    /**
     * 新签合同信息
     */
    private DataAmountVo newInfo = new DataAmountVo();
    /**
     * 续签合同信息
     */
    private DataAmountVo renewInfo = new DataAmountVo();

    public void cellPer(){
        if(0 == this.all.compareTo(BigDecimal.ZERO)) {
            this.newInfo.setPer("0%");
            this.renewInfo.setPer("0%");
        }else {
            this.newInfo.setPer(this.newInfo.getMoney().multiply(new BigDecimal("100.0")).divide(this.all,2, RoundingMode.HALF_UP).toPlainString()+"%");
            this.renewInfo.setPer(this.renewInfo.getMoney().multiply(new BigDecimal("100.0")).divide(this.all,2, RoundingMode.HALF_UP).toPlainString()+"%");
        }
    }

}
