增减钱包余额保护

This commit is contained in:
gaowdong 2025-04-30 09:34:54 +08:00
parent 96b57d76ae
commit 5d1ca83851
2 changed files with 9 additions and 0 deletions

View File

@ -52,6 +52,8 @@ public class AccWalletInfoBusiness {
IAccTradeService accTradeService;
@Autowired
IAccTradeWalletDetailService accTradeWalletDetailService;
//此方法不可以直接调用须通过service中的方法调用
@Transactional(rollbackFor = Exception.class)
public void addAccWalletBalance(WalletUpdateDTO walletUpdateDTO) {
log.info("新增钱包入参: {}", JacksonUtil.writeValueAsString(walletUpdateDTO));
@ -70,6 +72,7 @@ public class AccWalletInfoBusiness {
log.info("新增钱包结束");
}
//此方法不可以直接调用须通过service中的方法调用
@Transactional(rollbackFor = Exception.class)
public void clearAccWalletBalance(WalletUpdateDTO walletUpdateDTO) {
log.info("扣减钱包入参: {}", JacksonUtil.writeValueAsString(walletUpdateDTO));

View File

@ -180,6 +180,9 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
@Override
public void addAccWalletBalance(WalletUpdateDTO walletUpdateDTO) {
if(!walletUpdateDTO.isBatch()) {
if(Objects.isNull(walletUpdateDTO.getUserId())) {
throw new ServiceException("用户编号不能为空");
}
AccRedisUtils.lockUpdateAccWalletBalance(walletUpdateDTO.getUserId());
}
try {
@ -197,6 +200,9 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
@Override
public void clearAccWalletBalance(WalletUpdateDTO walletUpdateDTO) {
if(!walletUpdateDTO.isBatch()) {
if(Objects.isNull(walletUpdateDTO.getUserId())) {
throw new ServiceException("用户编号不能为空");
}
AccRedisUtils.lockUpdateAccWalletBalance(walletUpdateDTO.getUserId());
}
try {