Commit 744a359e by 朱亚洁

广告发送

parent d06426dc
...@@ -572,14 +572,26 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -572,14 +572,26 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
} }
List<AdvertisingDistributionBook> list = new ArrayList<>(); List<AdvertisingDistributionBook> list = new ArrayList<>();
Map<Long, Long> agentIdMap = new HashMap<>(); Map<Long, Long> agentIdMap = new HashMap<>();
for (DistributionWechatGroup group : bookGroups) { //过滤无机器人的群
//机器人不存在,不投放广告 for (int i = 0; i < bookGroups.size() && null != bookGroups; i++) {
GroupQrcode groupQrcode = groupQrcodeDao.getById(group.getQrcodeId()); DistributionWechatGroup wechatGroup = bookGroups.get(i);
String altId = wechatGroupConsr.getSendAdRobotByGroupId(groupQrcode.getWeixinGroupId()); if (null != wechatGroup) {
if (StringUtil.isEmpty(altId)) { //机器人不存在,不投放广告
bookGroups.remove(group); GroupQrcode groupQrcode = groupQrcodeDao.getById(wechatGroup.getQrcodeId());
continue; if (null != groupQrcode) {
String altId = wechatGroupConsr.getSendAdRobotByGroupId(groupQrcode.getWeixinGroupId());
if (StringUtil.isEmpty(altId)) {
LOGGER.info("机器人不在微信群,广告投放失败" + wechatGroup);
bookGroups.remove(wechatGroup);
}
}
} }
}
if (ListUtils.isEmpty(bookGroups)){
LOGGER.info("微信群为空,广告投放失败");
return;
}
for (DistributionWechatGroup group : bookGroups) {
AdvertisingDistributionBook distributionBook = new AdvertisingDistributionBook(); AdvertisingDistributionBook distributionBook = new AdvertisingDistributionBook();
distributionBook.setAdId(book.getAdId()); distributionBook.setAdId(book.getAdId());
distributionBook.setBookId(group.getBookId()); distributionBook.setBookId(group.getBookId());
...@@ -598,10 +610,6 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -598,10 +610,6 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
distributionBook.setIsBookGroup(true); distributionBook.setIsBookGroup(true);
list.add(distributionBook); list.add(distributionBook);
} }
if (ListUtils.isEmpty(bookGroups)) {
LOGGER.info("微信群为空或机器人不在微信群,广告投放失败" + book.getGroups());
return;
}
advertisingDistributionBookDao.batchInsert(list); advertisingDistributionBookDao.batchInsert(list);
//发送微信群消息 //发送微信群消息
SEND_MESSAGE_THREAD_POOL.execute(() -> { SEND_MESSAGE_THREAD_POOL.execute(() -> {
...@@ -719,8 +727,8 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -719,8 +727,8 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
WxGroupSDK.sendPicMessage(sendPicMessageVO); WxGroupSDK.sendPicMessage(sendPicMessageVO);
} }
try { try {
Thread.sleep(1000); Thread.sleep(4000);
LOGGER.info("发送微信消息-线程休眠1秒"); LOGGER.info("发送微信消息-线程休眠4秒");
} catch (InterruptedException e) { } catch (InterruptedException e) {
LOGGER.error("线程休眠失败" + e.getMessage()); LOGGER.error("线程休眠失败" + e.getMessage());
} }
......
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