Merge branch 'feature/community-center' into preview

master
yang 2025-03-31 15:23:32 +08:00
commit 0f7743abb1
2 changed files with 83 additions and 70 deletions

View File

@ -286,7 +286,16 @@ public class AliPayServiceImpl implements AliPayService {
@Override
@Transactional(rollbackFor = Exception.class)
public R<String> fetch(String amount) throws AlipayApiException, FileNotFoundException {
String lock = redisCache.getCacheObject("alipay:fetch:user:" + SecurityUtils.getUserId());
if (!StrUtil.isEmpty(lock)) {
return R.fail(HttpStatus.SHOW_ERROR_MSG, "请勿频繁点击");
}
try {
redisCache.setCacheObject("alipay:fetch:user:" + SecurityUtils.getUserId(), "1");
Long userId = SecurityUtils.getUserId();
SysUser sysUser = sysUserService.selectUserById(userId);
if (sysUser.getWallet() < Double.parseDouble(amount)) {
return R.fail(HttpStatus.SHOW_ERROR_MSG, "钱包余额不足");
@ -354,6 +363,10 @@ public class AliPayServiceImpl implements AliPayService {
}
System.out.println("用户" + SecurityUtils.getLoginUser().getUser().getNickName() + "提现失败:" + response.getSubMsg());
throw new ServiceException("提现失败", HttpStatus.SHOW_ERROR_MSG);
} finally {
redisCache.deleteObject("alipay:fetch:user:" + SecurityUtils.getUserId());
}
}
@Override

View File

@ -123,8 +123,8 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
CommissionRatio commissionRatio2 = commissionRatioService.lambdaQuery()
.eq(CommissionRatio::getType, 1)
.one();
redisCache.setCacheObject(CommissionRationEnum.COMMISSION_RATION_INVITER_USER.getName(), commissionRatio1);
redisCache.setCacheObject(CommissionRationEnum.COMMISSION_RATION_MERCHANT.getName(), commissionRatio2);
redisCache.setCacheObject(CommissionRationEnum.COMMISSION_RATION_INVITER_USER.getName(), commissionRatio1.getRatio().toString());
redisCache.setCacheObject(CommissionRationEnum.COMMISSION_RATION_MERCHANT.getName(), commissionRatio2.getRatio().toString());
}