✨ 微信消息封装服务
This commit is contained in:
parent
af1ba638f4
commit
a32d020b7c
@ -1,8 +1,6 @@
|
|||||||
package com.rymcu.vertical.wx.mp.handler;
|
package com.rymcu.vertical.wx.mp.handler;
|
||||||
|
|
||||||
import com.rymcu.vertical.wx.mp.builder.TextBuilder;
|
import com.rymcu.vertical.wx.mp.builder.TextBuilder;
|
||||||
import com.rymcu.vertical.wx.mp.utils.JsonUtils;
|
|
||||||
import me.chanjar.weixin.common.error.WxErrorException;
|
|
||||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||||
import me.chanjar.weixin.mp.api.WxMpService;
|
import me.chanjar.weixin.mp.api.WxMpService;
|
||||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||||
@ -29,21 +27,13 @@ public class MsgHandler extends AbstractHandler {
|
|||||||
//TODO 可以选择将消息保存到本地
|
//TODO 可以选择将消息保存到本地
|
||||||
}
|
}
|
||||||
|
|
||||||
//当用户输入关键词如“你好”,“客服”等,并且有客服在线时,把消息转发给在线客服
|
if (wxMessage == null || StringUtils.isBlank(wxMessage.getContent())) {
|
||||||
try {
|
return WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE()
|
||||||
if (StringUtils.startsWithAny(wxMessage.getContent(), "你好", "客服")
|
|
||||||
&& weixinService.getKefuService().kfOnlineList()
|
|
||||||
.getKfOnlineList().size() > 0) {
|
|
||||||
return WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE()
|
|
||||||
.fromUser(wxMessage.getToUser())
|
.fromUser(wxMessage.getToUser())
|
||||||
.toUser(wxMessage.getFromUser()).build();
|
.toUser(wxMessage.getFromUser()).build();
|
||||||
}
|
|
||||||
} catch (WxErrorException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO 组装回复消息
|
String content = "我们已经收到您的留言,稍后客服将会联系您!";
|
||||||
String content = "收到信息内容:" + JsonUtils.toJson(wxMessage);
|
|
||||||
|
|
||||||
return new TextBuilder().build(content, wxMessage, weixinService);
|
return new TextBuilder().build(content, wxMessage, weixinService);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user