fix: release transfer locks and allow agent self transfer
This commit is contained in:
parent
d9d67b8839
commit
fc7d248171
@ -89,12 +89,12 @@ public class UserBankTransferGoldCmdExe {
|
||||
|
||||
boolean freight = freightBalanceService.existsBalance(cmd.getAcceptUserId());
|
||||
ResponseAssert.isTrue(WalletErrorCode.TARGET_USER_NOT_RECHARGE_AGENCY, freight);
|
||||
ResponseAssert.isTrue(WalletErrorCode.NOT_TRANSFER_YOURSELF, !Objects.equals(cmd.getAcceptUserId(), cmd.requiredReqUserId()));
|
||||
|
||||
// 上锁
|
||||
String key = "UBWTransferGold:" + cmd.requiredReqUserId();
|
||||
ResponseAssert.isTrue(CommonErrorCode.REQUEST_LIMITING, redisService.lock(key, 60));
|
||||
|
||||
try {
|
||||
BigDecimal balance = userBankBalanceService.getBalance(cmd.requiredReqUserId())
|
||||
.getAccurateBalance();
|
||||
|
||||
@ -141,10 +141,12 @@ public class UserBankTransferGoldCmdExe {
|
||||
// 发送金额
|
||||
sendGold(cmd, freight, goldQuantity, bankRunWaterId, "转账金币");
|
||||
|
||||
redisService.unlock(key);
|
||||
return new UserBankWithdrawResultCO()
|
||||
.setBankBalance(decrUserBankBalanceDTO.getAccurateBalance())
|
||||
.setWithdrawAmount(Objects.toString(cmd.getAmount()));
|
||||
} finally {
|
||||
redisService.unlock(key);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendGold(UserBankWithdrawTransferCmd cmd, boolean freight, BigDecimal goldQuantity,
|
||||
|
||||
@ -44,11 +44,13 @@ public class UserBankSearchUserProfileQryExe {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isTransfer(cmd)) {
|
||||
if (Objects.equals(cmd.getReqUserId(), userProfile.getId())) {
|
||||
boolean transfer = isTransfer(cmd);
|
||||
boolean sameUser = Objects.equals(cmd.getReqUserId(), userProfile.getId());
|
||||
boolean freightAgent = cmd.typeEqAgent()
|
||||
&& Boolean.TRUE.equals(freightBalanceService.checkFreightAgent(userProfile.getId()));
|
||||
if (transfer && sameUser && !freightAgent) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.typeEqBD()) {
|
||||
return
|
||||
@ -67,11 +69,10 @@ public class UserBankSearchUserProfileQryExe {
|
||||
}
|
||||
|
||||
if (cmd.typeEqAgent()) {
|
||||
Boolean freightAgent = freightBalanceService.checkFreightAgent(userProfile.getId());
|
||||
if (freightAgent) {
|
||||
return userProfile;
|
||||
}
|
||||
if (isTransfer(cmd)) {
|
||||
if (transfer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -81,12 +81,12 @@ public class SalaryTransferGoldCmdExe {
|
||||
|
||||
boolean freight = freightBalanceService.existsBalance(cmd.getAcceptUserId());
|
||||
ResponseAssert.isTrue(WalletErrorCode.TARGET_USER_NOT_RECHARGE_AGENCY, freight);
|
||||
ResponseAssert.isTrue(WalletErrorCode.NOT_TRANSFER_YOURSELF, !Objects.equals(cmd.getAcceptUserId(), cmd.requiredReqUserId()));
|
||||
|
||||
// 上锁
|
||||
String key = "USTransferGold:" + cmd.requiredReqUserId();
|
||||
ResponseAssert.isTrue(CommonErrorCode.REQUEST_LIMITING, redisService.lock(key, 60));
|
||||
|
||||
try {
|
||||
BigDecimal balance = salaryAccountGateway.getAvailableBalance(cmd.getReqUserId(), SalaryType.of(cmd.getSalaryType())).getDollarAmount();
|
||||
|
||||
ResponseAssert.isTrue(WalletErrorCode.INSUFFICIENT_BALANCE,
|
||||
@ -113,10 +113,12 @@ public class SalaryTransferGoldCmdExe {
|
||||
// 发送金额
|
||||
sendGold(cmd, freight, goldQuantity, bankRunWaterId, "转账金币");
|
||||
|
||||
redisService.unlock(key);
|
||||
return new UserBankWithdrawResultCO()
|
||||
.setBankBalance(salaryReceiptRes.getAvailableBalance().getDollarAmount())
|
||||
.setWithdrawAmount(Objects.toString(cmd.getAmount()));
|
||||
} finally {
|
||||
redisService.unlock(key);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendGold(SalaryWithdrawCmd cmd, boolean freight, BigDecimal goldQuantity,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user