From 7004c068211476218e72fa54a7243c3c3d2fd4fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=9F=E6=9D=83=E4=BC=9F?= <872046794@qq.com> Date: Wed, 31 Jul 2024 13:50:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fuint/common/bean/WxPayBean.java | 18 +++++++++++ .../service/impl/WeixinServiceImpl.java | 31 +++++++++++++------ .../main/resources/application-dev.properties | 9 ++++-- .../resources/application-prod.properties | 2 ++ 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/common/bean/WxPayBean.java b/fuintBackend/fuint-application/src/main/java/com/fuint/common/bean/WxPayBean.java index 44cbe3a..1004b31 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/common/bean/WxPayBean.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/common/bean/WxPayBean.java @@ -19,6 +19,8 @@ public class WxPayBean { private String appSecret; private String mchId; private String apiV2; + private String slAppId; + private String slMchId; private String certPath; private String domain; // 填写完整的回调地址 @@ -70,6 +72,22 @@ public class WxPayBean { this.domain = domain; } + public String getSlAppId() { + return slAppId; + } + + public void setSlAppId(String slAppId) { + this.slAppId = slAppId; + } + + public String getSlMchId() { + return slMchId; + } + + public void setSlMchId(String slMchId) { + this.slMchId = slMchId; + } + @Override public String toString() { return "WxPayBean [appId=" + appId + ", appSecret=" + appSecret + ", mchId=" + mchId + ", apiV2=" diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/WeixinServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/WeixinServiceImpl.java index f81fafb..0fc1bd9 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/WeixinServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/WeixinServiceImpl.java @@ -607,8 +607,10 @@ public class WeixinServiceImpl implements WeixinService { getApiConfig(storeId, platform); WxPayApiConfig wxPayApiConfig = WxPayApiConfigKit.getWxPayApiConfig(); Map params = RefundModel.builder() - .appid(wxPayApiConfig.getAppId()) - .mch_id(wxPayApiConfig.getMchId()) + .sub_appid(wxPayApiConfig.getAppId()) + .sub_mch_id(wxPayApiConfig.getMchId()) + .appid(wxPayApiConfig.getSlAppId()) + .mch_id(wxPayApiConfig.getSlMchId()) .nonce_str(WxPayKit.generateStr()) .transaction_id("") .out_trade_no(orderSn) @@ -924,8 +926,10 @@ public class WeixinServiceImpl implements WeixinService { getApiConfig(storeId, platform); WxPayApiConfig wxPayApiConfig = WxPayApiConfigKit.getWxPayApiConfig(); Map params = MicroPayModel.builder() - .appid(wxPayApiConfig.getAppId()) - .mch_id(wxPayApiConfig.getMchId()) + .sub_appid(wxPayApiConfig.getAppId()) + .sub_mch_id(wxPayApiConfig.getMchId()) + .appid(wxPayApiConfig.getSlAppId()) + .mch_id(wxPayApiConfig.getSlMchId()) .nonce_str(WxPayKit.generateStr()) .body(reqData.get("body")) .attach(reqData.get("body")) @@ -1007,8 +1011,11 @@ public class WeixinServiceImpl implements WeixinService { WxPayApiConfig wxPayApiConfig = WxPayApiConfigKit.getWxPayApiConfig(); Map params = UnifiedOrderModel .builder() - .appid(wxPayApiConfig.getAppId()) - .mch_id(wxPayApiConfig.getMchId()) + .sub_appid(wxPayApiConfig.getAppId()) + .sub_mch_id(wxPayApiConfig.getMchId()) + .sub_openid(reqData.get("openid")) + .appid(wxPayApiConfig.getSlAppId()) + .mch_id(wxPayApiConfig.getSlMchId()) .nonce_str(WxPayKit.generateStr()) .body(reqData.get("body")) .attach(reqData.get("body")) @@ -1017,7 +1024,6 @@ public class WeixinServiceImpl implements WeixinService { .spbill_create_ip(ip) .notify_url(wxPayApiConfig.getDomain() + CALL_BACK_URL) .trade_type(reqData.get("trade_type")) - .openid(reqData.get("openid")) .build() .createSign(wxPayApiConfig.getPartnerKey(), SignType.MD5); String xmlResult = WxPayApi.pushOrder(false, params); @@ -1067,8 +1073,11 @@ public class WeixinServiceImpl implements WeixinService { sceneInfo.setH5Info(h5Info); Map params = UnifiedOrderModel .builder() - .appid(wxPayApiConfig.getAppId()) - .mch_id(wxPayApiConfig.getMchId()) + .sub_appid(wxPayApiConfig.getAppId()) + .sub_mch_id(wxPayApiConfig.getMchId()) + .sub_openid(reqData.get("openid")) + .appid(wxPayApiConfig.getSlAppId()) + .mch_id(wxPayApiConfig.getSlMchId()) .nonce_str(WxPayKit.generateStr()) .body(reqData.get("body")) .attach(reqData.get("body")) @@ -1119,6 +1128,8 @@ public class WeixinServiceImpl implements WeixinService { String apiV2 = wxPayBean.getApiV2(); String certPath = wxPayBean.getCertPath(); String appId = wxPayBean.getAppId(); + String slAppId = wxPayBean.getSlAppId(); + String slMchId = wxPayBean.getSlMchId(); logger.info("微信支付店铺信息:{}", JsonUtil.toJSONString(mtStore)); if (mtStore != null && StringUtil.isNotEmpty(mtStore.getWxApiV2()) && StringUtil.isNotEmpty(mtStore.getWxMchId())) { mchId = mtStore.getWxMchId(); @@ -1131,6 +1142,8 @@ public class WeixinServiceImpl implements WeixinService { } } apiConfig = WxPayApiConfig.builder() + .slAppId(slAppId) + .slMchId(slMchId) .appId(appId) .mchId(mchId) .partnerKey(apiV2) diff --git a/fuintBackend/fuint-application/src/main/resources/application-dev.properties b/fuintBackend/fuint-application/src/main/resources/application-dev.properties index 457d47f..f2a687a 100644 --- a/fuintBackend/fuint-application/src/main/resources/application-dev.properties +++ b/fuintBackend/fuint-application/src/main/resources/application-dev.properties @@ -84,15 +84,22 @@ aliyun.oss.domain = https://wine-east-img.oss-cn-zhangjiakou.aliyuncs.com ################## \u5FAE\u4FE1\u76F8\u5173\u914D\u7F6E ########################## # \u516C\u4F17\u53F7\u914D\u7F6E +# \u516C\u4F17\u53F7\u914D\u7F6E weixin.official.appId=wxf4327ef05c27a0 weixin.official.appSecret=1f55e8749332234d9a074873d8e6a3 # \u5C0F\u7A0B\u5E8F\u914D\u7F6E wxpay.appId = wx53b5ac263b9cdb5b wxpay.appSecret = baa127ca662344cf9b0b8e52b26bac9d +# \u5FAE\u4FE1\u652F\u4ED8 wxpay.mchId=1485526382 wxpay.apiV2=f5aacf8f7ff800f4cd039f2514c5d7da +wxpay.slAppId=1485526382 +wxpay.slMchId=f5aacf8f7ff800f4cd039f2514c5d7da +wxpay.certPath=D:/apiclient_cert.p12 +wxpay.domain=https://yanghaodong.51vip.biz + #\u5FAE\u4FE1\u5C0F\u7A0B\u5E8Fappid: wx53b5ac263b9cdb5b #\u5FAE\u4FE1\u5C0F\u7A0B\u5E8FAppSecret: baa127ca662344cf9b0b8e52b26bac9d #\u5FAE\u4FE1\u652F\u4ED8: 1485526382 @@ -101,8 +108,6 @@ wxpay.apiV2=f5aacf8f7ff800f4cd039f2514c5d7da #\u5FAE\u4FE1\u652F\u4ED8apiv3\u5BC6\u94A5\uFF1Af5aacf8f7ff800f4cd039f2514c5d7da -wxpay.certPath=D:/apiclient_cert.p12 -wxpay.domain=https://yanghaodong.51vip.biz ################## \u652F\u4ED8\u5B9D\u652F\u4ED8\u76F8\u5173\u914D\u7F6E ###################### alipay.appId = \u5E94\u7528\u7F16\u53F7 diff --git a/fuintBackend/fuint-application/src/main/resources/application-prod.properties b/fuintBackend/fuint-application/src/main/resources/application-prod.properties index 071a7bc..6c81ec5 100644 --- a/fuintBackend/fuint-application/src/main/resources/application-prod.properties +++ b/fuintBackend/fuint-application/src/main/resources/application-prod.properties @@ -88,6 +88,8 @@ wxpay.appId = wxb6af3741234162bc wxpay.appSecret = 76a538bfa5b55a4564d5f2be5540 wxpay.mchId=1636980812 wxpay.apiV2=34354320201030y323e432342343 +wxpay.slAppId=1485526382 +wxpay.slMchId=f5aacf8f7ff800f4cd039f2514c5d7da wxpay.certPath=/usr/local/fuint/cert/apiclient_cert.p12 wxpay.domain=https://www.fuint.cn/fuint-application