|
|
|
|
@@ -68,7 +68,7 @@ public class WechatPayServiceImpl implements WechatPayService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
|
|
|
|
/** SDK 配置缓存:按 mchId+certSerialNo+apiV3Key+privateKeyPath 缓存 */
|
|
|
|
|
/** SDK 配置缓存:按 mchId+certSerialNo+apiV3Key+privateKey 缓存 */
|
|
|
|
|
private final ConcurrentHashMap<String, Config> sdkConfigCache = new ConcurrentHashMap<>();
|
|
|
|
|
|
|
|
|
|
// ==================== 支付下单 ====================
|
|
|
|
|
@@ -551,8 +551,8 @@ public class WechatPayServiceImpl implements WechatPayService {
|
|
|
|
|
if (StringUtils.isBlank(getCertSerialNo(dbCfg))) {
|
|
|
|
|
throw new ASException("微信支付配置缺少 certSerialNo");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(getPrivateKeyPath(dbCfg))) {
|
|
|
|
|
throw new ASException("微信支付配置缺少 privateKeyPath");
|
|
|
|
|
if (StringUtils.isBlank(getPrivateKey(dbCfg))) {
|
|
|
|
|
throw new ASException("微信支付配置缺少 privateKey");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(getNotifyUrl(dbCfg))) {
|
|
|
|
|
throw new ASException("微信支付配置缺少 notifyUrl");
|
|
|
|
|
@@ -601,7 +601,7 @@ public class WechatPayServiceImpl implements WechatPayService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取或创建 SDK 配置实例(按商户号+证书+密钥+私钥路径缓存)
|
|
|
|
|
* 获取或创建 SDK 配置实例(按商户号+证书+密钥+私钥缓存)
|
|
|
|
|
*/
|
|
|
|
|
private Config getOrCreateConfig(WechatPayConfigEntity cfg) {
|
|
|
|
|
String cacheKey = buildCacheKey(cfg);
|
|
|
|
|
@@ -617,7 +617,7 @@ public class WechatPayServiceImpl implements WechatPayService {
|
|
|
|
|
logger.info("初始化微信支付 RSAAutoCertificateConfig: mchId={}", getMchId(cfg));
|
|
|
|
|
Config config = new RSAAutoCertificateConfig.Builder()
|
|
|
|
|
.merchantId(getMchId(cfg))
|
|
|
|
|
.privateKeyFromPath(getPrivateKeyPath(cfg))
|
|
|
|
|
.privateKey(getPrivateKey(cfg))
|
|
|
|
|
.merchantSerialNumber(getCertSerialNo(cfg))
|
|
|
|
|
.apiV3Key(getApiV3Key(cfg))
|
|
|
|
|
.build();
|
|
|
|
|
@@ -627,7 +627,7 @@ public class WechatPayServiceImpl implements WechatPayService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String buildCacheKey(WechatPayConfigEntity cfg) {
|
|
|
|
|
return getMchId(cfg) + "|" + getCertSerialNo(cfg) + "|" + getApiV3Key(cfg) + "|" + getPrivateKeyPath(cfg);
|
|
|
|
|
return getMchId(cfg) + "|" + getCertSerialNo(cfg) + "|" + getApiV3Key(cfg) + "|" + getPrivateKey(cfg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getAppId(WechatPayConfigEntity cfg) {
|
|
|
|
|
@@ -646,8 +646,8 @@ public class WechatPayServiceImpl implements WechatPayService {
|
|
|
|
|
return cfg != null && StringUtils.isNotBlank(cfg.getCertSerialNo()) ? cfg.getCertSerialNo() : wechatPayConfig.getCertSerialNo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getPrivateKeyPath(WechatPayConfigEntity cfg) {
|
|
|
|
|
return cfg != null && StringUtils.isNotBlank(cfg.getPrivateKeyPath()) ? cfg.getPrivateKeyPath() : wechatPayConfig.getPrivateKeyPath();
|
|
|
|
|
private String getPrivateKey(WechatPayConfigEntity cfg) {
|
|
|
|
|
return cfg != null && StringUtils.isNotBlank(cfg.getPrivateKey()) ? cfg.getPrivateKey() : wechatPayConfig.getPrivateKey();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getNotifyUrl(WechatPayConfigEntity cfg) {
|
|
|
|
|
|