Commit b5c11382 by 裴大威

add TODO

parent a02a2f45
...@@ -2,6 +2,7 @@ package com.pcloud.book.consumer.wechatgroup; ...@@ -2,6 +2,7 @@ package com.pcloud.book.consumer.wechatgroup;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.ResponseHandleUtil; import com.pcloud.common.utils.ResponseHandleUtil;
...@@ -13,8 +14,10 @@ import com.pcloud.wechatgroup.group.service.GroupMemberService; ...@@ -13,8 +14,10 @@ import com.pcloud.wechatgroup.group.service.GroupMemberService;
import com.pcloud.wechatgroup.message.dto.GroupChatCountDTO; import com.pcloud.wechatgroup.message.dto.GroupChatCountDTO;
import com.pcloud.wechatgroup.message.service.MessageService; import com.pcloud.wechatgroup.message.service.MessageService;
import com.pcloud.wechatgroup.monitor.service.MonitorService; import com.pcloud.wechatgroup.monitor.service.MonitorService;
import com.pcloud.wechatgroup.selfrobot.service.SelfRobotService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -35,6 +38,44 @@ public class WechatGroupConsr { ...@@ -35,6 +38,44 @@ public class WechatGroupConsr {
private MessageService messageService; private MessageService messageService;
@Autowired @Autowired
private MonitorService monitorService; private MonitorService monitorService;
@Autowired
private SelfRobotService selfRobotService;
@ParamLog("根据机器人id和用户微信id获取最新暗号")
public String getCipherByRobotAndUserWxId(String robotWxId, String userWxId) {
if (StringUtil.isBlank(robotWxId) || StringUtil.isBlank(userWxId)) {
return null;
}
try {
return ResponseHandleUtil.parseResponse(selfRobotService.getCipherByRobotAndUserWxId(robotWxId, userWxId), String.class);
} catch (BizException e) {
log.warn("根据机器人id和用户微信id获取最新暗号失败:" + e.getMessage(), e);
throw new BizException(e.getCode(), e.getMessage());
} catch (Exception e) {
log.error("根据机器人id和用户微信id获取最新暗号.[getCipherByRobotAndUserWxId]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_RES_ERROR, "服务内部错误,请稍后重试");
} finally {
log.info("【根据机器人id和用户微信id获取最新暗号,<END>");
}
}
@ParamLog("是否群机器人")
public Boolean isGroupRobot(String robotWxId) {
if (StringUtil.isBlank(robotWxId)) {
return null;
}
try {
return ResponseHandleUtil.parseResponse(selfRobotService.isGroupRobot(robotWxId), Boolean.class);
} catch (BizException e) {
log.warn("是否群机器人失败:" + e.getMessage(), e);
throw new BizException(e.getCode(), e.getMessage());
} catch (Exception e) {
log.error("是否群机器人.[isGroupRobot]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_RES_ERROR, "服务内部错误,请稍后重试");
} finally {
log.info("【是否群机器人,<END>");
}
}
/** /**
* 是否黑名单 * 是否黑名单
......
...@@ -37,6 +37,8 @@ import com.pcloud.book.keywords.vo.UpdateGuideVO; ...@@ -37,6 +37,8 @@ import com.pcloud.book.keywords.vo.UpdateGuideVO;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto; import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.UUIDUitl;
import com.pcloud.common.utils.rsa.AESCodec;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.wechatgroup.message.dto.AgreeAddUserDTO; import com.pcloud.wechatgroup.message.dto.AgreeAddUserDTO;
import com.sdk.wxgroup.SendMessageTypeEnum; import com.sdk.wxgroup.SendMessageTypeEnum;
...@@ -95,6 +97,15 @@ public class BookGuideBizImpl implements BookGuideBiz { ...@@ -95,6 +97,15 @@ public class BookGuideBizImpl implements BookGuideBiz {
@ParamLog("同意加好友发送欢迎语") @ParamLog("同意加好友发送欢迎语")
@Override @Override
public void sendGuide(AgreeAddUserDTO agreeAddUserDTO) { public void sendGuide(AgreeAddUserDTO agreeAddUserDTO) {
if(null == agreeAddUserDTO || StringUtil.isBlank(agreeAddUserDTO.getRobotWxId()) || StringUtil.isBlank(agreeAddUserDTO.getUserWxId())) {
log.info("[同意加好友发送欢迎语] 参数为空 agreeAddUserDTO:{}", agreeAddUserDTO);
return;
}
final String cipher = wechatGroupConsr.getCipherByRobotAndUserWxId(agreeAddUserDTO.getRobotWxId(), agreeAddUserDTO.getUserWxId());
if (StringUtil.isBlank(cipher)) {
log.info("[同意加好友发送欢迎语] 暗号为空 agreeAddUserDTO:{}", agreeAddUserDTO);
return;
}
SendTextMessageVO vo = new SendTextMessageVO(); SendTextMessageVO vo = new SendTextMessageVO();
vo.setContent("你好,我是本书智能小助手,请回复你的进群暗号,获取本书资源服务,以及入群链接如果忘了进群暗号,请重新扫描书上的二维码,点击入群即可获取"); vo.setContent("你好,我是本书智能小助手,请回复你的进群暗号,获取本书资源服务,以及入群链接如果忘了进群暗号,请重新扫描书上的二维码,点击入群即可获取");
vo.setCode(SendMessageTypeEnum.SELF.getCode()); vo.setCode(SendMessageTypeEnum.SELF.getCode());
...@@ -102,8 +113,8 @@ public class BookGuideBizImpl implements BookGuideBiz { ...@@ -102,8 +113,8 @@ public class BookGuideBizImpl implements BookGuideBiz {
vo.setGroupId(agreeAddUserDTO.getUserWxId()); vo.setGroupId(agreeAddUserDTO.getUserWxId());
WxGroupSDK.sendTextMessage(vo); WxGroupSDK.sendTextMessage(vo);
// TODO 推送关键词欢迎语 // TODO 推送关键词欢迎语
// List<KeywordDTO> keywords = bookKeywordBiz.listFiveKeyword(classifyQrcodeInfo.getClassifyId(), classifyQrcodeInfo.getBookGroupId()); List<KeywordDTO> keywords = bookKeywordBiz.listFiveKeyword(classifyQrcodeInfo.getClassifyId(), classifyQrcodeInfo.getBookGroupId());
// SendWeixinRequestTools.sendKeywordsInfo(keywords, agreeAddUserDTO.getRobotWxId(), agreeAddUserDTO.getUserWxId(), agreeAddUserDTO.getIp()); SendWeixinRequestTools.sendKeywordsInfo(keywords, agreeAddUserDTO.getRobotWxId(), agreeAddUserDTO.getUserWxId(), agreeAddUserDTO.getIp());
} }
@Override @Override
......
...@@ -462,19 +462,6 @@ public class BookKeywordBizImpl implements BookKeywordBiz { ...@@ -462,19 +462,6 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
SendWeixinRequestTools.sendKeywordMessage(replyKeywordDTO, robotId, weixinGroupId, ip, code); SendWeixinRequestTools.sendKeywordMessage(replyKeywordDTO, robotId, weixinGroupId, ip, code);
//新增关键词触发记录 //新增关键词触发记录
addKeywordAppTouchRecord(replyKeywordDTO, weixinGroupId, classifyQrcodeInfo.getClassifyId(), classifyQrcodeInfo.getBookGroupId()); addKeywordAppTouchRecord(replyKeywordDTO, weixinGroupId, classifyQrcodeInfo.getClassifyId(), classifyQrcodeInfo.getBookGroupId());
//第一推送关键词消息埋点
String keywordsKey = "BOOK:FIRSTKEYWORD:" + DateUtils.getShortDateStr() + "-" + weixinGroupId;
Boolean isSend = JedisClusterUtils.getJson(keywordsKey, Boolean.class);
if (isSend != null && isSend) {
return;
}
JedisClusterUtils.setJson(keywordsKey, true);
JedisClusterUtils.expire(keywordsKey, 86400);
RobotReplyDTO robotReplyDTO = new RobotReplyDTO();
robotReplyDTO.setKeyWord(content);
robotReplyDTO.setWxGroupId(weixinGroupId);
robotReplyDTO.setWxUserId(userWxId);
wechatGroupConsr.addFirstRobotReplyRecord(robotReplyDTO);
} }
/** /**
...@@ -486,6 +473,12 @@ public class BookKeywordBizImpl implements BookKeywordBiz { ...@@ -486,6 +473,12 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
if (StringUtil.isEmpty(content) || content.length() > 20) { if (StringUtil.isEmpty(content) || content.length() > 20) {
return; return;
} }
// 若非之前的机器人则不回复普通关键词
final Boolean groupRobot = wechatGroupConsr.isGroupRobot(robotId);
log.info("[wechatGroupConsr.isGroupRobot] robotId:{} groupRobot:{}", robotId, groupRobot);
if (!groupRobot) {
return;
}
//通过群id获取对应基本信息 //通过群id获取对应基本信息
GroupClassifyQrcodeDTO classifyQrcodeInfo = bookGroupClassifyBiz.getClassifyQrcodeInfo(weixinGroupId); GroupClassifyQrcodeDTO classifyQrcodeInfo = bookGroupClassifyBiz.getClassifyQrcodeInfo(weixinGroupId);
if (classifyQrcodeInfo == null) { if (classifyQrcodeInfo == null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment