File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed
weixin-java-cp/src/main/java/me/chanjar/weixin/cp Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,29 @@ public interface WxCpExternalContactService {
159
159
*/
160
160
String convertToOpenid (String externalUserid ) throws WxErrorException ;
161
161
162
+ /**
163
+ * 服务商为企业代开发微信小程序的场景,服务商可通过此接口,将微信客户的unionid转为external_userid。
164
+ * <pre>
165
+ *
166
+ * 文档地址:https://work.weixin.qq.com/api/doc/90001/90143/93274
167
+ *
168
+ * 服务商代开发小程序指企业使用的小程序为企业主体的,非服务商主体的小程序。
169
+ * 场景:企业客户在微信端从企业主体的小程序(非服务商应用)登录,同时企业在企业微信安装了服务商的第三方应用,服务商可以调用该接口将登录用户的unionid转换为服务商全局唯一的外部联系人id
170
+ *
171
+ * 权限说明:
172
+ *
173
+ * 仅认证企业可调用
174
+ * unionid必须是企业主体下的unionid。即unionid的主体(为绑定了该小程序的微信开放平台账号主体)需与当前企业的主体一致。
175
+ * unionid的主体(即微信开放平台账号主体)需认证
176
+ * 该客户的跟进人必须在应用的可见范围之内
177
+ * </pre>
178
+ *
179
+ * @param unionid 微信客户的unionid
180
+ * @return 该企业的外部联系人ID
181
+ * @throws WxErrorException .
182
+ */
183
+ String unionidToExternalUserid (String unionid ) throws WxErrorException ;
184
+
162
185
/**
163
186
* 批量获取客户详情.
164
187
* <pre>
Original file line number Diff line number Diff line change @@ -137,6 +137,16 @@ public String convertToOpenid(@NotNull String externalUserId) throws WxErrorExce
137
137
return tmpJson .get ("openid" ).getAsString ();
138
138
}
139
139
140
+ @ Override
141
+ public String unionidToExternalUserid (@ NotNull String unionid ) throws WxErrorException {
142
+ JsonObject json = new JsonObject ();
143
+ json .addProperty ("unionid" , unionid );
144
+ final String url = this .mainService .getWxCpConfigStorage ().getApiUrl (UNIONID_TO_EXTERNAL_USERID );
145
+ String responseContent = this .mainService .post (url , json .toString ());
146
+ JsonObject tmpJson = GsonParser .parse (responseContent );
147
+ return tmpJson .get ("external_userid" ).getAsString ();
148
+ }
149
+
140
150
@ Override
141
151
public WxCpExternalContactBatchInfo getContactDetailBatch (String userId ,
142
152
String cursor ,
Original file line number Diff line number Diff line change @@ -181,6 +181,7 @@ interface ExternalContact {
181
181
String GET_FOLLOW_USER_LIST = "/cgi-bin/externalcontact/get_follow_user_list" ;
182
182
String GET_CONTACT_DETAIL = "/cgi-bin/externalcontact/get?external_userid=" ;
183
183
String CONVERT_TO_OPENID = "/cgi-bin/externalcontact/convert_to_openid" ;
184
+ String UNIONID_TO_EXTERNAL_USERID = "/cgi-bin/externalcontact/unionid_to_external_userid" ;
184
185
String GET_CONTACT_DETAIL_BATCH = "/cgi-bin/externalcontact/batch/get_by_user?" ;
185
186
String UPDATE_REMARK = "/cgi-bin/externalcontact/remark" ;
186
187
String LIST_EXTERNAL_CONTACT = "/cgi-bin/externalcontact/list?userid=" ;
You can’t perform that action at this time.
0 commit comments