Skip to content

Commit f5dc216

Browse files
WalleVWalle
and
Walle
authored
feat(wecom): add customer service msg struct (#32)
Co-authored-by: Walle <walle@artisan-cloud.com>
1 parent 83af2a0 commit f5dc216

File tree

6 files changed

+121
-11
lines changed

6 files changed

+121
-11
lines changed

src/work/accountService/customer/client.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package customer
33
import (
44
"github.com/ArtisanCloud/go-libs/object"
55
"github.com/ArtisanCloud/power-wechat/src/kernel"
6+
"github.com/ArtisanCloud/power-wechat/src/kernel/power"
67
response2 "github.com/ArtisanCloud/power-wechat/src/kernel/response"
78
"github.com/ArtisanCloud/power-wechat/src/work/accountService/customer/request"
89
"github.com/ArtisanCloud/power-wechat/src/work/accountService/customer/response"
@@ -54,3 +55,18 @@ func (comp *Client) UpgradeService(options *request.RequestUpgradeService) (*res
5455

5556
return result, err
5657
}
58+
59+
// 为客户取消推荐
60+
// https://work.weixin.qq.com/api/doc/90000/90135/94674
61+
func (comp *Client) CancelUpgradeService(openKFID, externalUserID string) (*response2.ResponseWork, error) {
62+
63+
result := &response2.ResponseWork{}
64+
options := &power.StringMap{
65+
"open_kfid": openKFID,
66+
"external_userid": externalUserID,
67+
}
68+
69+
_, err := comp.HttpPostJson("cgi-bin/kf/customer/cancel_upgrade_service", options, nil, nil, result)
70+
71+
return result, err
72+
}
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
package request
22

3-
import "github.com/ArtisanCloud/power-wechat/src/kernel/power"
4-
53
type RequestUpgradeService struct {
6-
OpenKFID string `json:"open_kfid"`
7-
ExternalUserID string `json:"external_userid"`
8-
Type int `json:"type"`
9-
Member *power.StringMap `json:"member"`
10-
GroupChat *power.StringMap `json:"groupchat"`
4+
OpenKFID string `json:"open_kfid"`
5+
ExternalUserID string `json:"external_userid"`
6+
Type int `json:"type"`
7+
Member *RequestUpgradeServiceMember `json:"member,omitempty"`
8+
GroupChat *RequestUpgradeServiceGroupChat `json:"groupchat,omitempty"`
9+
}
10+
11+
type RequestUpgradeServiceMember struct {
12+
UserID string `json:"userid"`
13+
Wording string `json:"wording"`
14+
}
15+
16+
type RequestUpgradeServiceGroupChat struct {
17+
ChatID string `json:"chat_id"`
18+
Wording string `json:"wording"`
1119
}

src/work/accountService/message/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package message
33
import (
44
"github.com/ArtisanCloud/go-libs/object"
55
"github.com/ArtisanCloud/power-wechat/src/kernel"
6-
"github.com/ArtisanCloud/power-wechat/src/kernel/power"
6+
"github.com/ArtisanCloud/power-wechat/src/work/accountService/message/request"
77
"github.com/ArtisanCloud/power-wechat/src/work/accountService/message/response"
88
)
99

@@ -36,7 +36,7 @@ func (comp *Client) SyncMsg(cursor string, token string, limit int) (*response.R
3636

3737
// 发送消息
3838
// https://work.weixin.qq.com/api/doc/90000/90135/90236
39-
func (comp *Client) SendMsg(messages *power.HashMap) (*response.ResponseAccountServiceSendMsg, error) {
39+
func (comp *Client) SendMsg(messages *request.RequestAccountServiceSendMsg) (*response.ResponseAccountServiceSendMsg, error) {
4040

4141
result := &response.ResponseAccountServiceSendMsg{}
4242

@@ -47,7 +47,7 @@ func (comp *Client) SendMsg(messages *power.HashMap) (*response.ResponseAccountS
4747

4848
// 发送消息
4949
// https://work.weixin.qq.com/api/doc/90000/90135/95122
50-
func (comp *Client) SendMsgOnEvent(messages *power.HashMap) (*response.ResponseAccountServiceSendMsgOnEvent, error) {
50+
func (comp *Client) SendMsgOnEvent(messages *request.RequestAccountServiceSendMsgOnEvent) (*response.ResponseAccountServiceSendMsgOnEvent, error) {
5151

5252
result := &response.ResponseAccountServiceSendMsgOnEvent{}
5353

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package request
2+
3+
type RequestAccountServiceSendMsg struct {
4+
ToUser string `json:"touser"`
5+
OpenKfid string `json:"open_kfid"`
6+
MsgID string `json:"msgid"`
7+
MsgType string `json:"msgtype"`
8+
Text RequestAccountServiceMsgText `json:"text,omitempty"`
9+
Image RequestAccountServiceMsgImage `json:"image,omitempty"`
10+
Voice RequestAccountServiceMsgVoice `json:"voice,omitempty"`
11+
File RequestAccountServiceMsgFile `json:"file,omitempty"`
12+
Link RequestAccountServiceMsgLink `json:"link,omitempty"`
13+
MiniProgram RequestAccountServiceMsgMiniProgram `json:"miniprogram,omitempty"`
14+
Menu RequestAccountServiceMsgMenu `json:"msgmenu,omitempty"`
15+
Location RequestAccountServiceMsgLocation `json:"location,omitempty"`
16+
}
17+
18+
type RequestAccountServiceMsgText struct {
19+
Content string `json:"content"`
20+
}
21+
22+
type RequestAccountServiceMsgImage struct {
23+
MediaID string `json:"media_id"`
24+
}
25+
26+
type RequestAccountServiceMsgVoice struct {
27+
MediaID string `json:"media_id"`
28+
}
29+
30+
type RequestAccountServiceMsgFile struct {
31+
MediaID string `json:"media_id"`
32+
}
33+
34+
type RequestAccountServiceMsgLink struct {
35+
Title string `json:"title"`
36+
Desc string `json:"desc"`
37+
Url string `json:"url"`
38+
ThumbMediaId string `json:"thumb_media_id"`
39+
}
40+
41+
type RequestAccountServiceMsgMiniProgram struct {
42+
AppId string `json:"appid"`
43+
Title string `json:"title"`
44+
ThumbMediaID string `json:"thumb_media_id"`
45+
PagePath string `json:"pagepath"`
46+
}
47+
48+
type RequestAccountServiceMsgMenu struct {
49+
HeadContent string `json:"head_content"`
50+
TailContent string `json:"tail_content,omitempty"`
51+
List []RequestAccountServiceMsgMenuList `json:"list,omitempty"`
52+
}
53+
type RequestAccountServiceMsgMenuList struct {
54+
Click RequestAccountServiceMsgMenuListClick `json:"click,omitempty"`
55+
View RequestAccountServiceMsgMenuListView `json:"view,omitempty"`
56+
MiniProgram RequestAccountServiceMsgMenuListMiniProgram `json:"miniprogram,omitempty"`
57+
}
58+
type RequestAccountServiceMsgMenuListClick struct {
59+
ID string `json:"id"`
60+
Content string `json:"content"`
61+
}
62+
type RequestAccountServiceMsgMenuListView struct {
63+
Url string `json:"url"`
64+
Content string `json:"content"`
65+
}
66+
type RequestAccountServiceMsgMenuListMiniProgram struct {
67+
AppID string `json:"appid"`
68+
PagePath string `json:"pagepath"`
69+
Content string `json:"content"`
70+
}
71+
72+
type RequestAccountServiceMsgLocation struct {
73+
Name string `json:"name"`
74+
Address string `json:"address"`
75+
Latitude int `json:"latitude"`
76+
Longitude int `json:"longitude"`
77+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package request
2+
3+
type RequestAccountServiceSendMsgOnEvent struct {
4+
Code string `json:"code"`
5+
MsgID string `json:"msgid"`
6+
MsgType string `json:"msgtype"`
7+
Text RequestAccountServiceMsgText `json:"text,omitempty"`
8+
Menu RequestAccountServiceMsgMenu `json:"msgmenu,omitempty"`
9+
}

src/work/accountService/serviceState/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (comp *Client) Get(openKFID string, externalUserID string) (*response.Respo
3636

3737
// 变更会话状态
3838
// https://work.weixin.qq.com/api/doc/90000/90135/94669
39-
func (comp *Client) Trans(openKFID string, externalUserID string, serviceState string, servicerUserID string ) (*response2.ResponseWork, error) {
39+
func (comp *Client) Trans(openKFID string, externalUserID string, serviceState int, servicerUserID string ) (*response2.ResponseWork, error) {
4040

4141
result := &response2.ResponseWork{}
4242

0 commit comments

Comments
 (0)