Commit 3aa9ea997ba4f25e7c518c5b7bdab32327b9236a

Authored by YunaiV
1 parent d886f819

fix: 【mall】修正分销提现时,金额计算逻辑带上手续费,确保转账金额与实际提现金额一致

yudao-module-mall/yudao-module-trade/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java
... ... @@ -147,9 +147,10 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
147 147 userAccount = wallet.getId().toString();
148 148 }
149 149 // 1.2 构建请求
  150 + Integer transferPrice = withdraw.getPrice() - withdraw.getFeePrice(); // 计算实际转账金额(提现金额 - 手续费)
150 151 PayTransferCreateReqDTO transferReqDTO = new PayTransferCreateReqDTO()
151 152 .setAppKey(tradeOrderProperties.getPayAppKey()).setChannelCode(channelCode)
152   - .setMerchantTransferId(withdraw.getId().toString()).setSubject("佣金提现").setPrice(withdraw.getPrice())
  153 + .setMerchantTransferId(withdraw.getId().toString()).setSubject("佣金提现").setPrice(transferPrice)
153 154 .setUserAccount(userAccount).setUserName(userName).setUserIp(getClientIP())
154 155 .setUserId(withdraw.getUserId()).setUserType(UserTypeEnum.MEMBER.getValue()) // 用户信息
155 156 .setChannelExtras(channelExtras);
... ... @@ -280,9 +281,10 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
280 281 throw exception(BROKERAGE_WITHDRAW_UPDATE_STATUS_FAIL_PAY_TRANSFER_STATUS_NOT_SUCCESS_OR_CLOSED);
281 282 }
282 283 // 2.2 校验转账金额一致
283   - if (ObjectUtil.notEqual(payTransfer.getPrice(), withdraw.getPrice())) {
284   - log.error("[validateBrokerageTransferStatusCanUpdate][withdraw({}) payTransfer({}) 转账金额不匹配,请进行处理!withdraw 数据是:{},payTransfer 数据是:{}]",
285   - withdraw.getId(), payTransferId, JsonUtils.toJsonString(withdraw), JsonUtils.toJsonString(payTransfer));
  284 + Integer expectedTransferPrice = withdraw.getPrice() - withdraw.getFeePrice(); // 转账金额 = 提现金额 - 手续费
  285 + if (ObjectUtil.notEqual(payTransfer.getPrice(), expectedTransferPrice)) {
  286 + log.error("[validateBrokerageTransferStatusCanUpdate][withdraw({}) payTransfer({}) 转账金额不匹配,请进行处理!withdraw 数据是:{},payTransfer 数据是:{},期望转账金额:{}]",
  287 + withdraw.getId(), payTransferId, JsonUtils.toJsonString(withdraw), JsonUtils.toJsonString(payTransfer), expectedTransferPrice);
286 288 throw exception(BROKERAGE_WITHDRAW_UPDATE_STATUS_FAIL_PAY_PRICE_NOT_MATCH);
287 289 }
288 290 // 2.3 校验转账订单匹配
... ...