|
|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|
|
import com.tzld.piaoquan.api.common.enums.wecom.ConfigTaskContentTypeEnum;
|
|
|
import com.tzld.piaoquan.api.common.enums.wecom.MsgSendStatusEnum;
|
|
|
+import com.tzld.piaoquan.api.common.enums.wecom.ThirdPartWeComStaffStatusEnum;
|
|
|
import com.tzld.piaoquan.api.component.VideoApiService;
|
|
|
import com.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformPlanMapperExt;
|
|
|
import com.tzld.piaoquan.api.dao.mapper.wecom.thirdpart.ThirdPartWeComMsgMapper;
|
|
|
@@ -114,6 +115,15 @@ public class WeComSendMsgJob {
|
|
|
List<ThirdPartWeComRoomConfigTaskContent> taskContentList = weComThirdPartyRoomService.getRoomConfigTaskContents(configTaskIds);
|
|
|
Map<String, List<ThirdPartWeComRoomConfigTaskContent>> taskContentMap = taskContentList.stream()
|
|
|
.collect(Collectors.groupingBy(ThirdPartWeComRoomConfigTaskContent::getTaskId));
|
|
|
+ ThirdPartWeComStaff pushStaff = getSendStaff(roomConfig);
|
|
|
+ if (Objects.isNull(pushStaff)) {
|
|
|
+ LarkRobotUtil.sendWeComThirdPartMessage(
|
|
|
+ "【账号发送群消息,推送账号获取失败通知】\n" +
|
|
|
+ "账号名称:" + staff.getName() + "\n" +
|
|
|
+ "账号VID:" + staff.getThirdStaffId() + "\n" +
|
|
|
+ "群名称:" + room.getName());
|
|
|
+ return;
|
|
|
+ }
|
|
|
for (ThirdPartWeComRoomConfigTask configTask : taskList) {
|
|
|
List<String> timeList = getRoomSendTime(room, roomConfig, configTask);
|
|
|
if (timeList.contains(time)) {
|
|
|
@@ -126,20 +136,20 @@ public class WeComSendMsgJob {
|
|
|
for (ThirdPartWeComRoomConfigTaskContent configTaskContent : contentList) {
|
|
|
if (ConfigTaskContentTypeEnum.TEXT.getVal() == configTaskContent.getType()) {
|
|
|
// build发送体
|
|
|
- SendTextMsgRequest request = buildSendTextMsgRequest(configTaskContent.getContent(), staff, room);
|
|
|
+ SendTextMsgRequest request = buildSendTextMsgRequest(configTaskContent.getContent(), pushStaff, room);
|
|
|
// 发送消息
|
|
|
- CommonResponse<SendTextMsgResponse> response = weComThirdPartyService.sendTextMsg(staff, room, request);
|
|
|
+ CommonResponse<SendTextMsgResponse> response = weComThirdPartyService.sendTextMsg(pushStaff, room, request);
|
|
|
// 存储消息
|
|
|
- saveTextWeComMsg(staff.getId(), configTaskContent.getContent(), request, response);
|
|
|
+ saveTextWeComMsg(pushStaff.getId(), configTaskContent.getContent(), request, response);
|
|
|
} else if (ConfigTaskContentTypeEnum.MINI_PROGRAM.getVal() == configTaskContent.getType()) {
|
|
|
List<CgiReplyBucketData> cgiReplyBucketDataList = getCgiReplyBucketData(room.getThirdRoomId(), staff, roomConfig, configTaskContent);
|
|
|
for (CgiReplyBucketData cgiReplyBucketData : cgiReplyBucketDataList) {
|
|
|
// build发送体
|
|
|
- SendAppMsgRequest request = buildSendAppMsgRequest(cgiReplyBucketData, staff, room);
|
|
|
+ SendAppMsgRequest request = buildSendAppMsgRequest(cgiReplyBucketData, pushStaff, room);
|
|
|
// 发送消息
|
|
|
- CommonResponse<SendAppMsgResponse> response = weComThirdPartyService.sendAppMsg(staff, room, request);
|
|
|
+ CommonResponse<SendAppMsgResponse> response = weComThirdPartyService.sendAppMsg(pushStaff, room, request);
|
|
|
// 存储消息
|
|
|
- saveAppWeComMsg(staff.getId(), cgiReplyBucketData.getMiniVideoId(), request, response);
|
|
|
+ saveAppWeComMsg(pushStaff.getId(), cgiReplyBucketData.getMiniVideoId(), request, response);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -151,6 +161,24 @@ public class WeComSendMsgJob {
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
|
|
|
+ private ThirdPartWeComStaff getSendStaff(ThirdPartWeComRoomConfig roomConfig) {
|
|
|
+ List<ThirdPartWeComStaff> pushStaffList = weComThirdPartyRoomService.getRoomConfigPushList(Collections.singletonList(roomConfig));
|
|
|
+ Map<Long, ThirdPartWeComStaff> pushStaffMap = pushStaffList.stream()
|
|
|
+ .collect(Collectors.toMap(ThirdPartWeComStaff::getThirdStaffId, Function.identity()));
|
|
|
+ ThirdPartWeComStaff pushStaff = pushStaffMap.get(roomConfig.getPrimaryThirdStaffId());
|
|
|
+ if (Objects.isNull(pushStaff) || pushStaff.getStatus() != ThirdPartWeComStaffStatusEnum.NORMAL.getVal()) {
|
|
|
+ if (Objects.nonNull(roomConfig.getSecondThirdStaffId())) {
|
|
|
+ pushStaff = pushStaffMap.get(roomConfig.getSecondThirdStaffId());
|
|
|
+ if (Objects.isNull(pushStaff) || pushStaff.getStatus() != ThirdPartWeComStaffStatusEnum.NORMAL.getVal()) {
|
|
|
+ pushStaff = null;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ pushStaff = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return pushStaff;
|
|
|
+ }
|
|
|
+
|
|
|
private List<String> getRoomSendTime(ThirdPartWeComRoom room,
|
|
|
ThirdPartWeComRoomConfig roomConfig,
|
|
|
ThirdPartWeComRoomConfigTask configTask) {
|