From 839bd268d943d0b3e5ca634620fa9be672ff9fc7 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Tue, 30 Nov 2021 22:13:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cweb/controller/pay/OrderController.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java index bd646610..acf446e5 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java @@ -127,6 +127,7 @@ public class OrderController { } JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); Long orderId = jsonObject.getLong("orderId"); + Integer openIdType = jsonObject.getInteger("openIdType"); // openId类型 1:小程序 2:公众号 String orderScene = jsonObject.getString("orderScene"); // 订单类型 String openId = jsonObject.getString("openId"); // openId if ( orderId == null || StringUtils.isBlank(orderScene) || StringUtils.isBlank(openId)) { @@ -187,7 +188,11 @@ public class OrderController { WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo(); weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号 - weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId()); //商户号 + if (openIdType != null && openIdType.equals(2)) { + weChatPayReqInfo.setSub_appid("wxa075e8509802f826"); //商户号公众号 + } else { + weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId());//商户号 + } weChatPayReqInfo.setSub_mch_id(SysConst.getSysConfig().getWxSubMchId()); //子商户号 // weChatPayReqInfo.setOpenid(openId); @@ -204,7 +209,7 @@ public class OrderController { //附加数据,区分订单类型 Map payMap = new HashMap<>(); - payMap.put("app_id",SysConst.getSysConfig().getWxSubAppId()); + payMap.put("app_id", weChatPayReqInfo.getSub_appid()); payMap.put("api_key",SysConst.getSysConfig().getWxApiKey()); payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl()); SortedMap sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap);