Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
f25c6a33
Commit
f25c6a33
authored
Nov 11, 2021
by
liyang
Browse files
1.消息推送配置,智能回复
parent
a2838dd8
Changes
1
Hide whitespace changes
Inline
Side-by-side
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxMsgController.java
View file @
f25c6a33
package
org.linlinjava.litemall.wx.web
;
import
cn.binarywang.wx.miniapp.api.WxMaService
;
import
cn.binarywang.wx.miniapp.bean.WxMaKefuMessage
;
import
cn.binarywang.wx.miniapp.bean.WxMaMessage
;
import
cn.binarywang.wx.miniapp.message.WxMaXmlOutMessage
;
import
me.chanjar.weixin.common.error.WxErrorException
;
...
...
@@ -12,8 +13,6 @@ import org.springframework.web.bind.annotation.*;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author liyang
...
...
@@ -65,16 +64,9 @@ public class WxMsgController {
String
msgType
=
wxMaMessage
.
getMsgType
();
if
(
"text"
.
equals
(
msgType
))
{
try
{
Map
<
String
,
Object
>
msg
=
new
HashMap
<>();
Map
<
String
,
String
>
body
=
new
HashMap
<>();
msg
.
put
(
"access_token"
,
wxMaService
.
getAccessToken
());
msg
.
put
(
"touser"
,
wxMaMessage
.
getFromUser
());
msg
.
put
(
"msgtype"
,
wxMaMessage
.
getMsgType
());
body
.
put
(
"content"
,
wxMaMessage
.
getContent
());
msg
.
put
(
"text"
,
body
);
wxMaService
.
post
(
"https://api.weixin.qq.com/cgi-bin/message/custom/send"
,
msg
);
wxMaService
.
getMsgService
().
sendKefuMsg
(
WxMaKefuMessage
.
newTextBuilder
().
content
(
wxMaMessage
.
getContent
()).
toUser
(
wxMaMessage
.
getFromUser
()).
build
());
}
catch
(
WxErrorException
e
)
{
e
.
printStackTrace
(
);
logger
.
error
(
"消息自动回复失败"
);
}
}
WxMaXmlOutMessage
wxMaXmlOutMessage
=
new
WxMaXmlOutMessage
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment