package com.starry.admin.utils;

import com.starry.admin.common.exception.CustomException;

/**
 * 金额辅助类
 *
 * @author admin
 */
public class MoneyUtils {

    /**
     * 校验金钱值是否正常
     *
     * @param money
     *            金钱值
     */
    public static void verificationTypeIsNormal(String money) {
        if (money == null || money.isEmpty()) {
            throw new CustomException("金额类型异常");
        }
        float item;
        try {
            item = Float.parseFloat(money);
        } catch (Exception e) {
            throw new CustomException("金额类型异常");
        }
        if (item < 0) {
            throw new CustomException("金额不能小于0");
        }
        if (item > Integer.MAX_VALUE) {
            throw new CustomException("金额超出计算范围");
        }
    }

}
