mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-14 13:53:42 +08:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bd091e268 | ||
|
|
1ba456f5dd | ||
|
|
0635d59666 | ||
|
|
5941907d7c | ||
|
|
348fe9b5f1 | ||
|
|
fa0cc541de | ||
|
|
85fde9bb68 | ||
|
|
da0fe928eb | ||
|
|
1c27375d93 | ||
|
|
4271491bc3 | ||
|
|
730c15b6b8 | ||
|
|
dc6e48d538 | ||
|
|
36259fc8ac | ||
|
|
e6e704cc28 | ||
|
|
8578300d1c | ||
|
|
d7cdebc731 | ||
|
|
97d87ce6f0 | ||
|
|
99136f9bd6 | ||
|
|
571bd2e563 | ||
|
|
aef8ef9ac3 | ||
|
|
f630301bc3 | ||
|
|
f7ba4dd306 | ||
|
|
997f004708 | ||
|
|
5e63779f36 | ||
|
|
30613a2fdd | ||
|
|
e9388f62c1 | ||
|
|
685839089f | ||
|
|
7b9bdd21f7 | ||
|
|
8c4ecad809 | ||
|
|
e24aa83ba0 | ||
|
|
d6d5e33dae |
27
.github/ISSUE_TEMPLATE/issues.md
vendored
Normal file
27
.github/ISSUE_TEMPLATE/issues.md
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
name: issues
|
||||
about: 向维护者提问以帮助改进
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**提问前的思考**
|
||||
1. 我是否已经认真阅读了文档和相关操作说明
|
||||
2. 其它ISSUES是否已经有了解决方案
|
||||
|
||||
**描述问题**
|
||||
提问时应该按照以下要点清晰地描述问题,才能得到可靠的答复
|
||||
|
||||
**环境版本信息**
|
||||
问题发生的环境,不限于软件版本、运行时环境、操作系统等
|
||||
|
||||
**操作行为**
|
||||
产生问题的操作行为
|
||||
|
||||
**期望的结果**
|
||||
清晰地描述期望达成的结果
|
||||
|
||||
**代码与截图**
|
||||
通常不建议使用代码截图,这样不太方便维护者进行Preview。代码应该使用Markdown代码块进行格式化。因交互导致的问题才建议使用截图辅助排查。
|
||||
61
README.md
61
README.md
@@ -1,8 +1,8 @@
|
||||
<div align="center" style="margin-bottom: 10px"><h1>最全最好用的微信支付V3 Spring Boot 组件</h1></div>
|
||||
|
||||
<p align="center">
|
||||
<a target="_blank" href="https://github.com/NotFound403/payment-spring-boot/blob/release/LICENSE">
|
||||
<img alt="" src="https://img.shields.io/github/license/NotFound403/payment-spring-boot"/>
|
||||
<a target="_blank" href="https://github.com/dromara/payment-spring-boot/blob/release/LICENSE">
|
||||
<img alt="" src="https://img.shields.io/github/license/dromara/payment-spring-boot"/>
|
||||
</a>
|
||||
<a target="_blank" href="https://felord.cn">
|
||||
<img alt="" src="https://img.shields.io/badge/java-8-red"/>
|
||||
@@ -13,17 +13,20 @@
|
||||
<a target="_blank" href="https://mvnrepository.com/artifact/cn.felord/payment-spring-boot">
|
||||
<img alt="" src="https://img.shields.io/maven-central/v/cn.felord/payment-spring-boot.svg?style=flat-square"/>
|
||||
</a>
|
||||
<a target="_blank" href="https://github.com/NotFound403/payment-spring-boot">
|
||||
<img alt="" src="https://img.shields.io/github/stars/NotFound403/payment-spring-boot?style=social"/>
|
||||
<a target="_blank" href="https://github.com/dromara/payment-spring-boot">
|
||||
<img alt="" src="https://img.shields.io/github/stars/dromara/payment-spring-boot?style=social"/>
|
||||
</a>
|
||||
<a target="_blank" href="https://gitee.com/felord/payment-spring-boot/stargazers">
|
||||
<a target="_blank" href="https://gitee.com/dromara/payment-spring-boot/stargazers">
|
||||
<img alt="" src="https://gitee.com/felord/payment-spring-boot/badge/star.svg?theme=white"/>
|
||||
</a>
|
||||
<a target="_blank" href="https://work.weixin.qq.com/kfid/kfc9d9d759f27f087e1">
|
||||
<img alt="点击立即微信咨询" src="https://img.shields.io/badge/%E7%82%B9%E5%87%BB-%E5%BE%AE%E4%BF%A1%E5%92%A8%E8%AF%A2-brightgreen"/>
|
||||
</a>
|
||||
<a target="_blank" href="https://jq.qq.com/?_wv=1027&k=qRTKHWY0">
|
||||
<img alt="点击加入QQ交流群" src="https://img.shields.io/badge/QQ%E4%BA%A4%E6%B5%81%E7%BE%A4-945342113-ff69b4"/>
|
||||
<a target="_blank" href="#">
|
||||
<img alt="点击加入QQ交流①群(满)" src="https://img.shields.io/badge/QQ%E4%BA%A4%E6%B5%81%E7%BE%A4-945342113(满)-ff69b4"/>
|
||||
</a>
|
||||
<a target="_blank" href="https://jq.qq.com/?_wv=1027&k=cCiv8Vlv">
|
||||
<img alt="点击加入QQ交流②群" src="https://img.shields.io/badge/QQ%E4%BA%A4%E6%B5%81%E7%BE%A4-549174561-ff69b4"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
@@ -42,46 +45,33 @@ Starter,支持微信优惠券,代金券、商家券、智慧商圈、商家
|
||||
<dependency>
|
||||
<groupId>cn.felord</groupId>
|
||||
<artifactId>payment-spring-boot-starter</artifactId>
|
||||
<version>1.0.17.RELEASE</version>
|
||||
<version>1.0.19.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## JDK问题
|
||||
|
||||
**推荐使用Open JDK**,原因参见[FBI Warning](https://github.com/NotFound403/payment-spring-boot/issues/5)
|
||||
**推荐使用Open JDK**,原因参见[FBI Warning](https://github.com/dromara/payment-spring-boot/issues/5)
|
||||
|
||||
## 文档地址
|
||||
|
||||
- [payment-spring-boot GitHub文档](https://notfound403.github.io/payment-spring-boot)
|
||||
|
||||
## 目前已经实现所有服务商和直连商户接口
|
||||
|
||||
- 实现微信支付多商户
|
||||
- 集成支付宝SDK、快速接入Spring Boot
|
||||
- 实现微信支付V3 基础支付
|
||||
- 实现微信支付V3 合单支付
|
||||
- 实现微信支付V3 代金券
|
||||
- 实现微信支付V3 微信支付分
|
||||
- 实现微信支付V3 先享卡
|
||||
- 实现微信支付V3 商家券
|
||||
- 实现微信支付V3 批量转账到零钱
|
||||
|
||||
更新日志参考[changelog](https://notfound403.github.io/payment-spring-boot/#/changelog)
|
||||
- [payment-spring-boot GitHub文档](https://dromara.github.io/payment-spring-boot)
|
||||
|
||||
## API清单
|
||||
|
||||
API结构如下:
|
||||

|
||||
具体分为**直连商户**和**服务商**两个体系,请详细阅读文档说明
|
||||
目前已经实现绝大部分微信支付直连商户和服务商的接口,具体的API明细可查看[API清单](https://dromara.github.io/payment-spring-boot/#/wechat_v3_api)
|
||||
> 随着版本迭代功能会增加,也可通过API注册表类`WechatPayV3Type`进行API接口检索。
|
||||
|
||||
> 随着版本迭代功能会增加,可通过API注册表类`WechatPayV3Type`进行API接口检索。
|
||||
## CHANGELOG
|
||||
|
||||
更新日志[CHANGELOG](https://dromara.github.io/payment-spring-boot/#/changelog)
|
||||
|
||||
## 使用入门
|
||||
|
||||
### 集成配置
|
||||
|
||||
关于集成配置请详细阅读[payment-spring-boot GitHub文档](https://notfound403.github.io/payment-spring-boot)
|
||||
中[快速接入](https://notfound403.github.io/payment-spring-boot/#/quick_start)章节
|
||||
关于集成配置请详细阅读[payment-spring-boot GitHub文档](https://dromara.github.io/payment-spring-boot)
|
||||
中[快速接入](https://dromara.github.io/payment-spring-boot/#/quick_start)章节
|
||||
|
||||
### 调用示例
|
||||
|
||||
@@ -360,11 +350,6 @@ public class CallbackController {
|
||||
|
||||
## 仓库地址
|
||||
|
||||
- [GitHub](https://github.com/NotFound403/payment-spring-boot)
|
||||
- [Gitee](https://gitee.com/felord/payment-spring-boot)
|
||||
|
||||
## QQ交流群
|
||||
|
||||
为了交流解惑,新建QQ群,可通过扫码进入。
|
||||
|
||||

|
||||
- [GitHub](https://github.com/dromara/payment-spring-boot)
|
||||
- [Gitee](https://gitee.com/dromara/payment-spring-boot)
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<dependency>
|
||||
<groupId>cn.felord</groupId>
|
||||
<artifactId>payment-spring-boot-starter</artifactId>
|
||||
<version>1.0.17.RELEASE</version>
|
||||
<version>1.0.19.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
## 采用技术
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
## 1.0.18.RELEASE
|
||||
### 微信支付
|
||||
|
||||
- enhance: 使用`ResourceLoader`加载资源以改善Docker容器环境下的文件挂载问题
|
||||
- enhance: 修改了微信支付配置加载机制,现在可以借助于`WechatTenantService`实现不停机维护微信支付参数的能力
|
||||
- factor: 移除过时的V2退款API相关参数`RefundModel`和`RefundQueryModel`
|
||||
- docs: 更新文档地址到[dromara.org](https://gitee.com/dromara),现在你可以通过[https://dromara.org/payment-spring-boot/](https://dromara.org/payment-spring-boot/)访问项目文档
|
||||
- docs: 修正文档描述错误
|
||||
|
||||
## 1.0.17.RELEASE
|
||||
### 微信支付
|
||||
- feat: 直连商户合单支付增加查询单笔退款
|
||||
- feat: 支付分增加退款独立的API
|
||||
- factor: 营销图片上传API现在由WechatMediaApi#marketingImageUpload实现,以代替WechatMarketingFavorApi#marketingImageUpload,旧实现已标记为过时
|
||||
- factor:时间格式优化,移除时区限制为东八区,由LocalDateTime改为OffsetDateTime
|
||||
- docs: 现在可以通过API清单检索API了
|
||||
|
||||
## 1.0.16.RELEASE
|
||||
### 微信支付
|
||||
- feat: 直连商户-委托营销相关API实现
|
||||
@@ -186,4 +203,4 @@
|
||||
- 多租户
|
||||
- 支付宝
|
||||
- 仅仅引入支付宝SDK,后续维护以支付宝SDK变动为准
|
||||
- 支付宝暂时不支持多租户
|
||||
- 支付宝暂时不支持多租户
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<dependency>
|
||||
<groupId>cn.felord</groupId>
|
||||
<artifactId>payment-spring-boot-starter</artifactId>
|
||||
<version>1.0.17.RELEASE</version>
|
||||
<version>1.0.19.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
> 基于 **Spring Boot 2.x**
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#### 基础支付
|
||||
|
||||
- [x] `WechatDirectPayApi` 基础支付,通过`WechatApiProvider#directPayApi`初始化
|
||||
- [x] `jsPay` APP下单
|
||||
- [x] `appPay` JSAPI/小程序下单
|
||||
- [x] `jsPay` JSAPI/小程序下单
|
||||
- [x] `appPay` APP下单
|
||||
- [x] `h5Pay` H5下单
|
||||
- [x] `nativePay` Native下单
|
||||
- [x] 查询订单
|
||||
@@ -25,8 +25,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` 查询订单,**合单支付目前只支持商户订单号查询**
|
||||
@@ -153,7 +153,15 @@
|
||||
|
||||
##### 支付有礼
|
||||
|
||||
- [ ] 功能实现中……
|
||||
- [x] `WechatMarketingPayGiftActivityApi` 支付有礼,通过`WechatApiProvider#marketingPayGiftActivityApi`初始化
|
||||
- [x] `create` 创建全场满额送活动
|
||||
- [x] `details` 查询活动详情接口
|
||||
- [x] `merchants` 查询活动发券商户号
|
||||
- [x] `goods` 查询活动指定商品列表
|
||||
- [x] `terminate` 终止活动
|
||||
- [x] `addMches` 新增活动发券商户号
|
||||
- [x] `page` 获取支付有礼活动列表
|
||||
- [x] `deleteMch` 删除活动发券商户号
|
||||
|
||||
##### 图片上传(营销专用)
|
||||
|
||||
@@ -186,9 +194,6 @@
|
||||
- [x] 申请转账明细电子回单
|
||||
1. `transferElectronic` 受理转账明细电子回单
|
||||
2. `queryTransferElectronicResult` 查询转账账单电子回单接口
|
||||
- [x] 申请转账电子回单
|
||||
1. `` 转账账单电子回单申请受理接口
|
||||
2. `` 查询转账账单电子回单接口
|
||||
|
||||
##### 分账
|
||||
|
||||
@@ -224,4 +229,8 @@
|
||||
- [x] `mediaVideoUpload` 视频上传
|
||||
- [x] `marketingImageUpload` 营销图片上传
|
||||
|
||||
> 通过营销**图片上传API**上传图片后可获得图片url地址。图片url可在微信支付营销相关的API使用,包括商家券、代金券、支付有礼等。
|
||||
> 通过营销**图片上传API**上传图片后可获得图片url地址。图片url可在微信支付营销相关的API使用,包括商家券、代金券、支付有礼等。
|
||||
|
||||
### 服务商
|
||||
|
||||
施工中……
|
||||
@@ -22,11 +22,11 @@
|
||||
<parent>
|
||||
<groupId>cn.felord</groupId>
|
||||
<artifactId>payment-spring-boot</artifactId>
|
||||
<version>1.0.17.RELEASE</version>
|
||||
<version>1.0.19.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>payment-spring-boot-autoconfigure</artifactId>
|
||||
<version>1.0.17.RELEASE</version>
|
||||
<version>1.0.19.RELEASE</version>
|
||||
<packaging>jar</packaging>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -64,6 +64,42 @@
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.retrofit2</groupId>
|
||||
<artifactId>retrofit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.retrofit2</groupId>
|
||||
<artifactId>adapter-rxjava3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.retrofit2</groupId>
|
||||
<artifactId>converter-jaxb</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.retrofit2</groupId>
|
||||
<artifactId>converter-jackson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>logging-interceptor</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15to18</artifactId>
|
||||
|
||||
@@ -20,10 +20,13 @@ 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.CollectionUtils;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -31,32 +34,39 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 从配置文件中加载租户信息,默认实现,可被覆盖
|
||||
*
|
||||
* @author xiafang
|
||||
* @author dax
|
||||
* @since 2023/2/3 11:40
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
public class InMemoryWechatTenantService implements WechatTenantService {
|
||||
private final WechatPayProperties wechatPayProperties;
|
||||
private final ResourceLoader resourceLoader;
|
||||
private final Set<WechatMetaBean> cache = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public Set<WechatMetaBean> loadTenants() {
|
||||
Map<String, WechatPayProperties.V3> v3Map = wechatPayProperties.getV3();
|
||||
KeyPairFactory keyPairFactory = new KeyPairFactory();
|
||||
return v3Map.entrySet()
|
||||
.stream()
|
||||
.map(entry -> {
|
||||
WechatPayProperties.V3 v3 = entry.getValue();
|
||||
String tenantId = entry.getKey();
|
||||
String certPath = v3.getCertPath();
|
||||
String certAbsolutePath = v3.getCertAbsolutePath();
|
||||
String mchId = v3.getMchId();
|
||||
Resource resource = certAbsolutePath != null ? new FileSystemResource(certAbsolutePath) :
|
||||
new ClassPathResource(certPath == null ? "wechat/apiclient_cert.p12" : certPath);
|
||||
WechatMetaBean wechatMetaBean = keyPairFactory.initWechatMetaBean(resource, mchId);
|
||||
wechatMetaBean.setV3(v3);
|
||||
wechatMetaBean.setTenantId(tenantId);
|
||||
return wechatMetaBean;
|
||||
})
|
||||
.collect(Collectors.toSet());
|
||||
if (CollectionUtils.isEmpty(cache)) {
|
||||
Map<String, WechatPayProperties.V3> v3Map = wechatPayProperties.getV3();
|
||||
KeyPairFactory keyPairFactory = new KeyPairFactory();
|
||||
Set<WechatMetaBean> beans = v3Map.entrySet()
|
||||
.stream()
|
||||
.map(entry -> {
|
||||
WechatPayProperties.V3 v3 = entry.getValue();
|
||||
String tenantId = entry.getKey();
|
||||
String certPath = v3.getCertPath();
|
||||
String certAbsolutePath = v3.getCertAbsolutePath();
|
||||
String mchId = v3.getMchId();
|
||||
Resource resource = certAbsolutePath != null ? new FileSystemResource(certAbsolutePath) :
|
||||
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);
|
||||
return wechatMetaBean;
|
||||
})
|
||||
.collect(Collectors.toSet());
|
||||
cache.addAll(beans);
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.enumeration;
|
||||
|
||||
/**
|
||||
* The enum Activity status.
|
||||
*
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
public enum ActivityStatus {
|
||||
/**
|
||||
* 状态未知
|
||||
*/
|
||||
ACT_STATUS_UNKNOWN,
|
||||
/**
|
||||
* 已创建
|
||||
*/
|
||||
CREATE_ACT_STATUS,
|
||||
/**
|
||||
* 运行中
|
||||
*/
|
||||
ONGOING_ACT_STATUS,
|
||||
/**
|
||||
* 已终止
|
||||
*/
|
||||
TERMINATE_ACT_STATUS,
|
||||
|
||||
/**
|
||||
* 已暂停
|
||||
*/
|
||||
STOP_ACT_STATUS,
|
||||
|
||||
/**
|
||||
* 已过期
|
||||
*/
|
||||
OVER_TIME_ACT_STATUS,
|
||||
|
||||
/**
|
||||
* 创建活动失败
|
||||
*/
|
||||
CREATE_ACT_FAILED
|
||||
}
|
||||
@@ -15,11 +15,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.felord.payment.wechat.v2.model;
|
||||
package cn.felord.payment.wechat.enumeration;
|
||||
|
||||
/**
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
* The enum Award type.
|
||||
*
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
public class RefundQueryModel {
|
||||
public enum AwardType {
|
||||
/**
|
||||
* 商家券
|
||||
*/
|
||||
BUSIFAVOR
|
||||
}
|
||||
@@ -28,41 +28,57 @@ public enum CouponBgColor {
|
||||
/**
|
||||
* Color 010 coupon bg color.
|
||||
*/
|
||||
COLOR010,
|
||||
COLOR010("Color010"),
|
||||
/**
|
||||
* COLOR 020 coupon bg color.
|
||||
*/
|
||||
COLOR020,
|
||||
COLOR020("Color010"),
|
||||
/**
|
||||
* COLOR 030 coupon bg color.
|
||||
*/
|
||||
COLOR030,
|
||||
COLOR030("Color010"),
|
||||
/**
|
||||
* COLOR 040 coupon bg color.
|
||||
*/
|
||||
COLOR040,
|
||||
COLOR040("Color010"),
|
||||
/**
|
||||
* COLOR 050 coupon bg color.
|
||||
*/
|
||||
COLOR050,
|
||||
COLOR050("Color010"),
|
||||
/**
|
||||
* COLOR 060 coupon bg color.
|
||||
*/
|
||||
COLOR060,
|
||||
COLOR060("Color010"),
|
||||
/**
|
||||
* COLOR 070 coupon bg color.
|
||||
*/
|
||||
COLOR070,
|
||||
COLOR070("Color010"),
|
||||
/**
|
||||
* COLOR 080 coupon bg color.
|
||||
*/
|
||||
COLOR080,
|
||||
COLOR080("Color010"),
|
||||
/**
|
||||
* COLOR 090 coupon bg color.
|
||||
*/
|
||||
COLOR090,
|
||||
COLOR090("Color010"),
|
||||
/**
|
||||
* COLOR 100 coupon bg color.
|
||||
*/
|
||||
COLOR100
|
||||
COLOR100("Color010");
|
||||
|
||||
|
||||
private final String value;
|
||||
|
||||
CouponBgColor(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets value.
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.enumeration;
|
||||
|
||||
/**
|
||||
* The enum Delivery purpose.
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
public enum DeliveryPurpose {
|
||||
/**
|
||||
* 拉用户回店消费
|
||||
*/
|
||||
OFF_LINE_PAY,
|
||||
/**
|
||||
* 引导用户前往小程序消费
|
||||
*/
|
||||
JUMP_MINI_APP
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.enumeration;
|
||||
|
||||
/**
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
public enum DeliveryUserCategory {
|
||||
/**
|
||||
* 所有用户
|
||||
*/
|
||||
DELIVERY_ALL_PERSON,
|
||||
/**
|
||||
* 会员用户
|
||||
*/
|
||||
DELIVERY_MEMBER_PERSON
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.enumeration;
|
||||
|
||||
/**
|
||||
* The enum Send content.
|
||||
*
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
public enum SendContent {
|
||||
/**
|
||||
* 单张券
|
||||
*/
|
||||
SINGLE_COUPON,
|
||||
/**
|
||||
* 礼包
|
||||
*/
|
||||
GIFT_PACKAGE
|
||||
}
|
||||
@@ -20,7 +20,7 @@ package cn.felord.payment.wechat.enumeration;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author xiafang
|
||||
* @author dax
|
||||
* @since 2023/2/1 8:59
|
||||
*/
|
||||
@Getter
|
||||
|
||||
@@ -507,6 +507,55 @@ public enum WechatPayV3Type {
|
||||
*/
|
||||
MARKETING_PARTNERSHIPS_GET(HttpMethod.GET, "%s/v3/marketing/partnerships"),
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* 创建全场满额送活动API
|
||||
*
|
||||
* @since 1.0.19.RELEASES
|
||||
*/
|
||||
MARKETING_PAYGIFTACTIVITY(HttpMethod.POST, "%s/v3/marketing/paygiftactivity/unique-threshold-activity"),
|
||||
/**
|
||||
* 查询活动详情接口API
|
||||
*
|
||||
* @since 1.0.19.RELEASES
|
||||
*/
|
||||
MARKETING_PAYGIFTACTIVITY_DETAIL(HttpMethod.GET, "%s/v3/marketing/paygiftactivity/activities/{activity_id}"),
|
||||
/**
|
||||
* 查询活动发券商户号API
|
||||
*
|
||||
* @since 1.0.19.RELEASES
|
||||
*/
|
||||
MARKETING_PAYGIFTACTIVITY_MCH(HttpMethod.GET, "%s/v3/marketing/paygiftactivity/activities/{activity_id}/merchants"),
|
||||
/**
|
||||
* 查询活动指定商品列表API
|
||||
*
|
||||
* @since 1.0.19.RELEASES
|
||||
*/
|
||||
MARKETING_PAYGIFTACTIVITY_GOODS(HttpMethod.GET, "%s/v3/marketing/paygiftactivity/activities/{activity_id}/goods"),
|
||||
/**
|
||||
* 终止活动API
|
||||
*
|
||||
* @since 1.0.19.RELEASES
|
||||
*/
|
||||
MARKETING_PAYGIFTACTIVITY_TERMINATE(HttpMethod.POST, "%s/v3/marketing/paygiftactivity/activities/{activity_id}/terminate"),
|
||||
/**
|
||||
* 新增活动发券商户号API
|
||||
*
|
||||
* @since 1.0.19.RELEASES
|
||||
*/
|
||||
MARKETING_PAYGIFTACTIVITY_MCH_ADD(HttpMethod.POST, "%s/v3/marketing/paygiftactivity/activities/{activity_id}/merchants/add"),
|
||||
/**
|
||||
* 获取支付有礼活动列表API
|
||||
*
|
||||
* @since 1.0.19.RELEASES
|
||||
*/
|
||||
MARKETING_PAYGIFTACTIVITY_ACTIVITIES(HttpMethod.GET, "%s/v3/marketing/paygiftactivity/activities"),
|
||||
/**
|
||||
* 删除活动发券商户号API
|
||||
*
|
||||
* @since 1.0.19.RELEASES
|
||||
*/
|
||||
MARKETING_PAYGIFTACTIVITY_MCH_DEL(HttpMethod.POST, "%s/v3/marketing/paygiftactivity/activities/{activity_id}/merchants/delete"),
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* 发起批量转账API.
|
||||
|
||||
@@ -73,7 +73,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Getter
|
||||
public abstract class BaseModel {
|
||||
public static final String HMAC_SHA256="HMAC-SHA256";
|
||||
public static final String HMAC_SHA256 = "HMAC-SHA256";
|
||||
private static final XmlMapper XML_MAPPER = new XmlMapper();
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
||||
@@ -84,8 +84,7 @@ public abstract class BaseModel {
|
||||
.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
|
||||
OBJECT_MAPPER
|
||||
// .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +164,7 @@ public abstract class BaseModel {
|
||||
@SneakyThrows
|
||||
private String hmacSha256(String src) {
|
||||
String algorithm = "HmacSHA256";
|
||||
Mac sha256HMAC = Mac.getInstance(algorithm,"BC");
|
||||
Mac sha256HMAC = Mac.getInstance(algorithm, "BC");
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(appSecret.getBytes(), algorithm);
|
||||
sha256HMAC.init(secretKeySpec);
|
||||
byte[] bytes = sha256HMAC.doFinal(src.getBytes(StandardCharsets.UTF_8));
|
||||
@@ -182,7 +181,7 @@ public abstract class BaseModel {
|
||||
@SneakyThrows
|
||||
private <T> String link(T t) {
|
||||
Assert.hasText(appSecret, "wechat pay appSecret is required");
|
||||
String json = OBJECT_MAPPER
|
||||
String json = OBJECT_MAPPER
|
||||
.writeValueAsString(t);
|
||||
|
||||
TreeMap<String, String> map = OBJECT_MAPPER.readValue(json, new TypeReference<TreeMap<String, String>>() {
|
||||
@@ -200,8 +199,8 @@ public abstract class BaseModel {
|
||||
public JsonNode request(String mchId, HttpMethod method, String url) {
|
||||
String xml = this.xml();
|
||||
RequestEntity<String> body = RequestEntity.method(method, UriComponentsBuilder.fromHttpUrl(url)
|
||||
.build()
|
||||
.toUri())
|
||||
.build()
|
||||
.toUri())
|
||||
.contentType(MediaType.valueOf("application/x-www-form-urlencoded;charset=UTF-8"))
|
||||
.body(xml);
|
||||
ResponseEntity<String> responseEntity = this.getRestTemplateClientAuthentication(mchId)
|
||||
|
||||
@@ -27,11 +27,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter;
|
||||
import org.springframework.util.AlternativeJdkIdGenerator;
|
||||
@@ -54,8 +50,7 @@ import java.security.cert.Certificate;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -135,7 +130,7 @@ public class SignatureProvider {
|
||||
@SneakyThrows
|
||||
public String requestSign(String tenantId, String method, String canonicalUrl, String body) {
|
||||
|
||||
long timestamp = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"));
|
||||
long timestamp = Instant.now().getEpochSecond();
|
||||
String nonceStr = nonceStrGenerator.generateId()
|
||||
.toString()
|
||||
.replaceAll("-", "");
|
||||
@@ -175,7 +170,6 @@ public class SignatureProvider {
|
||||
* @param params the params
|
||||
* @return the boolean
|
||||
*/
|
||||
@SneakyThrows
|
||||
public boolean responseSignVerify(ResponseSignVerifyParams params) {
|
||||
|
||||
String wechatpaySerial = params.getWechatpaySerial();
|
||||
@@ -190,13 +184,15 @@ public class SignatureProvider {
|
||||
.orElseThrow(() -> new PayException("cannot obtain the certificate"));
|
||||
});
|
||||
|
||||
|
||||
final String signatureStr = createSign(params.getWechatpayTimestamp(), params.getWechatpayNonce(), params.getBody());
|
||||
Signature signer = Signature.getInstance("SHA256withRSA", BC_PROVIDER);
|
||||
signer.initVerify(certificate.getX509Certificate());
|
||||
signer.update(signatureStr.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
return signer.verify(Base64Utils.decodeFromString(params.getWechatpaySignature()));
|
||||
try {
|
||||
final String signatureStr = createSign(params.getWechatpayTimestamp(), params.getWechatpayNonce(), params.getBody());
|
||||
Signature signer = Signature.getInstance("SHA256withRSA", BC_PROVIDER);
|
||||
signer.initVerify(certificate.getX509Certificate());
|
||||
signer.update(signatureStr.getBytes(StandardCharsets.UTF_8));
|
||||
return signer.verify(Base64Utils.decodeFromString(params.getWechatpaySignature()));
|
||||
}catch (Exception e){
|
||||
throw new PayException("An exception occurred during the response verification, the cause: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -140,6 +140,17 @@ public class WechatApiProvider {
|
||||
return new WechatMarketingPartnershipApi(this.wechatPayClient, tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付有礼-直连商户
|
||||
*
|
||||
* @param tenantId the tenant id
|
||||
* @return the wechat marketing pay gift activity api
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
public WechatMarketingPayGiftActivityApi marketingPayGiftActivityApi(String tenantId) {
|
||||
return new WechatMarketingPayGiftActivityApi(this.wechatPayClient, tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量转账到零钱.
|
||||
* <p>
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* 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.v3;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.WeChatServer;
|
||||
import cn.felord.payment.wechat.enumeration.WechatPayV3Type;
|
||||
import cn.felord.payment.wechat.v3.model.paygiftactivity.ActivitiesListPageRequest;
|
||||
import cn.felord.payment.wechat.v3.model.paygiftactivity.ActivitiesPageRequest;
|
||||
import cn.felord.payment.wechat.v3.model.paygiftactivity.DeleteActivityMchRequest;
|
||||
import cn.felord.payment.wechat.v3.model.paygiftactivity.GiftActivityParams;
|
||||
import cn.felord.payment.wechat.v3.model.paygiftactivity.NewActivityMchRequest;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付有礼
|
||||
*
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
public class WechatMarketingPayGiftActivityApi extends AbstractApi {
|
||||
/**
|
||||
* Instantiates a new Abstract api.
|
||||
*
|
||||
* @param wechatPayClient the wechat pay client
|
||||
* @param tenantId the tenant id
|
||||
*/
|
||||
public WechatMarketingPayGiftActivityApi(WechatPayClient wechatPayClient, String tenantId) {
|
||||
super(wechatPayClient, tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建全场满额送活动API
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> create(GiftActivityParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY, params)
|
||||
.function((type, activityParams) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
return Post(uri, activityParams);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询活动详情接口API
|
||||
*
|
||||
* @param activityId the activity id
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> details(String activityId) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY_DETAIL, activityId)
|
||||
.function((type, param) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.expand(param)
|
||||
.toUri();
|
||||
return Get(uri);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询活动发券商户号API
|
||||
*
|
||||
* @param request the request
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> merchants(ActivitiesPageRequest request) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY_MCH, request)
|
||||
.function((type, params) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.queryParam("offset", params.getOffset())
|
||||
.queryParam("limit", params.getLimit())
|
||||
.build()
|
||||
.expand(params.getActivityId())
|
||||
.toUri();
|
||||
return Get(uri);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询活动指定商品列表API
|
||||
*
|
||||
* @param request the request
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> goods(ActivitiesPageRequest request) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY_GOODS, request)
|
||||
.function((type, params) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.queryParam("offset", params.getOffset())
|
||||
.queryParam("limit", params.getLimit())
|
||||
.build()
|
||||
.expand(params.getActivityId())
|
||||
.toUri();
|
||||
return Get(uri);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 终止活动API
|
||||
*
|
||||
* @param activityId the activity id
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> terminate(String activityId) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY_TERMINATE, activityId)
|
||||
.function((type, param) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.expand(param)
|
||||
.toUri();
|
||||
return Post(uri, Collections.emptyMap());
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增活动发券商户号API
|
||||
*
|
||||
* @param request the request
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> addMches(NewActivityMchRequest request) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY_MCH_ADD, request)
|
||||
.function((type, params) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.expand(params.getActivityId())
|
||||
.toUri();
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("merchant_id_list", params.getMerchantIdList());
|
||||
body.put("add_request_no", params.getAddRequestNo());
|
||||
return Post(uri, body);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付有礼活动列表API
|
||||
*
|
||||
* @param request the request
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> page(ActivitiesListPageRequest request) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY_ACTIVITIES, request)
|
||||
.function((type, params) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.queryParam("offset", params.getOffset())
|
||||
.queryParam("limit", params.getLimit())
|
||||
.queryParam("activity_name", params.getActivityName())
|
||||
.queryParam("activity_status", params.getActivityStatus())
|
||||
.queryParam("award_type", params.getAwardType())
|
||||
.build()
|
||||
.toUri();
|
||||
return Get(uri);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除活动发券商户号API
|
||||
*
|
||||
* @param request the request
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> deleteMch(DeleteActivityMchRequest request) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY_MCH_DEL, request)
|
||||
.function((type, params) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.expand(params.getActivityId())
|
||||
.toUri();
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("merchant_id_list", params.getMerchantIdList());
|
||||
body.put("delete_request_no", params.getDeleteRequestNo());
|
||||
return Post(uri, body);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,15 @@
|
||||
package cn.felord.payment.wechat.v3;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import cn.felord.payment.wechat.WechatTenantService;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 配置容器
|
||||
@@ -27,10 +33,10 @@ 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.
|
||||
@@ -43,22 +49,9 @@ public class WechatMetaContainer {
|
||||
|
||||
private void addMeta(WechatMetaBean wechatMetaBean) {
|
||||
String tenantId = wechatMetaBean.getTenantId();
|
||||
tenantIds.add(tenantId);
|
||||
wechatMetaBeanMap.put(tenantId, wechatMetaBean);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove wechat meta wechat meta bean.
|
||||
*
|
||||
* @param tenantId the tenantId
|
||||
* @return the wechat meta bean
|
||||
*/
|
||||
public WechatMetaBean removeWechatMeta(String tenantId) {
|
||||
tenantIds.remove(tenantId);
|
||||
return this.wechatMetaBeanMap.remove(tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets wechat meta.
|
||||
*
|
||||
@@ -66,7 +59,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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,6 +75,9 @@ public class WechatMetaContainer {
|
||||
* @return the properties keys
|
||||
*/
|
||||
public Set<String> getTenantIds() {
|
||||
return tenantIds;
|
||||
return wechatTenantService.loadTenants()
|
||||
.stream()
|
||||
.map(WechatMetaBean::getTenantId)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class WechatPartnerPayApi extends AbstractApi {
|
||||
WechatMetaBean wechatMetaBean = wechatMetaContainer.getWechatMeta(tenantId());
|
||||
PrivateKey privateKey = wechatMetaBean.getKeyPair().getPrivate();
|
||||
|
||||
String subAppid = partnerPayParams.getSubAppid();
|
||||
String spAppid = partnerPayParams.getSpAppid();
|
||||
long epochSecond = LocalDateTime.now()
|
||||
.toEpochSecond(ZoneOffset.of("+8"));
|
||||
String timestamp = String.valueOf(epochSecond);
|
||||
@@ -89,9 +89,8 @@ public class WechatPartnerPayApi extends AbstractApi {
|
||||
.toString()
|
||||
.replaceAll("-", "");
|
||||
String prepayId = body.get("prepay_id").asText();
|
||||
String paySign = signatureProvider.doRequestSign(privateKey, subAppid, timestamp, nonceStr, prepayId);
|
||||
|
||||
body.put("appid", subAppid);
|
||||
String paySign = signatureProvider.doRequestSign(privateKey, spAppid, timestamp, nonceStr, prepayId);
|
||||
body.put("appid", spAppid);
|
||||
body.put("partnerid", partnerPayParams.getSubMchid());
|
||||
body.put("prepayid", prepayId);
|
||||
body.put("package", "Sign=WXPay");
|
||||
@@ -129,7 +128,7 @@ public class WechatPartnerPayApi extends AbstractApi {
|
||||
WechatMetaBean wechatMetaBean = wechatMetaContainer.getWechatMeta(tenantId());
|
||||
PrivateKey privateKey = wechatMetaBean.getKeyPair().getPrivate();
|
||||
|
||||
String subAppid = partnerPayParams.getSubAppid();
|
||||
String spAppid = partnerPayParams.getSpAppid();
|
||||
long epochSecond = LocalDateTime.now()
|
||||
.toEpochSecond(ZoneOffset.of("+8"));
|
||||
String timestamp = String.valueOf(epochSecond);
|
||||
@@ -138,9 +137,8 @@ public class WechatPartnerPayApi extends AbstractApi {
|
||||
.toString()
|
||||
.replaceAll("-", "");
|
||||
String packageStr = "prepay_id=" + body.get("prepay_id").asText();
|
||||
String paySign = signatureProvider.doRequestSign(privateKey, subAppid, timestamp, nonceStr, packageStr);
|
||||
|
||||
body.put("appId", subAppid);
|
||||
String paySign = signatureProvider.doRequestSign(privateKey, spAppid, timestamp, nonceStr, packageStr);
|
||||
body.put("appid", spAppid);
|
||||
body.put("timeStamp", timestamp);
|
||||
body.put("nonceStr", nonceStr);
|
||||
body.put("package", packageStr);
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* 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.v3.client;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import okhttp3.ConnectionPool;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
|
||||
import retrofit2.converter.jackson.JacksonConverterFactory;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* The type Retrofit factory.
|
||||
*
|
||||
* @author dax
|
||||
* @since 2023 /5/21
|
||||
*/
|
||||
public final class RetrofitFactory {
|
||||
|
||||
/**
|
||||
* The constant JACKSON_CONVERTER_FACTORY.
|
||||
*/
|
||||
public static final JacksonConverterFactory JACKSON_CONVERTER_FACTORY = JacksonConverterFactoryBuilder.build();
|
||||
|
||||
/**
|
||||
* Create retrofit.
|
||||
*
|
||||
* @param baseUrl the base url
|
||||
* @return the retrofit
|
||||
*/
|
||||
public static Retrofit create(String baseUrl) {
|
||||
return create(baseUrl, new ConnectionPool());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create retrofit.
|
||||
*
|
||||
* @param baseUrl the base url
|
||||
* @param connectionPool the connection pool
|
||||
* @return the retrofit
|
||||
*/
|
||||
public static Retrofit create(String baseUrl, ConnectionPool connectionPool) {
|
||||
return create(baseUrl, connectionPool, HttpLoggingInterceptor.Level.NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create retrofit.
|
||||
*
|
||||
* @param baseUrl the base url
|
||||
* @param connectionPool the connection pool
|
||||
* @param level the level
|
||||
* @return the retrofit
|
||||
*/
|
||||
public static Retrofit create(String baseUrl, ConnectionPool connectionPool, HttpLoggingInterceptor.Level level) {
|
||||
return new Retrofit.Builder()
|
||||
.baseUrl(baseUrl)
|
||||
.client(okHttpClient(connectionPool, level))
|
||||
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
||||
.addConverterFactory(JACKSON_CONVERTER_FACTORY)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static OkHttpClient okHttpClient(ConnectionPool connectionPool, HttpLoggingInterceptor.Level level) {
|
||||
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
|
||||
httpLoggingInterceptor.level(level);
|
||||
return new OkHttpClient.Builder()
|
||||
.connectionPool(connectionPool)
|
||||
.addInterceptor(httpLoggingInterceptor)
|
||||
.retryOnConnectionFailure(true)
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.writeTimeout(30, TimeUnit.SECONDS)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The type Jackson converter factory builder.
|
||||
*/
|
||||
static final class JacksonConverterFactoryBuilder {
|
||||
private JacksonConverterFactoryBuilder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build jackson converter factory.
|
||||
*
|
||||
* @return the jackson converter factory
|
||||
*/
|
||||
public static JacksonConverterFactory build() {
|
||||
ObjectMapper objectMapper = new ObjectMapper().setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
// empty string error
|
||||
.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true)
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.registerModule(new JavaTimeModule());
|
||||
return JacksonConverterFactory.create(objectMapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class PatternInfo {
|
||||
/**
|
||||
* 背景色
|
||||
*/
|
||||
private CouponBgColor backgroundColor;
|
||||
private String backgroundColor;
|
||||
/**
|
||||
* 券详情图片
|
||||
*/
|
||||
@@ -49,4 +49,16 @@ public class PatternInfo {
|
||||
*/
|
||||
private String merchantName;
|
||||
|
||||
/**
|
||||
* Sets background color.
|
||||
*
|
||||
* @param backgroundColor the background color
|
||||
*/
|
||||
public void setBackgroundColor(CouponBgColor backgroundColor) {
|
||||
this.backgroundColor = backgroundColor.name();
|
||||
}
|
||||
|
||||
private void setBackgroundColor(String backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package cn.felord.payment.wechat.v3.model.busifavor;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.CouponBgColor;
|
||||
import cn.felord.payment.wechat.v3.WechatMarketingFavorApi;
|
||||
import cn.felord.payment.wechat.v3.WechatMediaApi;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class DisplayPatternInfo {
|
||||
/**
|
||||
* 背景颜色
|
||||
*/
|
||||
private CouponBgColor backgroundColor;
|
||||
private String backgroundColor;
|
||||
/**
|
||||
* 商户logo
|
||||
* <ol>
|
||||
@@ -42,7 +42,7 @@ public class DisplayPatternInfo {
|
||||
* </ol>
|
||||
* 仅支持通过 <a target= "_blank" href= "https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/marketing/chapter3_1.shtml">图片上传API</a> 接口获取的图片URL地址。
|
||||
*
|
||||
* @see WechatMarketingFavorApi#marketingImageUpload(MultipartFile)
|
||||
* @see WechatMediaApi#marketingImageUpload(MultipartFile)
|
||||
*/
|
||||
private String merchantLogoUrl;
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ public class DisplayPatternInfo {
|
||||
* </ol>
|
||||
* 仅支持通过 <a target= "_blank" href= "https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/marketing/chapter3_1.shtml">图片上传API</a> 接口获取的图片URL地址。
|
||||
*
|
||||
* @see WechatMarketingFavorApi#marketingImageUpload(MultipartFile)
|
||||
* @see WechatMediaApi#marketingImageUpload(MultipartFile)
|
||||
*/
|
||||
private String couponImageUrl;
|
||||
/**
|
||||
@@ -69,4 +69,17 @@ public class DisplayPatternInfo {
|
||||
* 商户名称,字数上限为16个
|
||||
*/
|
||||
private String merchantName;
|
||||
|
||||
/**
|
||||
* Sets background color.
|
||||
*
|
||||
* @param backgroundColor the background color
|
||||
*/
|
||||
public void setBackgroundColor(CouponBgColor backgroundColor) {
|
||||
this.backgroundColor = backgroundColor.getValue();
|
||||
}
|
||||
|
||||
private void setBackgroundColor(String backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,9 @@ import cn.felord.payment.wechat.enumeration.ContactType;
|
||||
import cn.felord.payment.wechat.enumeration.IdDocType;
|
||||
import cn.felord.payment.wechat.v3.model.specmch.FinanceInstitutionInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 二级商户进件申请API请求参数
|
||||
*
|
||||
@@ -41,6 +44,7 @@ public class EcommerceApplymentParams{
|
||||
private Boolean owner;
|
||||
private UboInfo uboInfo;
|
||||
private Boolean needAccountInfo;
|
||||
private List<UboInfoListItem> uboInfoList;
|
||||
private EcommerceAccountInfo accountInfo;
|
||||
private EcommerceContactInfo contactInfo;
|
||||
private SalesSceneInfo salesSceneInfo;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.v3.model.ecommerce;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.IdDocType;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
public class UboInfoListItem {
|
||||
private IdDocType uboIdDocType;
|
||||
private String uboIdDocCopy;
|
||||
private String uboIdDocCopyBack;
|
||||
private String uboIdDocName;
|
||||
private String uboIdDocNumber;
|
||||
private String uboIdDocAddress;
|
||||
private LocalDate uboIdDocPeriodBegin;
|
||||
private LocalDate uboIdDocPeriodEnd;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.v3.model.paygiftactivity;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.ActivityStatus;
|
||||
import cn.felord.payment.wechat.enumeration.AwardType;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class ActivitiesListPageRequest {
|
||||
private final long offset;
|
||||
private final long limit;
|
||||
private String activityName;
|
||||
private ActivityStatus activityStatus;
|
||||
private AwardType awardType;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.v3.model.paygiftactivity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class ActivitiesPageRequest {
|
||||
private final String activityId;
|
||||
private Long offset;
|
||||
private Long limit;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.v3.model.paygiftactivity;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.CouponBgColor;
|
||||
import cn.felord.payment.wechat.enumeration.DeliveryPurpose;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* The type Activity base info.
|
||||
*
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class ActivityBaseInfo {
|
||||
private String activityName;
|
||||
private String activitySecondTitle;
|
||||
private String merchantLogoUrl;
|
||||
private String backgroundColor;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX")
|
||||
private OffsetDateTime beginTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX")
|
||||
private OffsetDateTime endTime;
|
||||
private AvailablePeriods availablePeriods;
|
||||
private String outRequestNo;
|
||||
private DeliveryPurpose deliveryPurpose;
|
||||
private String miniProgramsPath;
|
||||
|
||||
/**
|
||||
* Sets background color.
|
||||
*
|
||||
* @param backgroundColor the background color
|
||||
*/
|
||||
void setBackgroundColor(String backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets background color.
|
||||
*
|
||||
* @param backgroundColor the background color
|
||||
*/
|
||||
public void setBackgroundColor(CouponBgColor backgroundColor) {
|
||||
this.backgroundColor = backgroundColor.getValue();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,30 +14,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.felord.payment.wechat.v2.model;
|
||||
|
||||
package cn.felord.payment.wechat.v3.model.paygiftactivity;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.DeliveryUserCategory;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
* @author dax
|
||||
* @since 1.0.19.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;
|
||||
|
||||
public class AdvancedSetting {
|
||||
private DeliveryUserCategory deliveryUserCategory;
|
||||
private String merchantMemberAppid;
|
||||
private Set<String> goodsTags;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.v3.model.paygiftactivity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Available periods.
|
||||
*
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class AvailablePeriods {
|
||||
private List<OffsetDateTimePeriods> availableTime;
|
||||
private List<LocalTimePeriods> availableDayTime;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.v3.model.paygiftactivity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class AwardItem {
|
||||
private final String stock_id;
|
||||
private final String original_image_url;
|
||||
private String thumbnail_url;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.v3.model.paygiftactivity;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.AwardType;
|
||||
import cn.felord.payment.wechat.enumeration.SendContent;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 满送活动规则
|
||||
*
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class AwardSendRule {
|
||||
private final int transactionAmountMinimum;
|
||||
private final SendContent sendContent;
|
||||
private final AwardType awardType;
|
||||
private final List<AwardItem> awardList;
|
||||
private final String merchantOption;
|
||||
private final List<String> merchantIdList;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.v3.model.paygiftactivity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class DeleteActivityMchRequest {
|
||||
private final String activityId;
|
||||
private String deleteRequestNo;
|
||||
private List<String> merchantIdList;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.v3.model.paygiftactivity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class GiftActivityParams {
|
||||
private final ActivityBaseInfo activityBaseInfo;
|
||||
private final AwardSendRule awardSendRule;
|
||||
private AdvancedSetting advancedSetting;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.v3.model.paygiftactivity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class LocalTimePeriods {
|
||||
@JsonFormat(pattern = "HHmmss")
|
||||
private final OffsetDateTime beginDayTime;
|
||||
@JsonFormat(pattern = "HHmmss")
|
||||
private final OffsetDateTime endDayTime;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.v3.model.paygiftactivity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class NewActivityMchRequest {
|
||||
private final String activityId;
|
||||
private final String addRequestNo;
|
||||
private List<String> merchantIdList;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.v3.model.paygiftactivity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* The type Time periods.
|
||||
*
|
||||
* @author dax
|
||||
* @since 1.0.19.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class OffsetDateTimePeriods {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX")
|
||||
private final OffsetDateTime beginTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX")
|
||||
private final OffsetDateTime endTime;
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.v3.model.profitsharing;
|
||||
|
||||
import lombok.Data;
|
||||
@@ -5,7 +22,7 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xiafang
|
||||
* @author dax
|
||||
* @since 2023/1/3 10:27
|
||||
*/
|
||||
@Data
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
<parent>
|
||||
<groupId>cn.felord</groupId>
|
||||
<artifactId>payment-spring-boot</artifactId>
|
||||
<version>1.0.17.RELEASE</version>
|
||||
<version>1.0.19.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>payment-spring-boot-starter</artifactId>
|
||||
<version>1.0.17.RELEASE</version>
|
||||
<version>1.0.19.RELEASE</version>
|
||||
<packaging>jar</packaging>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
82
pom.xml
82
pom.xml
@@ -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.19.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>
|
||||
@@ -91,6 +91,11 @@
|
||||
<spring-boot.version>2.7.7</spring-boot.version>
|
||||
<alipay-sdk.version>4.31.7.ALL</alipay-sdk.version>
|
||||
<bcprov.version>1.69</bcprov.version>
|
||||
<retrofit.version>2.9.0</retrofit.version>
|
||||
<okhttp3.version>4.10.0</okhttp3.version>
|
||||
<lombok.version>1.18.26</lombok.version>
|
||||
<jackson.version>2.13.5</jackson.version>
|
||||
<slf4j.version>2.0.7</slf4j.version>
|
||||
</properties>
|
||||
|
||||
<distributionManagement>
|
||||
@@ -116,7 +121,6 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
@@ -132,6 +136,78 @@
|
||||
<artifactId>payment-spring-boot-autoconfigure</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.retrofit2</groupId>
|
||||
<artifactId>retrofit</artifactId>
|
||||
<version>${retrofit.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.retrofit2</groupId>
|
||||
<artifactId>adapter-rxjava3</artifactId>
|
||||
<version>${retrofit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.retrofit2</groupId>
|
||||
<artifactId>converter-jaxb</artifactId>
|
||||
<version>${retrofit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.retrofit2</groupId>
|
||||
<artifactId>converter-jackson</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>${retrofit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>${okhttp3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>logging-interceptor</artifactId>
|
||||
<version>${okhttp3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jdk8</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
<artifactId>jackson-module-parameter-names</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user