mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-11-01 00:46:54 +08:00 
			
		
		
		
	🆕 #2479 【企业微信】增加获取企业群发成员执行结果的接口
This commit is contained in:
		| @@ -818,6 +818,20 @@ public interface WxCpExternalContactService { | ||||
|    */ | ||||
|   WxCpGroupMsgSendResult getGroupMsgSendResult(String msgid, String userid, Integer limit, String cursor) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 企业跟第三方应用可通过该接口获取到创建企业群发的群发发送结果。 | ||||
|    * https://work.weixin.qq.com/api/doc/16251 | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param msgid  群发消息的id,通过创建企业群发接口返回 | ||||
|    * @param limit  返回的最大记录数,整型,最大值10000,默认值10000 | ||||
|    * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 | ||||
|    * @return wx cp base resp | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   public WxCpGroupMsgResult getGroupMsgResult(String msgid, Integer limit, String cursor) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 获取群发成员发送任务列表。 | ||||
|   | ||||
| @@ -648,6 +648,30 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic | ||||
|     return WxCpGroupMsgSendResult.fromJson(result); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 企业跟第三方应用可通过该接口获取到创建企业群发的群发发送结果。 | ||||
|    * https://work.weixin.qq.com/api/doc/16251 | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param msgid  群发消息的id,通过创建企业群发接口返回 | ||||
|    * @param limit  返回的最大记录数,整型,最大值10000,默认值10000 | ||||
|    * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 | ||||
|    * @return wx cp base resp | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   @Override | ||||
|   public WxCpGroupMsgResult getGroupMsgResult(String msgid, Integer limit, String cursor) throws WxErrorException { | ||||
|     JsonObject json = new JsonObject(); | ||||
|     json.addProperty("msgid", msgid); | ||||
|     json.addProperty("limit", limit); | ||||
|     json.addProperty("cursor", cursor); | ||||
|  | ||||
|     final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_GROUP_MSG_RESULT); | ||||
|     final String result = this.mainService.post(url, json.toString()); | ||||
|     return WxCpGroupMsgResult.fromJson(result); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 获取群发成员发送任务列表。 | ||||
|   | ||||
							
								
								
									
										59
									
								
								weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgResult.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/WxCpGroupMsgResult.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,59 @@ | ||||
| package me.chanjar.weixin.cp.bean.external.contact; | ||||
|  | ||||
| import com.google.gson.annotations.SerializedName; | ||||
| import lombok.Getter; | ||||
| import lombok.Setter; | ||||
| import me.chanjar.weixin.cp.bean.WxCpBaseResp; | ||||
| import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | ||||
|  | ||||
| import java.io.Serializable; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * <pre> | ||||
|  * 获取企业群发成员执行结果 | ||||
|  * 参考文档:https://work.weixin.qq.com/api/doc/16251 | ||||
|  * </pre> | ||||
|  * | ||||
|  * @author <a href="https://github.com/timsims">Tim Sims</a> | ||||
|  */ | ||||
| @Getter | ||||
| @Setter | ||||
| public class WxCpGroupMsgResult extends WxCpBaseResp implements Serializable { | ||||
|   private static final long serialVersionUID = -5166048319463473186L; | ||||
|  | ||||
|   @SerializedName("detail_list") | ||||
|   private List<ExternalContactGroupMsgDetailInfo> detailList; | ||||
|  | ||||
|   @SerializedName("next_cursor") | ||||
|   private String nextCursor; | ||||
|  | ||||
|   @Getter | ||||
|   @Setter | ||||
|   public static class ExternalContactGroupMsgDetailInfo implements Serializable { | ||||
|     private static final long serialVersionUID = 1500416806087532531L; | ||||
|  | ||||
|     // 外部联系人userid,群发消息到企业的客户群不吐出该字段 | ||||
|     @SerializedName("external_userid") | ||||
|     private String externalUserId; | ||||
|  | ||||
|     // 外部客户群id,群发消息到客户不吐出该字段 | ||||
|     @SerializedName("chat_id") | ||||
|     private String chatId; | ||||
|  | ||||
|     // 企业服务人员的userid | ||||
|     @SerializedName("userid") | ||||
|     private String userId; | ||||
|  | ||||
|     // 发送状态 0-未发送 1-已发送 2-因客户不是好友导致发送失败 3-因客户已经收到其他群发消息导致发送失败 | ||||
|     private Integer status; | ||||
|  | ||||
|     // 发送时间,发送状态为1时返回 | ||||
|     @SerializedName("send_time") | ||||
|     private Long sendTime; | ||||
|   } | ||||
|  | ||||
|   public static WxCpGroupMsgResult fromJson(String json) { | ||||
|     return WxCpGsonBuilder.create().fromJson(json, WxCpGroupMsgResult.class); | ||||
|   } | ||||
| } | ||||
| @@ -233,6 +233,7 @@ public interface WxCpApiPathConsts { | ||||
|     String GET_GROUP_MSG_SEND_RESULT = "/cgi-bin/externalcontact/get_groupmsg_send_result"; | ||||
|     String GET_GROUP_MSG_TASK = "/cgi-bin/externalcontact/get_groupmsg_task"; | ||||
|     String GET_GROUP_MSG_LIST_V2 = "/cgi-bin/externalcontact/get_groupmsg_list_v2"; | ||||
|     String GET_GROUP_MSG_RESULT = "/cgi-bin/externalcontact/get_group_msg_result"; | ||||
|  | ||||
|     String GET_PRODUCT_ALBUM = "/cgi-bin/externalcontact/get_product_album"; | ||||
|     String GET_PRODUCT_ALBUM_LIST = "/cgi-bin/externalcontact/get_product_album_list"; | ||||
|   | ||||
| @@ -0,0 +1,37 @@ | ||||
| package me.chanjar.weixin.cp.bean.external.contact; | ||||
|  | ||||
| import org.testng.annotations.Test; | ||||
|  | ||||
| import static org.assertj.core.api.Assertions.assertThat; | ||||
|  | ||||
| public class WxCpGroupMsgResultTest { | ||||
|  | ||||
|   @Test | ||||
|   public void testToJson() { | ||||
|     /* | ||||
|       @see https://work.weixin.qq.com/api/doc/16251 | ||||
|      */ | ||||
|     String json = "{ " + | ||||
|       "\"errcode\": 0, " + | ||||
|       "\"errmsg\": \"ok\", " + | ||||
|       "\"detail_list\": [ " + | ||||
|       "   { " + | ||||
|       "     \"external_userid\": \"wmqfasd1e19278asdasAAAA\", " + | ||||
|       "     \"chat_id\":\"wrOgQhDgAAMYQiS5ol9G7gK9JVAAAA\", " + | ||||
|       "     \"userid\": \"zhangsan\", " + | ||||
|       "     \"status\": 1, " + | ||||
|       "     \"send_time\": 1552536375 " + | ||||
|       "   } " + | ||||
|       " ] " + | ||||
|       "}"; | ||||
|  | ||||
|     WxCpGroupMsgResult result = WxCpGroupMsgResult.fromJson(json); | ||||
|     assertThat(result.getDetailList().size()).isEqualTo(1); | ||||
|     WxCpGroupMsgResult.ExternalContactGroupMsgDetailInfo detail = result.getDetailList().get(0); | ||||
|     assertThat(detail.getChatId()).isEqualTo("wrOgQhDgAAMYQiS5ol9G7gK9JVAAAA"); | ||||
|     assertThat(detail.getExternalUserId()).isEqualTo("wmqfasd1e19278asdasAAAA"); | ||||
|     assertThat(detail.getUserId()).isEqualTo("zhangsan"); | ||||
|     assertThat(detail.getStatus()).isEqualTo(1); | ||||
|     assertThat(detail.getSendTime()).isEqualTo(1552536375L); | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Tim Sims
					Tim Sims