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,6 +16,9 @@ public class BrokerageWithdrawRespVO extends BrokerageWithdrawBaseVO {
16 @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161") 16 @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161")
17 private Long id; 17 private Long id;
18 18
  19 + @Schema(description = "转账错误提示", example = "余额不足")
  20 + private String transferErrorMsg;
  21 +
19 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) 22 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
20 private LocalDateTime createTime; 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,17 +28,17 @@ public interface BrokerageWithdrawMapper extends BaseMapperX<BrokerageWithdrawDO
28 .eqIfPresent(BrokerageWithdrawDO::getUserId, reqVO.getUserId()) 28 .eqIfPresent(BrokerageWithdrawDO::getUserId, reqVO.getUserId())
29 .eqIfPresent(BrokerageWithdrawDO::getType, reqVO.getType()) 29 .eqIfPresent(BrokerageWithdrawDO::getType, reqVO.getType())
30 .likeIfPresent(BrokerageWithdrawDO::getUserName, reqVO.getUserName()) 30 .likeIfPresent(BrokerageWithdrawDO::getUserName, reqVO.getUserName())
31 - .eqIfPresent(BrokerageWithdrawDO::getUserAccount, reqVO.getUserAccount()) 31 + .likeIfPresent(BrokerageWithdrawDO::getUserAccount, reqVO.getUserAccount())
32 .likeIfPresent(BrokerageWithdrawDO::getBankName, reqVO.getBankName()) 32 .likeIfPresent(BrokerageWithdrawDO::getBankName, reqVO.getBankName())
33 .eqIfPresent(BrokerageWithdrawDO::getStatus, reqVO.getStatus()) 33 .eqIfPresent(BrokerageWithdrawDO::getStatus, reqVO.getStatus())
34 .betweenIfPresent(BrokerageWithdrawDO::getCreateTime, reqVO.getCreateTime()) 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 return update(updateObj, new LambdaUpdateWrapper<BrokerageWithdrawDO>() 39 return update(updateObj, new LambdaUpdateWrapper<BrokerageWithdrawDO>()
40 .eq(BrokerageWithdrawDO::getId, id) 40 .eq(BrokerageWithdrawDO::getId, id)
41 - .eq(BrokerageWithdrawDO::getStatus, status)); 41 + .eq(BrokerageWithdrawDO::getStatus, whereStatus));
42 } 42 }
43 43
44 default List<BrokerageWithdrawSummaryRespBO> selectCountAndSumPriceByUserIdAndStatus(Collection<Long> userIds, 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,15 +86,24 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
86 public void auditBrokerageWithdraw(Long id, BrokerageWithdrawStatusEnum status, String auditReason, String userIp) { 86 public void auditBrokerageWithdraw(Long id, BrokerageWithdrawStatusEnum status, String auditReason, String userIp) {
87 // 1.1 校验存在 87 // 1.1 校验存在
88 BrokerageWithdrawDO withdraw = validateBrokerageWithdrawExists(id); 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 // 1.2 校验状态为审核中 98 // 1.2 校验状态为审核中
90 if (ObjectUtil.notEqual(BrokerageWithdrawStatusEnum.AUDITING.getStatus(), withdraw.getStatus())) { 99 if (ObjectUtil.notEqual(BrokerageWithdrawStatusEnum.AUDITING.getStatus(), withdraw.getStatus())) {
91 throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING); 100 throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING);
92 } 101 }
93 102
94 // 2. 更新状态 103 // 2. 更新状态
95 - int rows = brokerageWithdrawMapper.updateByIdAndStatus(id, BrokerageWithdrawStatusEnum.AUDITING.getStatus(), 104 + int updateCount = brokerageWithdrawMapper.updateByIdAndStatus(id, withdraw.getStatus(),
96 new BrokerageWithdrawDO().setStatus(status.getStatus()).setAuditReason(auditReason).setAuditTime(LocalDateTime.now())); 105 new BrokerageWithdrawDO().setStatus(status.getStatus()).setAuditReason(auditReason).setAuditTime(LocalDateTime.now()));
97 - if (rows == 0) { 106 + if (updateCount == 0) {
98 throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING); 107 throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING);
99 } 108 }
100 109