Commit 23c78e15 by 田超

fix bug

parent 23596ac8
...@@ -189,12 +189,11 @@ public class GroupQrcodeBizImpl implements GroupQrcodeBiz { ...@@ -189,12 +189,11 @@ public class GroupQrcodeBizImpl implements GroupQrcodeBiz {
if(nickNames==null){ if(nickNames==null){
nickNames = new HashMap<>(); nickNames = new HashMap<>();
nickNames.put(nickName,0); nickNames.put(nickName,0);
JedisClusterUtils.setJson("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId, nickNames, 600);
}else{ }else{
nickNames.put(nickName,0); nickNames.put(nickName,0);
JedisClusterUtils.setJson("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId, nickNames, 600);
} }
LOGGER.info("新用户"+nickNames);
JedisClusterUtils.setJson("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId, nickNames, 600);
String value = JedisClusterUtils.getJson("BOOK:WEIXINGROUP:GUIDE" + weixinGroupId, String.class); String value = JedisClusterUtils.getJson("BOOK:WEIXINGROUP:GUIDE" + weixinGroupId, String.class);
......
...@@ -149,32 +149,42 @@ public class SendWeixinRequestTools { ...@@ -149,32 +149,42 @@ public class SendWeixinRequestTools {
if (ListUtils.isEmpty(replyMessages)) { if (ListUtils.isEmpty(replyMessages)) {
return; return;
} }
int i = 0;
for (ReplyMessageVO replyMessageVO : replyMessages) { for (ReplyMessageVO replyMessageVO : replyMessages) {
SendMessageDTO sendMessageDTO = new SendMessageDTO(); SendMessageDTO sendMessageDTO = new SendMessageDTO();
BeanUtils.copyProperties(replyMessageVO, sendMessageDTO); BeanUtils.copyProperties(replyMessageVO, sendMessageDTO);
String nickNameStr = getNickNameStr(weixinGroupId);
if(i==0) {
LOGGER.info("发送欢迎语" + nickNameStr);
if (StringUtils.isNotEmpty(nickNameStr)) {
if (ReplyTypeEnum.TEXT.value.equals(sendMessageDTO.getReplyType())) {
sendMessageDTO.setContent(nickNameStr + " " + sendMessageDTO.getContent());
} else {
sendAtMessage(nickNameStr, robotId, weixinGroupId);
}
}
}
sendMessage(sendMessageDTO, robotId, weixinGroupId); sendMessage(sendMessageDTO, robotId, weixinGroupId);
i++;
} }
} }
@ParamLog("推送消息") @ParamLog("推送消息")
private static void sendMessage(SendMessageDTO sendMessageDTO, String robotId, String weixinGroupId) { private static void sendMessage(SendMessageDTO sendMessageDTO, String robotId, String weixinGroupId) {
String nickNameStr = getNickNameStr(weixinGroupId);
if (ReplyTypeEnum.TEXT.value.equals(sendMessageDTO.getReplyType())) { if (ReplyTypeEnum.TEXT.value.equals(sendMessageDTO.getReplyType())) {
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO(); SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(nickNameStr+" "+sendMessageDTO.getContent()); sendTextMessageVO.setContent(sendMessageDTO.getContent());
sendTextMessageVO.setAltId(robotId); sendTextMessageVO.setAltId(robotId);
sendTextMessageVO.setGroupId(weixinGroupId); sendTextMessageVO.setGroupId(weixinGroupId);
WxGroupSDK.sendTextMessage(sendTextMessageVO); WxGroupSDK.sendTextMessage(sendTextMessageVO);
} else if (ReplyTypeEnum.IMAGE.value.equals(sendMessageDTO.getReplyType())) { } else if (ReplyTypeEnum.IMAGE.value.equals(sendMessageDTO.getReplyType())) {
sendAtMessage(nickNameStr,robotId,weixinGroupId);
SendPicMessageVO sendPicMessageVO = new SendPicMessageVO(); SendPicMessageVO sendPicMessageVO = new SendPicMessageVO();
sendPicMessageVO.setGroupId(weixinGroupId); sendPicMessageVO.setGroupId(weixinGroupId);
sendPicMessageVO.setAltId(robotId); sendPicMessageVO.setAltId(robotId);
sendPicMessageVO.setPicUrl(sendMessageDTO.getPicUrl()); sendPicMessageVO.setPicUrl(sendMessageDTO.getPicUrl());
WxGroupSDK.sendPicMessage(sendPicMessageVO); WxGroupSDK.sendPicMessage(sendPicMessageVO);
} else if (ReplyTypeEnum.APP.value.equals(sendMessageDTO.getReplyType()) || ReplyTypeEnum.LINK.value.equals(sendMessageDTO.getReplyType())) { } else if (ReplyTypeEnum.APP.value.equals(sendMessageDTO.getReplyType()) || ReplyTypeEnum.LINK.value.equals(sendMessageDTO.getReplyType())) {
sendAtMessage(nickNameStr,robotId,weixinGroupId);
SendArticleMessageVO sendArticleMessageVO = new SendArticleMessageVO(); SendArticleMessageVO sendArticleMessageVO = new SendArticleMessageVO();
sendArticleMessageVO.setAltId(robotId); sendArticleMessageVO.setAltId(robotId);
sendArticleMessageVO.setDescription(sendMessageDTO.getDescription()); sendArticleMessageVO.setDescription(sendMessageDTO.getDescription());
...@@ -296,11 +306,10 @@ public class SendWeixinRequestTools { ...@@ -296,11 +306,10 @@ public class SendWeixinRequestTools {
public static void sendDefaultMessage(String groupName, String robotId, String weixinGroupId) { public static void sendDefaultMessage(String groupName, String robotId, String weixinGroupId) {
String content = getNickNameStr(weixinGroupId); String content = getNickNameStr(weixinGroupId);
if (StringUtil.isEmpty(groupName)) { if (StringUtil.isEmpty(groupName)) {
content += ",欢迎加入本群,凭以下关键词领取任务或资源:"; content += " 欢迎加入本群,凭以下关键词领取任务或资源:";
} else { } else {
content += ",欢迎加入" + groupName + "!凭以下关键词领取任务或资源:"; content += " 欢迎加入" + groupName + "!凭以下关键词领取任务或资源:";
} }
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO(); SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(content); sendTextMessageVO.setContent(content);
...@@ -322,10 +331,6 @@ public class SendWeixinRequestTools { ...@@ -322,10 +331,6 @@ public class SendWeixinRequestTools {
} }
Map.Entry<String, Integer> entry = iterator.next(); Map.Entry<String, Integer> entry = iterator.next();
String key=entry.getKey(); String key=entry.getKey();
Integer value=entry.getValue();
if(value==1){
continue;
}
names.add(key); names.add(key);
i++; i++;
} }
...@@ -333,7 +338,7 @@ public class SendWeixinRequestTools { ...@@ -333,7 +338,7 @@ public class SendWeixinRequestTools {
nickNames.remove(nickName); nickNames.remove(nickName);
nameStr = nameStr + "@" + nickName + " "; nameStr = nameStr + "@" + nickName + " ";
} }
JedisClusterUtils.setJson("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId,nickNames); JedisClusterUtils.setJson("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId,nickNames,600);
return nameStr; return nameStr;
} }
} }
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