/*
 * Copyright [2022] [https://www.xiaonuo.vip]
 *
 * Snowy采用APACHE LICENSE 2.0开源协议，您在使用过程中，需要注意以下几点：
 *
 * 1.请不要删除和修改根目录下的LICENSE文件。
 * 2.请不要删除和修改Snowy源码头部的版权声明。
 * 3.本项目代码可免费商业使用，商业使用请保留源码和相关描述文件的项目出处，作者声明等。
 * 4.分发源码时候，请注明软件出处 https://www.xiaonuo.vip
 * 5.不可二次分发开源参与同类竞品，如有想法可联系团队xiaonuobase@qq.com商议合作。
 * 6.若您的项目无法满足以上几点，需要更多功能代码，获取Snowy商业授权许可，请在官网购买授权，地址为 https://www.xiaonuo.vip
 */
package vip.xiaonuo.biz.modular.depotMapPage.entity;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;

/**
 * 地区交易额
 *
 * @author xiang
 * @date  2023/09/20 09:09
 **/
@Getter
@Setter
public class MapZoneSumVo {

    /** 地区 */
    @ApiModelProperty(value = "地区", position = 8)
    private String addressName;

    /** 贷款金额(元) */
    @ApiModelProperty(value = "贷款金额(元)", position = 9)
    private String loanSum;

    /** 质押库存数(吨) */
    @ApiModelProperty(value = "质押库存数(吨)", position = 10)
    private String mortgageCount;

    /** 累计利息(元) */
    @ApiModelProperty(value = "累计利息(元)", position = 11)
    private String loanInterest;

    public MapZoneSumVo(String addressName, BigDecimal loanSum, BigDecimal mortgageCount, BigDecimal loanInterest) {
        this.addressName = addressName;
        if (loanSum.doubleValue() > 1000000)
            this.loanSum = loanSum.movePointLeft(4).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "万";
        else
            this.loanSum = loanSum.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString();

        if (mortgageCount.doubleValue() > 1)
            this.mortgageCount = mortgageCount.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "万";
        else
            this.mortgageCount = mortgageCount.movePointRight(4).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString();;

        if (loanSum.doubleValue() > 1000000)
            this.loanInterest = loanInterest.movePointLeft(4).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "万";
        else
            this.loanInterest = loanInterest.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString();

    }
}
