查询二级商户可扫码充值员工列表
更新时间:2025.07.29收付通平台可以调用此接口查询二级子商户的最新的可扫码充值员工列表。
接口限频:单个平台商户50QPS,即每秒钟的请求频率不超过50次
接口说明
支持商户:【平台商户】
请求方式:【GET】/v3/platsolution/ecommerce/recharge-employees/sub-mchid/{sub_mchid}
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
path 路径参数
sub_mchid 必填 string(32)
【二级商户号】 二级商户号
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/platsolution/ecommerce/recharge-employees/sub-mchid/1900001109 \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" 5
需配合微信支付工具库 WXPayUtility 使用,请参考Java
1package com.java.demo; 2 3import com.java.utils.WXPayUtility; // 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/v3/partner/4014985777 4 5import com.google.gson.annotations.SerializedName; 6import com.google.gson.annotations.Expose; 7import okhttp3.MediaType; 8import okhttp3.OkHttpClient; 9import okhttp3.Request; 10import okhttp3.RequestBody; 11import okhttp3.Response; 12 13import java.io.IOException; 14import java.io.UncheckedIOException; 15import java.security.PrivateKey; 16import java.security.PublicKey; 17import java.util.ArrayList; 18import java.util.HashMap; 19import java.util.List; 20import java.util.Map; 21 22/** 23 * 查询二级商户可扫码充值员工列表 24 */ 25public class PlatSolutionRechargeEmployeeGetBySubMchCode { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "GET"; 28 private static String PATH = "/v3/platsolution/ecommerce/recharge-employees/sub-mchid/{sub_mchid}"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 PlatSolutionRechargeEmployeeGetBySubMchCode client = new PlatSolutionRechargeEmployeeGetBySubMchCode( 33 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 34 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 35 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 36 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 37 "/path/to/wxp_pub.pem" // 微信支付公钥文件路径,本地文件路径 38 ); 39 40 PlatSolutionRechargeEmployeeGetBySubMchCodeRequest request = new PlatSolutionRechargeEmployeeGetBySubMchCodeRequest(); 41 request.subMchid = "1900001109"; 42 try { 43 GetRechargeEmployeesBySubMchCodeResponse response = client.run(request); 44 // TODO: 请求成功,继续业务逻辑 45 System.out.println(response); 46 } catch (WXPayUtility.ApiException e) { 47 // TODO: 请求失败,根据状态码执行不同的逻辑 48 e.printStackTrace(); 49 } 50 } 51 52 public GetRechargeEmployeesBySubMchCodeResponse run(PlatSolutionRechargeEmployeeGetBySubMchCodeRequest request) { 53 String uri = PATH; 54 uri = uri.replace("{sub_mchid}", WXPayUtility.urlEncode(request.subMchid)); 55 56 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 57 reqBuilder.addHeader("Accept", "application/json"); 58 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 59 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 60 reqBuilder.method(METHOD, null); 61 Request httpRequest = reqBuilder.build(); 62 63 // 发送HTTP请求 64 OkHttpClient client = new OkHttpClient.Builder().build(); 65 try (Response httpResponse = client.newCall(httpRequest).execute()) { 66 String respBody = WXPayUtility.extractBody(httpResponse); 67 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 68 // 2XX 成功,验证应答签名 69 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 70 httpResponse.headers(), respBody); 71 72 // 从HTTP应答报文构建返回数据 73 return WXPayUtility.fromJson(respBody, GetRechargeEmployeesBySubMchCodeResponse.class); 74 } else { 75 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 76 } 77 } catch (IOException e) { 78 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 79 } 80 } 81 82 private final String mchid; 83 private final String certificateSerialNo; 84 private final PrivateKey privateKey; 85 private final String wechatPayPublicKeyId; 86 private final PublicKey wechatPayPublicKey; 87 88 public PlatSolutionRechargeEmployeeGetBySubMchCode(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 89 this.mchid = mchid; 90 this.certificateSerialNo = certificateSerialNo; 91 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 92 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 93 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 94 } 95 96 public static class PlatSolutionRechargeEmployeeGetBySubMchCodeRequest { 97 @SerializedName("sub_mchid") 98 @Expose(serialize = false) 99 public String subMchid; 100 } 101 102 public static class GetRechargeEmployeesBySubMchCodeResponse { 103 @SerializedName("employees") 104 public List<RechargeEmployee> employees; 105 } 106 107 public static class RechargeEmployee { 108 @SerializedName("sub_mchid") 109 public String subMchid; 110 111 @SerializedName("sp_openid") 112 public String spOpenid; 113 114 @SerializedName("state") 115 public RechargeEmployeeState state; 116 117 @SerializedName("create_time") 118 public String createTime; 119 120 @SerializedName("update_time") 121 public String updateTime; 122 } 123 124 public enum RechargeEmployeeState { 125 @SerializedName("EFFECTIVE") 126 EFFECTIVE, 127 @SerializedName("DELETED") 128 DELETED 129 } 130 131} 132
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "demo/wxpay_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/v3/partner/4015119446 5 "encoding/json" 6 "fmt" 7 "net/http" 8 "net/url" 9 "strings" 10 "time" 11) 12 13func main() { 14 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 15 config, err := wxpay_utility.CreateMchConfig( 16 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 17 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 18 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 19 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 20 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 21 ) 22 if err != nil { 23 fmt.Println(err) 24 return 25 } 26 27 request := &PlatSolutionRechargeEmployeeGetBySubMchCodeRequest{ 28 SubMchid: wxpay_utility.String("1900001109"), 29 } 30 31 response, err := PlatSolutionRechargeEmployeeGetBySubMchCode(config, request) 32 if err != nil { 33 fmt.Printf("请求失败: %+v\n", err) 34 // TODO: 请求失败,根据状态码执行不同的处理 35 return 36 } 37 38 // TODO: 请求成功,继续业务逻辑 39 fmt.Printf("请求成功: %+v\n", response) 40} 41 42func PlatSolutionRechargeEmployeeGetBySubMchCode(config *wxpay_utility.MchConfig, request *PlatSolutionRechargeEmployeeGetBySubMchCodeRequest) (response *GetRechargeEmployeesBySubMchCodeResponse, err error) { 43 const ( 44 host = "https://api.mch.weixin.qq.com" 45 method = "GET" 46 path = "/v3/platsolution/ecommerce/recharge-employees/sub-mchid/{sub_mchid}" 47 ) 48 49 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 50 if err != nil { 51 return nil, err 52 } 53 reqUrl.Path = strings.Replace(reqUrl.Path, "{sub_mchid}", url.PathEscape(*request.SubMchid), -1) 54 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 55 if err != nil { 56 return nil, err 57 } 58 httpRequest.Header.Set("Accept", "application/json") 59 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 60 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 61 if err != nil { 62 return nil, err 63 } 64 httpRequest.Header.Set("Authorization", authorization) 65 66 client := &http.Client{} 67 httpResponse, err := client.Do(httpRequest) 68 if err != nil { 69 return nil, err 70 } 71 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 72 if err != nil { 73 return nil, err 74 } 75 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 76 // 2XX 成功,验证应答签名 77 err = wxpay_utility.ValidateResponse( 78 config.WechatPayPublicKeyId(), 79 config.WechatPayPublicKey(), 80 &httpResponse.Header, 81 respBody, 82 ) 83 if err != nil { 84 return nil, err 85 } 86 response := &GetRechargeEmployeesBySubMchCodeResponse{} 87 if err := json.Unmarshal(respBody, response); err != nil { 88 return nil, err 89 } 90 91 return response, nil 92 } else { 93 return nil, wxpay_utility.NewApiException( 94 httpResponse.StatusCode, 95 httpResponse.Header, 96 respBody, 97 ) 98 } 99} 100 101type PlatSolutionRechargeEmployeeGetBySubMchCodeRequest struct { 102 SubMchid *string `json:"sub_mchid,omitempty"` 103} 104 105func (o *PlatSolutionRechargeEmployeeGetBySubMchCodeRequest) MarshalJSON() ([]byte, error) { 106 type Alias PlatSolutionRechargeEmployeeGetBySubMchCodeRequest 107 a := &struct { 108 SubMchid *string `json:"sub_mchid,omitempty"` 109 *Alias 110 }{ 111 // 序列化时移除非 Body 字段 112 SubMchid: nil, 113 Alias: (*Alias)(o), 114 } 115 return json.Marshal(a) 116} 117 118type GetRechargeEmployeesBySubMchCodeResponse struct { 119 Employees []RechargeEmployee `json:"employees,omitempty"` 120} 121 122type RechargeEmployee struct { 123 SubMchid *string `json:"sub_mchid,omitempty"` 124 SpOpenid *string `json:"sp_openid,omitempty"` 125 State *RechargeEmployeeState `json:"state,omitempty"` 126 CreateTime *time.Time `json:"create_time,omitempty"` 127 UpdateTime *time.Time `json:"update_time,omitempty"` 128} 129 130type RechargeEmployeeState string 131 132func (e RechargeEmployeeState) Ptr() *RechargeEmployeeState { 133 return &e 134} 135 136const ( 137 RECHARGEEMPLOYEESTATE_EFFECTIVE RechargeEmployeeState = "EFFECTIVE" 138 RECHARGEEMPLOYEESTATE_DELETED RechargeEmployeeState = "DELETED" 139) 140
应答参数
折叠全部参数
200 OK
employees 选填 array[object]
【员工列表】 包含当前所有的可充值员工
| 属性 | |
sub_mchid 必填 string(32) 【二级商户号】 二级商户号 sp_openid 必填 string(32) 【员工OpenID】 二级商户的员工在平台商户应用下的OpenID state 选填 string 【员工状态】 员工状态 可选取值
create_time 选填 string(32) 【添加员工时间】 添加员工时间,使用rfc3339标准格式 update_time 选填 string(32) 【最后更新时间】 最后更新时间,使用rfc3339标准格式 |
应答示例
200 OK
1{ 2 "employees" : [ 3 { 4 "sub_mchid" : "1900001109", 5 "sp_openid" : "oLTPCuCsfN3ABBz50VUZBNlHDbUU", 6 "state" : "EFFECTIVE", 7 "create_time" : "2015-05-20T13:29:35.120+08:00", 8 "update_time" : "2015-05-21T13:29:35.120+08:00" 9 } 10 ] 11} 12
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示
