Skip to content

Commit 320bbfe

Browse files
authored
🆕 #2825 【企业微信】增加分配在职成员的客户群的接口
1 parent 65134bd commit 320bbfe

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

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

+18
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,24 @@ WxCpUserExternalGroupChatList listGroupChat(Integer pageIndex, Integer pageSize,
595595
*/
596596
WxCpUserExternalGroupChatTransferResp transferGroupChat(String[] chatIds, String newOwner) throws WxErrorException;
597597

598+
599+
/**
600+
* 企业可通过此接口,将在职成员为群主的群,分配给另一个客服成员。
601+
* <per>
602+
* 注意:
603+
* 继承给的新群主,必须是配置了客户联系功能的成员
604+
* 继承给的新群主,必须有设置实名
605+
* 继承给的新群主,必须有激活企业微信
606+
* 同一个人的群,限制每天最多分配300个给新群主
607+
* 为保障客户服务体验,90个自然日内,在职成员的每个客户群仅可被转接2次。
608+
* </pre>
609+
* @param chatIds 需要转群主的客户群ID列表。取值范围: 1 ~ 100
610+
* @param newOwner 新群主ID
611+
* @return 分配结果 ,主要是分配失败的群列表
612+
* @throws WxErrorException the wx error exception
613+
*/
614+
WxCpUserExternalGroupChatTransferResp onjobTransferGroupChat(String[] chatIds, String newOwner) throws WxErrorException;
615+
598616
/**
599617
* <pre>
600618
* 企业可通过此接口获取成员联系客户的数据,包括发起申请数、新增客户数、聊天数、发送消息数和删除/拉黑成员的客户数等指标。

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

+12
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,18 @@ public WxCpUserExternalGroupChatTransferResp transferGroupChat(String[] chatIds,
373373
return WxCpUserExternalGroupChatTransferResp.fromJson(result);
374374
}
375375

376+
@Override
377+
public WxCpUserExternalGroupChatTransferResp onjobTransferGroupChat(String[] chatIds, String newOwner) throws WxErrorException {
378+
JsonObject json = new JsonObject();
379+
if (ArrayUtils.isNotEmpty(chatIds)) {
380+
json.add("chat_id_list", new Gson().toJsonTree(chatIds).getAsJsonArray());
381+
}
382+
json.addProperty("new_owner", newOwner);
383+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_ONJOB_TRANSFER);
384+
final String result = this.mainService.post(url, json.toString());
385+
return WxCpUserExternalGroupChatTransferResp.fromJson(result);
386+
}
387+
376388
@Override
377389
public WxCpUserExternalUserBehaviorStatistic getUserBehaviorStatistic(Date startTime, Date endTime,
378390
String[] userIds, String[] partyIds) throws WxErrorException {

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

+4
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,10 @@ interface ExternalContact {
10541054
* The constant GROUP_CHAT_TRANSFER.
10551055
*/
10561056
String GROUP_CHAT_TRANSFER = "/cgi-bin/externalcontact/groupchat/transfer";
1057+
/**
1058+
* The constant GROUP_CHAT_ONJOB_TRANSFER.
1059+
*/
1060+
String GROUP_CHAT_ONJOB_TRANSFER = "/cgi-bin/externalcontact/groupchat/onjob_transfer";
10571061
/**
10581062
* The constant LIST_USER_BEHAVIOR_DATA.
10591063
*/

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

+13
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,19 @@ public void testTransferGroupChat() throws WxErrorException {
406406
assertNotNull(result);
407407
}
408408

409+
/**
410+
* Test onjob transfer group chat.
411+
*
412+
* @throws WxErrorException the wx error exception
413+
*/
414+
@Test
415+
public void testOnjobTransferGroupChat() throws WxErrorException {
416+
String[] str = {"wrHlLKQAAAFbfB99-BO97YZlcywznGZg", "error_group_id"};
417+
WxCpUserExternalGroupChatTransferResp result = this.wxCpService.getExternalContactService().onjobTransferGroupChat(str
418+
, "x");
419+
System.out.println(result);
420+
assertNotNull(result);
421+
}
409422
/**
410423
* Test get user behavior statistic.
411424
*/

0 commit comments

Comments
 (0)