积分灵兰币控制负数
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user