- 对所有 Java 源文件应用统一的代码格式化 - 统一缩进为 4 个空格 - 清理尾随空白字符和文件末尾换行 - 优化导入语句组织 - 总计格式化 654 个 Java 文件 有问题可以回滚或者找我聊
37 lines
858 B
Java
37 lines
858 B
Java
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("金额超出计算范围");
|
|
}
|
|
}
|
|
|
|
}
|