服务人员查询
更新时间:2025.01.08用于查询已注册的服务人员ID等信息。
注意:
个人微信商家
传入门店ID,查询该门店下的所有已注册服务人员的信息(每次查询不可超过10条)
传入服务人员的工号(服务人员注册时填写)或手机号,查询单个服务人员的信息。
企业微信商家
传入门店ID,查询该门店下的所有已注册服务人员的信息(每次查询不可超过10条)
传入服务人员的企业微信员工ID或手机号,查询单个服务人员的信息。
服务人员注册API和查询API请求URL相同,区别主要是在body和query,请注意区分。
接口说明
支持商户:【普通商户】
请求方式:【GET】/v3/smartguide/guides
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
Wechatpay-Serial 必填 string
【微信支付公钥ID】或【微信支付平台证书序列号】请求参数中的敏感字段,需要使用微信支付公钥加密(推荐),请参考获取微信支付公钥ID说明以及微信支付公钥加密敏感信息指引,也可以使用微信支付平台证书公钥加密,参考获取平台证书序列号、平台证书加密敏感信息指引
query 查询参数
store_id 必填 integer
【门店ID】门店在微信支付商户平台的唯一标识
userid 选填 string(64)
【企业微信的员工ID】员工在商户企业微信通讯录使用的唯一标识,企业微信商家可传入
mobile 选填 string
【手机号码】服务人员通过小程序注册时填写的手机号码,该字段需要使用微信支付公钥加密(推荐),请参考获取微信支付公钥ID说明以及微信支付公钥加密敏感信息指引,也可以使用微信支付平台证书公钥加密,参考获取平台证书序列号、平台证书加密敏感信息指引
work_id 选填 string
【工号】服务人员通过小程序注册时填写的工号,个人微信商家可传入
limit 选填 integer
【最大资源条数】该次请求可返回的最大资源条数,不大于10
offset 选填 integer
【请求资源起始位置】该次请求资源的起始位置,默认值为0
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/smartguide/guides?store_id=1234&userid=robert&mobile=str2WoWy8uUiWM7xahvNv0lV3C+nn3t4QlKNnyr+iwlk2FoMcn/lxrR6YdKKFI6NFJkC5oyvzNwc1MDzIgjLR0W6bJKiwWeOV3Fp0x+VIoRDONal1Mgb6VTYg7lvACEqdwmVkvbt4/oEWaWP62njMGGe0fMiBSAvao3LrcsOwDvN3E9kiaw5XQZMP/rUdWTFfy5THuohcQobGMrxclHKAnwAHU8CWfkziW5crUc3Z83uMVcFQu38y9EcWR12FJ3jip5nyVKiqCF4iDSN+JRXjWsWlqTZ0Y8Q+piBCS5ACusK6nz7mKQeypi9fKjAggRfvNFPf/bNxPvork4mMVgZkA==&work_id=robert&limit=5&offset=0 \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" \ 5 -H "Wechatpay-Serial: 5157F09EFDC096DE15EBE81A47057A7232F1B8E1" 6
需配合微信支付工具库 WXPayUtility 使用,请参考Java
1package com.java.demo; 2 3import com.java.utils.WXPayUtility; // 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/v3/merchant/4014931831 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 ListGuides { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "GET"; 28 private static String PATH = "/v3/smartguide/guides"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/merchant/4013070756 32 ListGuides client = new ListGuides( 33 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756 34 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053 35 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 36 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816 37 "/path/to/wxp_pub.pem" // 微信支付公钥文件路径,本地文件路径 38 ); 39 40 ListGuidesRequest request = new ListGuidesRequest(); 41 request.storeId = 1234L; 42 request.userid = "robert"; 43 request.mobile = "str2WoWy8uUiWM7xahvNv0lV3C+nn3t4QlKNnyr+iwlk2FoMcn/lxrR6YdKKFI6NFJkC5oyvzNwc1MDzIgjLR0W6bJKiwWeOV3Fp0x+VIoRDONal1Mgb6VTYg7lvACEqdwmVkvbt4/oEWaWP62njMGGe0fMiBSAvao3LrcsOwDvN3E9kiaw5XQZMP/rUdWTFfy5THuohcQobGMrxclHKAnwAHU8CWfkziW5crUc3Z83uMVcFQu38y9EcWR12FJ3jip5nyVKiqCF4iDSN+JRXjWsWlqTZ0Y8Q+piBCS5ACusK6nz7mKQeypi9fKjAggRfvNFPf/bNxPvork4mMVgZkA=="; 44 request.workId = "robert"; 45 request.limit = 5L; 46 request.offset = 0L; 47 try { 48 ListGuidesResponse response = client.run(request); 49 // TODO: 请求成功,继续业务逻辑 50 System.out.println(response); 51 } catch (WXPayUtility.ApiException e) { 52 // TODO: 请求失败,根据状态码执行不同的逻辑 53 e.printStackTrace(); 54 } 55 } 56 57 public ListGuidesResponse run(ListGuidesRequest request) { 58 String uri = PATH; 59 Map<String, Object> args = new HashMap<>(); 60 args.put("store_id", request.storeId); 61 args.put("userid", request.userid); 62 args.put("mobile", request.mobile); 63 args.put("work_id", request.workId); 64 args.put("limit", request.limit); 65 args.put("offset", request.offset); 66 String queryString = WXPayUtility.urlEncode(args); 67 if (!queryString.isEmpty()) { 68 uri = uri + "?" + queryString; 69 } 70 71 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 72 reqBuilder.addHeader("Accept", "application/json"); 73 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 74 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 75 reqBuilder.method(METHOD, null); 76 Request httpRequest = reqBuilder.build(); 77 78 // 发送HTTP请求 79 OkHttpClient client = new OkHttpClient.Builder().build(); 80 try (Response httpResponse = client.newCall(httpRequest).execute()) { 81 String respBody = WXPayUtility.extractBody(httpResponse); 82 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 83 // 2XX 成功,验证应答签名 84 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 85 httpResponse.headers(), respBody); 86 87 // 从HTTP应答报文构建返回数据 88 return WXPayUtility.fromJson(respBody, ListGuidesResponse.class); 89 } else { 90 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 91 } 92 } catch (IOException e) { 93 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 94 } 95 } 96 97 private final String mchid; 98 private final String certificateSerialNo; 99 private final PrivateKey privateKey; 100 private final String wechatPayPublicKeyId; 101 private final PublicKey wechatPayPublicKey; 102 103 public ListGuides(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 104 this.mchid = mchid; 105 this.certificateSerialNo = certificateSerialNo; 106 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 107 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 108 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 109 } 110 111 public String encrypt(String plainText) { 112 return WXPayUtility.encrypt(this.wechatPayPublicKey, plainText); 113 } 114 115 public static class ListGuidesRequest { 116 @SerializedName("store_id") 117 @Expose(serialize = false) 118 public Long storeId; 119 120 @SerializedName("userid") 121 @Expose(serialize = false) 122 public String userid; 123 124 @SerializedName("mobile") 125 @Expose(serialize = false) 126 public String mobile; 127 128 @SerializedName("work_id") 129 @Expose(serialize = false) 130 public String workId; 131 132 @SerializedName("limit") 133 @Expose(serialize = false) 134 public Long limit; 135 136 @SerializedName("offset") 137 @Expose(serialize = false) 138 public Long offset; 139 } 140 141 public static class ListGuidesResponse { 142 @SerializedName("data") 143 public List<Guide> data; 144 145 @SerializedName("total_count") 146 public Long totalCount; 147 148 @SerializedName("limit") 149 public Long limit; 150 151 @SerializedName("offset") 152 public Long offset; 153 } 154 155 public static class Guide { 156 @SerializedName("guide_id") 157 public String guideId; 158 159 @SerializedName("store_id") 160 public Long storeId; 161 162 @SerializedName("name") 163 public String name; 164 165 @SerializedName("mobile") 166 public String mobile; 167 168 @SerializedName("userid") 169 public String userid; 170 171 @SerializedName("work_id") 172 public String workId; 173 } 174 175} 176
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "demo/wxpay_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/v3/merchant/4015119334 5 "encoding/json" 6 "fmt" 7 "net/http" 8 "net/url" 9) 10 11func main() { 12 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/merchant/4013070756 13 config, err := wxpay_utility.CreateMchConfig( 14 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756 15 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053 16 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 17 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816 18 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 19 ) 20 if err != nil { 21 fmt.Println(err) 22 return 23 } 24 25 request := &ListGuidesRequest{ 26 StoreId: wxpay_utility.Int64(1234), 27 Userid: wxpay_utility.String("robert"), 28 Mobile: wxpay_utility.String("str2WoWy8uUiWM7xahvNv0lV3C+nn3t4QlKNnyr+iwlk2FoMcn/lxrR6YdKKFI6NFJkC5oyvzNwc1MDzIgjLR0W6bJKiwWeOV3Fp0x+VIoRDONal1Mgb6VTYg7lvACEqdwmVkvbt4/oEWaWP62njMGGe0fMiBSAvao3LrcsOwDvN3E9kiaw5XQZMP/rUdWTFfy5THuohcQobGMrxclHKAnwAHU8CWfkziW5crUc3Z83uMVcFQu38y9EcWR12FJ3jip5nyVKiqCF4iDSN+JRXjWsWlqTZ0Y8Q+piBCS5ACusK6nz7mKQeypi9fKjAggRfvNFPf/bNxPvork4mMVgZkA=="), 29 WorkId: wxpay_utility.String("robert"), 30 Limit: wxpay_utility.Int64(5), 31 Offset: wxpay_utility.Int64(0), 32 } 33 34 response, err := ListGuides(config, request) 35 if err != nil { 36 fmt.Printf("请求失败: %+v\n", err) 37 // TODO: 请求失败,根据状态码执行不同的处理 38 return 39 } 40 41 // TODO: 请求成功,继续业务逻辑 42 fmt.Printf("请求成功: %+v\n", response) 43} 44 45func ListGuides(config *wxpay_utility.MchConfig, request *ListGuidesRequest) (response *ListGuidesResponse, err error) { 46 const ( 47 host = "https://api.mch.weixin.qq.com" 48 method = "GET" 49 path = "/v3/smartguide/guides" 50 ) 51 52 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 53 if err != nil { 54 return nil, err 55 } 56 query := reqUrl.Query() 57 if request.StoreId != nil { 58 query.Add("store_id", fmt.Sprintf("%v", *request.StoreId)) 59 } 60 if request.Userid != nil { 61 query.Add("userid", *request.Userid) 62 } 63 if request.Mobile != nil { 64 query.Add("mobile", *request.Mobile) 65 } 66 if request.WorkId != nil { 67 query.Add("work_id", *request.WorkId) 68 } 69 if request.Limit != nil { 70 query.Add("limit", fmt.Sprintf("%v", *request.Limit)) 71 } 72 if request.Offset != nil { 73 query.Add("offset", fmt.Sprintf("%v", *request.Offset)) 74 } 75 reqUrl.RawQuery = query.Encode() 76 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 77 if err != nil { 78 return nil, err 79 } 80 httpRequest.Header.Set("Accept", "application/json") 81 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 82 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 83 if err != nil { 84 return nil, err 85 } 86 httpRequest.Header.Set("Authorization", authorization) 87 88 client := &http.Client{} 89 httpResponse, err := client.Do(httpRequest) 90 if err != nil { 91 return nil, err 92 } 93 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 94 if err != nil { 95 return nil, err 96 } 97 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 98 // 2XX 成功,验证应答签名 99 err = wxpay_utility.ValidateResponse( 100 config.WechatPayPublicKeyId(), 101 config.WechatPayPublicKey(), 102 &httpResponse.Header, 103 respBody, 104 ) 105 if err != nil { 106 return nil, err 107 } 108 response := &ListGuidesResponse{} 109 if err := json.Unmarshal(respBody, response); err != nil { 110 return nil, err 111 } 112 113 return response, nil 114 } else { 115 return nil, wxpay_utility.NewApiException( 116 httpResponse.StatusCode, 117 httpResponse.Header, 118 respBody, 119 ) 120 } 121} 122 123type ListGuidesRequest struct { 124 StoreId *int64 `json:"store_id,omitempty"` 125 Userid *string `json:"userid,omitempty"` 126 Mobile *string `json:"mobile,omitempty"` 127 WorkId *string `json:"work_id,omitempty"` 128 Limit *int64 `json:"limit,omitempty"` 129 Offset *int64 `json:"offset,omitempty"` 130} 131 132func (o *ListGuidesRequest) MarshalJSON() ([]byte, error) { 133 type Alias ListGuidesRequest 134 a := &struct { 135 StoreId *int64 `json:"store_id,omitempty"` 136 Userid *string `json:"userid,omitempty"` 137 Mobile *string `json:"mobile,omitempty"` 138 WorkId *string `json:"work_id,omitempty"` 139 Limit *int64 `json:"limit,omitempty"` 140 Offset *int64 `json:"offset,omitempty"` 141 *Alias 142 }{ 143 // 序列化时移除非 Body 字段 144 StoreId: nil, 145 Userid: nil, 146 Mobile: nil, 147 WorkId: nil, 148 Limit: nil, 149 Offset: nil, 150 Alias: (*Alias)(o), 151 } 152 return json.Marshal(a) 153} 154 155type ListGuidesResponse struct { 156 Data []Guide `json:"data,omitempty"` 157 TotalCount *int64 `json:"total_count,omitempty"` 158 Limit *int64 `json:"limit,omitempty"` 159 Offset *int64 `json:"offset,omitempty"` 160} 161 162type Guide struct { 163 GuideId *string `json:"guide_id,omitempty"` 164 StoreId *int64 `json:"store_id,omitempty"` 165 Name *string `json:"name,omitempty"` 166 Mobile *string `json:"mobile,omitempty"` 167 Userid *string `json:"userid,omitempty"` 168 WorkId *string `json:"work_id,omitempty"` 169} 170
应答参数
|
data 选填 array[object]
【服务人员列表】
属性 | |
guide_id 选填 string 【服务人员ID】导购在导购系统中的唯一标识 store_id 选填 integer 【门店ID】门店在微信支付商户平台的唯一标识 name 选填 string 【服务人员姓名】员工在商户企业微信通讯录上的姓名,该字段需进行解密处理,具体解密方法详见如何使用API证书解密敏感字段 mobile 选填 string 【手机号码】服务人员通过小程序注册时填写的手机号码,使用微信商家不返回,该字段需进行解密处理,具体解密方法详见如何使用API证书解密敏感字段 userid 选填 string 【企业微信的员工ID】员工在商户企业微信通讯录使用的唯一标识,使用微信商家不返回 work_id 选填 string 【工号】服务人员通过小程序注册时填写的工号,使用微信商家不返回 |
total_count 选填 integer
【服务人员数量】符合条件筛选的服务人员数量
limit 选填 integer
【最大资源条数】该次请求可返回的最大资源条数,不大于10
offset 选填 integer
【请求资源起始位置】该次请求资源的起始位置,默认值为0
应答示例
200 OK
1{ 2 "data" : [ 3 { 4 "guide_id" : "LLA3WJ6DSZUfiaZDS79FH5Wm5m4X69TBic", 5 "store_id" : 1234, 6 "name" : "str2WoWy8uUiWM7xahvNv0lV3C+nn3t4QlKNnyr+iwlk2FoMcn/lxrR6YdKKFI6NFJkC5oyvzNwc1MDzIgjLR0W6bJKiwWeOV3Fp0x+VIoRDONal1Mgb6VTYg7lvACEqdwmVkvbt4/oEWaWP62njMGGe0fMiBSAvao3LrcsOwDvN3E9kiaw5XQZMP/rUdWTFfy5THuohcQobGMrxclHKAnwAHU8CWfkziW5crUc3Z83uMVcFQu38y9EcWR12FJ3jip5nyVKiqCF4iDSN+JRXjWsWlqTZ0Y8Q+piBCS5ACusK6nz7mKQeypi9fKjAggRfvNFPf/bNxPvork4mMVgZkA==", 7 "mobile" : "str2WoWy8uUiWM7xahvNv0lV3C+nn3t4QlKNnyr+iwlk2FoMcn/lxrR6YdKKFI6NFJkC5oyvzNwc1MDzIgjLR0W6bJKiwWeOV3Fp0x+VIoRDONal1Mgb6VTYg7lvACEqdwmVkvbt4/oEWaWP62njMGGe0fMiBSAvao3LrcsOwDvN3E9kiaw5XQZMP/rUdWTFfy5THuohcQobGMrxclHKAnwAHU8CWfkziW5crUc3Z83uMVcFQu38y9EcWR12FJ3jip5nyVKiqCF4iDSN+JRXjWsWlqTZ0Y8Q+piBCS5ACusK6nz7mKQeypi9fKjAggRfvNFPf/bNxPvork4mMVgZkA==", 8 "userid" : "robert", 9 "work_id" : "robert" 10 } 11 ], 12 "total_count" : 10, 13 "limit" : 5, 14 "offset" : 0 15} 16
错误码
公共错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
业务错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | INVALID_REQUEST | 子商户未授权 | 子商户未授权,请联系子商户授权 |
400 | INVALID_REQUEST | 子商户产品权限未开通 | 子商户产品权限未开通,请联系子商户开通 |
400 | INVALID_REQUEST | 子商户产品配置未完成 | 子商户产品配置未完成,请确认子商户完成产品配置后重试 |
400 | MCH_NOT_EXISTS | 子商户不存在 | 请确认商户号是否有误 |
400 | MCH_NOT_EXISTS | 商户号格式错误 | 请确认商户号是否有误 |
400 | MCH_NOT_EXISTS | 子商户号格式错误 | 请确认商户号是否有误 |
400 | MCH_NOT_EXISTS | 子商户号为空 | 请填写子商户号 |
400 | PARAM_ERROR | 必填参数为空 | 根据错误提示,传入正确参数 |
400 | PARAM_ERROR | 门店ID格式错误 | 根据错误提示,传入正确参数 |
400 | PARAM_ERROR | userid格式错误 | 根据错误提示,传入正确参数 |
400 | PARAM_ERROR | 手机号码格式错误 | 根据错误提示,传入正确参数 |
400 | PARAM_ERROR | 门店ID为空 | 请填写门店ID |
400 | PARAM_ERROR | 个人微信商家不应填写企业微信ID | 根据错误提示,传入正确参数 |
400 | PARAM_ERROR | 企业微信商家不应填写工号 | 根据错误提示,传入正确参数 |
400 | PARAM_ERROR | 最大资源条数大于10 | 根据错误提示,传入正确参数 |
500 | SYSTEM_ERROR | 系统错误 | 请使用相同参数稍后重新调用 |
500 | SYSTEM_ERROR | 扩展父子商户票据错误 | 请使用相同参数稍后重新调用 |
500 | SYSTEM_ERROR | 调用云函数错误 | 请使用相同参数稍后重新调用 |