mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-23 03:03:41 +08:00
优化加载
This commit is contained in:
@@ -2,6 +2,18 @@
|
|||||||
|
|
||||||
> ❗注意:<span style= 'color:red;'>目前并没有上传到Maven中央仓库,等稳定后会进行支持。</span>
|
> ❗注意:<span style= 'color:red;'>目前并没有上传到Maven中央仓库,等稳定后会进行支持。</span>
|
||||||
|
|
||||||
|
|
||||||
|
## Spring Boot 版本适配
|
||||||
|
|
||||||
|
克隆项目后修改根目录下的`pom.xml`以下配置项:
|
||||||
|
```xml
|
||||||
|
<properties>
|
||||||
|
<!-- 修改为你对应的Spring Boot版本号 -->
|
||||||
|
<spring-boot.version>2.4.0</spring-boot.version>
|
||||||
|
</properties>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## 自行安装
|
## 自行安装
|
||||||
|
|
||||||
以**Spring Boot Starter**的形式集成到项目中。从[GitHub项目地址](https://github.com/NotFound403/payment-spring-boot)拉取`release`分支到本地后使用以下两种方式之一进行环境集成:
|
以**Spring Boot Starter**的形式集成到项目中。从[GitHub项目地址](https://github.com/NotFound403/payment-spring-boot)拉取`release`分支到本地后使用以下两种方式之一进行环境集成:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cn.felord.payment.wechat;
|
|||||||
|
|
||||||
|
|
||||||
import cn.felord.payment.wechat.v3.*;
|
import cn.felord.payment.wechat.v3.*;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -23,19 +24,20 @@ public class WechatPayConfiguration {
|
|||||||
* @return the wechat cert bean
|
* @return the wechat cert bean
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
WechatMetaContainer wechatMetaContainer(WechatPayProperties wechatPayProperties) {
|
WechatMetaContainer wechatMetaContainer(WechatPayProperties wechatPayProperties) {
|
||||||
|
|
||||||
Map<String, WechatPayProperties.V3> v3Map = wechatPayProperties.getV3();
|
Map<String, WechatPayProperties.V3> v3Map = wechatPayProperties.getV3();
|
||||||
WechatMetaContainer container = new WechatMetaContainer();
|
WechatMetaContainer container = new WechatMetaContainer();
|
||||||
|
KeyPairFactory keyPairFactory = new KeyPairFactory();
|
||||||
v3Map.keySet().forEach(tenantId -> {
|
v3Map.keySet().forEach(tenantId -> {
|
||||||
WechatPayProperties.V3 v3 = v3Map.get(tenantId);
|
WechatPayProperties.V3 v3 = v3Map.get(tenantId);
|
||||||
String certPath = v3.getCertPath();
|
String certPath = v3.getCertPath();
|
||||||
String mchId = v3.getMchId();
|
String mchId = v3.getMchId();
|
||||||
WechatMetaBean wechatMetaBean = new KeyPairFactory().createPKCS12(certPath, CERT_ALIAS, mchId);
|
WechatMetaBean wechatMetaBean = keyPairFactory.createPKCS12(certPath, CERT_ALIAS, mchId);
|
||||||
wechatMetaBean.setV3(v3);
|
wechatMetaBean.setV3(v3);
|
||||||
wechatMetaBean.setTenantId(tenantId);
|
wechatMetaBean.setTenantId(tenantId);
|
||||||
container.addWechatMeta(tenantId, wechatMetaBean);
|
container.addWechatMeta(tenantId, wechatMetaBean);
|
||||||
container.addTenant(tenantId);
|
|
||||||
});
|
});
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package cn.felord.payment.wechat.v3;
|
package cn.felord.payment.wechat.v3;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -18,12 +17,13 @@ public class WechatMetaContainer {
|
|||||||
/**
|
/**
|
||||||
* Add wechat meta boolean.
|
* Add wechat meta boolean.
|
||||||
*
|
*
|
||||||
* @param tenantId the tenantId
|
* @param tenantId the tenantId
|
||||||
* @param wechatMetaBean the wechat meta bean
|
* @param wechatMetaBean the wechat meta bean
|
||||||
* @return the boolean
|
* @return the boolean
|
||||||
*/
|
*/
|
||||||
public boolean addWechatMeta(String tenantId, WechatMetaBean wechatMetaBean) {
|
public WechatMetaBean addWechatMeta(String tenantId, WechatMetaBean wechatMetaBean) {
|
||||||
return Objects.nonNull(this.wechatMetaBeanMap.put(tenantId, wechatMetaBean));
|
tenantIds.add(tenantId);
|
||||||
|
return this.wechatMetaBeanMap.put(tenantId, wechatMetaBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,6 +33,7 @@ public class WechatMetaContainer {
|
|||||||
* @return the wechat meta bean
|
* @return the wechat meta bean
|
||||||
*/
|
*/
|
||||||
public WechatMetaBean removeWechatMeta(String tenantId) {
|
public WechatMetaBean removeWechatMeta(String tenantId) {
|
||||||
|
tenantIds.remove(tenantId);
|
||||||
return this.wechatMetaBeanMap.remove(tenantId);
|
return this.wechatMetaBeanMap.remove(tenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,16 +47,6 @@ public class WechatMetaContainer {
|
|||||||
return Objects.requireNonNull(this.wechatMetaBeanMap.get(tenantId));
|
return Objects.requireNonNull(this.wechatMetaBeanMap.get(tenantId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add key boolean.
|
|
||||||
*
|
|
||||||
* @param tenantId the tenant id
|
|
||||||
* @return the boolean
|
|
||||||
*/
|
|
||||||
public boolean addTenant(String tenantId) {
|
|
||||||
return tenantIds.add(tenantId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets properties keys.
|
* Gets properties keys.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user