Commit bac30d47b770f542ac167128c3f679942d0dbee8

Authored by YunaiV
1 parent 20628987

增加支付回调地址的配置

yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/impl/PayOrderCoreServiceImpl.java
... ... @@ -130,7 +130,7 @@ public class PayOrderCoreServiceImpl implements PayOrderCoreService {
130 130 // 商户相关字段
131 131 unifiedOrderReqDTO.setMerchantOrderId(order.getMerchantOrderId())
132 132 .setSubject(order.getSubject()).setBody(order.getBody())
133   - .setNotifyUrl(genChannelPayNotifyUrl(reqDTO.getChannelCode()));
  133 + .setNotifyUrl(genChannelPayNotifyUrl(channel));
134 134 // 订单相关字段
135 135 unifiedOrderReqDTO.setAmount(order.getAmount()).setExpireTime(order.getExpireTime());
136 136 CommonResult<?> unifiedOrderResult = client.unifiedOrder(unifiedOrderReqDTO);
... ... @@ -145,12 +145,13 @@ public class PayOrderCoreServiceImpl implements PayOrderCoreService {
145 145 /**
146 146 * 根据支付渠道的编码,生成支付渠道的回调地址
147 147 *
148   - * @param channelCode 支付渠道的编码
  148 + * @param channel 支付渠道
149 149 * @return 支付渠道的回调地址
150 150 */
151   - private String genChannelPayNotifyUrl(String channelCode) {
  151 + private String genChannelPayNotifyUrl(PayChannelDO channel) {
152 152 // _ 转化为 - 的原因,是因为 URL 我们统一采用中划线的原则
153   - return payProperties.getPayNotifyUrl() + "/" + StrUtil.replace(channelCode, "_", "-");
  153 + return payProperties.getPayNotifyUrl() + "/" + StrUtil.replace(channel.getCode(), "_", "-")
  154 + + "/" + channel.getId();
154 155 }
155 156  
156 157 private String generateOrderExtensionNo() {
... ...
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java
... ... @@ -49,9 +49,10 @@ public class PayOrderController {
49 49  
50 50 // ========== 支付渠道的回调 ==========
51 51  
52   - @PostMapping("/notify/wx-pub")
  52 + @PostMapping("/notify/wx-pub/{channelId}")
53 53 @ApiOperation("通知微信公众号的结果")
54   - public String notifyWxPayOrder(@RequestBody String xmlData) {
  54 + public String notifyWxPayOrder(@PathVariable("channelId") Long channelId,
  55 + @RequestBody String xmlData) {
55 56 System.out.println(xmlData);
56 57 return "success";
57 58 }
... ...