From cf42cd8d54eeb8b25be46d5c93637a7ce20ac9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E6=99=B6?= Date: Mon, 21 Apr 2025 10:44:12 +0800 Subject: [PATCH] =?UTF-8?q?=20feat:=20=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=88=90=E5=91=98=E5=A4=9A=E6=AC=A1=E6=94=B6=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E8=AF=A6=E6=83=85API=20(#824)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(media): add getTempFile api add getTempFile api * feat: 添加获取成员多次收消息详情API - 添加customerAcquisitionGetChatInfoURL常量 - 实现GetChatInfo方法及相关请求/响应结构体 - 支持企业微信获客助手多次收消息功能 --------- Co-authored-by: caojing --- work/externalcontact/customer_acquisition.go | 41 ++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/work/externalcontact/customer_acquisition.go b/work/externalcontact/customer_acquisition.go index e2d8ea1..6befc88 100644 --- a/work/externalcontact/customer_acquisition.go +++ b/work/externalcontact/customer_acquisition.go @@ -23,6 +23,8 @@ const ( customerAcquisitionQuotaURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition_quota?access_token=%s" // customerAcquisitionStatistic 查询链接使用详情 customerAcquisitionStatisticURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/statistic?access_token=%s" + // customerAcquisitionGetChatInfo 获取成员多次收消息详情 + customerAcquisitionGetChatInfoURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/get_chat_info?access_token=%s" ) type ( @@ -308,3 +310,42 @@ func (r *Client) CustomerAcquisitionStatistic(req *CustomerAcquisitionStatisticR err = util.DecodeWithError(response, result, "CustomerAcquisitionStatistic") return result, err } + +type ( + // GetChatInfoRequest 获取成员多次收消息详情请求 + GetChatInfoRequest struct { + ChatKey string `json:"chat_key"` + } + // GetChatInfoResponse 获取成员多次收消息详情响应 + GetChatInfoResponse struct { + util.CommonError + UserID string `json:"userid"` + ExternalUserID string `json:"external_userid"` + ChatInfo ChatInfo `json:"chat_info"` + } + // ChatInfo 聊天信息 + ChatInfo struct { + RecvMsgCnt int64 `json:"recv_msg_cnt"` // 成员收到的此客户的消息次数 + LinkID string `json:"link_id"` // 成员添加客户的获客链接id + State string `json:"state"` // 成员添加客户的state + } +) + +// GetChatInfo 获取成员多次收消息详情 +// see https://developer.work.weixin.qq.com/document/path/100130 +func (r *Client) GetChatInfo(req *GetChatInfoRequest) (*GetChatInfoResponse, 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(customerAcquisitionGetChatInfoURL, accessToken), req); err != nil { + return nil, err + } + result := &GetChatInfoResponse{} + err = util.DecodeWithError(response, result, "GetChatInfo") + return result, err +}