From 796cb4c92115d9bba7caa783246de1cf88c6042d Mon Sep 17 00:00:00 2001 From: dax Date: Tue, 12 Jul 2022 10:07:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=B6=E5=AE=83=E8=83=BD=E5=8A=9B-?= =?UTF-8?q?=E9=93=B6=E8=A1=8C=E7=BB=84=E4=BB=B6=EF=BC=88=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=95=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 获取对私银行卡号开户银行API - 查询支持个人业务的银行列表API - 查询支持对公业务的银行列表API - 查询省份列表API - 查询城市列表API - 查询支行列表API --- .../wechat/enumeration/WechatPayV3Type.java | 39 ++++- .../wechat/v3/BranchBanksPageParams.java | 16 ++ .../payment/wechat/v3/WechatApiProvider.java | 11 ++ .../payment/wechat/v3/WechatCapitalApi.java | 163 ++++++++++++++++++ .../payment/wechat/v3/model/PageParams.java | 13 ++ 5 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/BranchBanksPageParams.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCapitalApi.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/PageParams.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 3ff61a3..f605562 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 @@ -991,7 +991,44 @@ public enum WechatPayV3Type { * * @since 1.0.14.RELEASE */ - MALL_SCORE_RESULT(HttpMethod.GET, "%s/v3/businesscircle/user-authorizations/{openid}"); + MALL_SCORE_RESULT(HttpMethod.GET, "%s/v3/businesscircle/user-authorizations/{openid}"), + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** + * 获取对私银行卡号开户银行API + * + * @since 1.0.14.RELEASE + */ + CAPITAL_SEARCH(HttpMethod.GET, "%s/v3/capital/capitallhh/banks/search-banks-by-bank-account"), + /** + * 查询支持个人业务的银行列表API + * + * @since 1.0.14.RELEASE + */ + CAPITAL_PERSONAL(HttpMethod.GET, "%s/v3/capital/capitallhh/banks/personal-banking"), + /** + * 查询支持对公业务的银行列表API + * + * @since 1.0.14.RELEASE + */ + CAPITAL_CORPORATE(HttpMethod.GET, "%s/v3/capital/capitallhh/banks/corporate-banking"), + /** + * 查询省份列表API + * + * @since 1.0.14.RELEASE + */ + CAPITAL_PROVINCES(HttpMethod.GET, "%s/v3/capital/capitallhh/areas/provinces"), + /** + * 查询城市列表API + * + * @since 1.0.14.RELEASE + */ + CAPITAL_CITIES(HttpMethod.GET, "%s/v3/capital/capitallhh/areas/provinces/{province_code}/cities"), + /** + * 查询支行列表API + * + * @since 1.0.14.RELEASE + */ + CAPITAL_BRANCHES(HttpMethod.GET, "%s/v3/capital/capitallhh/banks/{bank_alias_code}/branches"); /** * The Pattern. diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/BranchBanksPageParams.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/BranchBanksPageParams.java new file mode 100644 index 0000000..2d3c3e9 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/BranchBanksPageParams.java @@ -0,0 +1,16 @@ +package cn.felord.payment.wechat.v3; + +import cn.felord.payment.wechat.v3.model.PageParams; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author felord.cn + * @since 1.0.14.RELEASE + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class BranchBanksPageParams extends PageParams { + private String bankAliasCode; + private Integer cityCode; +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatApiProvider.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatApiProvider.java index 29dd179..8bac31e 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatApiProvider.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatApiProvider.java @@ -304,4 +304,15 @@ public class WechatApiProvider { return new WechatMediaApi(wechatPayClient, tenantId); } + /** + * 其它能力-银行组件(服务商) + * + * @param tenantId the tenant id + * @return the wechat media api + * @since 1.0.14.RELEASE + */ + public WechatCapitalApi capitalApi(String tenantId) { + return new WechatCapitalApi(wechatPayClient, tenantId); + } + } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCapitalApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCapitalApi.java new file mode 100644 index 0000000..8da9d6d --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCapitalApi.java @@ -0,0 +1,163 @@ +package cn.felord.payment.wechat.v3; + +import cn.felord.payment.wechat.enumeration.WeChatServer; +import cn.felord.payment.wechat.enumeration.WechatPayV3Type; +import cn.felord.payment.wechat.v3.model.PageParams; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.springframework.web.util.UriComponentsBuilder; + +import java.net.URI; +import java.security.cert.X509Certificate; + +/** + * 其它能力-银行组件(服务商) + *

+ * 具体参见 银行组件 + * + * @author felord.cn + * @since 1.0.14.RELEASE + */ +public class WechatCapitalApi extends AbstractApi{ + /** + * Instantiates a new Abstract api. + * + * @param wechatPayClient the wechat pay client + * @param tenantId the tenant id + */ + public WechatCapitalApi(WechatPayClient wechatPayClient, String tenantId) { + super(wechatPayClient, tenantId); + } + + /** + * 获取对私银行卡号开户银行API + * + * @param accountNumber accountNumber + * @return the wechat response entity + */ + public WechatResponseEntity searchBanksByBankAccount(String accountNumber) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.CAPITAL_SEARCH, accountNumber) + .function((type, param) -> { + SignatureProvider signatureProvider = this.client().signatureProvider(); + X509WechatCertificateInfo certificate = signatureProvider.getCertificate(this.wechatMetaBean().getTenantId()); + final X509Certificate x509Certificate = certificate.getX509Certificate(); + + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .queryParam("account_number", signatureProvider.encryptRequestMessage(param,x509Certificate)) + .build() + .toUri(); + return Get(uri); + }) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + + /** + * 查询支持个人业务的银行列表API + * + * @param params the params + * @return the wechat response entity + */ + public WechatResponseEntity queryPersonalBanks(PageParams params) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.CAPITAL_PERSONAL, params) + .function((type, pageParams) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .queryParam("offset", pageParams.getOffset()) + .queryParam("limit", pageParams.getLimit()) + .build() + .toUri(); + return Get(uri); + }) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + + /** + * 查询支持对公业务的银行列表API + * + * @param params the params + * @return the wechat response entity + */ + public WechatResponseEntity queryCorporateBanks(PageParams params) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.CAPITAL_CORPORATE, params) + .function((type, pageParams) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .queryParam("offset", pageParams.getOffset()) + .queryParam("limit", pageParams.getLimit()) + .build() + .toUri(); + return Get(uri); + }) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + + /** + * 查询省份列表API + * + * @return the wechat response entity + */ + public WechatResponseEntity queryProvinces() { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.CAPITAL_PROVINCES, "") + .function((type, pageParams) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .build() + .toUri(); + return Get(uri); + }) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + + /** + * 查询城市列表API + * + * @param provinceCode provinceCode + * @return the wechat response entity + */ + public WechatResponseEntity queryCitiesByProvince(Integer provinceCode) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.CAPITAL_CITIES, provinceCode) + .function((type, code) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .build() + .expand(code) + .toUri(); + return Get(uri); + }) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + + /** + * 查询支行列表API + * + * @param params branchBanksPageParams + * @return the wechat response entity + */ + public WechatResponseEntity queryBranchBanks(BranchBanksPageParams params) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.CAPITAL_BRANCHES, params) + .function((type, pageParams) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .queryParam("city_code", pageParams.getCityCode()) + .queryParam("offset", pageParams.getOffset()) + .queryParam("limit", pageParams.getLimit()) + .build() + .expand(pageParams.getBankAliasCode()) + .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/PageParams.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/PageParams.java new file mode 100644 index 0000000..a0335cb --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/PageParams.java @@ -0,0 +1,13 @@ +package cn.felord.payment.wechat.v3.model; + +import lombok.Data; + +/** + * @author felord.cn + * @since 1.0.14.RELEASE + */ +@Data +public class PageParams { + private Integer offset; + private Integer limit; +}