This commit is contained in:
huchuansai
2025-05-08 16:39:42 +08:00
parent e588acf896
commit 3d0a8493c5

View File

@@ -49,7 +49,6 @@ public class PlayCustomUserInfoServiceImpl extends ServiceImpl<PlayCustomUserInf
private IPlayBalanceDetailsInfoService playBalanceDetailsInfoService;
@Override
public PlayCustomUserInfoEntity selectByOpenid(String openId) {
LambdaQueryWrapper<PlayCustomUserInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -84,11 +83,37 @@ public class PlayCustomUserInfoServiceImpl extends ServiceImpl<PlayCustomUserInf
public void customAccountBalanceRecharge(BigDecimal rechargeAmount, String customId, String orderId) {
PlayCustomUserInfoEntity userInfo = this.selectById(customId);
//查询充值赠送金额暂是设置为0
BigDecimal giftAmount = BigDecimal.ZERO;
// 此处我想实现超过50送5超过100送10200送20300送30400送40500送50
BigDecimal giftAmount = calculateGiftMoney(rechargeAmount);
//修改用户账户余额
this.updateAccountBalanceById(customId, userInfo.getAccountBalance(), userInfo.getAccountBalance().add(rechargeAmount).add(giftAmount), "0", "重置", rechargeAmount.add(giftAmount), giftAmount, orderId);
this.updateAccountBalanceById(customId, userInfo.getAccountBalance(), userInfo.getAccountBalance().add(rechargeAmount).add(giftAmount), "0", "充值", rechargeAmount.add(giftAmount), giftAmount, orderId);
}
private static BigDecimal calculateGiftMoney(BigDecimal rechargeAmount) {
//此处我想实现超过50送5超过100送10200送20300送30400送40500送50
BigDecimal giftAmount = BigDecimal.ZERO;
if (rechargeAmount.compareTo(new BigDecimal(50)) >= 0) {
giftAmount = new BigDecimal(5);
}
if (rechargeAmount.compareTo(new BigDecimal(100)) >= 0) {
giftAmount = new BigDecimal(10);
}
if (rechargeAmount.compareTo(new BigDecimal(200)) >= 0) {
giftAmount = new BigDecimal(20);
}
if (rechargeAmount.compareTo(new BigDecimal(300)) >= 0) {
giftAmount = new BigDecimal(30);
}
if (rechargeAmount.compareTo(new BigDecimal(400)) >= 0) {
giftAmount = new BigDecimal(40);
}
if (rechargeAmount.compareTo(new BigDecimal(500)) >= 0) {
giftAmount = new BigDecimal(50);
}
return giftAmount;
}
/**
* 查询顾客
*