package com.ruoyi.cai.util;

import cn.hutool.core.util.NumberUtil;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class NumCaUtil {

    /**
     * 向下取整计算金额
     * @param value
     * @param rate
     * @return
     */
    public static Long coin(Long value, BigDecimal rate){
        if(value == null || rate == null){
            return 0L;
        }
        BigDecimal decimal = NumberUtil.mul(value, rate);
        return decimal.setScale(0, RoundingMode.DOWN).longValue();
    }

    public static void main(String[] args) {
        System.out.println(coin(5200L,BigDecimal.valueOf(0.07)));
    }
}
