From bbbada1b44ea39dd59a8a4da8ac10a4616e6af93 Mon Sep 17 00:00:00 2001 From: markwang <2951177317@qq.com> Date: Mon, 10 Oct 2022 10:07:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1-=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=BE=A4=E5=8F=91=E8=AE=B0=E5=BD=95=E5=88=97=E8=A1=A8?= =?UTF-8?q?=20(#621)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 企业微信-客户联系-统计管理 * 企业微信-客户联系-统计管理 * 企业微信-客户联系-统计管理 * debug * rollback * debug * debug * 获取用户信息 * token * json.Marshal错误输出 * debug * bugfix * 企业微信-通讯录管理相关接口 * 企业微信-通讯录管理 * 企业微信-通讯录管理 * 企业微信-通讯录管理 * 企业微信-[联系我]方式新增和查询 * 企业微信-[联系我]方式新增和获取 * 企业微信-[联系我]方式更新 * 企业微信-[联系我]方式列表、删除 * json.Marshal错误输出 * 已实现接口bug修改 * 历史接口bugfix * 历史接口bugfix * comment * 企业微信:客户联系-消息推送;素材管理-上传图片 * fix * 企业微信-获取群发记录列表 Co-authored-by: wang.yu --- doc/api/work.md | 1 + work/externalcontact/msg.go | 55 +++++++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/doc/api/work.md b/doc/api/work.md index 3a621b35f..9c4d78804 100644 --- a/doc/api/work.md +++ b/doc/api/work.md @@ -73,6 +73,7 @@ host: https://qyapi.weixin.qq.com/ | 获取企业已配置的「联系我」列表 | POST | /cgi-bin/externalcontact/list_contact_way | YES | (r *Client) ListContactWay | MARKWANG | | 删除企业已配置的「联系我」方式 | POST | /cgi-bin/externalcontact/del_contact_way | YES | (r *Client) DelContactWay | MARKWANG | | 创建企业群发 | POST | /cgi-bin/externalcontact/add_msg_template | YES | (r *Client) AddMsgTemplate | MARKWANG | +| 获取群发记录列表 | POST | /cgi-bin/externalcontact/get_groupmsg_list_v2 | YES | (r *Client) GetGroupMsgListV2 | MARKWANG | | 获取群发成员发送任务列表 | POST | /cgi-bin/externalcontact/get_groupmsg_task | YES | (r *Client) GetGroupMsgTask | MARKWANG | | 获取企业群发成员执行结果 | POST | /cgi-bin/externalcontact/get_groupmsg_send_result | YES | (r *Client) GetGroupMsgSendResult | MARKWANG | | 发送新客户欢迎语 | POST | /cgi-bin/externalcontact/send_welcome_msg | YES | (r *Client) SendWelcomeMsg | MARKWANG | diff --git a/work/externalcontact/msg.go b/work/externalcontact/msg.go index a34dffdbd..3e8a7fb4d 100644 --- a/work/externalcontact/msg.go +++ b/work/externalcontact/msg.go @@ -9,6 +9,8 @@ import ( const ( // AddMsgTemplateURL 创建企业群发 AddMsgTemplateURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_msg_template?access_token=%s" + // GetGroupMsgListV2URL 获取群发记录列表 + GetGroupMsgListV2URL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_groupmsg_list_v2?access_token=%s" // GetGroupMsgTaskURL 获取群发成员发送任务列表 GetGroupMsgTaskURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_groupmsg_task?access_token=%s" // GetGroupMsgSendResultURL 获取企业群发成员执行结果 @@ -98,6 +100,55 @@ func (r *Client) AddMsgTemplate(req *AddMsgTemplateRequest) (*AddMsgTemplateResp return result, nil } +// GetGroupMsgListV2Request 获取群发记录列表请求 +type GetGroupMsgListV2Request struct { + ChatType string `json:"chat_type"` + StartTime int `json:"start_time"` + EndTime int `json:"end_time"` + Creator string `json:"creator,omitempty"` + FilterType int `json:"filter_type"` + Limit int `json:"limit"` + Cursor string `json:"cursor"` +} + +// GetGroupMsgListV2Response 获取群发记录列表响应 +type GetGroupMsgListV2Response struct { + util.CommonError + NextCursor string `json:"next_cursor"` + GroupMsgList []*GroupMsg `json:"group_msg_list"` +} + +// GroupMsg 群发消息 +type GroupMsg struct { + MsgID string `json:"msgid"` + Creator string `json:"creator"` + CreateTime int `json:"create_time"` + CreateType int `json:"create_type"` + Text MsgText `json:"text"` + Attachments []*Attachment `json:"attachments"` +} + +// GetGroupMsgListV2 获取群发记录列表 +// see https://developer.work.weixin.qq.com/document/path/93338#%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%8F%91%E8%AE%B0%E5%BD%95%E5%88%97%E8%A1%A8 +func (r *Client) GetGroupMsgListV2(req *GetGroupMsgListV2Request) (*GetGroupMsgListV2Response, error) { + var ( + accessToken string + err error + ) + if accessToken, err = r.GetAccessToken(); err != nil { + return nil, err + } + var response []byte + if response, err = util.PostJSON(fmt.Sprintf(GetGroupMsgListV2URL, accessToken), req); err != nil { + return nil, err + } + result := &GetGroupMsgListV2Response{} + if err = util.DecodeWithError(response, result, "GetGroupMsgListV2"); err != nil { + return nil, err + } + return result, nil +} + // GetGroupMsgTaskRequest 获取群发成员发送任务列表请求 type GetGroupMsgTaskRequest struct { MsgID string `json:"msgid"` @@ -120,7 +171,7 @@ type Task struct { } // GetGroupMsgTask 获取群发成员发送任务列表 -// see https://developer.work.weixin.qq.com/document/path/93338 +// see https://developer.work.weixin.qq.com/document/path/93338#%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%8F%91%E6%88%90%E5%91%98%E5%8F%91%E9%80%81%E4%BB%BB%E5%8A%A1%E5%88%97%E8%A1%A8 func (r *Client) GetGroupMsgTask(req *GetGroupMsgTaskRequest) (*GetGroupMsgTaskResponse, error) { var ( accessToken string @@ -165,7 +216,7 @@ type Send struct { } // GetGroupMsgSendResult 获取企业群发成员执行结果 -// see https://developer.work.weixin.qq.com/document/path/93338 +// see https://developer.work.weixin.qq.com/document/path/93338#%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E7%BE%A4%E5%8F%91%E6%88%90%E5%91%98%E6%89%A7%E8%A1%8C%E7%BB%93%E6%9E%9C func (r *Client) GetGroupMsgSendResult(req *GetGroupMsgSendResultRequest) (*GetGroupMsgSendResultResponse, error) { var ( accessToken string