mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-02 20:02:37 +08:00
🆕 #2696 【微信支付】银行组件添加省市列表查询及支行列表查询的接口
This commit is contained in:
parent
1f3f133772
commit
a21a622936
@ -0,0 +1,176 @@
|
||||
package com.github.binarywang.wxpay.bean.bank;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支行列表
|
||||
*
|
||||
* @author hupeng
|
||||
**/
|
||||
@Data
|
||||
public class BankBranchesResult implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3500020131951579476L;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:查询数据总条数
|
||||
* 变量名:total_count
|
||||
* 是否必填:是
|
||||
* 类型:int
|
||||
* 描述:
|
||||
* 经过条件筛选,查询到的支行总数
|
||||
* 示例值:10
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("total_count")
|
||||
private Integer totalCount;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:本次查询条数
|
||||
* 变量名:count
|
||||
* 是否必填:是
|
||||
* 类型:int
|
||||
* 描述:
|
||||
* 本次查询到的支行数据条数
|
||||
* 示例值:10
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("count")
|
||||
private Integer count;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:支行列表
|
||||
* 变量名:data
|
||||
* 是否必填:否
|
||||
* 类型:array
|
||||
* 描述:
|
||||
* 单次查询返回的支行列表结果数组
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("data")
|
||||
private List<BankBranch> data;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:本次查询偏移量
|
||||
* 变量名:offset
|
||||
* 是否必填:是
|
||||
* 类型:int
|
||||
* 描述:
|
||||
* 该次请求资源的起始位置,请求中包含偏移量时应答消息返回相同偏移量,否则返回默认值0
|
||||
* 示例值:0
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("offset")
|
||||
private Integer offset;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:分页链接
|
||||
* 变量名:offset
|
||||
* 是否必填:是
|
||||
* 类型:object
|
||||
* 描述:
|
||||
* 返回前后页和当前页面的访问链接
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("links")
|
||||
private PageLink links;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:开户银行
|
||||
* 变量名:account_bank
|
||||
* 是否必填:是
|
||||
* 类型:string[1, 128]
|
||||
* 描述:
|
||||
* 查询到的支行所属开户银行的名称,非直连银行统一为其他银行
|
||||
* 示例值:招商银行其他银行
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("account_bank")
|
||||
private String accountBank;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:开户银行编码
|
||||
* 变量名:account_bank_code
|
||||
* 是否必填:是
|
||||
* 类型:int
|
||||
* 描述:
|
||||
* 查询到的支行所属开户银行的开户银行编码,可用于付款到银行卡等场景中指定银行卡的开户银行
|
||||
* 示例值:1001
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("account_bank_code")
|
||||
private Integer accountBankCode;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:银行别名
|
||||
* 变量名:bank_alias
|
||||
* 是否必填:是
|
||||
* 类型:string[1, 128]
|
||||
* 描述:
|
||||
* 查询到的支行所属银行的银行别名
|
||||
* 示例值:工商银行深圳前海微众银行
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("bank_alias")
|
||||
private String bankAlias;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:银行别名编码
|
||||
* 变量名:bank_alias_code
|
||||
* 是否必填:是
|
||||
* 类型:string[1, 32]
|
||||
* 描述:
|
||||
* 查询到的支行所属银行的银行别名编码,用于校验回包
|
||||
* 示例值:1000006247
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("bank_alias_code")
|
||||
private String bankAliasCode;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class BankBranch {
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:开户银行支行名称
|
||||
* 变量名:bank_branch_name
|
||||
* 是否必填:是
|
||||
* 类型:string[1, 128]
|
||||
* 描述:
|
||||
* 开户银行支行名称,用于开户银行为其他银行的情况下,在入驻、修改结算银行卡、企业付款等场景下填写结算银行卡信息。
|
||||
* 示例值:中国工商银行上海市周浦支行
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("bank_branch_name")
|
||||
private String bankBranchName;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:开户银行支行联行号
|
||||
* 变量名:bank_branch_id
|
||||
* 是否必填:是
|
||||
* 类型:string[1, 64]
|
||||
* 描述:
|
||||
* 开户银行支行的联行号,用于开户银行为其他银行的情况下,在入驻、修改结算银行卡、企业付款等场景下填写结算银行卡信息。
|
||||
* 示例值:102290072311
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("bank_branch_id")
|
||||
private String bankBranchId;
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package com.github.binarywang.wxpay.bean.bank;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 城市列表
|
||||
*
|
||||
* @author hupeng
|
||||
**/
|
||||
@Data
|
||||
public class CitiesResult implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6089905695087974693L;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:查询数据总条数
|
||||
* 变量名:total_count
|
||||
* 是否必填:是
|
||||
* 类型:int
|
||||
* 描述:
|
||||
* 查询到的省份数据总条数
|
||||
* 示例值:10
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("total_count")
|
||||
private Integer totalCount;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:城市列表
|
||||
* 变量名:data
|
||||
* 是否必填:否
|
||||
* 类型:array
|
||||
* 描述:
|
||||
* 查询返回的城市列表结果
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("data")
|
||||
private List<CityInfo> data;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class CityInfo {
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:城市名称
|
||||
* 变量名:city_name
|
||||
* 是否必填:是
|
||||
* 类型:string[1, 256]
|
||||
* 描述:
|
||||
* 城市名称
|
||||
* 示例值:北京市
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("city_name")
|
||||
private String cityName;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:城市编码
|
||||
* 变量名:city_code
|
||||
* 是否必填:是
|
||||
* 类型:int
|
||||
* 描述:
|
||||
* 城市编码,唯一标识一座城市,用于结合银行别名编码查询支行列表
|
||||
* 示例值:10
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("city_code")
|
||||
private Integer cityCode;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.github.binarywang.wxpay.bean.bank;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支行列表
|
||||
*
|
||||
* @author hupeng
|
||||
**/
|
||||
@Data
|
||||
public class PageLink implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2624233403271204837L;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:下一页链接
|
||||
* 变量名:next
|
||||
* 是否必填:否
|
||||
* 类型:string[1, 2048]
|
||||
* 描述:
|
||||
* 使用同样的limit进行下一页查询时的相对请求链接,使用方需要自行根据当前域名进行拼接。如果已经到最后时,为空
|
||||
* 示例值:/v3/capital/capitallhh/banks/1001/branches?offset=10&limit=5
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("next")
|
||||
private String next;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:上一页链接
|
||||
* 变量名:prev
|
||||
* 是否必填:否
|
||||
* 类型:string[1, 2048]
|
||||
* 描述:
|
||||
* 使用同样的limit进行上一页查询时的相对请求链接,使用方需要自行根据当前域名进行拼接。如果是第一页,为空
|
||||
* 示例值:/v3/capital/capitallhh/banks/1001/branchesoffset=0&limit=5
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("prev")
|
||||
private String prev;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:当前链接
|
||||
* 变量名:self
|
||||
* 是否必填:否
|
||||
* 类型:string[1, 2048]
|
||||
* 描述:
|
||||
* 当前的相对请求链接,使用方需要自行根据当前域名进行拼接
|
||||
* 示例值:/v3/capital/capitallhh/banks/1001/branches?offset=5&limit=5
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("self")
|
||||
private String self;
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package com.github.binarywang.wxpay.bean.bank;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 省份列表
|
||||
*
|
||||
* @author hupeng
|
||||
**/
|
||||
@Data
|
||||
public class ProvincesResult implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4118613374545722650L;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:查询数据总条数
|
||||
* 变量名:total_count
|
||||
* 是否必填:是
|
||||
* 类型:int
|
||||
* 描述:
|
||||
* 查询到的省份数据总条数
|
||||
* 示例值:10
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("total_count")
|
||||
private Integer totalCount;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:省份列表
|
||||
* 变量名:data
|
||||
* 是否必填:否
|
||||
* 类型:array
|
||||
* 描述:
|
||||
* 查询到的省份列表数组
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("data")
|
||||
private List<ProvinceInfo> data;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ProvinceInfo {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:省份名称
|
||||
* 变量名:province_name
|
||||
* 是否必填:是
|
||||
* 类型:string[1, 256]
|
||||
* 描述:
|
||||
* 省份名称
|
||||
* 示例值:广东省
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("province_name")
|
||||
private String provinceName;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:省份编码
|
||||
* 变量名:province_code
|
||||
* 是否必填:是
|
||||
* 类型:int
|
||||
* 描述:
|
||||
* 省份编码,唯一标识一个省份,用于根据省份编码查询省份下的城市列表数据
|
||||
* 示例值:22
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("province_code")
|
||||
private Integer provinceCode;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,6 @@
|
||||
package com.github.binarywang.wxpay.service;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.bank.BankAccountResult;
|
||||
import com.github.binarywang.wxpay.bean.bank.BankingResult;
|
||||
import com.github.binarywang.wxpay.bean.bank.*;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
|
||||
/**
|
||||
@ -64,4 +63,59 @@ public interface BankService {
|
||||
* @throws WxPayException .
|
||||
*/
|
||||
BankingResult corporateBanking(Integer offset, Integer limit) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* 查询省份列表API
|
||||
* 通过本接口获取省份列表数据(不包含中国港澳台地区),可用于省份下的城市数据查询
|
||||
*
|
||||
* 请求方式:GET(HTTPS)
|
||||
* 请求地址:<a href="https://api.mch.weixin.qq.com/v3/capital/capitallhh/areas/provinces">https://api.mch.weixin.qq.com/v3/capital/capitallhh/areas/provinces</a>
|
||||
*
|
||||
* 文档地址:<a href="https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_4.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_4.shtml</a>
|
||||
* </pre>
|
||||
*
|
||||
* @return ProvincesResult 省份列表信息
|
||||
* @throws WxPayException .
|
||||
*/
|
||||
ProvincesResult areasProvinces() throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* 查询城市列表API
|
||||
* 通过本接口根据省份编码获取省份下的城市列表信息,不包含中国港澳台地区城市信息,可用于支行数据过滤查询
|
||||
*
|
||||
* 请求方式:GET(HTTPS)
|
||||
* 请求地址:<a href="https://api.mch.weixin.qq.com/v3/capital/capitallhh/areas/provinces/{province_code}/cities">https://api.mch.weixin.qq.com/v3/capital/capitallhh/areas/provinces/{province_code}/cities</a>
|
||||
*
|
||||
* 文档地址:<a href="https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_5.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_5.shtml</a>
|
||||
* </pre>
|
||||
*
|
||||
* @return CitiesResult 城市列表信息
|
||||
* @throws WxPayException .
|
||||
*/
|
||||
CitiesResult areasCities(Integer provinceCode) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* 查询支行列表API
|
||||
* 本接口可以用于根据银行别名编码(仅支持需要填写支行的银行别名编码)和城市编码过滤查询支行列表数据
|
||||
*
|
||||
* 请求方式:GET(HTTPS)
|
||||
* 请求地址:<a href="https://api.mch.weixin.qq.com/v3/capital/capitallhh/banks/{bank_alias_code}/branches">https://api.mch.weixin.qq.com/v3/capital/capitallhh/banks/{bank_alias_code}/branches</a>
|
||||
*
|
||||
* 文档地址:<a href="https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_5.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_5.shtml</a>
|
||||
* </pre>
|
||||
*
|
||||
* @param bankAliasCode 银行别名的编码,查询支行接口仅支持需要填写支行的银行别名编码。示例值:1000006247
|
||||
* @param cityCode 城市编码,唯一标识一座城市,用于结合银行别名编码查询支行列表。示例值:536
|
||||
* @param offset 非负整数,表示该次请求资源的起始位置,从0开始计数。调用方选填,默认为0。offset为20,limit为100时,查询第21-120条数据
|
||||
* @param limit 非0非负的整数,该次请求可返回的最大资源条数。示例值:200
|
||||
* @return BankBranchesResult 城市列表信息
|
||||
* @throws WxPayException .
|
||||
*/
|
||||
BankBranchesResult bankBranches(String bankAliasCode, Integer cityCode, Integer offset, Integer limit) throws WxPayException;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public interface EcommerceService {
|
||||
* <pre>
|
||||
* 二级商户进件API
|
||||
* 接口地址: https://api.mch.weixin.qq.com/v3/ecommerce/applyments/
|
||||
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/applyments/chapter3_1.shtml
|
||||
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_1_8.shtml
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.github.binarywang.wxpay.service.impl;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.bank.BankAccountResult;
|
||||
import com.github.binarywang.wxpay.bean.bank.BankingResult;
|
||||
import com.github.binarywang.wxpay.bean.bank.*;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.BankService;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
@ -43,4 +42,27 @@ public class BankServiceImpl implements BankService {
|
||||
String response = payService.getV3(url);
|
||||
return GSON.fromJson(response, BankingResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProvincesResult areasProvinces() throws WxPayException {
|
||||
String url = String.format("%s/v3/capital/capitallhh/areas/provinces", this.payService.getPayBaseUrl());
|
||||
String response = payService.getV3WithWechatPaySerial(url);
|
||||
return GSON.fromJson(response, ProvincesResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CitiesResult areasCities(Integer provinceCode) throws WxPayException {
|
||||
String url = String.format("%s/v3/capital/capitallhh/areas/provinces/%s/cities", this.payService.getPayBaseUrl(), provinceCode);
|
||||
String response = payService.getV3WithWechatPaySerial(url);
|
||||
return GSON.fromJson(response, CitiesResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BankBranchesResult bankBranches(String bankAliasCode, Integer cityCode, Integer offset, Integer limit) throws WxPayException {
|
||||
offset = offset == null ? 0 : offset;
|
||||
limit = limit == null ? 200 : limit;
|
||||
String url = String.format("%s/v3/capital/capitallhh/banks/%s/branches?city_code=%s&offset=%s&limit=%s", this.payService.getPayBaseUrl(), bankAliasCode, cityCode, offset, limit);
|
||||
String response = payService.getV3(url);
|
||||
return GSON.fromJson(response, BankBranchesResult.class);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user