Browse Source

大改:重构项目

main
科技小王子 4 weeks ago
parent
commit
c52b4374e3
  1. 6
      SPRINGDOC_MIGRATION_REPORT.md
  2. 2
      application-override.yml
  3. 2
      src/main/java/com/gxwebsoft/common/core/config/CertificateProperties.java
  4. 38
      src/main/java/com/gxwebsoft/shop/service/impl/ShopOrderServiceImpl.java
  5. 0
      src/main/resources/dev/wechat/10398/apiclient_cert.pem
  6. 0
      src/main/resources/dev/wechat/10398/apiclient_key.pem
  7. 0
      src/main/resources/dev/wechat/10398/wechatpay_cert.pem
  8. 0
      src/main/resources/dev/wechat/10550/wechatpay_cert.pem

6
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 认证配置正常工作

2
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"

2
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";
/**
* 微信支付证书配置

38
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<ShopOrderMapper, ShopOrder> 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());
}
}

0
src/main/resources/dev/wechat/apiclient_cert.pem → src/main/resources/dev/wechat/10398/apiclient_cert.pem

0
src/main/resources/dev/wechat/apiclient_key.pem → src/main/resources/dev/wechat/10398/apiclient_key.pem

0
src/main/resources/dev/wechat/wechatpay_cert.pem → src/main/resources/dev/wechat/10398/wechatpay_cert.pem

0
src/main/resources/dev/wechat/10550/pub_key-3.pem → src/main/resources/dev/wechat/10550/wechatpay_cert.pem

Loading…
Cancel
Save