From 53de36012647e1ad8c8bca3f47b37e418b5704e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Sat, 30 Aug 2025 22:47:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(shop):=20=E4=BF=AE=E5=A4=8D=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E7=8E=AF=E5=A2=83=E8=AF=81=E4=B9=A6=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 优化私钥和公钥路径的拼接逻辑,适应数据库中不同格式的路径 - 添加日志输出,便于调试和追踪路径处理过程- 统一路径处理方式,提高代码可维护性 --- .../service/impl/ShopOrderServiceImpl.java | 82 ++++++++++++++----- 1 file changed, 62 insertions(+), 20 deletions(-) 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 01571e0..f5ad890 100644 --- a/src/main/java/com/gxwebsoft/shop/service/impl/ShopOrderServiceImpl.java +++ b/src/main/java/com/gxwebsoft/shop/service/impl/ShopOrderServiceImpl.java @@ -751,11 +751,25 @@ public class ShopOrderServiceImpl extends ServiceImpl " + pubKeyPath); + String pubKeyRelativePath = payment.getPubKey(); + System.out.println("数据库中的公钥相对路径: " + pubKeyRelativePath); + + // 修复公钥路径拼接逻辑,与私钥路径处理保持一致 + String pubKeyFullPath; + if (pubKeyRelativePath.startsWith("/file/")) { + // 路径已经包含 /file/ 前缀,直接拼接到根路径 + pubKeyFullPath = certRootPath + pubKeyRelativePath; + } else if (pubKeyRelativePath.startsWith("file/")) { + // 路径包含 file/ 前缀,添加根路径和斜杠 + pubKeyFullPath = certRootPath + "/" + pubKeyRelativePath; } else { - System.out.println("生产环境公钥路径: " + pubKeyPath); + // 路径不包含 file 前缀,添加完整的 /file/ 前缀 + pubKeyFullPath = certRootPath + "/file/" + pubKeyRelativePath; } - pubKeyFile = certificateLoader.loadCertificatePath(pubKeyPath); + System.out.println("生产环境公钥完整路径: " + pubKeyFullPath); + pubKeyFile = certificateLoader.loadCertificatePath(pubKeyFullPath); System.out.println("✅ 生产环境公钥文件加载成功: " + pubKeyFile); config = new RSAPublicKeyConfig.Builder() @@ -931,17 +952,25 @@ public class ShopOrderServiceImpl extends ServiceImpl