充天医币可以加小数点
This commit is contained in:
@@ -630,26 +630,25 @@ public class MyUserController {
|
||||
@RequestMapping("/pointChange")
|
||||
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("变动金额不能为负数");
|
||||
BigDecimal pointAmount = new BigDecimal(params.get("pointAmount"));
|
||||
if (pointAmount.compareTo(BigDecimal.ZERO)<=0){
|
||||
return R.error("变动金额不能为0或负数");
|
||||
}
|
||||
String id = params.get("id");
|
||||
MyUserEntity byId = userService.getById(id);
|
||||
int i = 0;
|
||||
BigDecimal i = BigDecimal.ZERO;
|
||||
if (pointType.equals("0")) {
|
||||
i = byId.getPeanutCoin().intValue() + Integer.valueOf(pointAmount);
|
||||
byId.setPeanutCoin(new BigDecimal(i));
|
||||
i = byId.getPeanutCoin().add(pointAmount);
|
||||
byId.setPeanutCoin(i);
|
||||
}else {
|
||||
i = byId.getPeanutCoin().intValue() - Integer.valueOf(pointAmount);
|
||||
if (i >= 0) {
|
||||
byId.setPeanutCoin(new BigDecimal(i));
|
||||
i = byId.getPeanutCoin().subtract(pointAmount);
|
||||
if (i.compareTo(BigDecimal.ZERO)>=0) {
|
||||
byId.setPeanutCoin(i);
|
||||
}else {
|
||||
return R.error("余额不足!扣除失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
|
||||
transactionDetailsEntity.setUserId(Integer.valueOf(id));
|
||||
transactionDetailsEntity.setOrderType("后台充扣操作");
|
||||
@@ -657,27 +656,14 @@ public class MyUserController {
|
||||
transactionDetailsEntity.setUserName(byId.getNickname());
|
||||
transactionDetailsEntity.setNote(params.get("note"));
|
||||
if (pointType.equals("0")) {
|
||||
transactionDetailsEntity.setChangeAmount(new BigDecimal(Integer.valueOf(pointAmount)));
|
||||
transactionDetailsEntity.setChangeAmount(pointAmount);
|
||||
transactionDetailsEntity.setRemark("充值");
|
||||
}else {
|
||||
transactionDetailsEntity.setChangeAmount(new BigDecimal(Integer.valueOf(pointAmount)).negate());
|
||||
transactionDetailsEntity.setChangeAmount(pointAmount.negate());
|
||||
transactionDetailsEntity.setRemark("扣费");
|
||||
}
|
||||
BigDecimal balance = new BigDecimal(i);
|
||||
transactionDetailsEntity.setUserBalance(balance);
|
||||
transactionDetailsEntity.setUserBalance(i);
|
||||
transactionDetailsService.save(transactionDetailsEntity);
|
||||
|
||||
|
||||
// 插入 花生币 充值记录
|
||||
// IosPayOrderEntity payPaymentOrderEntity = new IosPayOrderEntity();
|
||||
// payPaymentOrderEntity.setUserId(Integer.valueOf(id));
|
||||
// payPaymentOrderEntity.setRealAmount(new BigDecimal(byId.getPeanutCoin()));
|
||||
// payPaymentOrderEntity.setRechargeAmount(new BigDecimal(i));
|
||||
// payPaymentOrderEntity.setRechargeChannel("后台手动充值");
|
||||
// payPaymentOrderEntity.setRechargeStatus("success");
|
||||
// payPaymentOrderEntity.setSuccessTime(new Date());
|
||||
// payPaymentOrderService.save(payPaymentOrderEntity);
|
||||
|
||||
userService.updateById(byId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user