Merge pull request #99 from dromara/1.0.18

1.0.18
This commit is contained in:
felord.cn
2023-05-05 12:44:37 +08:00
committed by GitHub
14 changed files with 36 additions and 91 deletions

View File

@@ -45,7 +45,7 @@ Starter支持微信优惠券代金券、商家券、智慧商圈、商家
<dependency>
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot-starter</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
</dependency>
```

View File

@@ -35,7 +35,7 @@
<dependency>
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot-starter</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
</dependency>
```
## 采用技术

View File

@@ -2,6 +2,6 @@
* [项目简介](README.md)
* [快速接入](quick_start.md)
* [JavaDoc](apidocs/index.html ':ignore')
* [微信支付V3接口文档](wechat_v3_api.md)
* [Payment微信支付V3接口文档](wechat_v3_api.md)
* [日常踩坑](stackoverflow.md)
* [更新日志](changelog.md)

View File

@@ -4,7 +4,7 @@
<dependency>
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot-starter</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
</dependency>
```
> 基于 **Spring Boot 2.x**

View File

@@ -9,8 +9,8 @@
#### 基础支付
- [x] `WechatDirectPayApi` 基础支付,通过`WechatApiProvider#directPayApi`初始化
- [x] `jsPay` APP下单
- [x] `appPay` JSAPI/小程序下单
- [x] `jsPay` JSAPI/小程序下单
- [x] `appPay` APP下单
- [x] `h5Pay` H5下单
- [x] `nativePay` Native下单
- [x] 查询订单
@@ -24,8 +24,8 @@
- [x] `downloadTradeBill` 申请交易账单直接下载为gzip或者txt文件
- [x] `downloadFundFlowBill` 申请资金账单直接下载为gzip或者txt文件
- [x] `WechatCombinePayApi` 合单支付,通过`WechatApiProvider#combinePayApi`初始化
- [x] `jsPay` 合单APP下单
- [x] `appPay` 合单JSAPI/小程序下单
- [x] `jsPay` 合单JSAPI/小程序下单
- [x] `appPay` 合单APP下单
- [x] `h5Pay` 合单H5下单
- [x] `nativePay` 合单Native下单
- [x] `queryTransactionByOutTradeNo` 查询订单,**合单支付目前只支持商户订单号查询**

View File

@@ -22,11 +22,11 @@
<parent>
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
</parent>
<artifactId>payment-spring-boot-autoconfigure</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>

View File

@@ -20,9 +20,10 @@ package cn.felord.payment.wechat;
import cn.felord.payment.wechat.v3.KeyPairFactory;
import cn.felord.payment.wechat.v3.WechatMetaBean;
import lombok.AllArgsConstructor;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.ResourceUtils;
import java.util.Map;
import java.util.Set;
@@ -37,6 +38,7 @@ import java.util.stream.Collectors;
@AllArgsConstructor
public class InMemoryWechatTenantService implements WechatTenantService {
private final WechatPayProperties wechatPayProperties;
private final ResourceLoader resourceLoader;
@Override
public Set<WechatMetaBean> loadTenants() {
@@ -51,7 +53,8 @@ public class InMemoryWechatTenantService implements WechatTenantService {
String certAbsolutePath = v3.getCertAbsolutePath();
String mchId = v3.getMchId();
Resource resource = certAbsolutePath != null ? new FileSystemResource(certAbsolutePath) :
new ClassPathResource(certPath == null ? "wechat/apiclient_cert.p12" : certPath);
resourceLoader.getResource(certPath == null ? "classpath:wechat/apiclient_cert.p12" :
certPath.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX) ? certPath : ResourceUtils.CLASSPATH_URL_PREFIX + certPath);
WechatMetaBean wechatMetaBean = keyPairFactory.initWechatMetaBean(resource, mchId);
wechatMetaBean.setV3(v3);
wechatMetaBean.setTenantId(tenantId);

View File

@@ -43,9 +43,7 @@ public class WechatPayConfiguration {
@Bean
@ConditionalOnMissingBean
WechatMetaContainer wechatMetaContainer(WechatTenantService wechatTenantService) {
WechatMetaContainer container = new WechatMetaContainer();
container.addWechatMetas(wechatTenantService.loadTenants());
return container;
return new WechatMetaContainer(wechatTenantService);
}
/**

View File

@@ -22,6 +22,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ResourceLoader;
/**
* The type Wechat tenant service configuration.
@@ -42,7 +43,7 @@ public class WechatTenantServiceConfiguration {
*/
@Bean
@ConditionalOnMissingBean
public WechatTenantService wechatTenantService(WechatPayProperties wechatPayProperties) {
return new InMemoryWechatTenantService(wechatPayProperties);
public WechatTenantService wechatTenantService(WechatPayProperties wechatPayProperties, ResourceLoader resourceLoader) {
return new InMemoryWechatTenantService(wechatPayProperties, resourceLoader);
}
}

View File

@@ -1,43 +0,0 @@
/*
* Copyright 2019-2022 felord.cn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* Website:
* https://felord.cn
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.felord.payment.wechat.v2.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author felord.cn
* @since 1.0.4.RELEASE
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class RefundModel extends BaseModel {
private String appid;
private String mchId;
private String signType="MD5";
private String transactionId;
private String outTradeNo;
private String outRefundNo;
private Integer totalFee;
private Integer refundFee;
private String refundFeeType="CNY";
private String refundDesc;
private String refundAccount;
private String notifyUrl;
}

View File

@@ -1,25 +0,0 @@
/*
* Copyright 2019-2022 felord.cn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* Website:
* https://felord.cn
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.felord.payment.wechat.v2.model;
/**
* @author felord.cn
* @since 1.0.4.RELEASE
*/
public class RefundQueryModel {
}

View File

@@ -17,6 +17,9 @@
package cn.felord.payment.wechat.v3;
import cn.felord.payment.wechat.WechatTenantService;
import lombok.AllArgsConstructor;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
@@ -27,10 +30,11 @@ import java.util.concurrent.ConcurrentSkipListSet;
* @author felord.cn
* @since 1.0.0.RELEASE
*/
@AllArgsConstructor
public class WechatMetaContainer {
private final Map<String, WechatMetaBean> wechatMetaBeanMap = new ConcurrentHashMap<>();
private final Set<String> tenantIds = new ConcurrentSkipListSet<>();
private final WechatTenantService wechatTenantService;
/**
* Add wechat metas.
@@ -66,7 +70,14 @@ public class WechatMetaContainer {
* @return the wechat meta
*/
public WechatMetaBean getWechatMeta(String tenantId) {
return Objects.requireNonNull(this.wechatMetaBeanMap.get(tenantId));
WechatMetaBean wechatMetaBean = this.wechatMetaBeanMap.get(tenantId);
if (Objects.nonNull(wechatMetaBean)) {
return wechatMetaBean;
} else {
this.addWechatMetas(wechatTenantService.loadTenants());
return Objects.requireNonNull(this.wechatMetaBeanMap.get(tenantId),
"cant obtain the config with tenant: "+tenantId);
}
}
/**

View File

@@ -22,11 +22,11 @@
<parent>
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
</parent>
<artifactId>payment-spring-boot-starter</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>

View File

@@ -21,7 +21,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>cn.felord</groupId>
<artifactId>payment-spring-boot</artifactId>
<version>1.0.17.RELEASE</version>
<version>1.0.18.RELEASE</version>
<packaging>pom</packaging>
<modelVersion>4.0.0</modelVersion>
@@ -47,7 +47,7 @@
</developers>
<scm>
<tag>payment-spring-boot-1.0.14.RELEASE</tag>
<tag>payment-spring-boot-1.0.18.RELEASE</tag>
<url>https://github.com/NotFound403/payment-spring-boot</url>
<connection>scm:git:https://github.com/NotFound403/payment-spring-boot.git</connection>
<developerConnection>scm:git:https://github.com/NotFound403/payment-spring-boot.git</developerConnection>