Skip to content

Commit 26ddf1d

Browse files
committed
🆕 #1370 企业微信第三方应用客户管理里的获取客户详情接口增加新的接口实现
1 parent ea06197 commit 26ddf1d

File tree

4 files changed

+59
-8
lines changed

4 files changed

+59
-8
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,54 @@ public interface WxCpExternalContactService {
2424
* </pre>
2525
*
2626
* @param userId 外部联系人的userid
27+
* @return .
28+
* @deprecated 建议使用 {@link #getContactDetail(String)}
2729
*/
30+
@Deprecated
2831
WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException;
2932

3033
/**
31-
* 获取外部联系人列表.
34+
* 获取客户详情.
3235
* <pre>
33-
* 企业可通过此接口获取指定成员添加的客户列表。
34-
* 客户是指配置了客户联系功能的成员所添加的外部联系人。
35-
* 没有配置客户联系功能的成员,所添加的外部联系人将不会作为客户返回。
36+
*
37+
* 企业可通过此接口,根据外部联系人的userid(如何获取?),拉取客户详情。
38+
*
39+
* 请求方式:GET(HTTPS)
40+
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=ACCESS_TOKEN&external_userid=EXTERNAL_USERID
41+
*
42+
* 权限说明:
43+
*
44+
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?);
45+
* 第三方/自建应用调用时,返回的跟进人follow_user仅包含应用可见范围之内的成员。
46+
* </pre>
47+
*
48+
* @param userId 外部联系人的userid,注意不是企业成员的帐号
49+
* @return .
50+
* @throws WxErrorException .
51+
*/
52+
WxCpUserExternalContactInfo getContactDetail(String userId) throws WxErrorException;
53+
54+
/**
55+
* 获取客户列表.
56+
* <pre>
57+
* 企业可通过此接口获取指定成员添加的客户列表。客户是指配置了客户联系功能的成员所添加的外部联系人。没有配置客户联系功能的成员,所添加的外部联系人将不会作为客户返回。
58+
*
59+
* 请求方式:GET(HTTPS)
60+
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list?access_token=ACCESS_TOKEN&userid=USERID
61+
*
62+
* 权限说明:
63+
*
64+
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?);
3665
* 第三方应用需拥有“企业客户”权限。
37-
* 第三方应用调用时,返回的跟进人follow_user仅包含应用可见范围之内的成员
66+
* 第三方/自建应用只能获取到可见范围内的配置了客户联系功能的成员
3867
* </pre>
3968
*
40-
* @param userId 外部联系人的userid
69+
* @param userId 企业成员的userid
4170
* @return List of External wx id
71+
* @throws WxErrorException .
4272
*/
4373
List<String> listExternalContacts(String userId) throws WxErrorException;
4474

45-
4675
/**
4776
* 企业和第三方服务商可通过此接口获取配置了客户联系功能的成员(Customer Contact)列表。
4877
* <pre>
@@ -52,7 +81,9 @@ public interface WxCpExternalContactService {
5281
* </pre>
5382
*
5483
* @return List of CpUser id
84+
* @throws WxErrorException .
5585
*/
86+
@Deprecated
5687
List<String> listFollowUser() throws WxErrorException;
5788

5889
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ public WxCpUserExternalContactInfo getExternalContact(String userId) throws WxEr
2525
return WxCpUserExternalContactInfo.fromJson(responseContent);
2626
}
2727

28+
@Override
29+
public WxCpUserExternalContactInfo getContactDetail(String userId) throws WxErrorException {
30+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_DETAIL + userId);
31+
String responseContent = this.mainService.get(url, null);
32+
return WxCpUserExternalContactInfo.fromJson(responseContent);
33+
}
34+
2835
@Override
2936
public List<String> listExternalContacts(String userId) throws WxErrorException {
3037
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_EXTERNAL_CONTACT + userId);

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ public static class User {
110110
}
111111

112112
public static class ExternalContact {
113+
@Deprecated
113114
public static final String GET_EXTERNAL_CONTACT = "/cgi-bin/crm/get_external_contact?external_userid=";
114-
public static final String LIST_EXTERNAL_CONTACT = "/cgi-bin/externalcontact/list?userid=";
115+
@Deprecated
115116
public static final String GET_FOLLOW_USER_LIST = "/cgi-bin/externalcontact/get_follow_user_list";
117+
118+
public static final String GET_CONTACT_DETAIL = "/cgi-bin/externalcontact/get?external_userid=";
119+
public static final String LIST_EXTERNAL_CONTACT = "/cgi-bin/externalcontact/list?userid=";
116120
}
117121
}

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImplTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,13 @@ public void testListExternalWithPermission() throws WxErrorException {
4242
System.out.println(ret);
4343
assertNotNull(ret);
4444
}
45+
46+
@Test
47+
public void testGetContactDetail() throws WxErrorException {
48+
String externalUserId = this.configStorage.getExternalUserId();
49+
WxCpUserExternalContactInfo result = this.wxCpService.getExternalContactService().getContactDetail(externalUserId);
50+
System.out.println(result);
51+
assertNotNull(result);
52+
}
53+
4554
}

0 commit comments

Comments
 (0)