Commit ae1cf9e098d2a53d16970486897bac494744a560

Authored by 痴货
1 parent e025b52f

【功能优化】增加转账回调接口

yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java
... ... @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 5 import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
6 6 import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
  7 +import cn.iocoder.yudao.module.pay.api.notify.dto.PayTransferNotifyReqDTO;
7 8 import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRejectReqVO;
8 9 import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO;
9 10 import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO;
... ... @@ -14,6 +15,8 @@ import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService;
14 15 import io.swagger.v3.oas.annotations.Operation;
15 16 import io.swagger.v3.oas.annotations.Parameter;
16 17 import io.swagger.v3.oas.annotations.tags.Tag;
  18 +import jakarta.annotation.security.PermitAll;
  19 +import lombok.extern.slf4j.Slf4j;
17 20 import org.springframework.security.access.prepost.PreAuthorize;
18 21 import org.springframework.validation.annotation.Validated;
19 22 import org.springframework.web.bind.annotation.*;
... ... @@ -30,6 +33,7 @@ import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getCli
30 33 @RestController
31 34 @RequestMapping("/trade/brokerage-withdraw")
32 35 @Validated
  36 +@Slf4j
33 37 public class BrokerageWithdrawController {
34 38  
35 39 @Resource
... ... @@ -76,4 +80,14 @@ public class BrokerageWithdrawController {
76 80 return success(BrokerageWithdrawConvert.INSTANCE.convertPage(pageResult, userMap));
77 81 }
78 82  
  83 + @PostMapping("/update-transfer")
  84 + @Operation(summary = "更新转账订单为转账成功") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob
  85 + @PermitAll // 无需登录,安全由 PayDemoOrderService 内部校验实现
  86 + public CommonResult<Boolean> updateAfterRefund(@RequestBody PayTransferNotifyReqDTO notifyReqDTO) {
  87 + // 目前业务逻辑,不需要做任何事情
  88 + // 当然,退款会有小概率会失败的情况,可以监控失败状态,进行告警
  89 + log.info("[updateAfterRefund][notifyReqDTO({})]", notifyReqDTO);
  90 + return success(true);
  91 + }
  92 +
79 93 }
... ...
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java
... ... @@ -40,4 +40,9 @@ public class PayAppBaseVO {
40 40 @URL(message = "退款结果的回调地址必须为 URL 格式")
41 41 private String refundNotifyUrl;
42 42  
  43 + @Schema(description = "转账结果的回调地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "http://127.0.0.1:48080/refund-callback")
  44 + @NotNull(message = "转账结果的回调地址不能为空")
  45 + @URL(message = "转账结果的回调地址必须为 URL 格式")
  46 + private String transferNotifyUrl;
  47 +
43 48 }
... ...