Commit 395c6dbda0edbc8fc9653747cd45b5cfc5751401

Authored by YunaiV
1 parent ae8e9204

fix: 修复支付宝支付回调渠道用户 ID 获取问题 (!266)

yudao-module-pay/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java
... ... @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
4 4 import cn.hutool.core.date.LocalDateTimeUtil;
5 5 import cn.hutool.core.lang.Assert;
6 6 import cn.hutool.core.map.MapUtil;
  7 +import cn.hutool.core.text.CharSequenceUtil;
7 8 import cn.hutool.core.util.StrUtil;
8 9 import cn.hutool.http.HttpUtil;
9 10 import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
... ... @@ -92,9 +93,12 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPa
92 93 status = PayOrderStatusEnum.REFUND.getStatus();
93 94 }
94 95 Assert.notNull(status, (Supplier<Throwable>) () -> {
95   - throw new IllegalArgumentException(StrUtil.format("body({}) 的 trade_status 不正确", body));
  96 + throw new IllegalArgumentException(CharSequenceUtil.format("body({}) 的 trade_status 不正确", body));
96 97 });
97   - return PayOrderRespDTO.of(status, bodyObj.get("trade_no"), bodyObj.get("seller_id"), parseTime(params.get("gmt_payment")),
  98 + // https://opendocs.alipay.com/open/00dn78?pathHash=fef00e6d#%E5%BC%82%E6%AD%A5%E9%80%9A%E7%9F%A5%E5%8F%82%E6%95%B0
  99 + // buyer_id(buyer_open_id)买家支付宝用户号,seller_id 卖家支付宝用户号
  100 + String channelUserId = CharSequenceUtil.nullToDefault(bodyObj.get("buyer_open_id"), bodyObj.get("buyer_id"));
  101 + return PayOrderRespDTO.of(status, bodyObj.get("trade_no"), channelUserId, parseTime(params.get("gmt_payment")),
98 102 bodyObj.get("out_trade_no"), body);
99 103 }
100 104  
... ...