From 0b7c409aff156bc4d5605893e860c0c3652b9cd8 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期四, 17 七月 2025 19:25:30 +0800
Subject: [PATCH] 111
---
server/services/src/main/java/com/doumee/config/wx/WxMiniConfig.java | 89 +++++++++++++++++++++++++++++++++++++++++---
1 files changed, 83 insertions(+), 6 deletions(-)
diff --git a/server/services/src/main/java/com/doumee/config/wx/WxMiniConfig.java b/server/services/src/main/java/com/doumee/config/wx/WxMiniConfig.java
index f93edef..e0b82bb 100644
--- a/server/services/src/main/java/com/doumee/config/wx/WxMiniConfig.java
+++ b/server/services/src/main/java/com/doumee/config/wx/WxMiniConfig.java
@@ -10,6 +10,12 @@
import com.github.binarywang.wxpay.constant.WxPayConstants;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
+import com.wechat.pay.java.core.Config;
+import com.wechat.pay.java.core.RSAAutoCertificateConfig;
+import com.wechat.pay.java.service.billdownload.BillDownloadService;
+import com.wechat.pay.java.service.partnerpayments.jsapi.JsapiService;
+import com.wechat.pay.java.service.partnerpayments.jsapi.JsapiServiceExtension;
+import com.wechat.pay.java.service.refund.RefundService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
@@ -21,12 +27,18 @@
*/
@Configuration
public class WxMiniConfig {
- @Autowired
- private SystemDictDataBiz systemDictDataBiz;
/********寰俊灏忕▼搴忔湇鍔�**********/
public static WxMaService wxMaService;
/********寰俊灏忕▼搴忔敮浠�**********/
- public static WxPayService wxPayService;
+ public static JsapiService wxPayService;
+ public static WxPayService wxPayV2Service;
+ public static RefundService refundService;
+ public static JsapiServiceExtension jsapiExtService;
+ public static BillDownloadService billDownloadService;
+ public static WxPayProperties wxProperties;
+ public static TransferToUser transferToUser;
+ @Autowired
+ private WxPayProperties wxPayProperties;
public static WxMiniConfig me() {
return SpringUtils.get().getBean(WxMiniConfig.class);
@@ -35,15 +47,25 @@
@PostConstruct
void init() {
this.load_WxMaService();
-// this.load_wxPayService();
+ this.load_wxPayService();
+ this.load_wxPayV2Service();
+ this.load_transferToUser();
+ this.load_transferToUser();
+ this.wxProperties = wxPayProperties;
}
/**
* 鍒濆鍖栧井淇″皬绋嬪簭
*/
public void load_WxMaService() {
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
- config.setAppid(StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.WX_CONFIG,Constants.APPID).getCode()));
- config.setSecret(StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.WX_CONFIG,Constants.SECRET).getCode()));
+ if(wxPayProperties.getExistsSub() ==1){
+ //濡傛灉鏄湇鍔″晢鏀粯,鍙栧瓙鍟嗘埛淇℃伅
+ config.setAppid(StringUtils.trimToNull(wxPayProperties.getSubAppId()));
+ config.setSecret(StringUtils.trimToNull(wxPayProperties.getSubAppSecret()));
+ }else {
+ config.setAppid(StringUtils.trimToNull(wxPayProperties.getAppId()));
+ config.setSecret(StringUtils.trimToNull(wxPayProperties.getAppSecret()));
+ }
config.setMsgDataFormat("JSON");
//config.setToken("");
//config.setAesKey("");
@@ -51,6 +73,50 @@
wxMaService.setWxMaConfig(config);
this.wxMaService = wxMaService;
}
+
+ /**
+ * 鍒濆鍖栧井淇″皬绋嬪簭鏀粯
+ */
+ public void load_wxPayService() {
+ try {
+ Config config =
+ new RSAAutoCertificateConfig.Builder()
+ .merchantId(wxPayProperties.getMchId())
+ .privateKeyFromPath(wxPayProperties.getPrivateKeyPath())
+ .merchantSerialNumber(wxPayProperties.getSerialNumer())
+ .apiV3Key(wxPayProperties.getApiV3Key())
+ .build();
+ this.wxPayService = new JsapiService.Builder().config(config).build();
+
+ this.jsapiExtService = new JsapiServiceExtension.Builder().config(config).build();
+ this.refundService = new RefundService.Builder().config(config).build();
+ this.billDownloadService = new BillDownloadService.Builder().config(config).build();
+ }catch (Exception e){
+ e.printStackTrace();
+
+ }
+ }
+
+ /**
+ * 鍒濆鍖栧井淇″皬绋嬪簭鏀粯
+ */
+ public void load_wxPayV2Service()
+ {
+ WxPayConfig payConfig = new WxPayConfig();
+ payConfig.setTradeType(WxPayConstants.TradeType.JSAPI);
+ payConfig.setSignType(WxPayConstants.SignType.MD5);
+ payConfig.setAppId(StringUtils.trimToNull(wxPayProperties.getAppId()));
+ payConfig.setSubAppId(StringUtils.trimToNull(wxPayProperties.getSubAppId()));
+ payConfig.setMchId(StringUtils.trimToNull(wxPayProperties.getMchId()));
+ payConfig.setSubMchId(StringUtils.trimToNull(wxPayProperties.getSubMchId()));
+ payConfig.setMchKey(StringUtils.trimToNull(wxPayProperties.getMchKey()));
+// payConfig.setKeyPath(StringUtils.trimToNull(wxPayProperties.getKeyPath()));
+ payConfig.setNotifyUrl(StringUtils.trimToNull(wxPayProperties.getNotifyUrl()));
+ WxPayService wxPayService = new WxPayServiceImpl();
+ wxPayService.setConfig(payConfig);
+ this.wxPayV2Service = wxPayService;
+ }
+
/**
* 鍒濆鍖栧井淇″皬绋嬪簭鏀粯
@@ -70,7 +136,18 @@
// }
+ public void load_transferToUser()
+ {
+ TransferToUser transferToUser = new TransferToUser(
+ StringUtils.trimToNull(wxPayProperties.getMchId()), //鍟嗘埛id
+ StringUtils.trimToNull(wxPayProperties.getWechatSerialNumer()), //鍟嗘埛API璇佷功搴忓垪鍙凤紝濡備綍鑾峰彇璇峰弬鑰� https://pay.weixin.qq.com/doc/v3/merchant/4013053053
+ StringUtils.trimToNull(wxPayProperties.getWechatPrivateKeyPath()), // 鍟嗘埛API璇佷功绉侀挜鏂囦欢璺緞锛屾湰鍦版枃浠惰矾寰�
+ StringUtils.trimToNull(wxPayProperties.getWechatPayPublicKeyId()), // 寰俊鏀粯鍏挜ID锛屽浣曡幏鍙栬鍙傝�� https://pay.weixin.qq.com/doc/v3/merchant/4013038816
+ StringUtils.trimToNull(wxPayProperties.getWechatPubKeyPath()) // 寰俊鏀粯鍏挜鏂囦欢璺緞锛屾湰鍦版枃浠惰矾寰�
+ );
+ this.transferToUser = transferToUser;
+ }
}
--
Gitblit v1.9.3