From d702d98363c74a078a89089a9c5f70d1cba1b865 Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 12 Jun 2022 15:19:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E5=88=86=E8=B4=A6=E8=B4=A6=E5=8D=95API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wechat/enumeration/WechatPayV3Type.java | 10 +++- .../wechat/v3/WechatProfitsharingApi.java | 40 ++++++++++++++++ .../wechat/v3/model/TradeBillParams.java | 2 +- .../ProfitsharingBillParams.java | 47 +++++++++++++++++++ 4 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/profitsharing/ProfitsharingBillParams.java 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 03bab5d..ea44d28 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 @@ -455,7 +455,7 @@ public enum WechatPayV3Type { * * @since 1.0.13.RELEASES */ - MARKETING_BUSI_FAVOR_SUBSIDY_QUERY(HttpMethod.POST, "%s/v3/marketing/busifavor/subsidy/pay-receipts/{subsidy_receipt_id}"), + MARKETING_BUSI_FAVOR_SUBSIDY_QUERY(HttpMethod.GET, "%s/v3/marketing/busifavor/subsidy/pay-receipts/{subsidy_receipt_id}"), //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * 发起批量转账API. @@ -634,7 +634,13 @@ public enum WechatPayV3Type { * * @since 1.0.11.RELEASE */ - PROFITSHARING_RECEIVERS_DELETE(HttpMethod.POST, "%s/v3/profitsharing/receivers/delete"); + PROFITSHARING_RECEIVERS_DELETE(HttpMethod.POST, "%s/v3/profitsharing/receivers/delete"), + /** + * 申请分账账单API. + * + * @since 1.0.13.RELEASE + */ + PROFITSHARING_BILLS(HttpMethod.GET, "%s/v3/profitsharing/bills"); /** * The Pattern. * diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatProfitsharingApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatProfitsharingApi.java index c358eb2..0cbe4e4 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatProfitsharingApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatProfitsharingApi.java @@ -17,18 +17,24 @@ package cn.felord.payment.wechat.v3; import cn.felord.payment.wechat.WechatPayProperties; +import cn.felord.payment.wechat.enumeration.TarType; import cn.felord.payment.wechat.enumeration.WeChatServer; import cn.felord.payment.wechat.enumeration.WechatPayV3Type; import cn.felord.payment.wechat.v3.model.profitsharing.*; import com.fasterxml.jackson.databind.node.ObjectNode; import org.springframework.http.HttpHeaders; import org.springframework.util.CollectionUtils; +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.security.cert.X509Certificate; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -298,4 +304,38 @@ public class WechatProfitsharingApi extends AbstractApi { .request(); return wechatResponseEntity; } + + /** + * 申请分账账单API + *

+ * 微信支付按天提供分账账单文件,商户可以通过该接口获取账单文件的下载地址。详细参考文档 申请分账账单API + *

+ * 返回的下载链接可调用{@link #downloadBillResponse(String, String)}下载文件 + * + * @param billParams the bill params + * @return the wechat response entity + * @since 1.0.13.RELEASE + */ + public WechatResponseEntity downloadMerchantBills(ProfitsharingBillParams billParams){ + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.PAY_SCORE_MERCHANT_BILL,billParams) + .function(((wechatPayV3Type, params) -> { + MultiValueMap queryParams = new LinkedMultiValueMap<>(); + LocalDate billDate = params.getBillDate(); + queryParams.add("bill_date", billDate.format(DateTimeFormatter.ISO_DATE)); + 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(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + } 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 index a1628c8..a5429ea 100644 --- 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 @@ -34,7 +34,7 @@ public class TradeBillParams { /** * 账单日期,必传。 *

- * 格式YYYY-MM-DD,仅支持三个月内的账单下载申请。 + * 格式yyyy-MM-DD,仅支持三个月内的账单下载申请。 */ private LocalDate billDate; /** diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/profitsharing/ProfitsharingBillParams.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/profitsharing/ProfitsharingBillParams.java new file mode 100644 index 0000000..44a4d18 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/profitsharing/ProfitsharingBillParams.java @@ -0,0 +1,47 @@ +/* + * Copyright 2019-2022 felord.cn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * Website: + * https://felord.cn + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.felord.payment.wechat.v3.model.profitsharing; + +import cn.felord.payment.wechat.enumeration.TarType; +import lombok.Data; + +import java.time.LocalDate; + +/** + * 直连商户-申请分账账单API参数 + * + * @author felord.cn + * @since 1.0.12.RELEASE + */ +@Data +public class ProfitsharingBillParams { + + /** + * 账单日期,必传。 + *

+ * 格式yyyy-MM-DD,仅支持三个月内的账单下载申请。 + */ + private LocalDate billDate; + /** + * 压缩类型,不填默认值为数据流 + * + * @see TarType + */ + private TarType tarType; + +}