Commit 58c3afee08a5d0632a8dd010c11fca29a89b5afa
1 parent
c4020779
【支付宝通知回调】: AbstractAlipayClient.java : 支付宝统一回调参数 str转map 通知回调参数 Map<String, String> params = notifyData.getParams(); Map<String, String> params = strToMap(notifyData.getBody());
Showing
1 changed file
with
24 additions
and
2 deletions
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClient.java
| @@ -18,6 +18,7 @@ import lombok.SneakyThrows; | @@ -18,6 +18,7 @@ import lombok.SneakyThrows; | ||
| 18 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
| 19 | 19 | ||
| 20 | import java.nio.charset.StandardCharsets; | 20 | import java.nio.charset.StandardCharsets; |
| 21 | +import java.util.HashMap; | ||
| 21 | import java.util.Map; | 22 | import java.util.Map; |
| 22 | 23 | ||
| 23 | import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; | 24 | import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; |
| @@ -54,7 +55,7 @@ public abstract class AbstractAlipayClient extends AbstractPayClient<AlipayPayCl | @@ -54,7 +55,7 @@ public abstract class AbstractAlipayClient extends AbstractPayClient<AlipayPayCl | ||
| 54 | */ | 55 | */ |
| 55 | @Override | 56 | @Override |
| 56 | public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws Exception { | 57 | public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws Exception { |
| 57 | - Map<String, String> params = data.getParams(); | 58 | + Map<String, String> params = strToMap(data.getBody()); |
| 58 | return PayOrderNotifyRespDTO.builder().orderExtensionNo(params.get("out_trade_no")) | 59 | return PayOrderNotifyRespDTO.builder().orderExtensionNo(params.get("out_trade_no")) |
| 59 | .channelOrderNo(params.get("trade_no")).channelUserId(params.get("seller_id")) | 60 | .channelOrderNo(params.get("trade_no")).channelUserId(params.get("seller_id")) |
| 60 | .tradeStatus(params.get("trade_status")) | 61 | .tradeStatus(params.get("trade_status")) |
| @@ -64,7 +65,7 @@ public abstract class AbstractAlipayClient extends AbstractPayClient<AlipayPayCl | @@ -64,7 +65,7 @@ public abstract class AbstractAlipayClient extends AbstractPayClient<AlipayPayCl | ||
| 64 | 65 | ||
| 65 | @Override | 66 | @Override |
| 66 | public PayRefundNotifyDTO parseRefundNotify(PayNotifyDataDTO notifyData) { | 67 | public PayRefundNotifyDTO parseRefundNotify(PayNotifyDataDTO notifyData) { |
| 67 | - Map<String, String> params = notifyData.getParams(); | 68 | + Map<String, String> params = strToMap(notifyData.getBody()); |
| 68 | PayRefundNotifyDTO notifyDTO = PayRefundNotifyDTO.builder().channelOrderNo(params.get("trade_no")) | 69 | PayRefundNotifyDTO notifyDTO = PayRefundNotifyDTO.builder().channelOrderNo(params.get("trade_no")) |
| 69 | .tradeNo(params.get("out_trade_no")) | 70 | .tradeNo(params.get("out_trade_no")) |
| 70 | .reqNo(params.get("out_biz_no")) | 71 | .reqNo(params.get("out_biz_no")) |
| @@ -128,4 +129,25 @@ public abstract class AbstractAlipayClient extends AbstractPayClient<AlipayPayCl | @@ -128,4 +129,25 @@ public abstract class AbstractAlipayClient extends AbstractPayClient<AlipayPayCl | ||
| 128 | } | 129 | } |
| 129 | } | 130 | } |
| 130 | 131 | ||
| 132 | + /** | ||
| 133 | + * | ||
| 134 | + * 支付宝统一回调参数 str转map | ||
| 135 | + * | ||
| 136 | + * @param s 支付宝支付通知回调参数 | ||
| 137 | + * @return map 支付宝集合 | ||
| 138 | + */ | ||
| 139 | + public static Map<String, String> strToMap(String s) { | ||
| 140 | + Map<String, String> stringStringMap = new HashMap<>(); | ||
| 141 | + //调整时间格式 | ||
| 142 | + String s3 = s.replaceAll("%3A", ":"); | ||
| 143 | + //获取map | ||
| 144 | + String s4 = s3.replace("+", " "); | ||
| 145 | + String[] split = s4.split("&"); | ||
| 146 | + for (String s1 : split) { | ||
| 147 | + String[] split1 = s1.split("="); | ||
| 148 | + stringStringMap.put(split1[0], split1[1]); | ||
| 149 | + } | ||
| 150 | + return stringStringMap; | ||
| 151 | + } | ||
| 152 | + | ||
| 131 | } | 153 | } |