最新代码
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.starry.admin.utils;
|
||||
|
||||
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
|
||||
/**
|
||||
* 金额辅助类
|
||||
*/
|
||||
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 < 0f) {
|
||||
throw new CustomException("金额不能小于0");
|
||||
}
|
||||
if (item > Integer.MAX_VALUE) {
|
||||
throw new CustomException("金额超出计算范围");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user