mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-13 21:33:41 +08:00
feat: 其它能力-银行组件(服务商)
- 获取对私银行卡号开户银行API - 查询支持个人业务的银行列表API - 查询支持对公业务的银行列表API - 查询省份列表API - 查询城市列表API - 查询支行列表API
This commit is contained in:
@@ -991,7 +991,44 @@ public enum WechatPayV3Type {
|
|||||||
*
|
*
|
||||||
* @since 1.0.14.RELEASE
|
* @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.
|
* The Pattern.
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -304,4 +304,15 @@ public class WechatApiProvider {
|
|||||||
return new WechatMediaApi(wechatPayClient, tenantId);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 其它能力-银行组件(服务商)
|
||||||
|
* <p>
|
||||||
|
* 具体参见 <a href="https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_1.shtml">银行组件</a>
|
||||||
|
*
|
||||||
|
* @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<ObjectNode> searchBanksByBankAccount(String accountNumber) {
|
||||||
|
WechatResponseEntity<ObjectNode> 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<ObjectNode> queryPersonalBanks(PageParams params) {
|
||||||
|
WechatResponseEntity<ObjectNode> 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<ObjectNode> queryCorporateBanks(PageParams params) {
|
||||||
|
WechatResponseEntity<ObjectNode> 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<ObjectNode> queryProvinces() {
|
||||||
|
WechatResponseEntity<ObjectNode> 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<ObjectNode> queryCitiesByProvince(Integer provinceCode) {
|
||||||
|
WechatResponseEntity<ObjectNode> 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<ObjectNode> queryBranchBanks(BranchBanksPageParams params) {
|
||||||
|
WechatResponseEntity<ObjectNode> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user