Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🆕 【企业微信】增加服务商模式外部联系人unionid转换接口 #2298

Merged
merged 1 commit into from
Sep 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,29 @@ public interface WxCpExternalContactService {
*/
String convertToOpenid(String externalUserid) throws WxErrorException;

/**
* 服务商为企业代开发微信小程序的场景,服务商可通过此接口,将微信客户的unionid转为external_userid。
* <pre>
*
* 文档地址:https://work.weixin.qq.com/api/doc/90001/90143/93274
*
* 服务商代开发小程序指企业使用的小程序为企业主体的,非服务商主体的小程序。
* 场景:企业客户在微信端从企业主体的小程序(非服务商应用)登录,同时企业在企业微信安装了服务商的第三方应用,服务商可以调用该接口将登录用户的unionid转换为服务商全局唯一的外部联系人id
*
* 权限说明:
*
* 仅认证企业可调用
* unionid必须是企业主体下的unionid。即unionid的主体(为绑定了该小程序的微信开放平台账号主体)需与当前企业的主体一致。
* unionid的主体(即微信开放平台账号主体)需认证
* 该客户的跟进人必须在应用的可见范围之内
* </pre>
*
* @param unionid 微信客户的unionid
* @return 该企业的外部联系人ID
* @throws WxErrorException .
*/
String unionidToExternalUserid(String unionid) throws WxErrorException;

/**
* 批量获取客户详情.
* <pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ public String convertToOpenid(@NotNull String externalUserId) throws WxErrorExce
return tmpJson.get("openid").getAsString();
}

@Override
public String unionidToExternalUserid(@NotNull String unionid) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("unionid", unionid);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UNIONID_TO_EXTERNAL_USERID);
String responseContent = this.mainService.post(url, json.toString());
JsonObject tmpJson = GsonParser.parse(responseContent);
return tmpJson.get("external_userid").getAsString();
}

@Override
public WxCpExternalContactBatchInfo getContactDetailBatch(String userId,
String cursor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ interface ExternalContact {
String GET_FOLLOW_USER_LIST = "/cgi-bin/externalcontact/get_follow_user_list";
String GET_CONTACT_DETAIL = "/cgi-bin/externalcontact/get?external_userid=";
String CONVERT_TO_OPENID = "/cgi-bin/externalcontact/convert_to_openid";
String UNIONID_TO_EXTERNAL_USERID = "/cgi-bin/externalcontact/unionid_to_external_userid";
String GET_CONTACT_DETAIL_BATCH = "/cgi-bin/externalcontact/batch/get_by_user?";
String UPDATE_REMARK = "/cgi-bin/externalcontact/remark";
String LIST_EXTERNAL_CONTACT = "/cgi-bin/externalcontact/list?userid=";
Expand Down