Browse Source

小程序客服

master
zhizhi wu 4 years ago
parent
commit
8a725b22da
  1. 19
      src/main/java/com/ccsens/carbasics/api/MiniController.java

19
src/main/java/com/ccsens/carbasics/api/MiniController.java

@ -1,5 +1,6 @@
package com.ccsens.carbasics.api;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.wechatutil.bean.dto.wxmini.NoticeDto;
import com.ccsens.wechatutil.bean.vo.wxmini.Custom;
@ -15,7 +16,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
/**
* @description:
@ -44,8 +49,20 @@ public class MiniController {
@ApiOperation(value = "接收微信小程序消息通知", notes = "")
@RequestMapping(value = "/notice", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public String notice(@Validated NoticeDto.Notice notice) {
public String notice(HttpServletRequest request) throws IOException {
BufferedReader reader = request.getReader();
StringBuilder builder = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
log.info("获取参数:{}", builder.toString());
NoticeDto.Notice notice = JSONObject.parseObject(builder.toString(), NoticeDto.Notice.class);
log.info("接收微信小程序消息通知:{}", notice);
if (notice== null || StrUtil.isEmpty(notice.getContent())) {
return "success";
}
Custom.Text text = new Custom.Text();
text.setContent("客服人员正在赶来的路上...");
MiniCustomSendUtil.send(notice.getFromUserName(), Custom.Type.TEXT, text);

Loading…
Cancel
Save