Skip to content

Commit 7534975

Browse files
authored
🆕 #3079 【企业微信】增加提醒成员群发和停止企业群发的接口
1 parent 831aac3 commit 7534975

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,39 @@ WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime, Integer
690690
*/
691691
WxCpMsgTemplateAddResult addMsgTemplate(WxCpMsgTemplate wxCpMsgTemplate) throws WxErrorException;
692692

693+
694+
/**
695+
* 提醒成员群发
696+
* 企业和第三方应用可调用此接口,重新触发群发通知,提醒成员完成群发任务,24小时内每个群发最多触发三次提醒。
697+
* <p>
698+
* 请求方式: POST(HTTPS)
699+
* <p>
700+
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/remind_groupmsg_send?access_token=ACCESS_TOKEN
701+
* <p>
702+
* <a href="https://developer.work.weixin.qq.com/document/path/97610">文档地址</a>
703+
*
704+
* @param msgId 群发消息的id,通过获取群发记录列表接口返回
705+
* @return the wx cp msg template add result
706+
*/
707+
WxCpBaseResp remindGroupMsgSend(String msgId) throws WxErrorException;
708+
709+
710+
/**
711+
* 停止企业群发
712+
* 企业和第三方应用可调用此接口,停止无需成员继续发送的企业群发
713+
* <p>
714+
* 请求方式: POST(HTTPS)
715+
* <p>
716+
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/cancel_groupmsg_send?access_token=ACCESS_TOKEN
717+
* <p>
718+
* <a href="https://developer.work.weixin.qq.com/document/path/97611">文档地址</a>
719+
*
720+
* @param msgId 群发消息的id,通过获取群发记录列表接口返回
721+
* @return the wx cp msg template add result
722+
*/
723+
WxCpBaseResp cancelGroupMsgSend(String msgId) throws WxErrorException;
724+
725+
693726
/**
694727
* 发送新客户欢迎语
695728
* <pre>

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,24 @@ public WxCpMsgTemplateAddResult addMsgTemplate(WxCpMsgTemplate wxCpMsgTemplate)
418418
return WxCpMsgTemplateAddResult.fromJson(this.mainService.post(url, wxCpMsgTemplate.toJson()));
419419
}
420420

421+
@Override
422+
public WxCpBaseResp remindGroupMsgSend(String msgId) throws WxErrorException {
423+
JsonObject params = new JsonObject();
424+
params.addProperty("msgid", msgId);
425+
final String url = this.mainService.getWxCpConfigStorage()
426+
.getApiUrl(REMIND_GROUP_MSG_SEND);
427+
return WxCpBaseResp.fromJson(this.mainService.post(url, params.toString()));
428+
}
429+
430+
@Override
431+
public WxCpBaseResp cancelGroupMsgSend(String msgId) throws WxErrorException {
432+
JsonObject params = new JsonObject();
433+
params.addProperty("msgid", msgId);
434+
final String url = this.mainService.getWxCpConfigStorage()
435+
.getApiUrl(CANCEL_GROUP_MSG_SEND);
436+
return WxCpBaseResp.fromJson(this.mainService.post(url, params.toString()));
437+
}
438+
421439
@Override
422440
public void sendWelcomeMsg(WxCpWelcomeMsg msg) throws WxErrorException {
423441
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(SEND_WELCOME_MSG);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,14 @@ interface ExternalContact {
11481148
* The constant ADD_MSG_TEMPLATE.
11491149
*/
11501150
String ADD_MSG_TEMPLATE = "/cgi-bin/externalcontact/add_msg_template";
1151+
/**
1152+
* 提醒成员群发
1153+
*/
1154+
String REMIND_GROUP_MSG_SEND = "/cgi-bin/externalcontact/remind_groupmsg_send";
1155+
/**
1156+
* 停止企业群发
1157+
*/
1158+
String CANCEL_GROUP_MSG_SEND = "/cgi-bin/externalcontact/cancel_groupmsg_send";
11511159
/**
11521160
* The constant SEND_WELCOME_MSG.
11531161
*/

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,4 +615,26 @@ public void testGetJoinWay() throws WxErrorException {
615615

616616
this.wxCpService.getExternalContactService().getJoinWay(configId);
617617
}
618+
619+
/**
620+
* 提醒成员群发
621+
*
622+
* @throws WxErrorException
623+
*/
624+
@Test
625+
public void testRemindGroupMsgSend() throws WxErrorException {
626+
this.wxCpService.getExternalContactService()
627+
.remindGroupMsgSend("msgGCAAAXtWyujaWJHDDGi0mACAAAA");
628+
}
629+
630+
/**
631+
* 测试取消提醒成员群发
632+
*
633+
* @throws WxErrorException
634+
*/
635+
@Test
636+
public void testCancelGroupMsgSend() throws WxErrorException {
637+
this.wxCpService.getExternalContactService()
638+
.cancelGroupMsgSend("msgGCAAAXtWyujaWJHDDGi0mACAAAA");
639+
}
618640
}

0 commit comments

Comments
 (0)