feat: 新增申请分账账单API

This commit is contained in:
Fang
2022-06-12 15:19:28 +08:00
parent f5da8524d9
commit ca83440847
4 changed files with 96 additions and 3 deletions

View File

@@ -455,7 +455,7 @@ public enum WechatPayV3Type {
* *
* @since 1.0.13.RELEASES * @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. * 发起批量转账API.
@@ -634,7 +634,13 @@ public enum WechatPayV3Type {
* *
* @since 1.0.11.RELEASE * @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. * The Pattern.
* *

View File

@@ -17,18 +17,24 @@
package cn.felord.payment.wechat.v3; package cn.felord.payment.wechat.v3;
import cn.felord.payment.wechat.WechatPayProperties; 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.WeChatServer;
import cn.felord.payment.wechat.enumeration.WechatPayV3Type; import cn.felord.payment.wechat.enumeration.WechatPayV3Type;
import cn.felord.payment.wechat.v3.model.profitsharing.*; import cn.felord.payment.wechat.v3.model.profitsharing.*;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
import java.net.URI; import java.net.URI;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -298,4 +304,38 @@ public class WechatProfitsharingApi extends AbstractApi {
.request(); .request();
return wechatResponseEntity; return wechatResponseEntity;
} }
/**
* 申请分账账单API
* <p>
* 微信支付按天提供分账账单文件,商户可以通过该接口获取账单文件的下载地址。详细参考文档 <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_11.shtml">申请分账账单API</a>
* <p>
* 返回的下载链接可调用{@link #downloadBillResponse(String, String)}下载文件
*
* @param billParams the bill params
* @return the wechat response entity
* @since 1.0.13.RELEASE
*/
public WechatResponseEntity<ObjectNode> downloadMerchantBills(ProfitsharingBillParams billParams){
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
this.client().withType(WechatPayV3Type.PROFITSHARING_BILLS,billParams)
.function(((wechatPayV3Type, params) -> {
MultiValueMap<String, String> 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;
}
} }

View File

@@ -34,7 +34,7 @@ public class TradeBillParams {
/** /**
* 账单日期,必传。 * 账单日期,必传。
* <p> * <p>
* 格式YYYY-MM-DD仅支持三个月内的账单下载申请。 * 格式yyyy-MM-DD仅支持三个月内的账单下载申请。
*/ */
private LocalDate billDate; private LocalDate billDate;
/** /**

View File

@@ -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 {
/**
* 账单日期,必传。
* <p>
* 格式yyyy-MM-DD仅支持三个月内的账单下载申请。
*/
private LocalDate billDate;
/**
* 压缩类型,不填默认值为数据流
*
* @see TarType
*/
private TarType tarType;
}