update 修复部分修改金额的方法内未使用乐观锁
This commit is contained in:
@@ -355,10 +355,17 @@ public class MessageReceiver {
|
||||
.status(payWithdrawReturnMessage.getStatus())
|
||||
.build();
|
||||
if (payWithdrawReturnMessage.getStatus() == 1){
|
||||
// 使用乐观锁防止并发修改
|
||||
BigDecimal initBalance = leaseShopConfig.getBalance();
|
||||
leaseShopConfig.setBalance(leaseShopConfig.getBalance()
|
||||
.subtract(payWithdrawReturnMessage.getAmount())
|
||||
.subtract(payWithdrawReturnMessage.getFee()));
|
||||
leaseShopConfigMapper.updateById(leaseShopConfig);
|
||||
int update = leaseShopConfigMapper.update(leaseShopConfig, new LambdaUpdateWrapper<LeaseShopConfig>()
|
||||
.eq(LeaseShopConfig::getId, leaseShopConfig.getId())
|
||||
.eq(LeaseShopConfig::getBalance, initBalance));
|
||||
if (update < 1){
|
||||
throw new PayRechargeException("商家提现失败,余额已被修改,消息重试");
|
||||
}
|
||||
build.setTxHash(payWithdrawReturnMessage.getTx_hash());
|
||||
build.setBlockHeight(payWithdrawReturnMessage.getBlock_height());
|
||||
}
|
||||
|
||||
@@ -292,8 +292,15 @@ public class LeaseOrderInfoServiceImpl extends ServiceImpl<LeaseOrderInfoMapper,
|
||||
.stripTrailingZeros();
|
||||
throw new OrderException("下单失败,买家"+chainAndCoinKey+"钱包余额不足,缺少" + lackAmount + "满足支付需求");
|
||||
}
|
||||
// 使用乐观锁防止并发修改
|
||||
BigDecimal initBlockedBalance = leaseUserWalletData.getBlockedBalance();
|
||||
leaseUserWalletData.setBlockedBalance(leaseUserWalletData.getBlockedBalance().add(totalAmount).add(totalFee));
|
||||
leaseUserWalletDataMapper.updateById(leaseUserWalletData);
|
||||
int update = leaseUserWalletDataMapper.update(leaseUserWalletData, new LambdaUpdateWrapper<LeaseUserWalletData>()
|
||||
.eq(LeaseUserWalletData::getId, leaseUserWalletData.getId())
|
||||
.eq(LeaseUserWalletData::getBlockedBalance, initBlockedBalance));
|
||||
if (update < 1){
|
||||
throw new OrderException("下单失败,钱包余额已被修改,请重试");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user