Skip to content

Commit 3acf55a

Browse files
authored
🆕 #2937【企业微信】发送机器人消息支持模板卡片消息,客服消息支持以客服纬度查询
1 parent 677b2cf commit 3acf55a

File tree

6 files changed

+373
-0
lines changed

6 files changed

+373
-0
lines changed

Diff for: weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpGroupRobotService.java

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import me.chanjar.weixin.common.error.WxErrorException;
44
import me.chanjar.weixin.cp.bean.article.NewArticle;
5+
import me.chanjar.weixin.cp.bean.message.WxCpGroupRobotMessage;
56

67
import java.util.List;
78

@@ -96,4 +97,13 @@ public interface WxCpGroupRobotService {
9697
* @throws WxErrorException 异常
9798
*/
9899
void sendFile(String webhookUrl, String mediaId) throws WxErrorException;
100+
101+
/**
102+
* 发送模板卡片消息
103+
* @param webhookUrl
104+
* @param wxCpGroupRobotMessage
105+
* @throws WxErrorException
106+
*/
107+
void sendTemplateCardMessage(String webhookUrl, WxCpGroupRobotMessage wxCpGroupRobotMessage) throws WxErrorException;
108+
99109
}

Diff for: weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpKfService.java

+4
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,13 @@ WxCpKfServiceStateTransResp transServiceState(String openKfid, String externalUs
135135
* @return 微信消息 wx cp kf msg list resp
136136
* @throws WxErrorException 异常
137137
*/
138+
@Deprecated
138139
WxCpKfMsgListResp syncMsg(String cursor, String token, Integer limit, Integer voiceFormat)
139140
throws WxErrorException;
140141

142+
WxCpKfMsgListResp syncMsg(String cursor, String token, Integer limit, Integer voiceFormat,String open_kfid)
143+
throws WxErrorException;
144+
141145
/**
142146
* 发送消息
143147
* 当微信客户处于“新接入待处理”或“由智能助手接待”状态下,可调用该接口给用户发送消息。

Diff for: weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpGroupRobotServiceImpl.java

+5
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,9 @@ public void sendFile(String webhookUrl, String mediaId) throws WxErrorException
9292
.setMediaId(mediaId).toJson());
9393
}
9494

95+
@Override
96+
public void sendTemplateCardMessage(String webhookUrl, WxCpGroupRobotMessage wxCpGroupRobotMessage) throws WxErrorException {
97+
this.cpService.postWithoutToken(webhookUrl, wxCpGroupRobotMessage.toJson());
98+
}
99+
95100
}

Diff for: weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImpl.java

+25
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,31 @@ public WxCpKfMsgListResp syncMsg(String cursor, String token, Integer limit, Int
149149
return WxCpKfMsgListResp.fromJson(responseContent);
150150
}
151151

152+
@Override
153+
public WxCpKfMsgListResp syncMsg(String cursor, String token, Integer limit, Integer voiceFormat, String openKfId) throws WxErrorException {
154+
String url = cpService.getWxCpConfigStorage().getApiUrl(SYNC_MSG);
155+
156+
JsonObject json = new JsonObject();
157+
if (cursor!=null) {
158+
json.addProperty("cursor", cursor);
159+
}
160+
if (token!=null) {
161+
json.addProperty("token", token);
162+
}
163+
if (limit!=null) {
164+
json.addProperty("limit", limit);
165+
}
166+
if (voiceFormat!=null) {
167+
json.addProperty("voice_format", voiceFormat);
168+
}
169+
if (openKfId != null) {
170+
json.addProperty("open_kfid", openKfId);
171+
}
172+
173+
String responseContent = cpService.post(url, json);
174+
return WxCpKfMsgListResp.fromJson(responseContent);
175+
}
176+
152177
@Override
153178
public WxCpKfMsgSendResp sendMsg(WxCpKfMsgSendRequest request) throws WxErrorException {
154179
String url = cpService.getWxCpConfigStorage().getApiUrl(SEND_MSG);

0 commit comments

Comments
 (0)