From c52b4374e33ff0a31e31d75172b886e6bb5c0182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Sun, 27 Jul 2025 10:07:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E6=94=B9=EF=BC=9A=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SPRINGDOC_MIGRATION_REPORT.md | 6 +-- application-override.yml | 2 +- .../core/config/CertificateProperties.java | 2 +- .../service/impl/ShopOrderServiceImpl.java | 38 +++++++++++++++---- .../dev/wechat/{ => 10398}/apiclient_cert.pem | 0 .../dev/wechat/{ => 10398}/apiclient_key.pem | 0 .../dev/wechat/{ => 10398}/wechatpay_cert.pem | 0 .../{pub_key-3.pem => wechatpay_cert.pem} | 0 8 files changed, 35 insertions(+), 13 deletions(-) rename src/main/resources/dev/wechat/{ => 10398}/apiclient_cert.pem (100%) rename src/main/resources/dev/wechat/{ => 10398}/apiclient_key.pem (100%) rename src/main/resources/dev/wechat/{ => 10398}/wechatpay_cert.pem (100%) rename src/main/resources/dev/wechat/10550/{pub_key-3.pem => wechatpay_cert.pem} (100%) diff --git a/SPRINGDOC_MIGRATION_REPORT.md b/SPRINGDOC_MIGRATION_REPORT.md index 2f288e9..6bc6c37 100644 --- a/SPRINGDOC_MIGRATION_REPORT.md +++ b/SPRINGDOC_MIGRATION_REPORT.md @@ -132,9 +132,9 @@ knife4j: 重新编译后需要验证: - [ ] 应用正常启动无错误 -- [ ] 访问 Swagger UI: `http://localhost:9202/swagger-ui.html` -- [ ] 访问 API 文档: `http://localhost:9202/v3/api-docs` -- [ ] 访问 Knife4j UI: `http://localhost:9202/doc.html` +- [ ] 访问 Swagger UI: `http://localhost:9200/swagger-ui.html` +- [ ] 访问 API 文档: `http://localhost:9200/v3/api-docs` +- [ ] 访问 Knife4j UI: `http://localhost:9200/doc.html` - [ ] 各模块分组正常显示 - [ ] JWT 认证配置正常工作 diff --git a/application-override.yml b/application-override.yml index 4c470fa..9d52f35 100644 --- a/application-override.yml +++ b/application-override.yml @@ -15,4 +15,4 @@ certificate: dev: private-key-file: "apiclient_key.pem" apiclient-cert-file: "apiclient_cert.pem" - wechatpay-cert-file: "pub_key-3.pem" + wechatpay-cert-file: "wechatpay_cert.pem" diff --git a/src/main/java/com/gxwebsoft/common/core/config/CertificateProperties.java b/src/main/java/com/gxwebsoft/common/core/config/CertificateProperties.java index 4857dcc..6da6bdc 100644 --- a/src/main/java/com/gxwebsoft/common/core/config/CertificateProperties.java +++ b/src/main/java/com/gxwebsoft/common/core/config/CertificateProperties.java @@ -32,7 +32,7 @@ public class CertificateProperties { /** * 开发环境证书路径前缀 */ - private String devCertPath = "certs/dev"; + private String devCertPath = "dev"; /** * 微信支付证书配置 diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/ShopOrderServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/ShopOrderServiceImpl.java index f637dcf..a4c435e 100644 --- a/src/main/java/com/gxwebsoft/shop/service/impl/ShopOrderServiceImpl.java +++ b/src/main/java/com/gxwebsoft/shop/service/impl/ShopOrderServiceImpl.java @@ -12,6 +12,7 @@ import com.gxwebsoft.common.core.utils.CertificateLoader; import com.gxwebsoft.common.core.service.PaymentCacheService; import com.gxwebsoft.common.system.entity.Payment; + import lombok.extern.slf4j.Slf4j; import com.gxwebsoft.common.system.param.PaymentParam; import com.gxwebsoft.common.system.service.PaymentService; import com.gxwebsoft.common.system.service.SettingService; @@ -48,6 +49,7 @@ import com.gxwebsoft.common.core.service.PaymentCacheService; * @author 科技小王子 * @since 2025-01-11 10:45:12 */ + @Slf4j @Service public class ShopOrderServiceImpl extends ServiceImpl implements ShopOrderService { @Value("${spring.profiles.active}") @@ -217,20 +219,40 @@ import com.gxwebsoft.common.core.service.PaymentCacheService; // 开发环境配置 - 使用证书加载器 if (active.equals("dev")) { - privateKey = certificateLoader.loadCertificatePath( - certConfig.getWechatPayCertPath(certConfig.getWechatPay().getDev().getPrivateKeyFile())); - apiclientCert = certificateLoader.loadCertificatePath( - certConfig.getWechatPayCertPath(certConfig.getWechatPay().getDev().getWechatpayCertFile())); + // 构建包含租户号的证书路径: dev/wechat/{tenantId}/ + String tenantCertPath = "dev/wechat/" + order.getTenantId(); + String privateKeyPath = tenantCertPath + "/" + certConfig.getWechatPay().getDev().getPrivateKeyFile(); + String merchantCertPath = tenantCertPath + "/" + certConfig.getWechatPay().getDev().getApiclientCertFile(); + String wechatpayCertPath = tenantCertPath + "/" + certConfig.getWechatPay().getDev().getWechatpayCertFile(); + + System.out.println("开发环境证书路径 - 租户ID: " + order.getTenantId()); + System.out.println("开发环境证书路径 - 私钥: " + privateKeyPath); + System.out.println("开发环境证书路径 - 商户证书: " + merchantCertPath); + System.out.println("开发环境证书路径 - 微信支付平台证书: " + wechatpayCertPath); + System.out.println("支付配置信息 - 商户号: " + payment.getMchId() + + ", 序列号: " + payment.getMerchantSerialNumber() + + ", API密钥: " + (payment.getApiKey() != null ? "已配置" : "未配置")); + + privateKey = certificateLoader.loadCertificatePath(privateKeyPath); + apiclientCert = certificateLoader.loadCertificatePath(wechatpayCertPath); + + System.out.println("证书加载完成 - 私钥文件: " + privateKey); + System.out.println("证书加载完成 - 微信支付平台证书文件: " + apiclientCert); } else { - // 生产环境配置 - 从容器证书目录加载 + // 生产环境配置 - 从容器证书目录加载,包含租户号 final String certRootPath = certConfig.getCertRootPath(); // /www/wwwroot/file.ws + final String tenantCertPath = certRootPath + "/wechat/" + order.getTenantId(); + + System.out.println("生产环境证书路径 - 租户ID: " + order.getTenantId()); + System.out.println("生产环境证书根路径: " + tenantCertPath); + privateKey = certificateLoader.loadCertificatePath( - certRootPath + payment.getApiclientKey()); + tenantCertPath + "/" + payment.getApiclientKey()); apiclientCert = certificateLoader.loadCertificatePath( - certRootPath + payment.getApiclientCert()); + tenantCertPath + "/" + payment.getApiclientCert()); if (payment.getPubKey() != null && !payment.getPubKey().isEmpty()) { pubKey = certificateLoader.loadCertificatePath( - certRootPath + payment.getPubKey()); + tenantCertPath + "/" + payment.getPubKey()); } } diff --git a/src/main/resources/dev/wechat/apiclient_cert.pem b/src/main/resources/dev/wechat/10398/apiclient_cert.pem similarity index 100% rename from src/main/resources/dev/wechat/apiclient_cert.pem rename to src/main/resources/dev/wechat/10398/apiclient_cert.pem diff --git a/src/main/resources/dev/wechat/apiclient_key.pem b/src/main/resources/dev/wechat/10398/apiclient_key.pem similarity index 100% rename from src/main/resources/dev/wechat/apiclient_key.pem rename to src/main/resources/dev/wechat/10398/apiclient_key.pem diff --git a/src/main/resources/dev/wechat/wechatpay_cert.pem b/src/main/resources/dev/wechat/10398/wechatpay_cert.pem similarity index 100% rename from src/main/resources/dev/wechat/wechatpay_cert.pem rename to src/main/resources/dev/wechat/10398/wechatpay_cert.pem diff --git a/src/main/resources/dev/wechat/10550/pub_key-3.pem b/src/main/resources/dev/wechat/10550/wechatpay_cert.pem similarity index 100% rename from src/main/resources/dev/wechat/10550/pub_key-3.pem rename to src/main/resources/dev/wechat/10550/wechatpay_cert.pem