Commit fe8871b5f150df9ee43d828a11da5f47685991d6

Authored by YunaiV
1 parent 423c0b7e

feat:【MALL 商城】佣金提现,支持提现失败时,重新发起

yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java
... ... @@ -16,6 +16,9 @@ public class BrokerageWithdrawRespVO extends BrokerageWithdrawBaseVO {
16 16 @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161")
17 17 private Long id;
18 18  
  19 + @Schema(description = "转账错误提示", example = "余额不足")
  20 + private String transferErrorMsg;
  21 +
19 22 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
20 23 private LocalDateTime createTime;
21 24  
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java
... ... @@ -28,17 +28,17 @@ public interface BrokerageWithdrawMapper extends BaseMapperX<BrokerageWithdrawDO
28 28 .eqIfPresent(BrokerageWithdrawDO::getUserId, reqVO.getUserId())
29 29 .eqIfPresent(BrokerageWithdrawDO::getType, reqVO.getType())
30 30 .likeIfPresent(BrokerageWithdrawDO::getUserName, reqVO.getUserName())
31   - .eqIfPresent(BrokerageWithdrawDO::getUserAccount, reqVO.getUserAccount())
  31 + .likeIfPresent(BrokerageWithdrawDO::getUserAccount, reqVO.getUserAccount())
32 32 .likeIfPresent(BrokerageWithdrawDO::getBankName, reqVO.getBankName())
33 33 .eqIfPresent(BrokerageWithdrawDO::getStatus, reqVO.getStatus())
34 34 .betweenIfPresent(BrokerageWithdrawDO::getCreateTime, reqVO.getCreateTime())
35   - .orderByAsc(BrokerageWithdrawDO::getStatus).orderByDesc(BrokerageWithdrawDO::getId));
  35 + .orderByDesc(BrokerageWithdrawDO::getId));
36 36 }
37 37  
38   - default int updateByIdAndStatus(Long id, Integer status, BrokerageWithdrawDO updateObj) {
  38 + default int updateByIdAndStatus(Long id, Integer whereStatus, BrokerageWithdrawDO updateObj) {
39 39 return update(updateObj, new LambdaUpdateWrapper<BrokerageWithdrawDO>()
40 40 .eq(BrokerageWithdrawDO::getId, id)
41   - .eq(BrokerageWithdrawDO::getStatus, status));
  41 + .eq(BrokerageWithdrawDO::getStatus, whereStatus));
42 42 }
43 43  
44 44 default List<BrokerageWithdrawSummaryRespBO> selectCountAndSumPriceByUserIdAndStatus(Collection<Long> userIds,
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java
... ... @@ -86,15 +86,24 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
86 86 public void auditBrokerageWithdraw(Long id, BrokerageWithdrawStatusEnum status, String auditReason, String userIp) {
87 87 // 1.1 校验存在
88 88 BrokerageWithdrawDO withdraw = validateBrokerageWithdrawExists(id);
  89 + // 1.2 特殊:【重新转账】如果是提现失败,并且状态是审核中,那么更新状态为审核中,并且清空 transferErrorMsg
  90 + if (BrokerageWithdrawStatusEnum.WITHDRAW_FAIL.getStatus().equals(withdraw.getStatus())) {
  91 + int updateCount = brokerageWithdrawMapper.updateByIdAndStatus(id, withdraw.getStatus(),
  92 + new BrokerageWithdrawDO().setStatus(BrokerageWithdrawStatusEnum.AUDITING.getStatus()).setTransferErrorMsg(""));
  93 + if (updateCount == 0) {
  94 + throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING);
  95 + }
  96 + withdraw.setStatus(BrokerageWithdrawStatusEnum.AUDITING.getStatus()).setTransferErrorMsg("");
  97 + }
89 98 // 1.2 校验状态为审核中
90 99 if (ObjectUtil.notEqual(BrokerageWithdrawStatusEnum.AUDITING.getStatus(), withdraw.getStatus())) {
91 100 throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING);
92 101 }
93 102  
94 103 // 2. 更新状态
95   - int rows = brokerageWithdrawMapper.updateByIdAndStatus(id, BrokerageWithdrawStatusEnum.AUDITING.getStatus(),
  104 + int updateCount = brokerageWithdrawMapper.updateByIdAndStatus(id, withdraw.getStatus(),
96 105 new BrokerageWithdrawDO().setStatus(status.getStatus()).setAuditReason(auditReason).setAuditTime(LocalDateTime.now()));
97   - if (rows == 0) {
  106 + if (updateCount == 0) {
98 107 throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING);
99 108 }
100 109  
... ...