Commit d72d330b by 裴大威

Merge branch 'fix-del-live' into 'master'

fix del start live

See merge request rays/pcloud-book!182
parents c61f5c80 ad0a3465
...@@ -101,6 +101,7 @@ import java.util.Date; ...@@ -101,6 +101,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -184,7 +185,7 @@ public class BookGroupClassifyBizImpl implements BookGroupClassifyBiz { ...@@ -184,7 +185,7 @@ public class BookGroupClassifyBizImpl implements BookGroupClassifyBiz {
BookGroupClassify bookGroupClassify = new BookGroupClassify(); BookGroupClassify bookGroupClassify = new BookGroupClassify();
BeanUtils.copyProperties(addClassifyVO, bookGroupClassify); BeanUtils.copyProperties(addClassifyVO, bookGroupClassify);
QrcodeNameAndProIdDTO qrcodeNameAndProId = bookGroupBiz.getQrcodeNameAndProId(addClassifyVO.getBookGroupId()); QrcodeNameAndProIdDTO qrcodeNameAndProId = bookGroupBiz.getQrcodeNameAndProId(addClassifyVO.getBookGroupId());
if (qrcodeNameAndProId == null) { if (Objects.isNull(qrcodeNameAndProId) || Objects.isNull(qrcodeNameAndProId.getProductId())) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "请先填写社群码信息!"); throw new BookBizException(BookBizException.PARAM_IS_NULL, "请先填写社群码信息!");
} }
bookGroupClassify.setProductId(qrcodeNameAndProId.getProductId()); bookGroupClassify.setProductId(qrcodeNameAndProId.getProductId());
......
...@@ -57,40 +57,42 @@ public class WxLiveBroadcastReminderListener { ...@@ -57,40 +57,42 @@ public class WxLiveBroadcastReminderListener {
@ParamLog("直播开播提醒") @ParamLog("直播开播提醒")
@RabbitHandler @RabbitHandler
public void onMessage(LiveCourseDetailInfoDto liveCourse) throws BizException { public void onMessage(LiveCourseDetailInfoDto liveCourse) throws BizException {
if (Objects.isNull(liveCourse) || CollectionUtils.isEmpty(liveCourse.getTableDetailDtos())) { // 20190929 消息量大,重复消息多,导致小号闪退或者崩溃,暂时屏蔽掉
return; log.info("[直播开播提醒] liveCourse:{}", liveCourse);
} // if (Objects.isNull(liveCourse) || CollectionUtils.isEmpty(liveCourse.getTableDetailDtos())) {
Map<Long, Long> collect = liveCourse.getTableDetailDtos().stream().collect(Collectors.toMap(TableDetailDto::getOriginId, TableDetailDto::getTableId)); // return;
final List<GroupQrcodeServerDTO> wxGroups = groupQrcodeBiz.getWxGroupIdByServerId(Lists.newArrayList(collect.keySet())); // }
log.info("[直播开播提醒] : liveCourse :{} wxGroups:{}", liveCourse, wxGroups); // Map<Long, Long> collect = liveCourse.getTableDetailDtos().stream().collect(Collectors.toMap(TableDetailDto::getOriginId, TableDetailDto::getTableId));
if (CollectionUtils.isEmpty(wxGroups)) { // final List<GroupQrcodeServerDTO> wxGroups = groupQrcodeBiz.getWxGroupIdByServerId(Lists.newArrayList(collect.keySet()));
return; // log.info("[直播开播提醒] : liveCourse :{} wxGroups:{}", liveCourse, wxGroups);
} // if (CollectionUtils.isEmpty(wxGroups)) {
final Map<Long, AccountSettingDto> accountMap = Maps.newHashMap(); // return;
List<String> wxGroupIds = wxGroups.stream().map(GroupQrcodeServerDTO::getWxGroupId).collect(Collectors.toList()); // }
Map<String, BookWxQrcodeDTO> groupVersion = weixinQrcodeBiz.getGroupVersion(wxGroupIds); // final Map<Long, AccountSettingDto> accountMap = Maps.newHashMap();
final List<GroupQrcodeServerDTO> wxGroups2 = wxGroups.stream().collect( // List<String> wxGroupIds = wxGroups.stream().map(GroupQrcodeServerDTO::getWxGroupId).collect(Collectors.toList());
Collectors. collectingAndThen( // Map<String, BookWxQrcodeDTO> groupVersion = weixinQrcodeBiz.getGroupVersion(wxGroupIds);
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(GroupQrcodeServerDTO::getWxGroupId))), ArrayList::new) // final List<GroupQrcodeServerDTO> wxGroups2 = wxGroups.stream().collect(
); // Collectors. collectingAndThen(
for (GroupQrcodeServerDTO dto : wxGroups2) { // Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(GroupQrcodeServerDTO::getWxGroupId))), ArrayList::new)
// 避免重复挂服务调用性能损耗 // );
AccountSettingDto accountSettingDto = accountMap.get(dto.getChannelId()); // for (GroupQrcodeServerDTO dto : wxGroups2) {
if (Objects.isNull(accountSettingDto)) { // // 避免重复挂服务调用性能损耗
accountSettingDto = qrcodeSceneConsr.getWechatInfo(dto.getChannelId()); // AccountSettingDto accountSettingDto = accountMap.get(dto.getChannelId());
accountMap.put(dto.getChannelId(), accountSettingDto); // if (Objects.isNull(accountSettingDto)) {
} // accountSettingDto = qrcodeSceneConsr.getWechatInfo(dto.getChannelId());
String linkUrl = SendWeixinRequestTools.splitUrlNew(accountSettingDto, dto.getLinkUrl(), dto.getBookGroupId(), dto.getClassifyId(), dto.getGroupQrcodeId()); // accountMap.put(dto.getChannelId(), accountSettingDto);
// 定位到具体课程 // }
String liveInfo = linkUrl.replace("liveinfo?", "lesson/" + liveCourse.getLessonId() + "?tableId=" + collect.get(dto.getServeId()) + "&"); // String linkUrl = SendWeixinRequestTools.splitUrlNew(accountSettingDto, dto.getLinkUrl(), dto.getBookGroupId(), dto.getClassifyId(), dto.getGroupQrcodeId());
String shortUrl4Own = UrlUtils.getShortUrl4Own(liveInfo); // // 定位到具体课程
SendTextMessageVO vo = new SendTextMessageVO(); // String liveInfo = linkUrl.replace("liveinfo?", "lesson/" + liveCourse.getLessonId() + "?tableId=" + collect.get(dto.getServeId()) + "&");
vo.setContent("【" + liveCourse.getTitle() + "】即将开播啦,感兴趣的同学们可以开始进入啦。猛戳直播链接:" + shortUrl4Own); // String shortUrl4Own = UrlUtils.getShortUrl4Own(liveInfo);
vo.setWxGroupId(dto.getWxGroupId()); // SendTextMessageVO vo = new SendTextMessageVO();
// 负载均衡会根据群获取该群活跃小号,所以传什么都不重要,写死为“我为你笑着” // vo.setContent("【" + liveCourse.getTitle() + "】即将开播啦,感兴趣的同学们可以开始进入啦。猛戳直播链接:" + shortUrl4Own);
vo.setAltId(Optional.ofNullable(groupVersion.get(dto.getWxGroupId())).orElse(new BookWxQrcodeDTO()).getRobotWxId()); // vo.setWxGroupId(dto.getWxGroupId());
vo.setIp(Optional.ofNullable(groupVersion.get(dto.getWxGroupId())).orElse(new BookWxQrcodeDTO()).getWechatGroupIp()); // // 负载均衡会根据群获取该群活跃小号,所以传什么都不重要,写死为“我为你笑着”
WxGroupSDK.sendTextMessage(vo); // vo.setAltId(Optional.ofNullable(groupVersion.get(dto.getWxGroupId())).orElse(new BookWxQrcodeDTO()).getRobotWxId());
} // vo.setIp(Optional.ofNullable(groupVersion.get(dto.getWxGroupId())).orElse(new BookWxQrcodeDTO()).getWechatGroupIp());
// WxGroupSDK.sendTextMessage(vo);
// }
} }
} }
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