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

This commit is contained in:
ArBing
2021-09-05 16:03:37 +08:00
committed by GitHub
parent 2a36ebf45f
commit 59a1456799
3 changed files with 34 additions and 0 deletions

View File

@@ -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>

View File

@@ -137,6 +137,16 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
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,

View File

@@ -181,6 +181,7 @@ public interface WxCpApiPathConsts {
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=";