fix: allow transfers to regular users

This commit is contained in:
ZuoZuo 2026-05-01 14:50:43 +08:00
parent 8544ca34d0
commit cbc9b0e2f2
3 changed files with 27 additions and 18 deletions

View File

@ -88,8 +88,8 @@ public class UserBankTransferGoldCmdExe {
ArithmeticUtils.gtZero(cmd.getAmount()));
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()));
ResponseAssert.isTrue(WalletErrorCode.NOT_TRANSFER_YOURSELF,
!Objects.equals(cmd.getAcceptUserId(), cmd.requiredReqUserId()));
// 上锁
String key = "UBWTransferGold:" + cmd.requiredReqUserId();
@ -104,13 +104,18 @@ public class UserBankTransferGoldCmdExe {
// 获得区域兑换比例金币比例
Double goldRatio = getExchangeGoldRatio(cmd);
BigDecimal goldQuantity = BigDecimal.valueOf(goldRatio).multiply(cmd.getAmount()).setScale(0, RoundingMode.DOWN);
BigDecimal goldQuantity = BigDecimal.valueOf(goldRatio).multiply(cmd.getAmount())
.setScale(0, RoundingMode.DOWN);
if (freight) {
FreightBalance freightBalance = freightBalanceService.getFreightBalance(cmd.getAcceptUserId());
ResponseAssert.notNull(FreightErrorCode.NOT_FREIGHT, freightBalance);
long result = goldQuantity.divide(new BigDecimal(10000), RoundingMode.DOWN).setScale(0, RoundingMode.DOWN).longValue();
ResponseAssert.isTrue(FreightErrorCode.NOT_THRESHOLD, result >= Optional.ofNullable(freightBalance.getDeliveryThreshold()).orElse(0));
long result = goldQuantity.divide(new BigDecimal(10000), RoundingMode.DOWN)
.setScale(0, RoundingMode.DOWN).longValue();
ResponseAssert.isTrue(FreightErrorCode.NOT_THRESHOLD,
result >= Optional.ofNullable(freightBalance.getDeliveryThreshold()).orElse(0));
}
// 扣钱
BankBalanceDTO decrUserBankBalanceDTO = userBankBalanceService.decr(cmd.requiredReqUserId(),
@ -118,6 +123,7 @@ public class UserBankTransferGoldCmdExe {
ResponseAssert.notNull(WalletErrorCode.INSUFFICIENT_BALANCE, decrUserBankBalanceDTO);
Long bankRunWaterId = IdWorkerUtils.getId();
cmd.setReqTraceId(String.valueOf(bankRunWaterId));
// 银行卡流水
userBankRunningWaterService.add(

View File

@ -45,9 +45,10 @@ public class UserBankSearchUserProfileQryExe {
}
if (isTransfer(cmd)) {
if (Objects.equals(cmd.getReqUserId(), userProfile.getId())) {
return null;
}
if (Objects.equals(cmd.getReqUserId(), userProfile.getId())) {
return null;
}
return userProfile;
}
if (cmd.typeEqBD()) {
@ -71,9 +72,6 @@ public class UserBankSearchUserProfileQryExe {
if (freightAgent) {
return userProfile;
}
if (isTransfer(cmd)) {
return null;
}
return Objects.equals(
ResponseAssert.requiredSuccess(agentTeamClient.existsTeamOwn(userProfile.getId())),

View File

@ -80,8 +80,8 @@ public class SalaryTransferGoldCmdExe {
ArithmeticUtils.gtZero(cmd.getAmount()));
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()));
ResponseAssert.isTrue(WalletErrorCode.NOT_TRANSFER_YOURSELF,
!Objects.equals(cmd.getAcceptUserId(), cmd.requiredReqUserId()));
// 上锁
String key = "USTransferGold:" + cmd.requiredReqUserId();
@ -96,13 +96,18 @@ public class SalaryTransferGoldCmdExe {
Double goldRatio = getExchangeGoldRatio(cmd);
Long bankRunWaterId = IdWorkerUtils.getId();
BigDecimal goldQuantity = BigDecimal.valueOf(goldRatio).multiply(cmd.getAmount()).setScale(0, RoundingMode.DOWN);
BigDecimal goldQuantity = BigDecimal.valueOf(goldRatio).multiply(cmd.getAmount())
.setScale(0, RoundingMode.DOWN);
FreightBalance freightBalance = freightBalanceService.getFreightBalance(cmd.getAcceptUserId());
ResponseAssert.notNull(FreightErrorCode.NOT_FREIGHT, freightBalance);
if (freight) {
FreightBalance freightBalance = freightBalanceService.getFreightBalance(cmd.getAcceptUserId());
ResponseAssert.notNull(FreightErrorCode.NOT_FREIGHT, freightBalance);
long result = goldQuantity.divide(new BigDecimal(10000), RoundingMode.DOWN).setScale(0, RoundingMode.DOWN).longValue();
ResponseAssert.isTrue(FreightErrorCode.NOT_THRESHOLD, result >= Optional.ofNullable(freightBalance.getDeliveryThreshold()).orElse(0));
long result = goldQuantity.divide(new BigDecimal(10000), RoundingMode.DOWN)
.setScale(0, RoundingMode.DOWN).longValue();
ResponseAssert.isTrue(FreightErrorCode.NOT_THRESHOLD,
result >= Optional.ofNullable(freightBalance.getDeliveryThreshold()).orElse(0));
}
// 扣钱
cmd.setReqTraceId(String.valueOf(bankRunWaterId));