From c101cdd8579601b85b6a69f502ad021e843375ca Mon Sep 17 00:00:00 2001 From: dax Date: Mon, 28 Dec 2020 15:41:29 +0800 Subject: [PATCH 1/8] =?UTF-8?q?refactor:=20=E5=85=88=E4=BA=AB=E5=8D=A1?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/wechat/enumeration/CountType.java | 36 ++++++ .../DiscountCardAcceptedConsumeData.java | 83 +++++++------- .../DiscountCardAgreementEndConsumeData.java | 104 +++++++++++------- 3 files changed, 141 insertions(+), 82 deletions(-) create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CountType.java diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CountType.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CountType.java new file mode 100644 index 0000000..4fc2730 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CountType.java @@ -0,0 +1,36 @@ +/* + * + * Copyright 2019-2020 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.3.RELEASE + */ +public enum CountType { + /** + * 不限数量 + */ + COUNT_UNLIMITED, + /** + * 有限数量 + */ + COUNT_LIMIT +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAcceptedConsumeData.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAcceptedConsumeData.java index 54df467..f649370 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAcceptedConsumeData.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAcceptedConsumeData.java @@ -14,11 +14,11 @@ * 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.discountcard; import cn.felord.payment.wechat.enumeration.ContractStatus; +import cn.felord.payment.wechat.enumeration.CountType; import lombok.Data; import java.util.List; @@ -33,51 +33,54 @@ import java.util.List; public class DiscountCardAcceptedConsumeData { /** - * The Appid. + * 应用appid需要绑定微信商户平台 */ private String appid; /** - * The Card id. + * 先享卡ID,唯一标识一个先享卡 */ private String cardId; /** - * The Card template id. + * 先享卡模板ID,唯一定义此资源的标识。创建模板后可获得 */ private String cardTemplateId; /** - * The Create time. + * 创建先享卡的时间 */ private String createTime; /** - * The Mchid. + * 商户号 */ private String mchid; /** - * The Objectives. + * 用户先享卡目标列表 */ private List objectives; /** - * The Openid. + * 用户标识,用户在{@code appid}下的唯一标识 */ private String openid; /** - * The Out card code. + * 商户领卡号,商户在请求领卡预受理接口时传入的领卡请求号,同一个商户号下必须唯一,要求32个字符内,只能是数字、大小写字母_-|* */ private String outCardCode; /** - * The Rewards. + * 用户先享卡优惠列表 */ private List rewards; /** - * The Sharer openid. + * 邀请者用户标识 + *

+ * 微信用户在商户对应appid下的唯一标识。 + * 仅当此卡是通过“邀请有礼”渠道领卡时,会返回此字段;指此先享卡是通过此[邀请者]邀请领卡成功的。当此先享卡完成约定时,商户可给此[邀请者]下发应邀请有礼的奖励 */ private String sharerOpenid; /** - * The State. + * 先享卡的守约状态 */ private ContractStatus state; /** - * The Time range. + * 约定时间期限 */ private TimeRange timeRange; @@ -91,23 +94,27 @@ public class DiscountCardAcceptedConsumeData { public static class Objective { /** - * The Count. + * 目标数量 + *

+ * 履约目标需要完成的数量,必须大于0。 */ private Long count; /** - * The Description. + * 目标描述 */ private String description; /** - * The Name. + * 目标名称 */ private String name; /** - * The Objective id. + * 目标id */ private String objectiveId; /** - * The Unit. + * 目标单位 + *

+ * 示例值:次 */ private String unit; @@ -123,38 +130,42 @@ public class DiscountCardAcceptedConsumeData { public static class Reward { /** - * The Amount. + * 优惠金额 + *

+ * 1、优惠金额,此项优惠对应的优惠总金额,单位:分,必须大于0。 + * 2、此项优惠已享累计金额≤创建模板时配置的此项奖励的奖励金额, + * 例如:优惠为【满10元减3元优惠券4张】时,用户一次消费使用了2张优惠券,优惠金额为本次优惠总金额6元,优惠数量为本次使用优惠的优惠券数量2张 */ private Long amount; /** - * The Count. + * 优惠数量 */ private Long count; /** - * The Count type. + * 优惠数量类型 */ private CountType countType; /** - * The Description. + * 优惠描述 */ private String description; /** - * The Name. + * 优惠名称 */ private String name; /** - * The Reward id. + * 优惠ID */ private String rewardId; /** - * The Unit. + * 优惠单位,例如 “个” */ private String unit; } /** - * The type Time range. + * 先享卡约定时间期限 * * @author felord.cn * @since 1.0.2.RELEASE @@ -162,29 +173,13 @@ public class DiscountCardAcceptedConsumeData { @Data public static class TimeRange { /** - * The Betin time. + * 开始时间 */ private String betinTime; /** - * The End time. + * 结束时间 */ private String endTime; } - /** - * 优惠数量的类型标识 - * - * @author felord.cn - * @since 1.0.2.RELEASE - */ - public enum CountType{ - /** - * 不限数量 - */ - COUNT_UNLIMITED, - /** - * 有限数量 - */ - COUNT_LIMIT - } } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAgreementEndConsumeData.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAgreementEndConsumeData.java index 35de7b5..f900e2b 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAgreementEndConsumeData.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAgreementEndConsumeData.java @@ -14,10 +14,11 @@ * 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.discountcard; +import cn.felord.payment.wechat.enumeration.ContractStatus; +import cn.felord.payment.wechat.enumeration.CountType; import lombok.Data; import java.util.List; @@ -31,60 +32,60 @@ import java.util.List; @Data public class DiscountCardAgreementEndConsumeData { /** - * The Appid. + * 应用appid需要绑定微信商户平台 */ private String appid; /** - * The Card id. + * 先享卡ID,唯一标识一个先享卡 */ private String cardId; /** - * The Card template id. + * 先享卡模板ID,唯一定义此资源的标识。创建模板后可获得 */ private String cardTemplateId; /** - * The Create time. + * 创建先享卡的时间 */ private String createTime; /** - * The Mchid. + * 商户号 */ private String mchid; /** - * The Objectives. + * 用户先享卡目标列表 */ private List objectives; /** - * The Openid. + * 用户标识,用户在{@code appid}下的唯一标识 */ private String openid; /** - * The Out card code. + * 商户领卡号,商户在请求领卡预受理接口时传入的领卡请求号,同一个商户号下必须唯一,要求32个字符内,只能是数字、大小写字母_-|* */ private String outCardCode; /** - * The Rewards. + * 用户先享卡优惠列表 */ private List rewards; /** - * The State. + * 先享卡的守约状态 */ - private String state; + private ContractStatus state; /** - * The Time range. + * 先享卡约定时间期限 */ private TimeRange timeRange; /** - * The Total amount. + * 享受优惠总金额,单位为 “分” */ private Long totalAmount; /** - * The Unfinished reason. + * 未完成约定原因 */ - private String unfinishedReason; + private UnfinishedReason unfinishedReason; /** - * The type Objective. + * 目标列表属性 * * @author felord.cn * @since 1.0.2.RELEASE @@ -93,15 +94,17 @@ public class DiscountCardAgreementEndConsumeData { public static class Objective { /** - * The Count. + * 目标数量 + *

+ * 履约目标需要完成的数量,必须大于0。 */ private Long count; /** - * The Description. + * 目标描述 */ private String description; /** - * The Name. + * 目标名称 */ private String name; /** @@ -109,18 +112,20 @@ public class DiscountCardAgreementEndConsumeData { */ private List objectiveCompletionRecords; /** - * The Objective id. + * 目标id */ private String objectiveId; /** - * The Unit. + * 目标单位 + *

+ * 示例值:次 */ private String unit; } /** - * The type Time range. + * 先享卡约定时间期限 * * @author felord.cn * @since 1.0.2.RELEASE @@ -128,17 +133,17 @@ public class DiscountCardAgreementEndConsumeData { @Data public static class TimeRange { /** - * The Betin time. + * 开始时间 */ private String betinTime; /** - * The End time. + * 结束时间 */ private String endTime; } /** - * The type Reward. + * 优惠列表属性 * * @author felord.cn * @since 1.0.2.RELEASE @@ -147,37 +152,60 @@ public class DiscountCardAgreementEndConsumeData { public static class Reward { /** - * The Amount. + * 优惠金额 + *

+ * 1、优惠金额,此项优惠对应的优惠总金额,单位:分,必须大于0。 + * 2、此项优惠已享累计金额≤创建模板时配置的此项奖励的奖励金额, + * 例如:优惠为【满10元减3元优惠券4张】时,用户一次消费使用了2张优惠券,优惠金额为本次优惠总金额6元,优惠数量为本次使用优惠的优惠券数量2张 */ private Long amount; /** - * The Count. + * 优惠数量 */ private Long count; /** - * The Count type. + * 优惠数量类型 */ - private String countType; + private CountType countType; /** - * The Description. + * 优惠描述 */ private String description; /** - * The Name. + * 优惠名称 */ private String name; /** - * The Reward id. + * 优惠ID */ private String rewardId; /** - * The Reward usage records. - */ - private List rewardUsageRecords; - /** - * The Unit. + * 优惠单位,例如 “个” */ private String unit; + /** + * 优惠使用记录列表 + */ + private List rewardUsageRecords; } + + /** + * 未完成约定原因 + *

+ * 当订单守约状态为{@link ContractStatus#UNFINISHED},返回此字段 + * + * @since 1.0.3.RELEASE + */ + enum UnfinishedReason { + /** + * 到期未完成约 + */ + DUE_TO_QUIT, + /** + * 提前退出约定 + */ + EARLY_QUIT + } + } From e8737adbbf1e5968697fbd00591291c0a2e29c8d Mon Sep 17 00:00:00 2001 From: dax Date: Mon, 28 Dec 2020 16:54:01 +0800 Subject: [PATCH 2/8] =?UTF-8?q?refactor:=20=E5=85=88=E4=BA=AB=E5=8D=A1?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wechat/enumeration/ContractStatus.java | 17 +++++ .../payment/wechat/enumeration/CountType.java | 1 - .../wechat/enumeration/StrategyType.java | 17 +++++ .../wechat/enumeration/UnfinishedReason.java | 36 ++++++++++ .../payment/wechat/v3/WechatPayCallback.java | 1 + .../DiscountCardAgreementEndConsumeData.java | 21 +----- .../discountcard/DiscountCardConsumer.java | 7 +- .../DiscountCardUserPaidConsumeData.java | 65 ++++++++++++------- .../ObjectiveCompletionRecord.java | 17 +++-- .../model/discountcard/RewardUsageRecord.java | 24 ++++--- .../model/discountcard/UserRecordsParams.java | 10 ++- .../PayScoreConsumer.java | 9 +-- 12 files changed, 146 insertions(+), 79 deletions(-) create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/UnfinishedReason.java rename payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/{discountcard => payscore}/PayScoreConsumer.java (77%) diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/ContractStatus.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/ContractStatus.java index 17625b5..f3fc108 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/ContractStatus.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/ContractStatus.java @@ -1,3 +1,20 @@ +/* + * + * Copyright 2019-2020 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; /** diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CountType.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CountType.java index 4fc2730..216ca86 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CountType.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CountType.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.felord.payment.wechat.enumeration; /** diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/StrategyType.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/StrategyType.java index 2aa3bbc..6322c47 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/StrategyType.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/StrategyType.java @@ -1,3 +1,20 @@ +/* + * + * Copyright 2019-2020 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; /** diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/UnfinishedReason.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/UnfinishedReason.java new file mode 100644 index 0000000..f705629 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/UnfinishedReason.java @@ -0,0 +1,36 @@ +/* + * + * Copyright 2019-2020 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; + +/** + * 未完成约定原因 + *

+ * 当订单守约状态为{@link ContractStatus#UNFINISHED},返回此字段 + * + * @since 1.0.3.RELEASE + */ +public enum UnfinishedReason { + /** + * 到期未完成约 + */ + DUE_TO_QUIT, + /** + * 提前退出约定 + */ + EARLY_QUIT +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java index ddc9301..9a0ae13 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java @@ -24,6 +24,7 @@ import cn.felord.payment.wechat.v3.model.ResponseSignVerifyParams; import cn.felord.payment.wechat.v3.model.TransactionConsumeData; import cn.felord.payment.wechat.v3.model.combine.CombineTransactionConsumeData; import cn.felord.payment.wechat.v3.model.discountcard.*; +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; import cn.felord.payment.wechat.v3.model.payscore.PayScoreUserPermissionConsumeData; diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAgreementEndConsumeData.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAgreementEndConsumeData.java index f900e2b..f185b9d 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAgreementEndConsumeData.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAgreementEndConsumeData.java @@ -19,6 +19,7 @@ package cn.felord.payment.wechat.v3.model.discountcard; import cn.felord.payment.wechat.enumeration.ContractStatus; import cn.felord.payment.wechat.enumeration.CountType; +import cn.felord.payment.wechat.enumeration.UnfinishedReason; import lombok.Data; import java.util.List; @@ -108,7 +109,7 @@ public class DiscountCardAgreementEndConsumeData { */ private String name; /** - * The Objective completion records. + * 用户先享卡目标完成纪录 */ private List objectiveCompletionRecords; /** @@ -190,22 +191,4 @@ public class DiscountCardAgreementEndConsumeData { } - /** - * 未完成约定原因 - *

- * 当订单守约状态为{@link ContractStatus#UNFINISHED},返回此字段 - * - * @since 1.0.3.RELEASE - */ - enum UnfinishedReason { - /** - * 到期未完成约 - */ - DUE_TO_QUIT, - /** - * 提前退出约定 - */ - EARLY_QUIT - } - } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardConsumer.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardConsumer.java index 55220a8..c4ad7c9 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardConsumer.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardConsumer.java @@ -14,7 +14,6 @@ * 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.discountcard; @@ -31,15 +30,15 @@ import java.util.function.Consumer; @Data public class DiscountCardConsumer { /** - * The Accepted consume data consumer. + * 用户领取微信先享卡通知解密 */ private Consumer acceptedConsumeDataConsumer; /** - * The Agreement end consume data consumer. + * 微信支付先享卡用户守约状态变化通知解密 */ private Consumer agreementEndConsumeDataConsumer; /** - * The Card user paid consume data consumer. + * 先享卡扣费状态变化通知解密 */ private Consumer cardUserPaidConsumeDataConsumer; } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardUserPaidConsumeData.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardUserPaidConsumeData.java index a83710b..a1a31d2 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardUserPaidConsumeData.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardUserPaidConsumeData.java @@ -14,15 +14,15 @@ * 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.discountcard; +import cn.felord.payment.wechat.enumeration.ContractStatus; +import cn.felord.payment.wechat.enumeration.UnfinishedReason; import lombok.Data; /** - * 先享卡扣费状态变化通知解密. - * + * 先享卡扣费状态变化通知解密 * * @author felord.cn * @since 1.0.2.RELEASE @@ -31,67 +31,84 @@ import lombok.Data; public class DiscountCardUserPaidConsumeData { /** - * The Appid. + * 应用appid需要绑定微信商户平台 */ private String appid; /** - * The Card id. + * 先享卡ID,唯一标识一个先享卡 */ private String cardId; /** - * The Card template id. + * 先享卡模板ID,唯一定义此资源的标识。创建模板后可获得 */ private String cardTemplateId; /** - * The Mchid. + * 商户号 */ private String mchid; /** - * The Openid. + * 用户标识,用户在{@code appid}下的唯一标识 */ private String openid; /** - * The Out card code. + * 商户领卡号,商户在请求领卡预受理接口时传入的领卡请求号,同一个商户号下必须唯一,要求32个字符内,只能是数字、大小写字母_-|* */ private String outCardCode; /** - * The Pay information. + * 先享卡的守约状态 */ - private PayInformation payInformation; + private ContractStatus state; /** - * The State. - */ - private String state; - /** - * The Total amount. + * 享受优惠总金额,单位为 “分” */ private Long totalAmount; /** - * The Unfinished reason. + * 未完成约定原因 */ - private String unfinishedReason; + private UnfinishedReason unfinishedReason; + /** + * 用户退回优惠的付款信息 + */ + private PayInformation payInformation; /** - * The type Pay information. + * 用户退回优惠的付款信息 + *

+ * 当状态为{@link ContractStatus#UNFINISHED}(用户未完成约定)时,且需要退回已享受的优惠金额时,返回此字段; */ @Data public static class PayInformation { /** - * The Pay amount. + * 付款金额,用户需要退回优惠而付款的金额,单位为:分; */ private Long payAmount; /** - * The Pay state. + * 用户付款状态, */ - private String payState; + private PayState payState; /** - * The Pay time. + * 付款时间 */ private String payTime; /** - * The Transaction id. + * 微信支付订单号,仅在订单成功收款时才返回 */ private String transactionId; } + + /** + * 付款状态 + * @since 1.0.3.RELEASE + */ + public enum PayState { + /** + * 付款中 + */ + PAYING, + /** + * 已付款 + */ + PAID + } } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/ObjectiveCompletionRecord.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/ObjectiveCompletionRecord.java index f4f1de9..08a449b 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/ObjectiveCompletionRecord.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/ObjectiveCompletionRecord.java @@ -14,7 +14,6 @@ * 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.discountcard; @@ -22,7 +21,7 @@ import cn.felord.payment.wechat.enumeration.StrategyType; import lombok.Data; /** - * The type Objective completion record. + * 微信先享卡目标完成纪录 * * @author felord.cn * @since 1.0.2.RELEASE @@ -31,31 +30,31 @@ import lombok.Data; public class ObjectiveCompletionRecord { /** - * The Completion count. + * 目标完成数量 */ private Long completionCount; /** - * The Completion time. + * 目标完成时间 */ private String completionTime; /** - * The Completion type. + * 目标完成类型 */ private StrategyType completionType; /** - * The Description. + * 目标完成描述 */ private String description; /** - * The Objective completion serial no. + * 目标完成流水号 */ private String objectiveCompletionSerialNo; /** - * The Objective id. + * 目标id */ private String objectiveId; /** - * The Remark. + * 备注说明 */ private String remark; diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/RewardUsageRecord.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/RewardUsageRecord.java index b9841c8..d247874 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/RewardUsageRecord.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/RewardUsageRecord.java @@ -14,7 +14,6 @@ * 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.discountcard; @@ -22,7 +21,7 @@ import cn.felord.payment.wechat.enumeration.StrategyType; import lombok.Data; /** - * The type Reward usage record. + * 优惠使用纪录列表对象 * * @author felord.cn * @since 1.0.2.RELEASE @@ -31,35 +30,40 @@ import lombok.Data; public class RewardUsageRecord { /** - * The Amount. + * 优惠金额 + * + *

    + *
  1. 优惠金额,用户此项本次享受的优惠对应的优惠总金额,单位:分,必须大于0。
  2. + *
  3. 子优惠已享金额累计≤创建模板时配置的此子优惠的价值金额 例如:优惠为【满10元减3元优惠券4张】时,用户一次消费使用了2张优惠券,优惠金额为本次优惠总金额6元,优惠数量为本次使用优惠的优惠券数量2张
  4. + *
*/ private Long amount; /** - * The Description. + * 优惠使用描述 */ private String description; /** - * The Remark. + * 备注说明 */ private String remark; /** - * The Reward id. + * 优惠Id */ private String rewardId; /** - * The Reward usage serial no. + * 优惠使用纪录流水号 */ private String rewardUsageSerialNo; /** - * The Usage count. + * 优惠使用数量 */ private Long usageCount; /** - * The Usage time. + * 优惠使用时间 */ private String usageTime; /** - * The Usage type. + * 优惠使用类型 */ private StrategyType usageType; diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/UserRecordsParams.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/UserRecordsParams.java index ff5dcc9..78a95a0 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/UserRecordsParams.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/UserRecordsParams.java @@ -14,7 +14,6 @@ * 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.discountcard; @@ -30,21 +29,20 @@ import java.util.List; */ @Data public class UserRecordsParams { - /** - * The Out card code. + * 商户领卡号,商户在请求领卡预受理接口时传入的领卡请求号,同一个商户号下必须唯一,要求32个字符内,只能是数字、大小写字母_-|* */ private String outCardCode; /** - * The Card template id. + * 先享卡模板ID,唯一定义此资源的标识。创建模板后可获得 */ private String cardTemplateId; /** - * The Objective completion records. + * 微信先享卡目标完成纪录 */ private List objectiveCompletionRecords; /** - * The Reward usage records. + * 优惠使用纪录 */ private List rewardUsageRecords; diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/PayScoreConsumer.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/payscore/PayScoreConsumer.java similarity index 77% rename from payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/PayScoreConsumer.java rename to payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/payscore/PayScoreConsumer.java index 129d258..e5e971b 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/PayScoreConsumer.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/payscore/PayScoreConsumer.java @@ -14,12 +14,9 @@ * 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.discountcard; +package cn.felord.payment.wechat.v3.model.payscore; -import cn.felord.payment.wechat.v3.model.payscore.PayScoreUserConfirmConsumeData; -import cn.felord.payment.wechat.v3.model.payscore.PayScoreUserPaidConsumeData; import lombok.Data; import java.util.function.Consumer; @@ -33,11 +30,11 @@ import java.util.function.Consumer; @Data public class PayScoreConsumer { /** - * The Confirm consume data consumer. + * 用户确认回调消费接口 */ private Consumer confirmConsumeDataConsumer; /** - * The Paid consume data consumer. + * 用户支付回调消费接口 */ private Consumer paidConsumeDataConsumer; } From f2c66bef103060f371d39f0a56038693a3a6bffa Mon Sep 17 00:00:00 2001 From: dax Date: Mon, 28 Dec 2020 16:54:01 +0800 Subject: [PATCH 3/8] =?UTF-8?q?fix:=20#I2BCMZ=20=E5=90=88=E5=8D=95?= =?UTF-8?q?=E6=94=AF=E4=BB=98url=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wechat/enumeration/ContractStatus.java | 17 +++++ .../payment/wechat/enumeration/CountType.java | 1 - .../wechat/enumeration/StrategyType.java | 17 +++++ .../wechat/enumeration/UnfinishedReason.java | 36 ++++++++++ .../wechat/enumeration/WechatPayV3Type.java | 6 +- .../payment/wechat/v3/WechatPayCallback.java | 1 + .../DiscountCardAgreementEndConsumeData.java | 21 +----- .../discountcard/DiscountCardConsumer.java | 7 +- .../DiscountCardUserPaidConsumeData.java | 65 ++++++++++++------- .../ObjectiveCompletionRecord.java | 17 +++-- .../model/discountcard/RewardUsageRecord.java | 24 ++++--- .../model/discountcard/UserRecordsParams.java | 10 ++- .../PayScoreConsumer.java | 9 +-- 13 files changed, 149 insertions(+), 82 deletions(-) create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/UnfinishedReason.java rename payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/{discountcard => payscore}/PayScoreConsumer.java (77%) diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/ContractStatus.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/ContractStatus.java index 17625b5..f3fc108 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/ContractStatus.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/ContractStatus.java @@ -1,3 +1,20 @@ +/* + * + * Copyright 2019-2020 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; /** diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CountType.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CountType.java index 4fc2730..216ca86 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CountType.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CountType.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.felord.payment.wechat.enumeration; /** diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/StrategyType.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/StrategyType.java index 2aa3bbc..6322c47 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/StrategyType.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/StrategyType.java @@ -1,3 +1,20 @@ +/* + * + * Copyright 2019-2020 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; /** diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/UnfinishedReason.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/UnfinishedReason.java new file mode 100644 index 0000000..f705629 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/UnfinishedReason.java @@ -0,0 +1,36 @@ +/* + * + * Copyright 2019-2020 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; + +/** + * 未完成约定原因 + *

+ * 当订单守约状态为{@link ContractStatus#UNFINISHED},返回此字段 + * + * @since 1.0.3.RELEASE + */ +public enum UnfinishedReason { + /** + * 到期未完成约 + */ + DUE_TO_QUIT, + /** + * 提前退出约定 + */ + EARLY_QUIT +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java index 4ca20a2..c8decc6 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java @@ -107,19 +107,19 @@ public enum WechatPayV3Type { * * @since 1.0.0.RELEASE */ - COMBINE_JSAPI(HttpMethod.POST, "%s/v3/pay/combine-transactions/jsapi"), + COMBINE_JSAPI(HttpMethod.POST, "%s/v3/combine-transactions/jsapi"), /** * 合单下单-H5支付API. * * @since 1.0.0.RELEASE */ - COMBINE_MWEB(HttpMethod.POST, "%s/v3/pay/combine-transactions/h5"), + COMBINE_MWEB(HttpMethod.POST, "%s/v3/combine-transactions/h5"), /** * 合单下单-Native支付API. * * @since 1.0.0.RELEASE */ - COMBINE_NATIVE(HttpMethod.POST, "%s/v3/pay/combine-transactions/native"), + COMBINE_NATIVE(HttpMethod.POST, "%s/v3/combine-transactions/native"), /** * 合单查询订单API. * diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java index ddc9301..9a0ae13 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java @@ -24,6 +24,7 @@ import cn.felord.payment.wechat.v3.model.ResponseSignVerifyParams; import cn.felord.payment.wechat.v3.model.TransactionConsumeData; import cn.felord.payment.wechat.v3.model.combine.CombineTransactionConsumeData; import cn.felord.payment.wechat.v3.model.discountcard.*; +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; import cn.felord.payment.wechat.v3.model.payscore.PayScoreUserPermissionConsumeData; diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAgreementEndConsumeData.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAgreementEndConsumeData.java index f900e2b..f185b9d 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAgreementEndConsumeData.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardAgreementEndConsumeData.java @@ -19,6 +19,7 @@ package cn.felord.payment.wechat.v3.model.discountcard; import cn.felord.payment.wechat.enumeration.ContractStatus; import cn.felord.payment.wechat.enumeration.CountType; +import cn.felord.payment.wechat.enumeration.UnfinishedReason; import lombok.Data; import java.util.List; @@ -108,7 +109,7 @@ public class DiscountCardAgreementEndConsumeData { */ private String name; /** - * The Objective completion records. + * 用户先享卡目标完成纪录 */ private List objectiveCompletionRecords; /** @@ -190,22 +191,4 @@ public class DiscountCardAgreementEndConsumeData { } - /** - * 未完成约定原因 - *

- * 当订单守约状态为{@link ContractStatus#UNFINISHED},返回此字段 - * - * @since 1.0.3.RELEASE - */ - enum UnfinishedReason { - /** - * 到期未完成约 - */ - DUE_TO_QUIT, - /** - * 提前退出约定 - */ - EARLY_QUIT - } - } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardConsumer.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardConsumer.java index 55220a8..c4ad7c9 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardConsumer.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardConsumer.java @@ -14,7 +14,6 @@ * 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.discountcard; @@ -31,15 +30,15 @@ import java.util.function.Consumer; @Data public class DiscountCardConsumer { /** - * The Accepted consume data consumer. + * 用户领取微信先享卡通知解密 */ private Consumer acceptedConsumeDataConsumer; /** - * The Agreement end consume data consumer. + * 微信支付先享卡用户守约状态变化通知解密 */ private Consumer agreementEndConsumeDataConsumer; /** - * The Card user paid consume data consumer. + * 先享卡扣费状态变化通知解密 */ private Consumer cardUserPaidConsumeDataConsumer; } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardUserPaidConsumeData.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardUserPaidConsumeData.java index a83710b..a1a31d2 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardUserPaidConsumeData.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/DiscountCardUserPaidConsumeData.java @@ -14,15 +14,15 @@ * 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.discountcard; +import cn.felord.payment.wechat.enumeration.ContractStatus; +import cn.felord.payment.wechat.enumeration.UnfinishedReason; import lombok.Data; /** - * 先享卡扣费状态变化通知解密. - * + * 先享卡扣费状态变化通知解密 * * @author felord.cn * @since 1.0.2.RELEASE @@ -31,67 +31,84 @@ import lombok.Data; public class DiscountCardUserPaidConsumeData { /** - * The Appid. + * 应用appid需要绑定微信商户平台 */ private String appid; /** - * The Card id. + * 先享卡ID,唯一标识一个先享卡 */ private String cardId; /** - * The Card template id. + * 先享卡模板ID,唯一定义此资源的标识。创建模板后可获得 */ private String cardTemplateId; /** - * The Mchid. + * 商户号 */ private String mchid; /** - * The Openid. + * 用户标识,用户在{@code appid}下的唯一标识 */ private String openid; /** - * The Out card code. + * 商户领卡号,商户在请求领卡预受理接口时传入的领卡请求号,同一个商户号下必须唯一,要求32个字符内,只能是数字、大小写字母_-|* */ private String outCardCode; /** - * The Pay information. + * 先享卡的守约状态 */ - private PayInformation payInformation; + private ContractStatus state; /** - * The State. - */ - private String state; - /** - * The Total amount. + * 享受优惠总金额,单位为 “分” */ private Long totalAmount; /** - * The Unfinished reason. + * 未完成约定原因 */ - private String unfinishedReason; + private UnfinishedReason unfinishedReason; + /** + * 用户退回优惠的付款信息 + */ + private PayInformation payInformation; /** - * The type Pay information. + * 用户退回优惠的付款信息 + *

+ * 当状态为{@link ContractStatus#UNFINISHED}(用户未完成约定)时,且需要退回已享受的优惠金额时,返回此字段; */ @Data public static class PayInformation { /** - * The Pay amount. + * 付款金额,用户需要退回优惠而付款的金额,单位为:分; */ private Long payAmount; /** - * The Pay state. + * 用户付款状态, */ - private String payState; + private PayState payState; /** - * The Pay time. + * 付款时间 */ private String payTime; /** - * The Transaction id. + * 微信支付订单号,仅在订单成功收款时才返回 */ private String transactionId; } + + /** + * 付款状态 + * @since 1.0.3.RELEASE + */ + public enum PayState { + /** + * 付款中 + */ + PAYING, + /** + * 已付款 + */ + PAID + } } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/ObjectiveCompletionRecord.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/ObjectiveCompletionRecord.java index f4f1de9..08a449b 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/ObjectiveCompletionRecord.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/ObjectiveCompletionRecord.java @@ -14,7 +14,6 @@ * 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.discountcard; @@ -22,7 +21,7 @@ import cn.felord.payment.wechat.enumeration.StrategyType; import lombok.Data; /** - * The type Objective completion record. + * 微信先享卡目标完成纪录 * * @author felord.cn * @since 1.0.2.RELEASE @@ -31,31 +30,31 @@ import lombok.Data; public class ObjectiveCompletionRecord { /** - * The Completion count. + * 目标完成数量 */ private Long completionCount; /** - * The Completion time. + * 目标完成时间 */ private String completionTime; /** - * The Completion type. + * 目标完成类型 */ private StrategyType completionType; /** - * The Description. + * 目标完成描述 */ private String description; /** - * The Objective completion serial no. + * 目标完成流水号 */ private String objectiveCompletionSerialNo; /** - * The Objective id. + * 目标id */ private String objectiveId; /** - * The Remark. + * 备注说明 */ private String remark; diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/RewardUsageRecord.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/RewardUsageRecord.java index b9841c8..d247874 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/RewardUsageRecord.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/RewardUsageRecord.java @@ -14,7 +14,6 @@ * 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.discountcard; @@ -22,7 +21,7 @@ import cn.felord.payment.wechat.enumeration.StrategyType; import lombok.Data; /** - * The type Reward usage record. + * 优惠使用纪录列表对象 * * @author felord.cn * @since 1.0.2.RELEASE @@ -31,35 +30,40 @@ import lombok.Data; public class RewardUsageRecord { /** - * The Amount. + * 优惠金额 + * + *

    + *
  1. 优惠金额,用户此项本次享受的优惠对应的优惠总金额,单位:分,必须大于0。
  2. + *
  3. 子优惠已享金额累计≤创建模板时配置的此子优惠的价值金额 例如:优惠为【满10元减3元优惠券4张】时,用户一次消费使用了2张优惠券,优惠金额为本次优惠总金额6元,优惠数量为本次使用优惠的优惠券数量2张
  4. + *
*/ private Long amount; /** - * The Description. + * 优惠使用描述 */ private String description; /** - * The Remark. + * 备注说明 */ private String remark; /** - * The Reward id. + * 优惠Id */ private String rewardId; /** - * The Reward usage serial no. + * 优惠使用纪录流水号 */ private String rewardUsageSerialNo; /** - * The Usage count. + * 优惠使用数量 */ private Long usageCount; /** - * The Usage time. + * 优惠使用时间 */ private String usageTime; /** - * The Usage type. + * 优惠使用类型 */ private StrategyType usageType; diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/UserRecordsParams.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/UserRecordsParams.java index ff5dcc9..78a95a0 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/UserRecordsParams.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/UserRecordsParams.java @@ -14,7 +14,6 @@ * 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.discountcard; @@ -30,21 +29,20 @@ import java.util.List; */ @Data public class UserRecordsParams { - /** - * The Out card code. + * 商户领卡号,商户在请求领卡预受理接口时传入的领卡请求号,同一个商户号下必须唯一,要求32个字符内,只能是数字、大小写字母_-|* */ private String outCardCode; /** - * The Card template id. + * 先享卡模板ID,唯一定义此资源的标识。创建模板后可获得 */ private String cardTemplateId; /** - * The Objective completion records. + * 微信先享卡目标完成纪录 */ private List objectiveCompletionRecords; /** - * The Reward usage records. + * 优惠使用纪录 */ private List rewardUsageRecords; diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/PayScoreConsumer.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/payscore/PayScoreConsumer.java similarity index 77% rename from payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/PayScoreConsumer.java rename to payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/payscore/PayScoreConsumer.java index 129d258..e5e971b 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/discountcard/PayScoreConsumer.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/payscore/PayScoreConsumer.java @@ -14,12 +14,9 @@ * 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.discountcard; +package cn.felord.payment.wechat.v3.model.payscore; -import cn.felord.payment.wechat.v3.model.payscore.PayScoreUserConfirmConsumeData; -import cn.felord.payment.wechat.v3.model.payscore.PayScoreUserPaidConsumeData; import lombok.Data; import java.util.function.Consumer; @@ -33,11 +30,11 @@ import java.util.function.Consumer; @Data public class PayScoreConsumer { /** - * The Confirm consume data consumer. + * 用户确认回调消费接口 */ private Consumer confirmConsumeDataConsumer; /** - * The Paid consume data consumer. + * 用户支付回调消费接口 */ private Consumer paidConsumeDataConsumer; } From 08f3ee6e0b8b1af31a7db389b74872f0329b2195 Mon Sep 17 00:00:00 2001 From: "felord.cn" Date: Mon, 4 Jan 2021 15:27:39 +0800 Subject: [PATCH 4/8] =?UTF-8?q?feat:=201.=E5=90=88=E5=8D=95=E6=94=AF?= =?UTF-8?q?=E4=BB=98-=E7=94=B3=E8=AF=B7=E4=BA=A4=E6=98=93=E8=B4=A6?= =?UTF-8?q?=E5=8D=95API=202.=E5=90=88=E5=8D=95=E6=94=AF=E4=BB=98-=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E8=B5=84=E9=87=91=E8=B4=A6=E5=8D=95API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wechat/enumeration/CouponBgColor.java | 2 +- .../enumeration/FundFlowAccountType.java | 38 ++++++++ .../payment/wechat/enumeration/TarType.java | 31 ++++++ .../wechat/enumeration/TradeBillType.java | 40 ++++++++ .../wechat/enumeration/WechatPayV3Type.java | 15 ++- .../felord/payment/wechat/v3/AbstractApi.java | 24 ++++- .../wechat/v3/WechatCombinePayApi.java | 95 ++++++++++++++++++- .../wechat/v3/WechatMarketingFavorApi.java | 35 +------ .../payment/wechat/v3/WechatPayClient.java | 13 +-- .../v3/model/combine/FundFlowBillParams.java | 52 ++++++++++ .../v3/model/combine/TradeBillParams.java | 70 ++++++++++++++ 11 files changed, 367 insertions(+), 48 deletions(-) create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/FundFlowAccountType.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/TarType.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/TradeBillType.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/FundFlowBillParams.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/TradeBillParams.java diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CouponBgColor.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CouponBgColor.java index 392111f..1cb4b7b 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CouponBgColor.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CouponBgColor.java @@ -20,7 +20,7 @@ package cn.felord.payment.wechat.enumeration; /** * 优惠券背景色 *

- * https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/marketing/convention/chapter3_1.shtml#menu1 + * 详见优惠券背景色参考 * * @author felord.cn * @since 1.0.0.RELEASE diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/FundFlowAccountType.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/FundFlowAccountType.java new file mode 100644 index 0000000..effbbf8 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/FundFlowAccountType.java @@ -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; + +/** + * 申请资金账单账户类型. + * + * @since 1.0.3.RELEASE + */ +public enum FundFlowAccountType { + /** + * 基本账户 + */ + BASIC, + /** + * 运营账户 + */ + OPERATION, + /** + * 手续费账户 + */ + FEES +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/TarType.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/TarType.java new file mode 100644 index 0000000..5d0c90d --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/TarType.java @@ -0,0 +1,31 @@ +/* + * + * 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.3.RELEASE + */ +public enum TarType { + /** + * 格式为{@code .gzip}的压缩包账单 + */ + GZIP +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/TradeBillType.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/TradeBillType.java new file mode 100644 index 0000000..8f7473d --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/TradeBillType.java @@ -0,0 +1,40 @@ +/* + * + * 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.3.RELEASE + */ +public enum TradeBillType { + /** + * 返回当日所有订单信息(不含充值退款订单) + */ + ALL, + /** + * 返回当日成功支付的订单(不含充值退款订单) + */ + SUCCESS, + /** + * 返回当日退款订单(不含充值退款订单) + */ + REFUND + +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java index c8decc6..96ef262 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java @@ -133,6 +133,18 @@ public enum WechatPayV3Type { * @since 1.0.0.RELEASE */ COMBINE_CLOSE(HttpMethod.POST, "%s/v3/combine-transactions/out-trade-no/{combine_out_trade_no}/close"), + /** + * 申请交易账单API. + * + * @since 1.0.3.RELEASE + */ + COMBINE_TRADEBILL(HttpMethod.POST, "%s/v3/bill/tradebill"), + /** + * 申请资金账单API. + * + * @since 1.0.3.RELEASE + */ + COMBINE_FUNDFLOWBILL(HttpMethod.POST, "%s/v3/bill/fundflowbill"), //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -222,7 +234,8 @@ public enum WechatPayV3Type { PAY_SCORE_SYNC_USER_SERVICE_ORDER(HttpMethod.POST, "%s/v3/payscore/serviceorder/{out_order_no}/sync"), -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** * 微信先享卡预受理领卡请求API. * diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java index 2964e3d..04d078e 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java @@ -19,6 +19,7 @@ package cn.felord.payment.wechat.v3; import cn.felord.payment.PayException; +import cn.felord.payment.wechat.enumeration.WechatPayV3Type; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -27,6 +28,7 @@ import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.springframework.http.RequestEntity; import org.springframework.util.Assert; +import org.springframework.web.util.UriComponentsBuilder; import java.net.URI; @@ -127,7 +129,7 @@ public abstract class AbstractApi { } /** - * Post request entity. + * 构建Post请求对象. * * @param uri the uri * @param params the params @@ -143,7 +145,7 @@ public abstract class AbstractApi { } /** - * Get request entity. + * 构建Get请求对象. * * @param uri the uri * @return the request entity @@ -152,4 +154,22 @@ public abstract class AbstractApi { return RequestEntity.get(uri).header("Pay-TenantId", tenantId) .build(); } + + + /** + * 对账单下载。 + * + * @param link the link + * @return 对账单内容,有可能为空字符 “” + */ + protected String billDownload(String link) { + return this.client().withType(WechatPayV3Type.FILE_DOWNLOAD, link) + .function((type, downloadUrl) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(downloadUrl) + .build() + .toUri(); + return Get(uri); + }) + .download(); + } } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCombinePayApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCombinePayApi.java index 9c62786..1169705 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCombinePayApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCombinePayApi.java @@ -19,16 +19,20 @@ package cn.felord.payment.wechat.v3; 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.combine.CombineCloseParams; -import cn.felord.payment.wechat.v3.model.combine.CombineH5PayParams; -import cn.felord.payment.wechat.v3.model.combine.CombinePayParams; +import cn.felord.payment.wechat.enumeration.*; +import cn.felord.payment.wechat.v3.model.combine.*; 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; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Objects; +import java.util.Optional; /** * 微信合单支付. @@ -211,4 +215,85 @@ public class WechatCombinePayApi extends AbstractApi { .request(); return wechatResponseEntity; } + + /** + * 申请交易账单API + *

+ * 微信支付按天提供交易账单文件,商户可以通过该接口获取账单文件的下载地址。文件内包含交易相关的金额、时间、营销等信息,供商户核对订单、退款、银行到账等情况。 + *

+ * 注意: + *

    + *
  • 微信侧未成功下单的交易不会出现在对账单中。支付成功后撤销的交易会出现在对账单中,跟原支付单订单号一致;
  • + *
  • 对账单中涉及金额的字段单位为“元”;
  • + *
  • 对账单接口只能下载三个月以内的账单。
  • + *
  • 小微商户不单独提供对账单下载,如有需要,可在调取“下载对账单”API接口时不传sub_mch_id,获取服务商下全量电商二级商户(包括小微商户和非小微商户)的对账单。
  • + *
+ * + * @param tradeBillParams tradeBillParams + * @since 1.0.3.RELEASE + */ + public void downloadTradeBill(TradeBillParams tradeBillParams) { + this.client().withType(WechatPayV3Type.COMBINE_TRADEBILL, tradeBillParams) + .function((wechatPayV3Type, params) -> { + MultiValueMap queryParams = new LinkedMultiValueMap<>(); + LocalDate billDate = params.getBillDate(); + queryParams.add("bill_date", billDate.format(DateTimeFormatter.ISO_DATE)); + String subMchid = params.getSubMchid(); + + if (StringUtils.hasText(subMchid)) { + queryParams.add("sub_mchid", subMchid); + } + + TradeBillType tradeBillType = Optional.ofNullable(params.getBillType()) + .orElse(TradeBillType.ALL); + queryParams.add("bill_type", tradeBillType.name()); + TarType tarType = params.getTarType(); + if (Objects.nonNull(tarType)) { + queryParams.add("tar_type", tarType.name()); + } + URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA)) + .queryParams(queryParams) + .build().toUri(); + return Get(uri); + }) + .consumer(response -> this.billDownload(Objects.requireNonNull(response.getBody()).get("download_url").asText())) + .request(); + } + + /** + * 申请资金账单API + *

+ * 微信支付按天提供微信支付账户的资金流水账单文件,商户可以通过该接口获取账单文件的下载地址。文件内包含该账户资金操作相关的业务单号、收支金额、记账时间等信息,供商户进行核对。 + *

+ * 注意: + *

    + *
  • 资金账单中的数据反映的是商户微信支付账户资金变动情况;
  • + *
  • 对账单中涉及金额的字段单位为“元”。
  • + *
+ * + * @param fundFlowBillParams fundFlowBillParams + * @since 1.0.3.RELEASE + */ + public void downloadFundFlowBill(FundFlowBillParams fundFlowBillParams) { + this.client().withType(WechatPayV3Type.COMBINE_FUNDFLOWBILL, fundFlowBillParams) + .function((wechatPayV3Type, params) -> { + MultiValueMap queryParams = new LinkedMultiValueMap<>(); + LocalDate billDate = params.getBillDate(); + queryParams.add("bill_date", billDate.format(DateTimeFormatter.ISO_DATE)); + + FundFlowAccountType accountType = Optional.ofNullable(params.getAccountType()) + .orElse(FundFlowAccountType.BASIC); + queryParams.add("account_type", accountType.name()); + TarType tarType = params.getTarType(); + if (Objects.nonNull(tarType)) { + queryParams.add("tar_type", tarType.name()); + } + URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA)) + .queryParams(queryParams) + .build().toUri(); + return Get(uri); + }) + .consumer(response -> this.billDownload(Objects.requireNonNull(response.getBody()).get("download_url").asText())) + .request(); + } } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingFavorApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingFavorApi.java index ccfbce2..2209320 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingFavorApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingFavorApi.java @@ -490,6 +490,7 @@ public class WechatMarketingFavorApi extends AbstractApi { * * @param stockId the stock id * @return the wechat response entity + * @see AbstractApi#billDownload(String) 对账单下载api */ public WechatResponseEntity downloadStockUseFlow(String stockId) { WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); @@ -497,7 +498,7 @@ public class WechatMarketingFavorApi extends AbstractApi { .function(this::downloadFlowFunction) .consumer(wechatResponseEntity::convert) .request(); - String csv = billDownload(wechatResponseEntity.getBody().get("url").asText()); + String csv = this.billDownload(wechatResponseEntity.getBody().get("url").asText()); wechatResponseEntity.getBody().put("csv", csv); return wechatResponseEntity; } @@ -511,6 +512,7 @@ public class WechatMarketingFavorApi extends AbstractApi { * * @param stockId the stock id * @return the wechat response entity + * @see AbstractApi#billDownload(String) 对账单下载api */ public WechatResponseEntity downloadStockRefundFlow(String stockId) { WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); @@ -518,7 +520,7 @@ public class WechatMarketingFavorApi extends AbstractApi { .function(this::downloadFlowFunction) .consumer(wechatResponseEntity::convert) .request(); - String csv = billDownload(wechatResponseEntity.getBody().get("url").asText()); + String csv = this.billDownload(wechatResponseEntity.getBody().get("url").asText()); wechatResponseEntity.getBody().put("csv", csv); return wechatResponseEntity; } @@ -629,35 +631,6 @@ public class WechatMarketingFavorApi extends AbstractApi { .toUri(); return Post(uri, body); } - - /** - * csv对账单下载。 - * - * @param link the link - * @return the string - * @see WechatMarketingFavorApi#downloadStockUseFlow(String) 下载批次核销明细API - * @see WechatMarketingFavorApi#downloadStockRefundFlow(String) 下载批次退款明细API - */ - public String billDownload(String link) { - return this.client().withType(WechatPayV3Type.FILE_DOWNLOAD, link) - .function(this::billDownloadFunction) - .download(); - } - - - /** - * Bill download function request entity. - * - * @param type the type - * @param link the link - * @return the request entity - */ - private RequestEntity billDownloadFunction(WechatPayV3Type type, String link) { - URI uri = UriComponentsBuilder.fromHttpUrl(link) - .build() - .toUri(); - return Get(uri); - } } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayClient.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayClient.java index efe1a10..e2011f0 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayClient.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayClient.java @@ -37,6 +37,7 @@ import org.springframework.web.util.UriComponentsBuilder; import java.util.Collections; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.function.BiFunction; import java.util.function.Consumer; @@ -238,7 +239,7 @@ public class WechatPayClient { // 微信请求id String requestId = headers.getFirst("Request-ID"); if (!statusCode.is2xxSuccessful()) { - throw new PayException("wechat pay server error, Request-ID "+requestId+" , statusCode " + statusCode + ",result : " + body); + throw new PayException("wechat pay server error, Request-ID " + requestId + " , statusCode " + statusCode + ",result : " + body); } ResponseSignVerifyParams params = new ResponseSignVerifyParams(); @@ -261,7 +262,7 @@ public class WechatPayClient { responseConsumer.accept(responseEntity); } } else { - throw new PayException("wechat pay signature failed, Request-ID "+requestId ); + throw new PayException("wechat pay signature failed, Request-ID " + requestId); } } @@ -276,17 +277,13 @@ public class WechatPayClient { ResponseEntity responseEntity = restOperations.exchange(requestEntity, String.class); - String body = responseEntity.getBody(); HttpStatus statusCode = responseEntity.getStatusCode(); // 微信请求id String requestId = requestEntity.getHeaders().getFirst("Request-ID"); if (!statusCode.is2xxSuccessful()) { - throw new PayException("wechat pay server error, Request-ID "+requestId+" , statusCode " + statusCode + ",result : " + body); + throw new PayException("wechat pay server error, Request-ID " + requestId + " , statusCode " + statusCode + ",result : " + responseEntity); } - if (Objects.isNull(body)) { - throw new PayException("cant obtain wechat response body, Request-ID "+requestId); - } - return body; + return Optional.ofNullable(responseEntity.getBody()).orElse(""); } } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/FundFlowBillParams.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/FundFlowBillParams.java new file mode 100644 index 0000000..e889562 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/FundFlowBillParams.java @@ -0,0 +1,52 @@ +/* + * + * 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.combine; + +import cn.felord.payment.wechat.enumeration.FundFlowAccountType; +import cn.felord.payment.wechat.enumeration.TarType; +import lombok.Data; + +import java.time.LocalDate; + +/** + * 合单支付申请资金账单请求参数 + * + * @author felord.cn + * @since 1.0.3.RELEASE + */ +@Data +public class FundFlowBillParams { + /** + * 账单日期,必传。 + *

+ * 格式YYYY-MM-DD,仅支持三个月内的账单下载申请。 + */ + private LocalDate billDate; + /** + * 资金账户类型,不填则默认值为{@link FundFlowAccountType#BASIC} + * + * @see FundFlowAccountType + */ + private FundFlowAccountType accountType; + /** + * 压缩类型,不填默认值为数据流 + * + * @see TarType + */ + private TarType tarType; +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/TradeBillParams.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/TradeBillParams.java new file mode 100644 index 0000000..df7b80f --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/TradeBillParams.java @@ -0,0 +1,70 @@ +/* + * + * 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.combine; + +import cn.felord.payment.wechat.enumeration.TarType; +import cn.felord.payment.wechat.enumeration.TradeBillType; +import lombok.Data; + +import java.time.LocalDate; + +/** + * 合单支付申请交易账单请求参数 + * + * @author felord.cn + * @since 1.0.3.RELEASE + */ +@Data +public class TradeBillParams { + /** + * 账单日期,必传。 + *

+ * 格式YYYY-MM-DD,仅支持三个月内的账单下载申请。 + */ + private LocalDate billDate; + /** + * 二级商户号,选填。 + * + *

    + *
  1. 若商户是直连商户:无需填写该字段。
  2. + *
  3. 若商户是服务商: + *
      + *
    • 不填则默认返回服务商下的交易或退款数据。
    • + *
    • 如需下载某个子商户下的交易或退款数据,则该字段必填。
    • + *
    + *
  4. + *
+ *

+ * 特殊规则:最小字符长度为8 + *

+ * 注意:仅适用于电商平台 服务商 + */ + private String subMchid; + /** + * 账单类型,不填则默认值为{@link TradeBillType#ALL} + * + * @see TradeBillType + */ + private TradeBillType billType; + /** + * 压缩类型,不填默认值为数据流 + * + * @see TarType + */ + private TarType tarType; +} From b291dbfa44ca8acf0ea4f0d4465608e880105bb9 Mon Sep 17 00:00:00 2001 From: "felord.cn" Date: Tue, 5 Jan 2021 21:21:02 +0800 Subject: [PATCH 5/8] =?UTF-8?q?refactor:=20=E4=B8=8B=E8=BD=BD=E4=BA=A4?= =?UTF-8?q?=E6=98=93=E8=B4=A6=E5=8D=95API=E5=92=8C=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E8=B5=84=E9=87=91=E8=B4=A6=E5=8D=95=E7=8E=B0=E5=9C=A8=E6=98=AF?= =?UTF-8?q?=E5=85=AC=E5=85=B1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- docs/README.md | 3 +- docs/changelog.md | 6 ++ docs/quick_start.md | 2 +- .../wechat/enumeration/WechatPayV3Type.java | 24 ++--- .../felord/payment/wechat/v3/AbstractApi.java | 93 +++++++++++++++++- .../wechat/v3/WechatCombinePayApi.java | 95 +------------------ .../{combine => }/FundFlowBillParams.java | 4 +- .../model/{combine => }/TradeBillParams.java | 4 +- 9 files changed, 123 insertions(+), 110 deletions(-) rename payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/{combine => }/FundFlowBillParams.java (93%) rename payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/{combine => }/TradeBillParams.java (95%) diff --git a/README.md b/README.md index 8613e8c..c1bad36 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ cn.felord payment-spring-boot-starter - 1.0.2.RELEASE + 1.0.3.RELEASE ``` diff --git a/docs/README.md b/docs/README.md index 8ad18f7..6a5a65e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -24,11 +24,12 @@ - 微信合单支付 `WechatCombinePayApi` 100% ## Maven 中央仓库坐标 +> 推荐使用最新版本 ```xml cn.felord payment-spring-boot-starter - 1.0.1.RELEASE + 1.0.3.RELEASE ``` ## 采用技术 diff --git a/docs/changelog.md b/docs/changelog.md index a10b01a..0524842 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,3 +1,9 @@ +## 1.0.2.RELEASE +- 微信支付 + - feat: 接入微信支付分 + - feat: 接入微信支付先享卡 + - fix: 支付回调参数不全的问题 + ## 1.0.1.RELEASE - 微信支付 diff --git a/docs/quick_start.md b/docs/quick_start.md index 4a656ec..cd2d15e 100644 --- a/docs/quick_start.md +++ b/docs/quick_start.md @@ -4,7 +4,7 @@ cn.felord payment-spring-boot-starter - 1.0.1.RELEASE + 1.0.3.RELEASE ``` > 基于 **Spring Boot 2.4.1** diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java index 96ef262..59bb9d1 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java @@ -44,6 +44,18 @@ public enum WechatPayV3Type { * @since 1.0.0.RELEASE */ FILE_DOWNLOAD(HttpMethod.GET, "%s/v3/billdownload/file"), + /** + * 申请交易账单API. + * + * @since 1.0.3.RELEASE + */ + TRADEBILL(HttpMethod.GET, "%s/v3/bill/tradebill"), + /** + * 申请资金账单API. + * + * @since 1.0.3.RELEASE + */ + FUNDFLOWBILL(HttpMethod.GET, "%s/v3/bill/fundflowbill"), //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -133,18 +145,6 @@ public enum WechatPayV3Type { * @since 1.0.0.RELEASE */ COMBINE_CLOSE(HttpMethod.POST, "%s/v3/combine-transactions/out-trade-no/{combine_out_trade_no}/close"), - /** - * 申请交易账单API. - * - * @since 1.0.3.RELEASE - */ - COMBINE_TRADEBILL(HttpMethod.POST, "%s/v3/bill/tradebill"), - /** - * 申请资金账单API. - * - * @since 1.0.3.RELEASE - */ - COMBINE_FUNDFLOWBILL(HttpMethod.POST, "%s/v3/bill/fundflowbill"), //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java index 04d078e..ff27c9b 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java @@ -19,7 +19,9 @@ package cn.felord.payment.wechat.v3; import cn.felord.payment.PayException; -import cn.felord.payment.wechat.enumeration.WechatPayV3Type; +import cn.felord.payment.wechat.enumeration.*; +import cn.felord.payment.wechat.v3.model.FundFlowBillParams; +import cn.felord.payment.wechat.v3.model.TradeBillParams; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -28,9 +30,16 @@ import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.springframework.http.RequestEntity; import org.springframework.util.Assert; +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; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Objects; +import java.util.Optional; /** * The type Abstract api. @@ -172,4 +181,86 @@ public abstract class AbstractApi { }) .download(); } + + + /** + * 申请交易账单API + *

+ * 微信支付按天提供交易账单文件,商户可以通过该接口获取账单文件的下载地址。文件内包含交易相关的金额、时间、营销等信息,供商户核对订单、退款、银行到账等情况。 + *

+ * 注意: + *

    + *
  • 微信侧未成功下单的交易不会出现在对账单中。支付成功后撤销的交易会出现在对账单中,跟原支付单订单号一致;
  • + *
  • 对账单中涉及金额的字段单位为“元”;
  • + *
  • 对账单接口只能下载三个月以内的账单。
  • + *
  • 小微商户不单独提供对账单下载,如有需要,可在调取“下载对账单”API接口时不传sub_mch_id,获取服务商下全量电商二级商户(包括小微商户和非小微商户)的对账单。
  • + *
+ * + * @param tradeBillParams tradeBillParams + * @since 1.0.3.RELEASE + */ + public final void downloadTradeBill(TradeBillParams tradeBillParams) { + this.client().withType(WechatPayV3Type.TRADEBILL, tradeBillParams) + .function((wechatPayV3Type, params) -> { + MultiValueMap queryParams = new LinkedMultiValueMap<>(); + LocalDate billDate = params.getBillDate(); + queryParams.add("bill_date", billDate.format(DateTimeFormatter.ISO_DATE)); + String subMchid = params.getSubMchid(); + + if (StringUtils.hasText(subMchid)) { + queryParams.add("sub_mchid", subMchid); + } + + TradeBillType tradeBillType = Optional.ofNullable(params.getBillType()) + .orElse(TradeBillType.ALL); + queryParams.add("bill_type", tradeBillType.name()); + TarType tarType = params.getTarType(); + if (Objects.nonNull(tarType)) { + queryParams.add("tar_type", tarType.name()); + } + URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA)) + .queryParams(queryParams) + .build().toUri(); + return Get(uri); + }) + .consumer(response -> this.billDownload(Objects.requireNonNull(response.getBody()).get("download_url").asText())) + .request(); + } + + /** + * 申请资金账单API + *

+ * 微信支付按天提供微信支付账户的资金流水账单文件,商户可以通过该接口获取账单文件的下载地址。文件内包含该账户资金操作相关的业务单号、收支金额、记账时间等信息,供商户进行核对。 + *

+ * 注意: + *

    + *
  • 资金账单中的数据反映的是商户微信支付账户资金变动情况;
  • + *
  • 对账单中涉及金额的字段单位为“元”。
  • + *
+ * + * @param fundFlowBillParams fundFlowBillParams + * @since 1.0.3.RELEASE + */ + public final void downloadFundFlowBill(FundFlowBillParams fundFlowBillParams) { + this.client().withType(WechatPayV3Type.FUNDFLOWBILL, fundFlowBillParams) + .function((wechatPayV3Type, params) -> { + MultiValueMap queryParams = new LinkedMultiValueMap<>(); + LocalDate billDate = params.getBillDate(); + queryParams.add("bill_date", billDate.format(DateTimeFormatter.ISO_DATE)); + + FundFlowAccountType accountType = Optional.ofNullable(params.getAccountType()) + .orElse(FundFlowAccountType.BASIC); + queryParams.add("account_type", accountType.name()); + TarType tarType = params.getTarType(); + if (Objects.nonNull(tarType)) { + queryParams.add("tar_type", tarType.name()); + } + URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA)) + .queryParams(queryParams) + .build().toUri(); + return Get(uri); + }) + .consumer(response -> this.billDownload(Objects.requireNonNull(response.getBody()).get("download_url").asText())) + .request(); + } } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCombinePayApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCombinePayApi.java index 1169705..9c62786 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCombinePayApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCombinePayApi.java @@ -19,20 +19,16 @@ package cn.felord.payment.wechat.v3; import cn.felord.payment.wechat.WechatPayProperties; -import cn.felord.payment.wechat.enumeration.*; -import cn.felord.payment.wechat.v3.model.combine.*; +import cn.felord.payment.wechat.enumeration.WeChatServer; +import cn.felord.payment.wechat.enumeration.WechatPayV3Type; +import cn.felord.payment.wechat.v3.model.combine.CombineCloseParams; +import cn.felord.payment.wechat.v3.model.combine.CombineH5PayParams; +import cn.felord.payment.wechat.v3.model.combine.CombinePayParams; 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; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.Objects; -import java.util.Optional; /** * 微信合单支付. @@ -215,85 +211,4 @@ public class WechatCombinePayApi extends AbstractApi { .request(); return wechatResponseEntity; } - - /** - * 申请交易账单API - *

- * 微信支付按天提供交易账单文件,商户可以通过该接口获取账单文件的下载地址。文件内包含交易相关的金额、时间、营销等信息,供商户核对订单、退款、银行到账等情况。 - *

- * 注意: - *

    - *
  • 微信侧未成功下单的交易不会出现在对账单中。支付成功后撤销的交易会出现在对账单中,跟原支付单订单号一致;
  • - *
  • 对账单中涉及金额的字段单位为“元”;
  • - *
  • 对账单接口只能下载三个月以内的账单。
  • - *
  • 小微商户不单独提供对账单下载,如有需要,可在调取“下载对账单”API接口时不传sub_mch_id,获取服务商下全量电商二级商户(包括小微商户和非小微商户)的对账单。
  • - *
- * - * @param tradeBillParams tradeBillParams - * @since 1.0.3.RELEASE - */ - public void downloadTradeBill(TradeBillParams tradeBillParams) { - this.client().withType(WechatPayV3Type.COMBINE_TRADEBILL, tradeBillParams) - .function((wechatPayV3Type, params) -> { - MultiValueMap queryParams = new LinkedMultiValueMap<>(); - LocalDate billDate = params.getBillDate(); - queryParams.add("bill_date", billDate.format(DateTimeFormatter.ISO_DATE)); - String subMchid = params.getSubMchid(); - - if (StringUtils.hasText(subMchid)) { - queryParams.add("sub_mchid", subMchid); - } - - TradeBillType tradeBillType = Optional.ofNullable(params.getBillType()) - .orElse(TradeBillType.ALL); - queryParams.add("bill_type", tradeBillType.name()); - TarType tarType = params.getTarType(); - if (Objects.nonNull(tarType)) { - queryParams.add("tar_type", tarType.name()); - } - URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA)) - .queryParams(queryParams) - .build().toUri(); - return Get(uri); - }) - .consumer(response -> this.billDownload(Objects.requireNonNull(response.getBody()).get("download_url").asText())) - .request(); - } - - /** - * 申请资金账单API - *

- * 微信支付按天提供微信支付账户的资金流水账单文件,商户可以通过该接口获取账单文件的下载地址。文件内包含该账户资金操作相关的业务单号、收支金额、记账时间等信息,供商户进行核对。 - *

- * 注意: - *

    - *
  • 资金账单中的数据反映的是商户微信支付账户资金变动情况;
  • - *
  • 对账单中涉及金额的字段单位为“元”。
  • - *
- * - * @param fundFlowBillParams fundFlowBillParams - * @since 1.0.3.RELEASE - */ - public void downloadFundFlowBill(FundFlowBillParams fundFlowBillParams) { - this.client().withType(WechatPayV3Type.COMBINE_FUNDFLOWBILL, fundFlowBillParams) - .function((wechatPayV3Type, params) -> { - MultiValueMap queryParams = new LinkedMultiValueMap<>(); - LocalDate billDate = params.getBillDate(); - queryParams.add("bill_date", billDate.format(DateTimeFormatter.ISO_DATE)); - - FundFlowAccountType accountType = Optional.ofNullable(params.getAccountType()) - .orElse(FundFlowAccountType.BASIC); - queryParams.add("account_type", accountType.name()); - TarType tarType = params.getTarType(); - if (Objects.nonNull(tarType)) { - queryParams.add("tar_type", tarType.name()); - } - URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA)) - .queryParams(queryParams) - .build().toUri(); - return Get(uri); - }) - .consumer(response -> this.billDownload(Objects.requireNonNull(response.getBody()).get("download_url").asText())) - .request(); - } } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/FundFlowBillParams.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/FundFlowBillParams.java similarity index 93% rename from payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/FundFlowBillParams.java rename to payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/FundFlowBillParams.java index e889562..b4ad6af 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/FundFlowBillParams.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/FundFlowBillParams.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package cn.felord.payment.wechat.v3.model.combine; +package cn.felord.payment.wechat.v3.model; import cn.felord.payment.wechat.enumeration.FundFlowAccountType; import cn.felord.payment.wechat.enumeration.TarType; @@ -24,7 +24,7 @@ import lombok.Data; import java.time.LocalDate; /** - * 合单支付申请资金账单请求参数 + * 申请资金账单请求参数 * * @author felord.cn * @since 1.0.3.RELEASE diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/TradeBillParams.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/TradeBillParams.java similarity index 95% rename from payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/TradeBillParams.java rename to payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/TradeBillParams.java index df7b80f..b44e0b3 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/combine/TradeBillParams.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/TradeBillParams.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package cn.felord.payment.wechat.v3.model.combine; +package cn.felord.payment.wechat.v3.model; import cn.felord.payment.wechat.enumeration.TarType; import cn.felord.payment.wechat.enumeration.TradeBillType; @@ -24,7 +24,7 @@ import lombok.Data; import java.time.LocalDate; /** - * 合单支付申请交易账单请求参数 + * 申请交易账单请求参数 * * @author felord.cn * @since 1.0.3.RELEASE From f1a3683bc6516b25580437b1a106a0fbecdb84b6 Mon Sep 17 00:00:00 2001 From: "felord.cn" Date: Thu, 7 Jan 2021 21:07:48 +0800 Subject: [PATCH 6/8] =?UTF-8?q?fix:=20=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E8=83=BD=E5=A4=9F=E6=AD=A3=E7=A1=AE=E6=A0=B9=E6=8D=AE=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E6=9D=A1=E4=BB=B6=E5=8A=A8=E6=80=81=E5=90=AF=E7=94=A8?= =?UTF-8?q?=E4=BA=86=EF=BC=8C=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=8D=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=90=AF=E7=94=A8=E6=94=AF=E4=BB=98=E5=AE=9D?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82=20=20=20=20=201.=20?= =?UTF-8?q?=E5=BD=93=E9=85=8D=E7=BD=AE=E4=B8=AD=E5=AD=98=E5=9C=A8`wechat.p?= =?UTF-8?q?ay.v3`=E9=85=8D=E7=BD=AE=E6=97=B6=EF=BC=8C=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=90=AF=E7=94=A8=EF=BC=9B=E5=90=A6=E5=88=99?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98=E4=B8=8D=E5=90=AF=E7=94=A8?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E4=BC=9A=E5=BD=B1=E5=93=8D=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=AE=9D=E7=9A=84=E8=BF=90=E8=A1=8C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/changelog.md | 10 +++ docs/stackoverflow.md | 2 +- payment-spring-boot-autoconfigure/pom.xml | 4 +- .../wechat/WechatPayConfiguration.java | 2 + .../wechat/WechatPayConfiguredCondition.java | 64 +++++++++++++++++++ payment-spring-boot-starter/pom.xml | 4 +- pom.xml | 2 +- 7 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/WechatPayConfiguredCondition.java diff --git a/docs/changelog.md b/docs/changelog.md index 0524842..9332e68 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,3 +1,13 @@ +## 1.0.3.RELEASE +- 微信支付 + - feat: 完善合单支付账单 + 1. 增加合单支付-申请交易账单API。 + 2. 增加合单支付-申请资金账单API。 + - fix: #I2BCMZ 合单支付url不正确的问题。 + - fix: 微信支付能够正确根据环境条件动态启用了,修复了不配置微信支付时,无法启用支付宝的问题。 + 1. 当配置中存在`wechat.pay.v3`配置时,微信支付启用;否则微信支付不启用,不会影响支付宝的运行。 + - refactor: 先享卡优化 + ## 1.0.2.RELEASE - 微信支付 - feat: 接入微信支付分 diff --git a/docs/stackoverflow.md b/docs/stackoverflow.md index aa73e1d..8982758 100644 --- a/docs/stackoverflow.md +++ b/docs/stackoverflow.md @@ -35,7 +35,7 @@ ## 支付宝 -### 证书 +### 支付宝证书 请注意因为未来**SHA1withRSA**将被淘汰,因此采用最新的**SHA256withRSA**证书,旧的模式将不提供支持。步骤如下: diff --git a/payment-spring-boot-autoconfigure/pom.xml b/payment-spring-boot-autoconfigure/pom.xml index bae82a5..6c96d52 100644 --- a/payment-spring-boot-autoconfigure/pom.xml +++ b/payment-spring-boot-autoconfigure/pom.xml @@ -5,11 +5,11 @@ cn.felord payment-spring-boot - 1.0.2.RELEASE + 1.0.3.RELEASE payment-spring-boot-autoconfigure - 1.0.2.RELEASE + 1.0.3.RELEASE jar 4.0.0 diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/WechatPayConfiguration.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/WechatPayConfiguration.java index 68d98eb..9878264 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/WechatPayConfiguration.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/WechatPayConfiguration.java @@ -23,6 +23,7 @@ import cn.felord.payment.wechat.v3.*; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import java.util.Map; @@ -34,6 +35,7 @@ import java.util.Map; * @since 1.0.0.RELEASE */ @Configuration +@Conditional(WechatPayConfiguredCondition.class) @EnableConfigurationProperties(WechatPayProperties.class) public class WechatPayConfiguration { /** diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/WechatPayConfiguredCondition.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/WechatPayConfiguredCondition.java new file mode 100644 index 0000000..bb624a8 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/WechatPayConfiguredCondition.java @@ -0,0 +1,64 @@ +/* + * + * 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; + +import org.springframework.boot.autoconfigure.condition.ConditionMessage; +import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.SpringBootCondition; +import org.springframework.boot.context.properties.bind.Bindable; +import org.springframework.boot.context.properties.bind.Binder; +import org.springframework.context.annotation.ConditionContext; +import org.springframework.core.env.Environment; +import org.springframework.core.type.AnnotatedTypeMetadata; + +import java.util.Collections; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * The type Wechat pay configured condition. + * + * @author felord.cn + * @since 1.0.3.RELEASE + */ +public class WechatPayConfiguredCondition extends SpringBootCondition { + + /** + * The constant STRING_WECHAT_V3_MAP. + */ + private static final Bindable> STRING_WECHAT_V3_MAP = Bindable + .mapOf(String.class, WechatPayProperties.V3.class); + + @Override + public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { + ConditionMessage.Builder message = ConditionMessage.forCondition("Wechat Pay V3 Configured Condition"); + Map v3 = getV3(context.getEnvironment()); + if (!v3.isEmpty()) { + return ConditionOutcome.match(message.foundExactly("registered wechat mchIds " + v3.values().stream() + .map(WechatPayProperties.V3::getMchId).collect(Collectors.joining(", ")))); + } + return ConditionOutcome.noMatch(message.notAvailable("registered wechat pay configs")); + } + + private Map getV3(Environment environment) { + return Binder.get(environment).bind("wechat.pay.v3", STRING_WECHAT_V3_MAP) + .orElse(Collections.emptyMap()); + } + +} diff --git a/payment-spring-boot-starter/pom.xml b/payment-spring-boot-starter/pom.xml index d738dc4..116f47e 100644 --- a/payment-spring-boot-starter/pom.xml +++ b/payment-spring-boot-starter/pom.xml @@ -5,11 +5,11 @@ cn.felord payment-spring-boot - 1.0.2.RELEASE + 1.0.3.RELEASE payment-spring-boot-starter - 1.0.2.RELEASE + 1.0.3.RELEASE jar 4.0.0 diff --git a/pom.xml b/pom.xml index 2130491..31ddea9 100644 --- a/pom.xml +++ b/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"> cn.felord payment-spring-boot - 1.0.2.RELEASE + 1.0.3.RELEASE pom 4.0.0 From 282836d0363f52b26d78a3374e84e12ad9e5275c Mon Sep 17 00:00:00 2001 From: "felord.cn" Date: Thu, 7 Jan 2021 21:08:49 +0800 Subject: [PATCH 7/8] changelog --- docs/changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index 9332e68..95f9bcc 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -5,7 +5,7 @@ 2. 增加合单支付-申请资金账单API。 - fix: #I2BCMZ 合单支付url不正确的问题。 - fix: 微信支付能够正确根据环境条件动态启用了,修复了不配置微信支付时,无法启用支付宝的问题。 - 1. 当配置中存在`wechat.pay.v3`配置时,微信支付启用;否则微信支付不启用,不会影响支付宝的运行。 + 1. 当配置中存在`wechat.pay.v3`配置时,微信支付启用;否则微信支付不启用,不会再影响支付宝的运行。 - refactor: 先享卡优化 ## 1.0.2.RELEASE From 60a47fa5bcb8e5c9d85095c69c6579eb18859b22 Mon Sep 17 00:00:00 2001 From: "felord.cn" Date: Thu, 7 Jan 2021 21:10:23 +0800 Subject: [PATCH 8/8] README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index c1bad36..950592a 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ 为了满足业务中出现app支付、公众号支付、小程序支付等多appid并存的场景,对原有的进行了增强开发出了多租户版本。 +请给[Payment Spring Boot](https://github.com/NotFound403/payment-spring-boot) **Star**以鼓励,谢谢。 + + ## Maven 最新中央仓库坐标 ```xml