Commit 0c2d835b by 高鹏

Merge branch 'zyj-sendad' into 'master'

修改发广告小号+保存群发记录

See merge request rays/pcloud-book!278
parents 16155b94 2f5dc014
...@@ -83,7 +83,6 @@ import com.pcloud.book.group.dto.ClassifyDTO; ...@@ -83,7 +83,6 @@ import com.pcloud.book.group.dto.ClassifyDTO;
import com.pcloud.book.group.dto.GroupQrcodeInfo4Advertising; import com.pcloud.book.group.dto.GroupQrcodeInfo4Advertising;
import com.pcloud.book.group.dto.GroupQrcodeInfoDTO; import com.pcloud.book.group.dto.GroupQrcodeInfoDTO;
import com.pcloud.book.group.entity.BookGroup; import com.pcloud.book.group.entity.BookGroup;
import com.pcloud.book.group.entity.BookGroupClassify;
import com.pcloud.book.group.entity.GroupQrcode; import com.pcloud.book.group.entity.GroupQrcode;
import com.pcloud.book.group.vo.GroupQrcodeVO; import com.pcloud.book.group.vo.GroupQrcodeVO;
import com.pcloud.book.util.common.CommonUtils; import com.pcloud.book.util.common.CommonUtils;
...@@ -582,8 +581,8 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -582,8 +581,8 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
if (null != wechatGroup) { if (null != wechatGroup) {
//机器人不存在,不投放广告 //机器人不存在,不投放广告
GroupQrcode groupQrcode = groupQrcodeDao.getById(wechatGroup.getQrcodeId()); GroupQrcode groupQrcode = groupQrcodeDao.getById(wechatGroup.getQrcodeId());
if (null != groupQrcode) { if (null != groupQrcode) {//取群里活跃的小号发送20191216
String altId = wechatGroupConsr.getSendAdRobotByGroupId(groupQrcode.getWeixinGroupId()); String altId = wechatGroupConsr.getRobotIdByGroupId(groupQrcode.getWeixinGroupId());
if (StringUtil.isEmpty(altId)) { if (StringUtil.isEmpty(altId)) {
LOGGER.info("机器人不在微信群,广告投放失败" + wechatGroup); LOGGER.info("机器人不在微信群,广告投放失败" + wechatGroup);
bookGroups.remove(wechatGroup); bookGroups.remove(wechatGroup);
...@@ -662,7 +661,7 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -662,7 +661,7 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
GroupQrcode groupQrcode = groupQrcodeDao.getById(group.getQrcodeId()); GroupQrcode groupQrcode = groupQrcodeDao.getById(group.getQrcodeId());
String groupId = groupQrcode.getWeixinGroupId(); String groupId = groupQrcode.getWeixinGroupId();
// 获取机器人微信号 // 获取机器人微信号
String altId = wechatGroupConsr.getSendAdRobotByGroupId(groupId); String altId = wechatGroupConsr.getRobotIdByGroupId(groupId);
if (StringUtil.isEmpty(altId)) { if (StringUtil.isEmpty(altId)) {
continue; continue;
} }
...@@ -752,8 +751,8 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -752,8 +751,8 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
WxGroupSDK.sendPicMessage(sendPicMessageVO); WxGroupSDK.sendPicMessage(sendPicMessageVO);
} }
try { try {
Thread.sleep(10000); Thread.sleep(5000);
LOGGER.info("发送微信消息-线程休眠10秒"); LOGGER.info("发送微信消息-线程休眠5秒");
} catch (InterruptedException e) { } catch (InterruptedException e) {
LOGGER.error("线程休眠失败" + e.getMessage()); LOGGER.error("线程休眠失败" + e.getMessage());
} }
......
...@@ -3,7 +3,9 @@ package com.pcloud.book.group.tools; ...@@ -3,7 +3,9 @@ package com.pcloud.book.group.tools;
import com.pcloud.book.util.common.ThreadPoolUtils; import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.wechatgroup.selfrobot.dto.SelfRobotMsgRecord; import com.pcloud.wechatgroup.selfrobot.dto.SelfRobotMsgRecord;
import com.pcloud.wechatgroup.selfrobot.service.SelfRobotService; import com.pcloud.wechatgroup.selfrobot.service.SelfRobotService;
import com.sdk.wxgroup.SendArticleMessageVO;
import com.sdk.wxgroup.SendGroupInviteVO; import com.sdk.wxgroup.SendGroupInviteVO;
import com.sdk.wxgroup.SendPicMessageVO;
import com.sdk.wxgroup.SendTextMessageVO; import com.sdk.wxgroup.SendTextMessageVO;
import com.sdk.wxgroup.WxGroupSDK; import com.sdk.wxgroup.WxGroupSDK;
...@@ -60,6 +62,37 @@ public class SendSelfMsgTools { ...@@ -60,6 +62,37 @@ public class SendSelfMsgTools {
}); });
} }
/**
* 发送链接
* @param sendArticleMessageVO
*/
public static void sendArticleMessage(SendArticleMessageVO sendArticleMessageVO){
WxGroupSDK.sendArticleMessage(sendArticleMessageVO);
ThreadPoolUtils.OTHER_THREAD_POOL.execute(() -> {
SelfRobotMsgRecord selfRobotMsgRecord = new SelfRobotMsgRecord();
selfRobotMsgRecord.setMessageType(11);//链接
selfRobotMsgRecord.setWxId(sendArticleMessageVO.getAltId());
selfRobotMsgRecord.setWxUserId(sendArticleMessageVO.getWxGroupId());
selfRobotMsgRecord.setTitle(sendArticleMessageVO.getTitle());
selfRobotMsgRecord.setUrl(sendArticleMessageVO.getLinkUrl());
insertMsg(selfRobotMsgRecord);
});
}
/**
* 发送图片
*/
public static void sendPicMessage(SendPicMessageVO sendPicMessageVO){
WxGroupSDK.sendPicMessage(sendPicMessageVO);
ThreadPoolUtils.OTHER_THREAD_POOL.execute(() -> {
SelfRobotMsgRecord selfRobotMsgRecord = new SelfRobotMsgRecord();
selfRobotMsgRecord.setMessageType(2);//图片
selfRobotMsgRecord.setWxId(sendPicMessageVO.getAltId());
selfRobotMsgRecord.setWxUserId(sendPicMessageVO.getWxGroupId());
selfRobotMsgRecord.setResourceUrl(sendPicMessageVO.getPicUrl());
insertMsg(selfRobotMsgRecord);
});
}
/** /**
* 保存发送记录 * 保存发送记录
......
...@@ -4,6 +4,7 @@ import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr; ...@@ -4,6 +4,7 @@ import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.group.dao.WeixinQrcodeGenerationDao; import com.pcloud.book.group.dao.WeixinQrcodeGenerationDao;
import com.pcloud.book.group.entity.WeixinQrcodeGeneration; import com.pcloud.book.group.entity.WeixinQrcodeGeneration;
import com.pcloud.book.group.set.GroupSet; import com.pcloud.book.group.set.GroupSet;
import com.pcloud.book.group.tools.SendSelfMsgTools;
import com.pcloud.book.group.vo.UserBookInfoVO; import com.pcloud.book.group.vo.UserBookInfoVO;
import com.pcloud.book.push.biz.SelfPushBiz; import com.pcloud.book.push.biz.SelfPushBiz;
import com.pcloud.book.push.constant.PushConstant; import com.pcloud.book.push.constant.PushConstant;
...@@ -200,7 +201,8 @@ public class SelfPushBizImpl implements SelfPushBiz { ...@@ -200,7 +201,8 @@ public class SelfPushBizImpl implements SelfPushBiz {
sendTextMessageVO.setAltId(altId); sendTextMessageVO.setAltId(altId);
sendTextMessageVO.setWxGroupId(userWxId); sendTextMessageVO.setWxGroupId(userWxId);
sendTextMessageVO.setIp(getIpByRobot(altId)); sendTextMessageVO.setIp(getIpByRobot(altId));
WxGroupSDK.sendTextMessage(sendTextMessageVO); SendSelfMsgTools.sendTextMessage(sendTextMessageVO);
return;
} }
if (ItemTypeEnum.LINK.value.equals(itemType)) { if (ItemTypeEnum.LINK.value.equals(itemType)) {
SendArticleMessageVO sendArticleMessageVO = new SendArticleMessageVO(); SendArticleMessageVO sendArticleMessageVO = new SendArticleMessageVO();
...@@ -213,7 +215,8 @@ public class SelfPushBizImpl implements SelfPushBiz { ...@@ -213,7 +215,8 @@ public class SelfPushBizImpl implements SelfPushBiz {
sendArticleMessageVO.setPicUrl(selfPushItem.getLinkImageUrl()); sendArticleMessageVO.setPicUrl(selfPushItem.getLinkImageUrl());
sendArticleMessageVO.setTitle(selfPushItem.getLinkTitle()); sendArticleMessageVO.setTitle(selfPushItem.getLinkTitle());
sendArticleMessageVO.setIp(getIpByRobot(altId)); sendArticleMessageVO.setIp(getIpByRobot(altId));
WxGroupSDK.sendArticleMessage(sendArticleMessageVO); SendSelfMsgTools.sendArticleMessage(sendArticleMessageVO);
return;
} }
if (ItemTypeEnum.APP.value.equals(itemType)) { if (ItemTypeEnum.APP.value.equals(itemType)) {
return;//应用类型不参与群发C1002029 return;//应用类型不参与群发C1002029
...@@ -225,7 +228,8 @@ public class SelfPushBizImpl implements SelfPushBiz { ...@@ -225,7 +228,8 @@ public class SelfPushBizImpl implements SelfPushBiz {
sendPicMessageVO.setWxGroupId(userWxId); sendPicMessageVO.setWxGroupId(userWxId);
sendPicMessageVO.setPicUrl(selfPushItem.getImageUrl()); sendPicMessageVO.setPicUrl(selfPushItem.getImageUrl());
sendPicMessageVO.setIp(getIpByRobot(altId)); sendPicMessageVO.setIp(getIpByRobot(altId));
WxGroupSDK.sendPicMessage(sendPicMessageVO); SendSelfMsgTools.sendPicMessage(sendPicMessageVO);
return;
} }
} }
......
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