diff --git a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java index 49c3d1e0..d4d81ad8 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java @@ -299,6 +299,7 @@ public class OutRechargeOrderController { } JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); Long orderId = jsonObject.getLong("orderId"); + Integer openIdType = jsonObject.getInteger("openIdType"); // openId类型 1:小程序 2:公众号 String openId = jsonObject.getString("openId"); // openId if (orderId == null || StringUtils.isBlank(openId)) { log.error("orderToPay error!", "参数错误"); @@ -331,7 +332,11 @@ public class OutRechargeOrderController { 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("1614670195"); weChatPayReqInfo.setSub_openid(openId); weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串 @@ -346,7 +351,7 @@ public class OutRechargeOrderController { //附加数据,区分订单类型 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);