积分灵兰币控制负数

This commit is contained in:
wuchunlei
2025-05-07 14:23:56 +08:00
parent 1c049763d8
commit b6cf9efc7a
2 changed files with 10 additions and 0 deletions

View File

@@ -631,6 +631,9 @@ public class MyUserController {
public R pointChange(@RequestParam Map<String, String> params){
String pointType = params.get("pointType");
String pointAmount = params.get("pointAmount");
if (Integer.valueOf(pointAmount)<=0){
return R.error("变动金额不能为负数");
}
String id = params.get("id");
MyUserEntity byId = userService.getById(id);
int i = 0;

View File

@@ -83,12 +83,19 @@ public class JfTransactionDetailsController {
JfTransactionDetails jf = new JfTransactionDetails();
MyUserEntity user = userService.getById(params.get("userId").toString());
BigDecimal changeAmount = new BigDecimal(params.get("changeAmount").toString());
if (changeAmount.compareTo(BigDecimal.ZERO)<1){
return R.error("变动金额不能为负数");
}
String actType = params.get("actType").toString();
if (actType.equals("0")) {
jf.setActType(0);
user.setJf(user.getJf().add(changeAmount));
jf.setChangeAmount(changeAmount);
}else {
BigDecimal resAmount = user.getJf().subtract(changeAmount);
if (resAmount.compareTo(BigDecimal.ZERO)<0){
return R.error("余额不足,扣除失败");
}
jf.setActType(1);
user.setJf(user.getJf().subtract(changeAmount));
jf.setChangeAmount(changeAmount.negate());