diff --git a/README.md b/README.md index 8613e8c..950592a 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,16 @@ 为了满足业务中出现app支付、公众号支付、小程序支付等多appid并存的场景,对原有的进行了增强开发出了多租户版本。 +请给[Payment Spring Boot](https://github.com/NotFound403/payment-spring-boot) **Star**以鼓励,谢谢。 + + ## Maven 最新中央仓库坐标 ```xml 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 6e4c625..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.2.RELEASE + 1.0.3.RELEASE ``` ## 采用技术 diff --git a/docs/changelog.md b/docs/changelog.md index a10b01a..95f9bcc 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,3 +1,19 @@ +## 1.0.3.RELEASE +- 微信支付 + - feat: 完善合单支付账单 + 1. 增加合单支付-申请交易账单API。 + 2. 增加合单支付-申请资金账单API。 + - fix: #I2BCMZ 合单支付url不正确的问题。 + - fix: 微信支付能够正确根据环境条件动态启用了,修复了不配置微信支付时,无法启用支付宝的问题。 + 1. 当配置中存在`wechat.pay.v3`配置时,微信支付启用;否则微信支付不启用,不会再影响支付宝的运行。 + - refactor: 先享卡优化 + +## 1.0.2.RELEASE +- 微信支付 + - feat: 接入微信支付分 + - feat: 接入微信支付先享卡 + - fix: 支付回调参数不全的问题 + ## 1.0.1.RELEASE - 微信支付 diff --git a/docs/quick_start.md b/docs/quick_start.md index a87bde0..cd2d15e 100644 --- a/docs/quick_start.md +++ b/docs/quick_start.md @@ -4,7 +4,7 @@ cn.felord payment-spring-boot-starter - 1.0.2.RELEASE + 1.0.3.RELEASE ``` > 基于 **Spring Boot 2.4.1** 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-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 new file mode 100644 index 0000000..216ca86 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CountType.java @@ -0,0 +1,35 @@ +/* + * + * 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/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/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/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/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..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"), //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -107,19 +119,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. * @@ -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..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,6 +19,9 @@ package cn.felord.payment.wechat.v3; import cn.felord.payment.PayException; +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; @@ -27,8 +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. @@ -127,7 +138,7 @@ public abstract class AbstractApi { } /** - * Post request entity. + * 构建Post请求对象. * * @param uri the uri * @param params the params @@ -143,7 +154,7 @@ public abstract class AbstractApi { } /** - * Get request entity. + * 构建Get请求对象. * * @param uri the uri * @return the request entity @@ -152,4 +163,104 @@ 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(); + } + + + /** + * 申请交易账单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/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/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/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/FundFlowBillParams.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/FundFlowBillParams.java new file mode 100644 index 0000000..b4ad6af --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/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; + +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/TradeBillParams.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/TradeBillParams.java new file mode 100644 index 0000000..b44e0b3 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/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; + +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; +} 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..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 @@ -14,10 +14,12 @@ * 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 cn.felord.payment.wechat.enumeration.UnfinishedReason; import lombok.Data; import java.util.List; @@ -31,60 +33,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,34 +95,38 @@ public class DiscountCardAgreementEndConsumeData { public static class Objective { /** - * The Count. + * 目标数量 + *

+ * 履约目标需要完成的数量,必须大于0。 */ private Long count; /** - * The Description. + * 目标描述 */ private String description; /** - * The Name. + * 目标名称 */ private String name; /** - * The Objective completion records. + * 用户先享卡目标完成纪录 */ 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 +134,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 +153,42 @@ 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; } + } 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; } 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