feat:充值模板配置,可配置充值多少送多少(基于目前的开发)

This commit is contained in:
0000 2025-06-16 23:42:46 +08:00
parent ad74be0e2b
commit 9add2e7643
3 changed files with 22 additions and 9 deletions

View file

@ -174,19 +174,29 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
@Override
public BigDecimal getRechargeBonus(BigDecimal rechargeAmount) {
// 获取充值赠送配置type=279
log.info("rechargeAmount{}", rechargeAmount);
CommonInfo rechargeConfig = commonInfoDao.findOne(279);
log.info("获取充值赠送配置:{}", rechargeConfig);
if (rechargeConfig == null || StringUtils.isBlank(rechargeConfig.getValue())) {
log.info("StringUtils.isBlank final{}", StringUtils.isBlank(rechargeConfig.getValue()),rechargeConfig.getValue());
return BigDecimal.ZERO;
}
// 解析充值赠送配置
// 格式为充值金额:赠送金额,充值金额:赠送金额,...
// 例如100:10,200:20,500:50,...
String configValue = rechargeConfig.getValue();
Map<BigDecimal, BigDecimal> bonusMap = parseRechargeBonusConfig(configValue);
log.info("bonusMap final{}", bonusMap);
BigDecimal bonus = BigDecimal.ZERO;
for (Map.Entry<BigDecimal, BigDecimal> entry : bonusMap.entrySet()) {
if (entry.getKey().compareTo(rechargeAmount) == 0) {
bonus = entry.getValue();
break;
}
}
log.info("get rechargeAmount final{}", bonus);
// 根据充值金额获取赠送金额
BigDecimal bonus = bonusMap.getOrDefault(rechargeAmount, BigDecimal.ZERO);
return bonus;
}
/**

View file

@ -171,7 +171,7 @@ public class AliPayController {
orders.setUpdateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
payOrderDao.updateById(orders);
// 处理充值赠送金额
BigDecimal bonusAmount = commonInfoService.getRechargeBonus(orders.getPayMoney());
BigDecimal bonusAmount = commonInfoService.getRechargeBonus(orders.getMoney());
// 计算总金额充值金额 + 赠送金额
BigDecimal totalAmount = orders.getMoney().add(bonusAmount);

View file

@ -513,7 +513,9 @@ public class WxServiceImpl implements WxService {
orders.setUpdateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
payOrderDao.updateById(orders);
// 处理充值赠送金额
BigDecimal bonusAmount = commonInfoService.getRechargeBonus(orders.getPayMoney());
BigDecimal bonusAmount = commonInfoService.getRechargeBonus(orders.getMoney());
log.info("get bonusAmount{}", bonusAmount);
// 计算总金额充值金额 + 赠送金额
BigDecimal totalAmount = orders.getMoney().add(bonusAmount);
@ -522,6 +524,7 @@ public class WxServiceImpl implements WxService {
// 创建交易记录列表
List<UserMoneyDetails> detailsList = new ArrayList<>();
log.info("get totalAmount{}", bonusAmount);
// 添加充值记录
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
@ -863,7 +866,7 @@ public class WxServiceImpl implements WxService {
payOrderDao.updateById(orders);
//调用处理接口
// 处理充值赠送金额
BigDecimal bonusAmount = commonInfoService.getRechargeBonus(orders.getPayMoney());
BigDecimal bonusAmount = commonInfoService.getRechargeBonus(orders.getMoney());
// 计算总金额充值金额 + 赠送金额
BigDecimal totalAmount = orders.getMoney().add(bonusAmount);