|
|
@ -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()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|