|
@@ -1095,10 +1095,10 @@ public class BizUserServiceImpl extends ServiceImpl<BizUserMapper, BizUser> impl
|
|
|
.eq(BizUser::getPhone, CommonCryptogramUtil.doSm4CbcEncrypt(phone))) > 0) {
|
|
|
return JSONUtil.createObj().set("index", i + 1).set("success", false).set("msg", "存在重复的手机号,手机号为:"+phone);
|
|
|
}
|
|
|
- if(!isNonNegativeInteger(accountBalance)){
|
|
|
+ if(!isNonNegative(accountBalance)){
|
|
|
return JSONUtil.createObj().set("index", i + 1).set("success", false).set("msg", "糕点填写大于等于0的数字");
|
|
|
}
|
|
|
- if(!isNonNegativeInteger(voucherBalance)){
|
|
|
+ if(!isNonNegative(voucherBalance)){
|
|
|
return JSONUtil.createObj().set("index", i + 1).set("success", false).set("msg", "积分填写大于等于0的数字");
|
|
|
}
|
|
|
|
|
@@ -1130,4 +1130,19 @@ public class BizUserServiceImpl extends ServiceImpl<BizUserMapper, BizUser> impl
|
|
|
public static boolean isNonNegativeInteger(String str) {
|
|
|
return str != null && str.matches("^\\d*\\.?\\d+$");
|
|
|
}
|
|
|
+
|
|
|
+ public boolean isNonNegative(String numberStr) {
|
|
|
+ try {
|
|
|
+ if(ObjectUtil.isEmpty(numberStr)){
|
|
|
+ numberStr = "0";
|
|
|
+ }
|
|
|
+ // 根据实际需求选择合适的类型
|
|
|
+ double number = Double.parseDouble(numberStr);
|
|
|
+ return number >= 0;
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ // 处理非法输入
|
|
|
+ System.out.println("输入的字符串不是一个有效的数字!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|