mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-13 21:33:41 +08:00
@@ -1,4 +1,4 @@
|
||||
# 微信支付 Spring Boot 组件
|
||||
# 最好用的微信支付V3 Spring Boot 组件
|
||||
|
||||
为了满足业务中出现app支付、公众号支付、小程序支付等多appid并存的场景,对原有的进行了增强开发出了多租户版本。
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<dependency>
|
||||
<groupId>cn.felord</groupId>
|
||||
<artifactId>payment-spring-boot-starter</artifactId>
|
||||
<version>1.0.3.RELEASE</version>
|
||||
<version>1.0.4.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
- 实现微信支付V3 微信支付分
|
||||
- 实现微信支付V3 先享卡
|
||||
|
||||
## 核心API结构
|
||||

|
||||
|
||||
> 随着版本迭代会增加
|
||||
|
||||
## 开源协议
|
||||
**Apache 2.0**
|
||||
|
||||
|
||||
@@ -18,10 +18,14 @@
|
||||
- [x] **微信支付V3** 全量支持,并支持多租户以同时满足移动应用App、公众号、小程序等支付场景
|
||||
- [x] **支付宝** 集成SDK,作简单适配
|
||||
|
||||
## 微信支付V3进度
|
||||
- 微信支付营销-代金券 `WechatMarketingFavorApi` 100%
|
||||
- 微信支付 支付功能-普通支付直连模式 `WechatDirectPayApi` 100%
|
||||
- 微信合单支付 `WechatCombinePayApi` 100%
|
||||
## 功能
|
||||
- 实现微信支付多商户
|
||||
- 集成支付宝SDK、快速接入Spring Boot
|
||||
- 实现微信支付V3 基础支付
|
||||
- 实现微信支付V3 合单支付
|
||||
- 实现微信支付V3 代金券
|
||||
- 实现微信支付V3 微信支付分
|
||||
- 实现微信支付V3 先享卡
|
||||
|
||||
## Maven 中央仓库坐标
|
||||
> 推荐使用最新版本
|
||||
@@ -29,7 +33,7 @@
|
||||
<dependency>
|
||||
<groupId>cn.felord</groupId>
|
||||
<artifactId>payment-spring-boot-starter</artifactId>
|
||||
<version>1.0.3.RELEASE</version>
|
||||
<version>1.0.4.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
## 采用技术
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
## 1.0.3.RELEASE
|
||||
- 微信支付
|
||||
- feat: 支持微信支付商家券
|
||||
- feat: 代金券功能增加发放消费卡接口`WechatMarketingBusiFavorApi`
|
||||
- refactor: 一些代码优化
|
||||
- refactor: 现在app支付、小程序支付返回所有客户端拉起支付的参数,不再需要用户再进行签名操作了
|
||||
- build: SDK开发环境 Spring Boot 版本升级到2.4.2
|
||||
- fix: 支付分RiskFund下枚举无法使用的问题(#2)
|
||||
## 1.0.3.RELEASE
|
||||
- 微信支付
|
||||
- feat: 完善合单支付账单
|
||||
1. 增加合单支付-申请交易账单API。
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<dependency>
|
||||
<groupId>cn.felord</groupId>
|
||||
<artifactId>payment-spring-boot-starter</artifactId>
|
||||
<version>1.0.3.RELEASE</version>
|
||||
<version>1.0.4.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
> 基于 **Spring Boot 2.4.1**
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
<parent>
|
||||
<groupId>cn.felord</groupId>
|
||||
<artifactId>payment-spring-boot</artifactId>
|
||||
<version>1.0.3.RELEASE</version>
|
||||
<version>1.0.4.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>payment-spring-boot-autoconfigure</artifactId>
|
||||
<version>1.0.3.RELEASE</version>
|
||||
<version>1.0.4.RELEASE</version>
|
||||
<packaging>jar</packaging>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -32,10 +32,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @author felord.cn
|
||||
@@ -78,9 +75,12 @@ public class AliPayConfiguration {
|
||||
|
||||
|
||||
private String appRSAPrivateKey(String classPath) {
|
||||
ClassPathResource resource = new ClassPathResource(classPath);
|
||||
try {
|
||||
File file = new ClassPathResource(classPath).getFile();
|
||||
return new BufferedReader(new FileReader(file)).readLine();
|
||||
FileReader in = new FileReader(resource.getFile());
|
||||
try(BufferedReader bufferedReader = new BufferedReader(in)){
|
||||
return bufferedReader.readLine();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("ali pay app private key is required ,{}", e.getMessage());
|
||||
throw new PayException("ali pay app private key is required");
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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;
|
||||
|
||||
/**
|
||||
* code展示模式
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
public enum BusiFavorCodeDisplayMode {
|
||||
/**
|
||||
* 不展示code
|
||||
*/
|
||||
NOT_SHOW,
|
||||
/**
|
||||
* 一维码(条形码)
|
||||
*/
|
||||
BARCODE,
|
||||
/**
|
||||
* 二维码
|
||||
*/
|
||||
QRCODE
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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 felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
public enum BusiFavorUseMethod {
|
||||
|
||||
/**
|
||||
* 线下滴码核销,点击券“立即使用”跳转展示券二维码详情。
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
OFF_LINE,
|
||||
/**
|
||||
* 线上小程序核销,点击券“立即使用”跳转至配置的商家小程序(需要添加小程序appid和path)。
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
MINI_PROGRAMS,
|
||||
/**
|
||||
* 微信支付付款码核销,点击券“立即使用”跳转至微信支付钱包付款码。
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
PAYMENT_CODE,
|
||||
/**
|
||||
* 用户自助核销,点击券“立即使用”跳转至用户自助操作核销界面(当前暂不支持用户自助核销)。
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
SELF_CONSUME;
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
package cn.felord.payment.wechat.enumeration;
|
||||
|
||||
/**
|
||||
* 代金券状态.
|
||||
* 代金券、商家券状态.
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.0.RELEASE
|
||||
|
||||
@@ -20,6 +20,7 @@ package cn.felord.payment.wechat.enumeration;
|
||||
/**
|
||||
* 申请资金账单账户类型.
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.3.RELEASE
|
||||
*/
|
||||
public enum FundFlowAccountType {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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 felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
public enum StockType {
|
||||
/**
|
||||
* 固定面额满减券批次
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
NORMAL,
|
||||
/**
|
||||
* 折扣券批次
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
DISCOUNT,
|
||||
/**
|
||||
* 换购券批次
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
EXCHANGE
|
||||
}
|
||||
@@ -21,7 +21,7 @@ package cn.felord.payment.wechat.enumeration;
|
||||
* 未完成约定原因
|
||||
* <p>
|
||||
* 当订单守约状态为{@link ContractStatus#UNFINISHED},返回此字段
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.3.RELEASE
|
||||
*/
|
||||
public enum UnfinishedReason {
|
||||
|
||||
@@ -341,8 +341,99 @@ public enum WechatPayV3Type {
|
||||
*
|
||||
* @since 1.0.0.RELEASE
|
||||
*/
|
||||
MARKETING_FAVOR_CALLBACKS(HttpMethod.POST, "%s/v3/marketing/favor/callbacks");
|
||||
MARKETING_FAVOR_CALLBACKS(HttpMethod.POST, "%s/v3/marketing/favor/callbacks"),
|
||||
/**
|
||||
* 发放代金券消费卡API.
|
||||
*
|
||||
* @since 1.0.4.RELEASES
|
||||
*/
|
||||
MARKETING_FAVOR_COUPONS_SEND(HttpMethod.POST, "%s/v3/marketing/busifavor/coupons/{card_id}/send"),
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
/**
|
||||
* 创建商家券API.
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
MARKETING_BUSI_FAVOR_CREATE_STOCKS(HttpMethod.POST, "%s/v3/marketing/busifavor/stocks"),
|
||||
/**
|
||||
* 查询商家券详情API.
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
MARKETING_BUSI_FAVOR_STOCKS_DETAIL(HttpMethod.GET, "%s/v3/marketing/busifavor/stocks/{stock_id}"),
|
||||
/**
|
||||
* 核销用户券API.
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
MARKETING_BUSI_FAVOR_COUPON_USE(HttpMethod.POST, "%s/v3/marketing/busifavor/coupons/use"),
|
||||
/**
|
||||
* 根据过滤条件查询用户券API.
|
||||
*
|
||||
* @since 1.0.4.RELEASES
|
||||
*/
|
||||
MARKETING_BUSI_FAVOR_USER_COUPONS(HttpMethod.GET, "%s/v3/marketing/busifavor/users/{openid}/coupons"),
|
||||
/**
|
||||
* 查询用户单张券详情API.
|
||||
*
|
||||
* @since 1.0.4.RELEASES
|
||||
*/
|
||||
MARKETING_BUSI_FAVOR_USER_COUPON(HttpMethod.GET, "%s/v3/marketing/busifavor/users/{openid}/coupons/{coupon_code}/appids/{appid}"),
|
||||
/**
|
||||
* 商家券上传预存Code API.
|
||||
*
|
||||
* @since 1.0.4.RELEASES
|
||||
*/
|
||||
MARKETING_BUSI_FAVOR_UPLOAD_COUPON_CODES(HttpMethod.POST, "%s/v3/marketing/busifavor/stocks/{stock_id}/couponcodes"),
|
||||
/**
|
||||
* 设置商家券事件通知地址API.
|
||||
*
|
||||
* @since 1.0.4.RELEASES
|
||||
*/
|
||||
MARKETING_BUSI_FAVOR_SETTING_CALLBACKS(HttpMethod.POST, "%s/v3/marketing/busifavor/callbacks"),
|
||||
/**
|
||||
* 查询商家券事件通知地址API.
|
||||
*
|
||||
* @since 1.0.4.RELEASES
|
||||
*/
|
||||
MARKETING_BUSI_FAVOR_GET_CALLBACKS(HttpMethod.GET, "%s/v3/marketing/busifavor/callbacks"),
|
||||
/**
|
||||
* 关联订单信息API.
|
||||
*
|
||||
* @since 1.0.4.RELEASES
|
||||
*/
|
||||
MARKETING_BUSI_FAVOR_ASSOCIATE(HttpMethod.POST, "%s/v3/marketing/busifavor/coupons/associate"),
|
||||
/**
|
||||
* 取消关联订单信息API.
|
||||
*
|
||||
* @since 1.0.4.RELEASES
|
||||
*/
|
||||
MARKETING_BUSI_FAVOR_DISASSOCIATE(HttpMethod.POST, "%s/v3/marketing/busifavor/coupons/disassociate"),
|
||||
/**
|
||||
* 取消关联订单信息API.
|
||||
*
|
||||
* @since 1.0.4.RELEASES
|
||||
*/
|
||||
MARKETING_BUSI_FAVOR_BUDGET(HttpMethod.POST, "%s/v3/marketing/busifavor/stocks/{stock_id}/budget"),
|
||||
/**
|
||||
* 修改商家券基本信息API.
|
||||
*
|
||||
* @since 1.0.4.RELEASES
|
||||
*/
|
||||
MARKETING_BUSI_FAVOR_UPDATE(HttpMethod.POST, "%s/v3/marketing/busifavor/stocks/{stock_id}"),
|
||||
/**
|
||||
* 申请退券API.
|
||||
*
|
||||
* @since 1.0.4.RELEASES
|
||||
*/
|
||||
MARKETING_BUSI_FAVOR_RETURN(HttpMethod.POST, "%s/v3/marketing/busifavor/coupons/return"),
|
||||
/**
|
||||
* 使券失效API.
|
||||
*
|
||||
* @since 1.0.4.RELEASES
|
||||
*/
|
||||
MARKETING_BUSI_FAVOR_DEACTIVATE(HttpMethod.POST, "%s/v3/marketing/busifavor/coupons/deactivate");
|
||||
|
||||
/**
|
||||
* The Pattern.
|
||||
|
||||
@@ -55,36 +55,35 @@ final class ExtensionFormHttpMessageConverter extends FormHttpMessageConverter {
|
||||
*/
|
||||
private static final String BOUNDARY = "boundary";
|
||||
|
||||
|
||||
/**
|
||||
* The constant jaxb2Present.
|
||||
*/
|
||||
private static final boolean jaxb2Present;
|
||||
private static final boolean JAXB_2_PRESENT;
|
||||
|
||||
/**
|
||||
* The constant jackson2Present.
|
||||
*/
|
||||
private static final boolean jackson2Present;
|
||||
private static final boolean JACKSON_2_PRESENT;
|
||||
|
||||
/**
|
||||
* The constant jackson2XmlPresent.
|
||||
*/
|
||||
private static final boolean jackson2XmlPresent;
|
||||
private static final boolean JACKSON_2_XML_PRESENT;
|
||||
|
||||
/**
|
||||
* The constant jackson2SmilePresent.
|
||||
*/
|
||||
private static final boolean jackson2SmilePresent;
|
||||
private static final boolean JACKSON_2_SMILE_PRESENT;
|
||||
|
||||
/**
|
||||
* The constant gsonPresent.
|
||||
*/
|
||||
private static final boolean gsonPresent;
|
||||
private static final boolean GSON_PRESENT;
|
||||
|
||||
/**
|
||||
* The constant jsonbPresent.
|
||||
*/
|
||||
private static final boolean jsonbPresent;
|
||||
private static final boolean JSONB_PRESENT;
|
||||
|
||||
/**
|
||||
* The Part converters.
|
||||
@@ -93,13 +92,13 @@ final class ExtensionFormHttpMessageConverter extends FormHttpMessageConverter {
|
||||
|
||||
static {
|
||||
ClassLoader classLoader = AllEncompassingFormHttpMessageConverter.class.getClassLoader();
|
||||
jaxb2Present = ClassUtils.isPresent("javax.xml.bind.Binder", classLoader);
|
||||
jackson2Present = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader) &&
|
||||
JAXB_2_PRESENT = ClassUtils.isPresent("javax.xml.bind.Binder", classLoader);
|
||||
JACKSON_2_PRESENT = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader) &&
|
||||
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", classLoader);
|
||||
jackson2XmlPresent = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper", classLoader);
|
||||
jackson2SmilePresent = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.smile.SmileFactory", classLoader);
|
||||
gsonPresent = ClassUtils.isPresent("com.google.gson.Gson", classLoader);
|
||||
jsonbPresent = ClassUtils.isPresent("javax.json.bind.Jsonb", classLoader);
|
||||
JACKSON_2_XML_PRESENT = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper", classLoader);
|
||||
JACKSON_2_SMILE_PRESENT = ClassUtils.isPresent("com.fasterxml.jackson.dataformat.smile.SmileFactory", classLoader);
|
||||
GSON_PRESENT = ClassUtils.isPresent("com.google.gson.Gson", classLoader);
|
||||
JSONB_PRESENT = ClassUtils.isPresent("javax.json.bind.Jsonb", classLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +106,8 @@ final class ExtensionFormHttpMessageConverter extends FormHttpMessageConverter {
|
||||
*/
|
||||
public ExtensionFormHttpMessageConverter() {
|
||||
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
|
||||
stringHttpMessageConverter.setWriteAcceptCharset(false); // see SPR-7316
|
||||
// see SPR-7316
|
||||
stringHttpMessageConverter.setWriteAcceptCharset(false);
|
||||
|
||||
this.partConverters.add(new ByteArrayHttpMessageConverter());
|
||||
this.partConverters.add(stringHttpMessageConverter);
|
||||
@@ -118,23 +118,23 @@ final class ExtensionFormHttpMessageConverter extends FormHttpMessageConverter {
|
||||
// Ignore when no TransformerFactory implementation is available
|
||||
}
|
||||
|
||||
if (jaxb2Present && !jackson2XmlPresent) {
|
||||
if (JAXB_2_PRESENT && !JACKSON_2_XML_PRESENT) {
|
||||
this.partConverters.add(new Jaxb2RootElementHttpMessageConverter());
|
||||
}
|
||||
|
||||
if (jackson2Present) {
|
||||
if (JACKSON_2_PRESENT) {
|
||||
this.partConverters.add(new MappingJackson2HttpMessageConverter());
|
||||
} else if (gsonPresent) {
|
||||
} else if (GSON_PRESENT) {
|
||||
this.partConverters.add(new GsonHttpMessageConverter());
|
||||
} else if (jsonbPresent) {
|
||||
} else if (JSONB_PRESENT) {
|
||||
this.partConverters.add(new JsonbHttpMessageConverter());
|
||||
}
|
||||
|
||||
if (jackson2XmlPresent) {
|
||||
if (JACKSON_2_XML_PRESENT) {
|
||||
this.partConverters.add(new MappingJackson2XmlHttpMessageConverter());
|
||||
}
|
||||
|
||||
if (jackson2SmilePresent) {
|
||||
if (JACKSON_2_SMILE_PRESENT) {
|
||||
this.partConverters.add(new MappingJackson2SmileHttpMessageConverter());
|
||||
}
|
||||
this.setPartConverters(this.partConverters);
|
||||
@@ -205,7 +205,8 @@ final class ExtensionFormHttpMessageConverter extends FormHttpMessageConverter {
|
||||
outputMessage.getHeaders().setContentType(contentType);
|
||||
|
||||
Charset charset = contentType.getCharset();
|
||||
Assert.notNull(charset, "No charset"); // should never occur
|
||||
// should never occur
|
||||
Assert.notNull(charset, "No charset");
|
||||
|
||||
final byte[] bytes = serializeForm(formData, charset).getBytes(charset);
|
||||
outputMessage.getHeaders().setContentLength(bytes.length);
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
package cn.felord.payment.wechat.v3;
|
||||
|
||||
|
||||
import cn.felord.payment.PayException;
|
||||
import cn.felord.payment.wechat.enumeration.WeChatServer;
|
||||
import cn.felord.payment.wechat.enumeration.WechatPayV3Type;
|
||||
import cn.felord.payment.wechat.v3.model.ResponseSignVerifyParams;
|
||||
import cn.felord.payment.PayException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -46,6 +46,8 @@ import java.security.*;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
@@ -70,7 +72,7 @@ public class SignatureProvider {
|
||||
/**
|
||||
* The constant ID_GENERATOR.
|
||||
*/
|
||||
private static final IdGenerator ID_GENERATOR = new AlternativeJdkIdGenerator();
|
||||
private final IdGenerator nonceStrGenerator = new AlternativeJdkIdGenerator();
|
||||
/**
|
||||
* The constant SCHEMA.
|
||||
*/
|
||||
@@ -114,18 +116,14 @@ public class SignatureProvider {
|
||||
*/
|
||||
@SneakyThrows
|
||||
public String requestSign(String tenantId, String method, String canonicalUrl, String body) {
|
||||
Signature signer = Signature.getInstance("SHA256withRSA");
|
||||
WechatMetaBean wechatMetaBean = wechatMetaContainer.getWechatMeta(tenantId);
|
||||
signer.initSign(wechatMetaBean.getKeyPair().getPrivate());
|
||||
|
||||
long timestamp = System.currentTimeMillis() / 1000;
|
||||
String nonceStr = ID_GENERATOR.generateId()
|
||||
long timestamp = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"));
|
||||
String nonceStr = nonceStrGenerator.generateId()
|
||||
.toString()
|
||||
.replaceAll("-", "");
|
||||
final String signatureStr = createSign(method, canonicalUrl, String.valueOf(timestamp), nonceStr, body);
|
||||
signer.update(signatureStr.getBytes(StandardCharsets.UTF_8));
|
||||
String encode = Base64Utils.encodeToString(signer.sign());
|
||||
|
||||
WechatMetaBean wechatMetaBean = wechatMetaContainer.getWechatMeta(tenantId);
|
||||
PrivateKey privateKey = wechatMetaBean.getKeyPair().getPrivate();
|
||||
String encode = this.doRequestSign(privateKey, method, canonicalUrl, String.valueOf(timestamp), nonceStr, body);
|
||||
// 序列号
|
||||
String serialNo = wechatMetaBean.getSerialNumber();
|
||||
// 生成token
|
||||
@@ -135,6 +133,24 @@ public class SignatureProvider {
|
||||
return SCHEMA.concat(token);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Do request sign.
|
||||
*
|
||||
* @param privateKey the private key
|
||||
* @param orderedComponents the orderedComponents
|
||||
* @return the string
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@SneakyThrows
|
||||
public String doRequestSign(PrivateKey privateKey, String... orderedComponents) {
|
||||
Signature signer = Signature.getInstance("SHA256withRSA");
|
||||
signer.initSign(privateKey);
|
||||
final String signatureStr = createSign(orderedComponents);
|
||||
signer.update(signatureStr.getBytes(StandardCharsets.UTF_8));
|
||||
return Base64Utils.encodeToString(signer.sign());
|
||||
}
|
||||
|
||||
/**
|
||||
* 我方对响应验签,和应答签名做比较,使用微信平台证书.
|
||||
*
|
||||
@@ -257,6 +273,16 @@ public class SignatureProvider {
|
||||
return wechatMetaContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Nonce generator.
|
||||
*
|
||||
* @return the id generator
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
public IdGenerator nonceStrGenerator() {
|
||||
return nonceStrGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求时设置签名 组件
|
||||
*
|
||||
|
||||
@@ -94,6 +94,17 @@ public class WechatApiProvider {
|
||||
return new WechatDiscountCardApi(wechatPayClient, tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付商家券.
|
||||
*
|
||||
* @param tenantId the tenant id
|
||||
* @return the wechat discount card api
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
public WechatMarketingBusiFavorApi busiFavorApi(String tenantId) {
|
||||
return new WechatMarketingBusiFavorApi(wechatPayClient, tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回调.
|
||||
* <p>
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
*/
|
||||
package cn.felord.payment.wechat.v3;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.WeChatServer;
|
||||
import cn.felord.payment.PayException;
|
||||
import cn.felord.payment.wechat.WechatPayProperties;
|
||||
import cn.felord.payment.wechat.enumeration.WeChatServer;
|
||||
import cn.felord.payment.wechat.enumeration.WechatPayV3Type;
|
||||
import cn.felord.payment.wechat.v3.model.PayParams;
|
||||
import cn.felord.payment.wechat.v3.model.TransactionQueryParams;
|
||||
@@ -30,6 +31,10 @@ import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.net.URI;
|
||||
import java.security.PrivateKey;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 普通支付-直连模式.
|
||||
@@ -59,7 +64,41 @@ public class WechatDirectPayApi extends AbstractApi {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.APP, payParams)
|
||||
.function(this::payFunction)
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.consumer(responseEntity -> {
|
||||
ObjectNode body = responseEntity.getBody();
|
||||
if (Objects.isNull(body)) {
|
||||
throw new PayException("response body cannot be resolved");
|
||||
}
|
||||
|
||||
SignatureProvider signatureProvider = this.client().signatureProvider();
|
||||
WechatMetaContainer wechatMetaContainer = signatureProvider.wechatMetaContainer();
|
||||
WechatMetaBean wechatMetaBean = wechatMetaContainer.getWechatMeta(tenantId());
|
||||
PrivateKey privateKey = wechatMetaBean.getKeyPair().getPrivate();
|
||||
|
||||
String appId = wechatMetaBean.getV3().getAppId();
|
||||
long epochSecond = LocalDateTime.now()
|
||||
.toEpochSecond(ZoneOffset.of("+8"));
|
||||
String timestamp = String.valueOf(epochSecond);
|
||||
String nonceStr = signatureProvider.nonceStrGenerator()
|
||||
.generateId()
|
||||
.toString()
|
||||
.replaceAll("-", "");
|
||||
String prepayId = body.get("prepay_id").asText();
|
||||
String paySign = signatureProvider.doRequestSign(privateKey, appId, timestamp, nonceStr, prepayId);
|
||||
String mchId = wechatMetaBean.getV3().getMchId();
|
||||
|
||||
body.put("appid", appId);
|
||||
body.put("partnerid", mchId);
|
||||
body.put("prepayid", prepayId);
|
||||
body.put("package", "Sign=WXPay");
|
||||
body.put("nonceStr", nonceStr);
|
||||
body.put("timeStamp", timestamp);
|
||||
body.put("signType", "RSA");
|
||||
body.put("paySign", paySign);
|
||||
|
||||
wechatResponseEntity.setHttpStatus(responseEntity.getStatusCodeValue());
|
||||
wechatResponseEntity.setBody(body);
|
||||
})
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
@@ -74,7 +113,38 @@ public class WechatDirectPayApi extends AbstractApi {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.JSAPI, payParams)
|
||||
.function(this::payFunction)
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.consumer(responseEntity -> {
|
||||
ObjectNode body = responseEntity.getBody();
|
||||
if (Objects.isNull(body)) {
|
||||
throw new PayException("response body cannot be resolved");
|
||||
}
|
||||
|
||||
SignatureProvider signatureProvider = this.client().signatureProvider();
|
||||
WechatMetaContainer wechatMetaContainer = signatureProvider.wechatMetaContainer();
|
||||
WechatMetaBean wechatMetaBean = wechatMetaContainer.getWechatMeta(tenantId());
|
||||
PrivateKey privateKey = wechatMetaBean.getKeyPair().getPrivate();
|
||||
|
||||
String appId = wechatMetaBean.getV3().getAppId();
|
||||
long epochSecond = LocalDateTime.now()
|
||||
.toEpochSecond(ZoneOffset.of("+8"));
|
||||
String timestamp = String.valueOf(epochSecond);
|
||||
String nonceStr = signatureProvider.nonceStrGenerator()
|
||||
.generateId()
|
||||
.toString()
|
||||
.replaceAll("-", "");
|
||||
String packageStr = "prepay_id=" + body.get("prepay_id").asText();
|
||||
String paySign = signatureProvider.doRequestSign(privateKey, appId, timestamp, nonceStr, packageStr);
|
||||
|
||||
body.put("appId", appId);
|
||||
body.put("timeStamp", timestamp);
|
||||
body.put("nonceStr", nonceStr);
|
||||
body.put("package", packageStr);
|
||||
body.put("signType", "RSA");
|
||||
body.put("paySign", paySign);
|
||||
|
||||
wechatResponseEntity.setHttpStatus(responseEntity.getStatusCodeValue());
|
||||
wechatResponseEntity.setBody(body);
|
||||
})
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,438 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.WechatPayProperties;
|
||||
import cn.felord.payment.wechat.enumeration.CouponStatus;
|
||||
import cn.felord.payment.wechat.enumeration.WeChatServer;
|
||||
import cn.felord.payment.wechat.enumeration.WechatPayV3Type;
|
||||
import cn.felord.payment.wechat.v3.model.busifavor.*;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* 微信支付商家券.
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
public class WechatMarketingBusiFavorApi extends AbstractApi {
|
||||
/**
|
||||
* Instantiates a new Abstract api.
|
||||
*
|
||||
* @param wechatPayClient the wechat pay client
|
||||
* @param tenantId the tenant id
|
||||
*/
|
||||
public WechatMarketingBusiFavorApi(WechatPayClient wechatPayClient, String tenantId) {
|
||||
super(wechatPayClient, tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商家券券批次API
|
||||
* <p>
|
||||
* 商家券介绍详见 <a target= "_blank" href= "https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/marketing/busifavor/chapter1_1.shtml">微信支付商家券</a>
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> createStock(BusiFavorCreateParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_BUSI_FAVOR_CREATE_STOCKS, params)
|
||||
.function(this::createStocksFunction)
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
private RequestEntity<?> createStocksFunction(WechatPayV3Type type, BusiFavorCreateParams busiFavorCreateParams) {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
if (!StringUtils.hasText(busiFavorCreateParams.getBelongMerchant())) {
|
||||
WechatPayProperties.V3 v3 = this.wechatMetaBean().getV3();
|
||||
String mchId = v3.getMchId();
|
||||
busiFavorCreateParams.setBelongMerchant(mchId);
|
||||
}
|
||||
return Post(uri, busiFavorCreateParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商家券详情API
|
||||
* <p>
|
||||
* 商户可通过该接口查询已创建的商家券批次详情信息。
|
||||
*
|
||||
* @param stockId the stock id
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> queryStockDetail(String stockId) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_BUSI_FAVOR_STOCKS_DETAIL, stockId)
|
||||
.function((type, id) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.expand(id)
|
||||
.toUri();
|
||||
return Get(uri);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销用户券API,暂时appid需要手工在参数中传递
|
||||
* <p>
|
||||
* 在用户满足优惠门槛后,服务商可通过该接口核销用户微信卡包中具体某一张商家券。
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> use(BusiFavorUseParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_BUSI_FAVOR_COUPON_USE, params)
|
||||
.function((type, useParams) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
if (!StringUtils.hasText(params.getAppid())) {
|
||||
WechatPayProperties.V3 v3 = this.wechatMetaBean().getV3();
|
||||
String appId = v3.getAppId();
|
||||
useParams.setAppid(appId);
|
||||
}
|
||||
return Post(uri, useParams);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据过滤条件查询用户券API
|
||||
* <p>
|
||||
* 商户自定义筛选条件(如创建商户号、归属商户号、发放商户号等),查询指定微信用户卡包中满足对应条件的所有商家券信息。
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> queryUserStocks(UserBusiFavorQueryParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_BUSI_FAVOR_USER_COUPONS, params)
|
||||
.function((type, userBusiFavorQueryParams) -> {
|
||||
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
|
||||
|
||||
String appid = userBusiFavorQueryParams.getAppid();
|
||||
if (StringUtils.hasText(appid)) {
|
||||
queryParams.add("appid", appid);
|
||||
}
|
||||
queryParams.add("stock_id", userBusiFavorQueryParams.getStockId());
|
||||
queryParams.add("coupon_state", userBusiFavorQueryParams.getCouponState().name());
|
||||
queryParams.add("creator_merchant", userBusiFavorQueryParams.getCreatorMerchant());
|
||||
queryParams.add("belong_merchant", userBusiFavorQueryParams.getBelongMerchant());
|
||||
queryParams.add("sender_merchant", userBusiFavorQueryParams.getSenderMerchant());
|
||||
queryParams.add("offset", String.valueOf(params.getOffset()));
|
||||
queryParams.add("limit", String.valueOf(params.getLimit()));
|
||||
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.queryParams(queryParams)
|
||||
.build()
|
||||
.expand(userBusiFavorQueryParams.getOpenid())
|
||||
.toUri();
|
||||
return Get(uri);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户单张券详情API
|
||||
* <p>
|
||||
* 服务商可通过该接口查询微信用户卡包中某一张商家券的详情信息。
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> queryUserCoupon(UserBusiCouponQueryParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_BUSI_FAVOR_USER_COUPON, params)
|
||||
.function((type, queryParams) -> {
|
||||
if (!StringUtils.hasText(params.getAppid())) {
|
||||
WechatPayProperties.V3 v3 = this.wechatMetaBean().getV3();
|
||||
String appId = v3.getAppId();
|
||||
queryParams.setAppid(appId);
|
||||
}
|
||||
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.expand(queryParams.getOpenid(), queryParams.getCouponCode(), queryParams.getAppid())
|
||||
.toUri();
|
||||
return Get(uri);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传预存code API
|
||||
* <p>
|
||||
* 商家券的Code码可由微信后台随机分配,同时支持商户自定义。
|
||||
* 如商家已有自己的优惠券系统,可直接使用自定义模式。
|
||||
* 即商家预先向微信支付上传券Code,当券在发放时,微信支付自动从已导入的Code中随机取值(不能指定),派发给用户。
|
||||
*
|
||||
* @param params the params
|
||||
* @return wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> uploadCouponCodes(BusiCouponCodeUploadParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_BUSI_FAVOR_UPLOAD_COUPON_CODES, params)
|
||||
.function((type, queryParams) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.expand(queryParams.getStockId())
|
||||
.toUri();
|
||||
queryParams.setStockId(null);
|
||||
return Post(uri, queryParams);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置商家券事件通知地址API
|
||||
* <p>
|
||||
* 用于设置接收商家券相关事件通知的URL,可接收商家券相关的事件通知、包括发放通知等。
|
||||
* 需要设置接收通知的URL,并在商户平台开通 <a target= "_blank" href= "https://pay.weixin.qq.com/index.php/xphp/cmkt_product/index#/pages/product/product?pid=3">营销事件推送</a> 的能力,即可接收到相关通知。
|
||||
* <p>
|
||||
* 营销事件推送:<a target= "_blank" href= "https://pay.weixin.qq.com/index.php/core/home/login?return_url=%2Findex.php%2Fxphp%2Fcmkt_product%2Findex#/pages/product/product?pid=3">点击开通产品权限</a>。由商家券批次创建方登录Pay平台,操作开通
|
||||
* <p>
|
||||
* 注意:
|
||||
* <ul>
|
||||
* <li>仅可以收到由商户自己创建的批次相关的通知</li>
|
||||
* <li>需要设置apiv3秘钥,否则无法收到回调。</li>
|
||||
* <li>如果需要领券回调中的参数openid。需要创券时候传入 notify_appid参数。</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param params the params
|
||||
* @return callbacks callbacks
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> setCallbacks(BusiFavorCallbackSettingParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_BUSI_FAVOR_SETTING_CALLBACKS, params)
|
||||
.function((type, queryParams) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
return Post(uri, queryParams);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商家券事件通知地址API
|
||||
* <p>
|
||||
* 通过调用此接口可查询设置的通知URL。
|
||||
* <p>
|
||||
* 注意:
|
||||
* <ul>
|
||||
* <li>仅可以查询由请求商户号设置的商家券通知url</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param mchId the mch id
|
||||
* @return callbacks callbacks
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> getCallbacks(String mchId) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_BUSI_FAVOR_GET_CALLBACKS, mchId)
|
||||
.function((type, id) -> {
|
||||
|
||||
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA));
|
||||
|
||||
if (StringUtils.hasText(id)) {
|
||||
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
|
||||
queryParams.add("mchid", id);
|
||||
uriComponentsBuilder.queryParams(queryParams);
|
||||
}
|
||||
|
||||
URI uri = uriComponentsBuilder
|
||||
.build()
|
||||
.toUri();
|
||||
return Get(uri);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家券关联订单信息API
|
||||
* <p>
|
||||
* 将有效态(未核销)的商家券与订单信息关联,用于后续参与摇奖&返佣激励等操作的统计。
|
||||
* <p>
|
||||
* 注意:
|
||||
* 仅对有关联订单需求的券进行该操作
|
||||
*
|
||||
* @param associateInfo the associate info
|
||||
* @return wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> associate(BusiFavorAssociateInfo associateInfo) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_BUSI_FAVOR_ASSOCIATE, associateInfo)
|
||||
.function(this::associateFunction)
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家券取消关联订单信息API
|
||||
* <p>
|
||||
* 取消商家券与订单信息的关联关系。
|
||||
* <p>
|
||||
* 注意:
|
||||
* 建议取消前调用查询接口,查到当前关联的商户单号并确认后,再进行取消操作
|
||||
*
|
||||
* @param associateInfo the associate info
|
||||
* @return wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> disassociate(BusiFavorAssociateInfo associateInfo) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_BUSI_FAVOR_DISASSOCIATE, associateInfo)
|
||||
.function(this::associateFunction)
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* associate and disassociate function
|
||||
*
|
||||
* @param type WechatPayV3Type
|
||||
* @param associateInfo the associateInfo
|
||||
* @return RequestEntity
|
||||
*/
|
||||
private RequestEntity<?> associateFunction(WechatPayV3Type type, BusiFavorAssociateInfo associateInfo) {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
return Post(uri, associateInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改批次预算API
|
||||
* <p>
|
||||
* 商户可以通过该接口修改批次单天发放上限数量或者批次最大发放数量
|
||||
*
|
||||
* @param params the params
|
||||
* @return wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> budget(BusiFavorBudgetParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_BUSI_FAVOR_BUDGET, params)
|
||||
.function((type, budgetParams) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.expand(budgetParams.getStockId())
|
||||
.toUri();
|
||||
budgetParams.setStockId(null);
|
||||
return Post(uri, budgetParams);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商家券基本信息API
|
||||
* <p>
|
||||
* 商户可以通过该接口修改商家券基本信息
|
||||
*
|
||||
* @param params the params
|
||||
* @return wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> updateStock(BusiFavorUpdateParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_BUSI_FAVOR_UPDATE, params)
|
||||
.function((type, updateParams) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.expand(updateParams.getStockId())
|
||||
.toUri();
|
||||
updateParams.setStockId(null);
|
||||
return Post(uri, updateParams);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请退券API
|
||||
* <p>
|
||||
* 商户可以通过该接口为已核销的券申请退券
|
||||
*
|
||||
* @param params the params
|
||||
* @return wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> refund(BusiFavorRefundParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_BUSI_FAVOR_RETURN, params)
|
||||
.function((type, refundParams) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
return Post(uri, refundParams);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使券失效API
|
||||
* <p>
|
||||
* 前置条件:券的状态为{@link CouponStatus#SENDED}
|
||||
* <p>
|
||||
* 商户可以通过该接口将可用券进行失效处理,券被失效后无法再被核销
|
||||
*
|
||||
* @param params the params
|
||||
* @return wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> deactivate(BusiFavorDeactivateParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_BUSI_FAVOR_DEACTIVATE, params)
|
||||
.function((type, deactivateParams) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
return Post(uri, deactivateParams);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
}
|
||||
@@ -92,10 +92,11 @@ public class WechatMarketingFavorApi extends AbstractApi {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
|
||||
WechatPayProperties.V3 v3 = this.wechatMetaBean().getV3();
|
||||
String mchId = v3.getMchId();
|
||||
params.setBelongMerchant(mchId);
|
||||
if (!StringUtils.hasText(params.getBelongMerchant())) {
|
||||
WechatPayProperties.V3 v3 = this.wechatMetaBean().getV3();
|
||||
String mchId = v3.getMchId();
|
||||
params.setBelongMerchant(mchId);
|
||||
}
|
||||
return Post(uri, params);
|
||||
}
|
||||
|
||||
@@ -490,7 +491,7 @@ public class WechatMarketingFavorApi extends AbstractApi {
|
||||
*
|
||||
* @param stockId the stock id
|
||||
* @return the wechat response entity
|
||||
* @see AbstractApi#billDownload(String) 对账单下载api
|
||||
* @see AbstractApi#billDownload(String) AbstractApi#billDownload(String)对账单下载api
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> downloadStockUseFlow(String stockId) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
@@ -512,7 +513,7 @@ public class WechatMarketingFavorApi extends AbstractApi {
|
||||
*
|
||||
* @param stockId the stock id
|
||||
* @return the wechat response entity
|
||||
* @see AbstractApi#billDownload(String) 对账单下载api
|
||||
* @see AbstractApi#billDownload(String) AbstractApi#billDownload(String)对账单下载api
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> downloadStockRefundFlow(String stockId) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
@@ -601,7 +602,7 @@ public class WechatMarketingFavorApi extends AbstractApi {
|
||||
*
|
||||
* @param notifyUrl the notify url
|
||||
* @return the wechat response entity
|
||||
* @see WechatPayCallback#couponCallback(ResponseSignVerifyParams, Consumer) 核销回调
|
||||
* @see WechatPayCallback#couponCallback(ResponseSignVerifyParams, Consumer) WechatPayCallback#couponCallback(ResponseSignVerifyParams, Consumer)核销回调
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> setMarketingFavorCallback(String notifyUrl) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
@@ -631,6 +632,40 @@ public class WechatMarketingFavorApi extends AbstractApi {
|
||||
.toUri();
|
||||
return Post(uri, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发放消费卡API
|
||||
* <p>
|
||||
* 商户通过调用本接口向用户发放消费卡,用户领到卡的同时会领取到一批代金券,消费卡会自动放入卡包中。
|
||||
* <p>
|
||||
* 注意:
|
||||
* <ul>
|
||||
* <li>调用该接口前,需要在微信支付商户平台创建“消费卡”,获得card_id。</li>
|
||||
* <li>此功能仅向指定邀约商户开放,如有需要请联系微信支付运营经理。</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param params the params
|
||||
* @return wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> sendCouponsCard(CouponsCardSendParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_FAVOR_COUPONS_SEND, params)
|
||||
.function((type, sendParams) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.expand(sendParams.getCardId())
|
||||
.toUri();
|
||||
sendParams.setCardId(null);
|
||||
if (!StringUtils.hasText(sendParams.getAppid())) {
|
||||
WechatPayProperties.V3 v3 = this.wechatMetaBean().getV3();
|
||||
sendParams.setAppid(v3.getAppId());
|
||||
}
|
||||
return Post(uri, sendParams);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,8 +22,12 @@ import cn.felord.payment.wechat.v3.model.CallbackParams;
|
||||
import cn.felord.payment.wechat.v3.model.CouponConsumeData;
|
||||
import cn.felord.payment.wechat.v3.model.ResponseSignVerifyParams;
|
||||
import cn.felord.payment.wechat.v3.model.TransactionConsumeData;
|
||||
import cn.felord.payment.wechat.v3.model.busifavor.BusiFavorReceiveConsumeData;
|
||||
import cn.felord.payment.wechat.v3.model.combine.CombineTransactionConsumeData;
|
||||
import cn.felord.payment.wechat.v3.model.discountcard.*;
|
||||
import cn.felord.payment.wechat.v3.model.discountcard.DiscountCardAcceptedConsumeData;
|
||||
import cn.felord.payment.wechat.v3.model.discountcard.DiscountCardAgreementEndConsumeData;
|
||||
import cn.felord.payment.wechat.v3.model.discountcard.DiscountCardConsumer;
|
||||
import cn.felord.payment.wechat.v3.model.discountcard.DiscountCardUserPaidConsumeData;
|
||||
import cn.felord.payment.wechat.v3.model.payscore.PayScoreConsumer;
|
||||
import cn.felord.payment.wechat.v3.model.payscore.PayScoreUserConfirmConsumeData;
|
||||
import cn.felord.payment.wechat.v3.model.payscore.PayScoreUserPaidConsumeData;
|
||||
@@ -95,7 +99,7 @@ public class WechatPayCallback {
|
||||
*/
|
||||
@SneakyThrows
|
||||
public Map<String, ?> couponCallback(ResponseSignVerifyParams params, Consumer<CouponConsumeData> consumeDataConsumer) {
|
||||
String data = this.callback(params, EventType.COUPON);
|
||||
String data = this.callback(params, EventType.COUPON_USE);
|
||||
CouponConsumeData consumeData = MAPPER.readValue(data, CouponConsumeData.class);
|
||||
consumeDataConsumer.accept(consumeData);
|
||||
Map<String, Object> responseBody = new HashMap<>(2);
|
||||
@@ -230,7 +234,7 @@ public class WechatPayCallback {
|
||||
String data = this.decrypt(callbackParams);
|
||||
DiscountCardAcceptedConsumeData acceptedConsumeData = MAPPER.readValue(data, DiscountCardAcceptedConsumeData.class);
|
||||
discountCardConsumer.getAcceptedConsumeDataConsumer().accept(acceptedConsumeData);
|
||||
} else if (Objects.equals(eventType, EventType.DISCOUNT_CARD_USER_PAID.event)) {
|
||||
} else if (Objects.equals(eventType, EventType.DISCOUNT_CARD_USER_PAID.event)) {
|
||||
String data = this.decrypt(callbackParams);
|
||||
DiscountCardUserPaidConsumeData paidConsumeData = MAPPER.readValue(data, DiscountCardUserPaidConsumeData.class);
|
||||
discountCardConsumer.getCardUserPaidConsumeDataConsumer().accept(paidConsumeData);
|
||||
@@ -241,6 +245,32 @@ public class WechatPayCallback {
|
||||
return Collections.singletonMap("code", "SUCCESS");
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家券领券事件回调通知API
|
||||
* <p>
|
||||
* 领券完成后,微信会把相关支付结果和用户信息发送给商户,商户需要接收处理,并按照文档规范返回应答。出于安全的考虑,我们对支付结果数据进行了加密,商户需要先对通知数据进行解密,才能得到支付结果数据。
|
||||
* <p>
|
||||
* 该链接是通过商户<a target= "_blank" href= "https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/marketing/busifavor/chapter3_7.shtml">设置商家券事件通知地址API</a>中提交notify_url参数,必须为https协议。如果链接无法访问,商户将无法接收到微信通知。 通知url必须为直接可访问的url,不能携带参数。示例: “https://pay.weixin.qq.com/wxpay/pay.action”
|
||||
*
|
||||
* @param params the params
|
||||
* @param consumeDataConsumer the consume data consumer
|
||||
* @return the map
|
||||
*/
|
||||
@SneakyThrows
|
||||
public Map<String, ?> busiFavorReceiveCallback(ResponseSignVerifyParams params, Consumer<BusiFavorReceiveConsumeData> consumeDataConsumer) {
|
||||
CallbackParams callbackParams = resolve(params);
|
||||
String eventType = callbackParams.getEventType();
|
||||
|
||||
if (!Objects.equals(eventType, EventType.COUPON_SEND.event)) {
|
||||
log.error("wechat pay event type is not matched, callbackParams {}", callbackParams);
|
||||
throw new PayException(" wechat pay event type is not matched");
|
||||
}
|
||||
String data = this.decrypt(callbackParams);
|
||||
BusiFavorReceiveConsumeData consumeData = MAPPER.readValue(data, BusiFavorReceiveConsumeData.class);
|
||||
|
||||
consumeDataConsumer.accept(consumeData);
|
||||
return Collections.singletonMap("code", "SUCCESS");
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback.
|
||||
@@ -352,10 +382,22 @@ public class WechatPayCallback {
|
||||
|
||||
/**
|
||||
* 优惠券核销事件.
|
||||
* <p>
|
||||
* 代金券
|
||||
*
|
||||
* @since 1.0.0.RELEASE
|
||||
*/
|
||||
COUPON("COUPON.USE"),
|
||||
COUPON_USE("COUPON.USE"),
|
||||
|
||||
/**
|
||||
* 优惠券领券事件.
|
||||
* <p>
|
||||
* 商家券
|
||||
*
|
||||
* @since 1.0.0.RELEASE
|
||||
*/
|
||||
COUPON_SEND("COUPON.SEND"),
|
||||
|
||||
/**
|
||||
* 支付成功事件.
|
||||
*
|
||||
|
||||
@@ -21,7 +21,7 @@ package cn.felord.payment.wechat.v3.model;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* The type Coupon available time.
|
||||
* 代金券生效时间
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.0.RELEASE
|
||||
@@ -29,15 +29,26 @@ import lombok.Data;
|
||||
@Data
|
||||
public class CouponAvailableTime {
|
||||
/**
|
||||
* The Available time after receive.
|
||||
* 领取后有效时间,【单位:分钟】
|
||||
* <p>
|
||||
* 领取后,券的结束时间为领取N天后,如设置领取后7天有效,那么7月1日领券,在7月7日23:59:59失效(在可用时间内计算失效时间,若券还未到领取后N天,但是已经到了可用结束时间,那么也会过期)
|
||||
*/
|
||||
private Long availableTimeAfterReceive;
|
||||
/**
|
||||
* The Fix available time.
|
||||
* 固定时间段可用
|
||||
*/
|
||||
private FixAvailableTime fixAvailableTime;
|
||||
/**
|
||||
* The Second day available.
|
||||
* 领取后N天有效
|
||||
* <p>
|
||||
* 领取后,券的开始时间为领券后第二天,如7月1日领券,那么在7月2日00:00:00开始。
|
||||
* 当设置领取后N天有效时,不可设置固定时间段可用。枚举值:
|
||||
*
|
||||
* <ul>
|
||||
* <li>true:是</li>
|
||||
* <li>false:否</li>
|
||||
* </ul>
|
||||
*
|
||||
*/
|
||||
private Boolean secondDayAvailable;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 核销规则.
|
||||
* 代金券核销规则.
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.0.RELEASE
|
||||
@@ -30,32 +30,26 @@ import java.util.List;
|
||||
@Data
|
||||
public class CouponUseRule {
|
||||
|
||||
|
||||
/**
|
||||
* 可核销商品编码
|
||||
*/
|
||||
private List<String> availableItems;
|
||||
|
||||
/**
|
||||
* 可用商户
|
||||
*/
|
||||
private List<String> availableMerchants;
|
||||
|
||||
/**
|
||||
* 是否可以叠加使用
|
||||
*/
|
||||
private Boolean combineUse;
|
||||
|
||||
/**
|
||||
* 券生效时间
|
||||
* 券生效时间(暂时未开放,日期2021-1-12,请以微信官方通知为准)
|
||||
*/
|
||||
private CouponAvailableTime couponAvailableTime;
|
||||
|
||||
/**
|
||||
* 固定面额满减券使用规则
|
||||
*/
|
||||
private FixedNormalCoupon fixedNormalCoupon;
|
||||
|
||||
/**
|
||||
* 订单优惠标记
|
||||
*/
|
||||
@@ -80,8 +74,9 @@ public class CouponUseRule {
|
||||
* <li>FACE:人脸支付</li>
|
||||
* <li>OTHER:其他支付</li>
|
||||
* </ul>
|
||||
* 不填则默认“不限”
|
||||
*/
|
||||
private String tradeType;
|
||||
private CouponTradeType tradeType;
|
||||
|
||||
|
||||
/**
|
||||
@@ -106,4 +101,50 @@ public class CouponUseRule {
|
||||
*/
|
||||
private List<String> bin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 代金券核销规则-支付方式.
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
public enum CouponTradeType {
|
||||
/**
|
||||
* 小程序支付
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
MICROAPP,
|
||||
/**
|
||||
* APP支付
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
APPPAY,
|
||||
/**
|
||||
* 免密支付
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
PPAY,
|
||||
/**
|
||||
* 刷卡支付
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
CARD,
|
||||
/**
|
||||
* 人脸支付
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
FACE,
|
||||
/**
|
||||
* 其他支付
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
OTHER,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* 发放代金券消费卡API请求参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class CouponsCardSendParams {
|
||||
|
||||
/**
|
||||
* 消费卡ID
|
||||
* <p>
|
||||
* 获取方法请参见<a target= "_blank" href= "https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/marketing/coupons/chapter2_2.shtml">《接入流程》</a>中的创建消费卡。
|
||||
*/
|
||||
private String cardId;
|
||||
/**
|
||||
* 消费卡归属appid
|
||||
*/
|
||||
private String appid;
|
||||
/**
|
||||
* 需为消费卡归属appid生成的openid。
|
||||
*/
|
||||
private String openid;
|
||||
/**
|
||||
* 商户此次发放凭据号。
|
||||
* <p>
|
||||
* 推荐使用大小写字母和数字,不同添加请求发放凭据号不同,商户侧需保证同一发券请求的out_request_no和send_time的唯一性。
|
||||
*/
|
||||
private String outRequestNo;
|
||||
/**
|
||||
* 请求发卡时间,由于系统限制,暂不支持传入早于当前时间24小时以上的时间进行发券请求。
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "GMT+8")
|
||||
private OffsetDateTime sendTime;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Detail.
|
||||
* 支付优惠功能.
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.0.RELEASE
|
||||
|
||||
@@ -21,7 +21,7 @@ package cn.felord.payment.wechat.v3.model;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 减至优惠限定字段,仅减至优惠场景有返回
|
||||
* 微信代金券核销通知参数-减至优惠限定字段,仅减至优惠场景有返回
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.0.RELEASE
|
||||
@@ -30,11 +30,11 @@ import lombok.Data;
|
||||
public class DiscountTo {
|
||||
|
||||
/**
|
||||
* The Cut to price.
|
||||
* 减至后优惠单价,单位:分。
|
||||
*/
|
||||
private Long cutToPrice;
|
||||
/**
|
||||
* The Max price.
|
||||
* 可享受优惠的最高价格,单位:分。
|
||||
*/
|
||||
private Long maxPrice;
|
||||
|
||||
|
||||
@@ -23,7 +23,9 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Fix available time.
|
||||
* 固定时间段可用
|
||||
* <p>
|
||||
* 允许指定券在特殊时间段生效。当设置固定时间段可用时不可设置领取后N天有效
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.0.RELEASE
|
||||
@@ -32,15 +34,21 @@ import java.util.List;
|
||||
public class FixAvailableTime {
|
||||
|
||||
/**
|
||||
* The Available week day.
|
||||
* 可用星期数
|
||||
*
|
||||
* 允许指定每周固定星期数生效,0代表周日生效,1代表周一生效,以此类推;不填则代表在可用时间内周一至周日都生效。
|
||||
*/
|
||||
private List<Long> availableWeekDay;
|
||||
/**
|
||||
* The Begin time.
|
||||
* 允许指定特殊生效星期数中的具体生效的时间段。
|
||||
*
|
||||
* 当天开始时间,单位:秒。
|
||||
*/
|
||||
private Long beginTime;
|
||||
/**
|
||||
* The End time.
|
||||
* 允许指定特殊生效星期数中的具体生效的时间段。
|
||||
*
|
||||
* 当天结束时间,单位:秒,默认为23点59分59秒。
|
||||
*/
|
||||
private Long endTime;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package cn.felord.payment.wechat.v3.model;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.StockType;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -43,12 +44,12 @@ public class StocksCreateParams {
|
||||
*/
|
||||
private String belongMerchant;
|
||||
/**
|
||||
* 批次开始时间 rfc 3339 yyyy-mm-ddthh:mm:ss.sss+timezone
|
||||
* 批次开始时间 rfc 3339 yyyy-MM-ddTHH:mm:ss+TIMEZONE
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "GMT+8")
|
||||
private OffsetDateTime availableBeginTime;
|
||||
/**
|
||||
* 批次结束时间 rfc 3339 YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE
|
||||
* 批次结束时间 rfc 3339 yyyy-MM-ddTHH:mm:ss+TIMEZONE
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "GMT+8")
|
||||
private OffsetDateTime availableEndTime;
|
||||
@@ -62,8 +63,10 @@ public class StocksCreateParams {
|
||||
private Boolean noCash;
|
||||
/**
|
||||
* 批次类型
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
private String stockType = "NORMAL";
|
||||
private StockType stockType = StockType.NORMAL;
|
||||
/**
|
||||
* 商户单据号
|
||||
*/
|
||||
|
||||
@@ -18,14 +18,26 @@
|
||||
*/
|
||||
package cn.felord.payment.wechat.v3.model;
|
||||
|
||||
import cn.felord.payment.wechat.v3.WechatDirectPayApi;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 微信支付订单号查询API请求参数.
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.0.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class TransactionQueryParams {
|
||||
/**
|
||||
* 商户id
|
||||
*/
|
||||
private String mchId;
|
||||
/**
|
||||
* <ul>
|
||||
* <li>调用 {@link WechatDirectPayApi#queryTransactionByOutTradeNo(TransactionQueryParams)} 传递【商户侧订单号】</li>
|
||||
* <li>调用 {@link WechatDirectPayApi#queryTransactionById(TransactionQueryParams)} (TransactionQueryParams)} 传递【微信支付订单号】</li>
|
||||
* </ul>
|
||||
*/
|
||||
private String transactionIdOrOutTradeNo;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商家券当天可用时间段
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class AvailableDayTimeItem {
|
||||
|
||||
/**
|
||||
* 当天可用开始时间,单位:秒,1代表当天0点0分1秒。
|
||||
*/
|
||||
private Integer endTime;
|
||||
/**
|
||||
* 当天可用结束时间,单位:秒,86399代表当天23点59分59秒。
|
||||
*/
|
||||
private Integer beginTime;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 固定周期有效时间段
|
||||
* <p>
|
||||
* 可以设置多个星期下的多个可用时间段,比如每周二10点到18点,用户自定义字段。
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class AvailableWeek {
|
||||
|
||||
/**
|
||||
* 当天可用时间段
|
||||
* <p>
|
||||
* 可以填写多个时间段,最多不超过2个。
|
||||
*/
|
||||
private List<AvailableDayTimeItem> availableDayTime;
|
||||
/**
|
||||
* 可用星期数
|
||||
* <p>
|
||||
* 0代表周日,1代表周一,以此类推
|
||||
* <p>
|
||||
* 当填写{@link #availableDayTime}时,{@code weekDay}必填
|
||||
*/
|
||||
private List<Integer> weekDay;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 商家券上传预存code API请求参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class BusiCouponCodeUploadParams {
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String stockId;
|
||||
/**
|
||||
* 券code列表
|
||||
* <p>
|
||||
* 特殊规则:单个券code长度为【1,32】,条目个数限制为【1,200】。
|
||||
*/
|
||||
private Set<String> couponCodeList;
|
||||
/**
|
||||
* 请求业务单据号
|
||||
*/
|
||||
private String uploadRequestNo;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商家券关联订单信息API请求参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class BusiFavorAssociateInfo {
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String stockId;
|
||||
/**
|
||||
* 券code
|
||||
*/
|
||||
private String couponCode;
|
||||
/**
|
||||
* 关联的商户订单号
|
||||
*/
|
||||
private String outTradeNo;
|
||||
/**
|
||||
* 商户请求单号
|
||||
* @see BusiFavorCreateParams#getOutRequestNo()
|
||||
*/
|
||||
private String outRequestNo;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 修改商家券批次预算API请求参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class BusiFavorBudgetParams {
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String stockId;
|
||||
/**
|
||||
* 目标批次最大发放个数,同{@link #targetMaxCouponsByDay}二选一
|
||||
*/
|
||||
private Integer targetMaxCoupons;
|
||||
/**
|
||||
* 目标单天发放上限个数,同{@link #targetMaxCoupons}二选一
|
||||
*/
|
||||
private Integer targetMaxCouponsByDay;
|
||||
/**
|
||||
* 当前批次最大发放个数,当传入{@link #targetMaxCoupons}大于0时,必传
|
||||
*/
|
||||
private Integer currentMaxCoupons;
|
||||
/**
|
||||
* 当前单天发放上限个数 ,当传入{@link #targetMaxCouponsByDay}大于0时,必填
|
||||
*/
|
||||
private Integer currentMaxCouponsByDay;
|
||||
/**
|
||||
* 修改预算请求单据号
|
||||
*/
|
||||
private String modifyBudgetRequestNo;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 设置商家券事件通知地址API请求参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class BusiFavorCallbackSettingParams {
|
||||
|
||||
/**
|
||||
* 微信支付商户的商户号,由微信支付生成并下发,不填默认查询调用方商户的通知URL。
|
||||
*/
|
||||
private String mchid;
|
||||
/**
|
||||
* 商户提供的用于接收商家券事件通知的url地址,必须支持https。
|
||||
*/
|
||||
private String notifyUrl;
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.StockType;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 创建商家券请求参数.
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class BusiFavorCreateParams {
|
||||
|
||||
/**
|
||||
* 商家券批次名称,[1,21],必填
|
||||
*/
|
||||
private String stockName;
|
||||
/**
|
||||
* 批次归属商户号,必填
|
||||
*/
|
||||
private String belongMerchant;
|
||||
/**
|
||||
* 批次备注,[1,20],选填
|
||||
*/
|
||||
private String comment;
|
||||
/**
|
||||
* 适用商品范围,必填
|
||||
* <p>
|
||||
* 用来描述批次在哪些商品可用,会显示在微信卡包中。字数上限为15个,一个中文汉字/英文字母/数字均占用一个字数。
|
||||
*/
|
||||
private String goodsName;
|
||||
/**
|
||||
* 批次类型
|
||||
*/
|
||||
private StockType stockType;
|
||||
/**
|
||||
* 核销规则
|
||||
*/
|
||||
private CouponUseRule couponUseRule;
|
||||
/**
|
||||
* 自定义入口
|
||||
*/
|
||||
private CustomEntrance customEntrance;
|
||||
/**
|
||||
* 商家券code模式枚举
|
||||
*/
|
||||
private CouponCodeMode couponCodeMode;
|
||||
/**
|
||||
* 样式信息
|
||||
*/
|
||||
private DisplayPatternInfo displayPatternInfo;
|
||||
/**
|
||||
* 券发放规则
|
||||
*/
|
||||
private StockSendRule stockSendRule;
|
||||
/**
|
||||
* 商户请求单号
|
||||
* <p>
|
||||
* 商户创建批次凭据号(格式:商户id+日期+流水号),商户侧需保持唯一性。
|
||||
*/
|
||||
private String outRequestNo;
|
||||
/**
|
||||
* 事件通知配置
|
||||
*/
|
||||
private BusiFavorNotifyConfig notifyConfig;
|
||||
|
||||
|
||||
/**
|
||||
* 商家券code模式枚举
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
public enum CouponCodeMode {
|
||||
|
||||
/**
|
||||
* 系统分配券code。(固定22位纯数字)
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
WECHATPAY_MODE,
|
||||
/**
|
||||
* 商户发放时接口指定券code。
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
MERCHANT_API,
|
||||
/**
|
||||
* 商户上传自定义code,发券时系统随机选取上传的券code。
|
||||
*
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
MERCHANT_UPLOAD
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 使券失效API请求参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class BusiFavorDeactivateParams {
|
||||
|
||||
/**
|
||||
* 券code
|
||||
*/
|
||||
private String couponCode;
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String stockId;
|
||||
/**
|
||||
* 失效请求单据号
|
||||
*/
|
||||
private String deactivateRequestNo;
|
||||
/**
|
||||
* 失效原因
|
||||
*/
|
||||
private String deactivateReason;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 事件通知配置
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class BusiFavorNotifyConfig {
|
||||
|
||||
/**
|
||||
* 事件通知appid
|
||||
* <p>
|
||||
* 用于回调通知时,计算返回操作用户的openid(诸如领券用户),支持小程序or公众号的APPID;
|
||||
* 如该字段不填写,则回调通知中涉及到用户身份信息的openid与unionid都将为空。
|
||||
*/
|
||||
private String notifyAppid;
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* 商家券领券事件回调通知解密
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class BusiFavorReceiveConsumeData {
|
||||
|
||||
/**
|
||||
* 业务细分事件类型
|
||||
* <p>
|
||||
* 枚举值:
|
||||
* EVENT_TYPE_BUSICOUPON_SEND:商家券用户领券通知
|
||||
*/
|
||||
private String eventType;
|
||||
/**
|
||||
* 券code
|
||||
*/
|
||||
private String couponCode;
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String stockId;
|
||||
/**
|
||||
* 发放时间 rfc 3339 yyyy-MM-ddTHH:mm:ss+TIMEZONE
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX", timezone = "GMT+8")
|
||||
private OffsetDateTime sendTime;
|
||||
/**
|
||||
* 微信用户在appid下的唯一标识。
|
||||
*/
|
||||
private String openid;
|
||||
/**
|
||||
* 微信用户在同一个微信开放平台账号下的唯一用户标识,
|
||||
* unionid获取方式请参见 <a target= "_blank" href= "https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/union-id.html">《UnionID机制说明》</a> 文档。
|
||||
*/
|
||||
private String unionid;
|
||||
/**
|
||||
* 发券商户号
|
||||
*/
|
||||
private String sendMerchant;
|
||||
/**
|
||||
* 发放渠道
|
||||
*/
|
||||
private SendChannel sendChannel;
|
||||
/**
|
||||
* 发券附加信息,仅在支付有礼、扫码领券(营销馆)、会员有礼发放渠道,才有该信息
|
||||
*/
|
||||
private AttachInfo attachInfo;
|
||||
|
||||
|
||||
/**
|
||||
* 发放渠道
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
public enum SendChannel {
|
||||
|
||||
/**
|
||||
* 小程序
|
||||
*/
|
||||
BUSICOUPON_SEND_CHANNEL_MINIAPP,
|
||||
/**
|
||||
* API
|
||||
*/
|
||||
BUSICOUPON_SEND_CHANNEL_API,
|
||||
/**
|
||||
* 支付有礼
|
||||
*/
|
||||
BUSICOUPON_SEND_CHANNEL_PAYGIFT,
|
||||
/**
|
||||
* H5
|
||||
*/
|
||||
BUSICOUPON_SEND_CHANNEL_H5,
|
||||
|
||||
/**
|
||||
* 面对面
|
||||
*/
|
||||
BUSICOUPON_SEND_CHANNEL_FTOF,
|
||||
/**
|
||||
* 会员卡活动
|
||||
*/
|
||||
BUSICOUPON_SEND_CHANNEL_MEMBER_CARD_ACT,
|
||||
/**
|
||||
* 扫码领券(营销馆)
|
||||
*/
|
||||
BUSICOUPON_SEND_CHANNEL_HALL
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家券领券事件回调通知解密-发券附加信息
|
||||
* <p>
|
||||
* 仅在支付有礼、扫码领券(营销馆)、会员有礼发放渠道,才有该信息
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public static class AttachInfo {
|
||||
|
||||
/**
|
||||
* 交易订单编号
|
||||
* <p>
|
||||
* 仅在支付有礼渠道,才有该信息,对应支付有礼曝光支付订单编号信息
|
||||
*/
|
||||
private String transactionId;
|
||||
/**
|
||||
* 支付有礼活动编号对应{@link SendChannel#BUSICOUPON_SEND_CHANNEL_PAYGIFT}
|
||||
* <p>
|
||||
* 营销馆活动ID对应{@link SendChannel#BUSICOUPON_SEND_CHANNEL_HALL}
|
||||
* <p>
|
||||
* 二选一,且只在对应场景下出现
|
||||
*/
|
||||
private String actCode;
|
||||
/**
|
||||
* 仅在扫码领券(营销馆)渠道,才有该信息,对应领券的营销馆 馆ID信息
|
||||
*/
|
||||
private String hallCode;
|
||||
/**
|
||||
* 仅在扫码领券(营销馆)渠道,才有该信息,对应领券的营销馆所属商户号信息
|
||||
*/
|
||||
private Integer hallBelongMchId;
|
||||
/**
|
||||
* 仅在会员卡活动渠道,才有该信息,对应会员卡Card_ID信息
|
||||
*/
|
||||
private String cardId;
|
||||
/**
|
||||
* 仅在会员卡活动渠道,才有该信息,对应用户卡包会员卡卡Code信息
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 仅在会员卡活动渠道,才有该信息,对应会员有礼活动ID信息
|
||||
*/
|
||||
private String activityId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 修改商家券基本信息API请求参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class BusiFavorRefundParams {
|
||||
|
||||
/**
|
||||
* 券code
|
||||
*/
|
||||
private String couponCode;
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String stockId;
|
||||
/**
|
||||
* 退券请求单据号
|
||||
*/
|
||||
private String returnRequestNo;
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.BusiFavorCodeDisplayMode;
|
||||
import cn.felord.payment.wechat.enumeration.BusiFavorUseMethod;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 修改商家券基本信息API请求参数.
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class BusiFavorUpdateParams {
|
||||
|
||||
/**
|
||||
* 商家券批次号,必传
|
||||
*/
|
||||
private String stockId;
|
||||
/**
|
||||
* 自定义入口
|
||||
*/
|
||||
private UpdateCustomEntrance customEntrance;
|
||||
/**
|
||||
* 商家券批次名称,[1,21]
|
||||
*/
|
||||
private String stockName;
|
||||
/**
|
||||
* 批次备注,[1,20]
|
||||
*/
|
||||
private String comment;
|
||||
/**
|
||||
* 适用商品范围
|
||||
* <p>
|
||||
* 用来描述批次在哪些商品可用,会显示在微信卡包中。字数上限为15个,一个中文汉字/英文字母/数字均占用一个字数。
|
||||
*/
|
||||
private String goodsName;
|
||||
/**
|
||||
* 商户请求单号
|
||||
* <p>
|
||||
* 商户创建批次凭据号(格式:商户id+日期+流水号),商户侧需保持唯一性。
|
||||
*/
|
||||
private String outRequestNo;
|
||||
/**
|
||||
* 样式信息
|
||||
*/
|
||||
private DisplayPatternInfo displayPatternInfo;
|
||||
/**
|
||||
* 核销规则
|
||||
*/
|
||||
private UpdateCouponUseRule couponUseRule;
|
||||
/**
|
||||
* 券发放规则
|
||||
*/
|
||||
private UpdateStockSendRule stockSendRule;
|
||||
/**
|
||||
* 事件通知配置
|
||||
*/
|
||||
private BusiFavorNotifyConfig notifyConfig;
|
||||
|
||||
|
||||
/**
|
||||
* 商家券核销规则-自定义入口修改参数
|
||||
* <p>
|
||||
* 卡详情页面,可选择多种入口引导用户。
|
||||
*
|
||||
* @author felord.cn
|
||||
* @see CustomEntrance
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public static class UpdateCustomEntrance {
|
||||
|
||||
/**
|
||||
* 营销馆id
|
||||
*/
|
||||
private String hallId;
|
||||
/**
|
||||
* 小程序入口
|
||||
*/
|
||||
private MiniProgramsInfo miniProgramsInfo;
|
||||
/**
|
||||
* 商户公众号appid
|
||||
* <p>
|
||||
* 从券详情可跳转至公众号
|
||||
*/
|
||||
private String appid;
|
||||
/**
|
||||
* code展示模式
|
||||
*/
|
||||
private BusiFavorCodeDisplayMode codeDisplayMode;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家券核销规则修改参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @see CouponUseRule
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public static class UpdateCouponUseRule {
|
||||
|
||||
/**
|
||||
* 核销方式
|
||||
*/
|
||||
private BusiFavorUseMethod useMethod;
|
||||
/**
|
||||
* 核销小程序appid
|
||||
*
|
||||
* @see BusiFavorUseMethod#MINI_PROGRAMS
|
||||
*/
|
||||
private String miniProgramsAppid;
|
||||
/**
|
||||
* 核销小程序path
|
||||
*
|
||||
* @see #miniProgramsAppid
|
||||
*/
|
||||
private String miniProgramsPath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 商家券发放规则修改参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @see StockSendRule
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public static class UpdateStockSendRule {
|
||||
|
||||
/**
|
||||
* 是否开启自然人限制
|
||||
*/
|
||||
private Boolean naturalPersonLimit;
|
||||
/**
|
||||
* 可疑账号拦截
|
||||
*/
|
||||
private Boolean preventApiAbuse;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* 核销用户券请求参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class BusiFavorUseParams {
|
||||
/**
|
||||
* 券code
|
||||
*/
|
||||
private String couponCode;
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String stockId;
|
||||
/**
|
||||
* 公众账号ID
|
||||
*/
|
||||
private String appid;
|
||||
/**
|
||||
* 请求核销时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX", timezone = "GMT+8")
|
||||
private OffsetDateTime useTime;
|
||||
/**
|
||||
* 核销请求单据号,商户侧保证唯一
|
||||
*/
|
||||
private String useRequestNo;
|
||||
/**
|
||||
* 用户标识,用户的唯一标识,做安全校验使用
|
||||
*/
|
||||
private String openid;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商家券核销规则-券可核销时间
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class CouponAvailableTime {
|
||||
|
||||
/**
|
||||
* 领取后N天开始生效
|
||||
* <p>
|
||||
* 日期区间内,用户领券后需等待x天开始生效。例如领券后当天开始生效则无需填写,领券后第2天开始生效填1,以此类推……
|
||||
* <p>
|
||||
* 用户在有效期开始前领取商家券,则从有效期第1天开始计算天数,用户在有效期内领取商家券,则从领取当天开始计算天数。无论用户何时领取商家券,商家券在活动有效期结束后均不可用。
|
||||
* <p>
|
||||
* 需配合{@link #availableDayAfterReceive} 一同填写,不可单独填写。
|
||||
*/
|
||||
private int waitDaysAfterReceive;
|
||||
/**
|
||||
* 生效后N天内有效
|
||||
* <p>
|
||||
* 日期区间内,券生效后x天内有效。例如生效当天内有效填1,生效后2天内有效填2,以此类推……
|
||||
* <p>
|
||||
* 注意,用户在有效期开始前领取商家券,则从有效期第1天开始计算天数,用户在有效期内领取商家券,则从领取当天开始计算天数,无论用户何时领取商家券,商家券在活动有效期结束后均不可用。
|
||||
* <p>
|
||||
* 可配合{@link #waitDaysAfterReceive}一同填写,也可单独填写。单独填写时,有效期内领券后立即生效,生效后x天内有效。
|
||||
*/
|
||||
private int availableDayAfterReceive;
|
||||
/**
|
||||
* 批次开始时间 rfc 3339 yyyy-MM-ddTHH:mm:ss+TIMEZONE
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX", timezone = "GMT+8")
|
||||
private OffsetDateTime availableBeginTime;
|
||||
/**
|
||||
* 批次结束时间 rfc 3339 yyyy-MM-ddTHH:mm:ss+TIMEZONE
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX", timezone = "GMT+8")
|
||||
private OffsetDateTime availableEndTime;
|
||||
/**
|
||||
* 固定周期有效时间段
|
||||
*/
|
||||
private AvailableWeek availableWeek;
|
||||
/**
|
||||
* 无规律的有效时间段
|
||||
*/
|
||||
private List<IrregularyAvaliableTimeItem> irregularyAvaliableTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.BusiFavorUseMethod;
|
||||
import cn.felord.payment.wechat.enumeration.StockType;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商家券核销规则
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class CouponUseRule {
|
||||
|
||||
/**
|
||||
* 核销方式
|
||||
*/
|
||||
private BusiFavorUseMethod useMethod;
|
||||
/**
|
||||
* 换购券使用规则
|
||||
*
|
||||
* @see StockType#EXCHANGE
|
||||
*/
|
||||
private ExchangeCoupon exchangeCoupon;
|
||||
/**
|
||||
* 券可核销时间
|
||||
*/
|
||||
private CouponAvailableTime couponAvailableTime;
|
||||
/**
|
||||
* 核销小程序appid
|
||||
*
|
||||
* @see BusiFavorUseMethod#MINI_PROGRAMS
|
||||
*/
|
||||
private String miniProgramsAppid;
|
||||
/**
|
||||
* 核销小程序path
|
||||
*
|
||||
* @see #miniProgramsAppid
|
||||
*/
|
||||
private String miniProgramsPath;
|
||||
/**
|
||||
* 固定面额满减券使用规则
|
||||
*
|
||||
* @see StockType#NORMAL
|
||||
*/
|
||||
private FixedNormalCoupon fixedNormalCoupon;
|
||||
/**
|
||||
* 折扣券使用规则
|
||||
*
|
||||
* @see StockType#DISCOUNT
|
||||
*/
|
||||
private DiscountCoupon discountCoupon;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.BusiFavorCodeDisplayMode;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商家券核销规则-自定义入口
|
||||
* <p>
|
||||
* 卡详情页面,可选择多种入口引导用户。
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class CustomEntrance {
|
||||
|
||||
/**
|
||||
* 可用门店id
|
||||
* <p>
|
||||
* 不可修改项
|
||||
*/
|
||||
private String storeId;
|
||||
/**
|
||||
* 营销馆id
|
||||
*/
|
||||
private String hallId;
|
||||
/**
|
||||
* 小程序入口
|
||||
*/
|
||||
private MiniProgramsInfo miniProgramsInfo;
|
||||
/**
|
||||
* 商户公众号appid
|
||||
* <p>
|
||||
* 从券详情可跳转至公众号
|
||||
*/
|
||||
private String appid;
|
||||
/**
|
||||
* code展示模式
|
||||
*/
|
||||
private BusiFavorCodeDisplayMode codeDisplayMode;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.felord.payment.wechat.v3.model.busifavor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商家券核销规则-折扣券使用规则
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class DiscountCoupon {
|
||||
|
||||
/**
|
||||
* 折扣百分比,例如:88为八八折
|
||||
*/
|
||||
private Integer discountPercent;
|
||||
/**
|
||||
* 消费门槛,单位:分。
|
||||
* <p>
|
||||
* 特殊规则:取值范围 1 ≤ transactionMinimum ≤ 10000000
|
||||
*/
|
||||
private Integer transactionMinimum;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package cn.felord.payment.wechat.v3.model.busifavor;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.CouponBgColor;
|
||||
import cn.felord.payment.wechat.v3.WechatMarketingFavorApi;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 商家券样式信息.
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class DisplayPatternInfo {
|
||||
|
||||
/**
|
||||
* 背景颜色
|
||||
*/
|
||||
private CouponBgColor backgroundColor;
|
||||
/**
|
||||
* 商户logo
|
||||
* <p>
|
||||
* <ol>
|
||||
* <li>商户logo大小需为120像素*120像素</li>
|
||||
* <li>支持JPG/JPEG/PNG格式,且图片小于1M</li>
|
||||
* </ol>
|
||||
* <p>
|
||||
* 仅支持通过 <a target= "_blank" href= "https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/marketing/chapter3_1.shtml">图片上传API</a> 接口获取的图片URL地址。
|
||||
*
|
||||
* @see WechatMarketingFavorApi#marketingImageUpload(MultipartFile)
|
||||
*/
|
||||
private String merchantLogoUrl;
|
||||
/**
|
||||
* 券详情图片
|
||||
* <p>
|
||||
* <ol>
|
||||
* <li>需为850像素*350像素</li>
|
||||
* <li>图片大小不超过2M</li>
|
||||
* <li>支持JPG/PNG格式</li>
|
||||
* </ol>
|
||||
* <p>
|
||||
* 仅支持通过 <a target= "_blank" href= "https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/marketing/chapter3_1.shtml">图片上传API</a> 接口获取的图片URL地址。
|
||||
*
|
||||
* @see WechatMarketingFavorApi#marketingImageUpload(MultipartFile)
|
||||
*/
|
||||
private String couponImageUrl;
|
||||
/**
|
||||
* 使用须知
|
||||
* <p>
|
||||
* 用于说明详细的活动规则,会展示在代金券详情页。
|
||||
* <p>
|
||||
* 示例值:xxx门店可用
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 商户名称,字数上限为16个
|
||||
*/
|
||||
private String merchantName;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商家券核销规则-换购券使用规则
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class ExchangeCoupon {
|
||||
|
||||
/**
|
||||
* 单品换购价,单位:分。
|
||||
* <p>
|
||||
* 特殊规则:取值范围 1 ≤ exchangePrice ≤ 10000000
|
||||
*/
|
||||
private Integer exchangePrice;
|
||||
/**
|
||||
* 消费门槛,单位:分。
|
||||
* <p>
|
||||
* 特殊规则:取值范围 1 ≤ transactionMinimum ≤ 10000000
|
||||
*/
|
||||
private Integer transactionMinimum;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.felord.payment.wechat.v3.model.busifavor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商家券核销规则-固定面额满减券使用规则
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class FixedNormalCoupon {
|
||||
|
||||
/**
|
||||
* 优惠金额,单位:分。
|
||||
* <p>
|
||||
* 特殊规则:取值范围 1 ≤ transactionMinimum ≤ 10000000
|
||||
*/
|
||||
private Integer discountAmount;
|
||||
/**
|
||||
* 消费门槛,单位:分。
|
||||
* <p>
|
||||
* 特殊规则:取值范围 1 ≤ transactionMinimum ≤ 10000000
|
||||
*/
|
||||
private Integer transactionMinimum;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
/**
|
||||
* 商家券核销规则-券可核销时间-无规律的有效时间段
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class IrregularyAvaliableTimeItem{
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX", timezone = "GMT+8")
|
||||
private OffsetDateTime beginTime;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX", timezone = "GMT+8")
|
||||
private OffsetDateTime endTime;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商家券核销规则-自定义入口-小程序入口
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class MiniProgramsInfo{
|
||||
|
||||
/**
|
||||
* 商家小程序appid
|
||||
* <p>
|
||||
* 商家小程序appid要与归属商户号有M-A or M-m-suba关系。
|
||||
*/
|
||||
private String miniProgramsAppid;
|
||||
/**
|
||||
* 商家小程序path
|
||||
*/
|
||||
private String miniProgramsPath;
|
||||
/**
|
||||
* 入口文案,字数上限为5个,一个中文汉字/英文字母/数字均占用一个字数。
|
||||
*/
|
||||
private String guidingWords;
|
||||
/**
|
||||
* 小程序入口引导文案,用户自定义字段。字数上限为6个,一个中文汉字/英文字母/数字均占用一个字数。
|
||||
*/
|
||||
private String entranceWords;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.felord.payment.wechat.v3.model.busifavor;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.StockType;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商家券发放规则.
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class StockSendRule {
|
||||
|
||||
/**
|
||||
* 批次最大发放个数
|
||||
* <p>
|
||||
* 特殊规则:取值范围 1 ≤ maxCoupons ≤ 1000000000
|
||||
*/
|
||||
private Integer maxCoupons;
|
||||
/**
|
||||
* 用户最大可领个数
|
||||
* <p>
|
||||
* 每个用户最多100张券 。
|
||||
*/
|
||||
private Integer maxCouponsPerUser;
|
||||
/**
|
||||
* 单天发放上限个数
|
||||
* <p>
|
||||
* {@link StockType#DISCOUNT}或者{@link StockType#DISCOUNT}时可传入此字段控制单天发放上限
|
||||
* <p>
|
||||
* 特殊规则:取值范围 1 ≤ maxCouponsByDay ≤ 1000000000
|
||||
*/
|
||||
private Integer maxCouponsByDay;
|
||||
/**
|
||||
* 是否开启自然人限制
|
||||
*/
|
||||
private Boolean naturalPersonLimit;
|
||||
/**
|
||||
* 可疑账号拦截
|
||||
*/
|
||||
private Boolean preventApiAbuse;
|
||||
/**
|
||||
* 是否允许转赠
|
||||
*/
|
||||
private Boolean transferable;
|
||||
/**
|
||||
* 是否允许分享链接
|
||||
*/
|
||||
private Boolean shareable;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 查询用户单张券详情请求参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class UserBusiCouponQueryParams {
|
||||
|
||||
/**
|
||||
* 券code
|
||||
*/
|
||||
private String couponCode;
|
||||
/**
|
||||
* 与当前调用接口商户号有绑定关系的appid。支持小程序appid与公众号appid。
|
||||
*/
|
||||
private String appid;
|
||||
/**
|
||||
* Openid信息,用户在appid下的唯一标识。
|
||||
*/
|
||||
private String openid;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.busifavor;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.CouponStatus;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 根据过滤条件查询用户券API查询参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.4.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class UserBusiFavorQueryParams {
|
||||
|
||||
/**
|
||||
* 用户标识,用户在appid下的唯一标识。
|
||||
*/
|
||||
private String openid;
|
||||
/**
|
||||
* 与当前调用接口商户号有绑定关系的appid。支持小程序appid与公众号appid。
|
||||
*/
|
||||
private String appid;
|
||||
/**
|
||||
* 商户券批次号
|
||||
*/
|
||||
private String stockId;
|
||||
/**
|
||||
* 券状态
|
||||
*/
|
||||
private CouponStatus couponState;
|
||||
/**
|
||||
* 创建批次的商户号
|
||||
*/
|
||||
private String creatorMerchant;
|
||||
/**
|
||||
* 批次归属商户号
|
||||
*/
|
||||
private String belongMerchant;
|
||||
/**
|
||||
* 批次发放商户号
|
||||
*/
|
||||
private String senderMerchant;
|
||||
/**
|
||||
* 分页页码
|
||||
*/
|
||||
private String offset;
|
||||
/**
|
||||
* 分页大小
|
||||
*/
|
||||
private String limit;
|
||||
}
|
||||
@@ -5,11 +5,11 @@
|
||||
<parent>
|
||||
<groupId>cn.felord</groupId>
|
||||
<artifactId>payment-spring-boot</artifactId>
|
||||
<version>1.0.3.RELEASE</version>
|
||||
<version>1.0.4.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>payment-spring-boot-starter</artifactId>
|
||||
<version>1.0.3.RELEASE</version>
|
||||
<version>1.0.4.RELEASE</version>
|
||||
<packaging>jar</packaging>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
6
pom.xml
6
pom.xml
@@ -4,7 +4,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.3.RELEASE</version>
|
||||
<version>1.0.4.RELEASE</version>
|
||||
<packaging>pom</packaging>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<tag>payment-spring-boot-1.0.0.RELEASE</tag>
|
||||
<tag>payment-spring-boot-1.0.4.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>
|
||||
@@ -48,7 +48,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-boot.version>2.4.1</spring-boot.version>
|
||||
<spring-boot.version>2.4.2</spring-boot.version>
|
||||
<aliy-pay-sdk.version>4.10.167.ALL</aliy-pay-sdk.version>
|
||||
<oss-starter.version>1.0.0.RELEASE</oss-starter.version>
|
||||
<lombok.verison>1.18.12</lombok.verison>
|
||||
|
||||
Reference in New Issue
Block a user