From e821293fcb3a2de15e94d1daadb52ffcfb739425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=9F=E6=9D=83=E4=BC=9F?= <872046794@qq.com> Date: Mon, 2 Sep 2024 22:06:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BE=AE=E4=BF=A1=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E4=B8=BA=E7=AC=AC=E4=B8=89=E6=96=B9=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/impl/weixin/WxPubPayClient.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java index 390c513..5ecd98d 100644 --- a/ruoyi-vue-pro-master/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java @@ -2,10 +2,12 @@ package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpRequest; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; +import com.alibaba.fastjson.JSONObject; import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; @@ -15,6 +17,8 @@ import com.github.binarywang.wxpay.constant.WxPayConstants; import com.github.binarywang.wxpay.exception.WxPayException; import lombok.extern.slf4j.Slf4j; +import java.util.HashMap; + import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException; import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; @@ -47,8 +51,24 @@ public class WxPubPayClient extends AbstractWxPayClient { WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO) .setOpenid(getOpenid(reqDTO)); // 执行请求 - WxPayMpOrderResult response = client.createOrder(request); +// WxPayMpOrderResult response = client.createOrder(request); + JSONObject paramMap = new JSONObject(); + paramMap.put("payAmount", request.getTotalFee().toString()); + paramMap.put("appid", config.getAppId()); + paramMap.put("mchid", config.getMchId()); + paramMap.put("keyString", config.getKeyContent()); + paramMap.put("apiv2", config.getMchKey()); + paramMap.put("domainUrl", request.getNotifyUrl()); + paramMap.put("orderSn",request.getOutTradeNo()); + paramMap.put("openId",request.getOpenid()); + String json = HttpRequest.post("http://alipay.huamar.com/pay/order/createOrder") + .body(paramMap.toJSONString()) + .execute().body(); + WxPayMpOrderResult response = JSONObject.parseObject(JSONObject.parseObject(json).getString("data"), WxPayMpOrderResult.class); + if (response == null){ + throw invalidParamException("支付请求失败!"); + } // 转换结果 return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.APP.getMode(), toJsonString(response), reqDTO.getOutTradeNo(), response);