|
|
@@ -21,10 +21,7 @@ import com.tzld.piaoquan.api.model.param.wecom.thirdpart.*;
|
|
|
import com.tzld.piaoquan.api.model.po.wecom.thirdpart.*;
|
|
|
import com.tzld.piaoquan.api.model.vo.IdNameVO;
|
|
|
import com.tzld.piaoquan.api.model.vo.contentplatform.AccountQrCodeVO;
|
|
|
-import com.tzld.piaoquan.api.model.vo.wecom.thirdpart.ThirdPartyAccountConfigTaskContentVO;
|
|
|
-import com.tzld.piaoquan.api.model.vo.wecom.thirdpart.ThirdPartyAccountConfigTaskVO;
|
|
|
-import com.tzld.piaoquan.api.model.vo.wecom.thirdpart.ThirdPartyAccountConfigVO;
|
|
|
-import com.tzld.piaoquan.api.model.vo.wecom.thirdpart.ThirdPartyAccountVO;
|
|
|
+import com.tzld.piaoquan.api.model.vo.wecom.thirdpart.*;
|
|
|
import com.tzld.piaoquan.api.service.wecom.thirdparty.WeComThirdPartyAccountService;
|
|
|
import com.tzld.piaoquan.api.service.wecom.thirdparty.WeComThirdPartyRoomService;
|
|
|
import com.tzld.piaoquan.api.service.wecom.thirdparty.WeComThirdPartyService;
|
|
|
@@ -277,6 +274,44 @@ public class WeComThirdPartyAccountServiceImpl implements WeComThirdPartyAccount
|
|
|
return staffConfigTaskContentMapper.selectByExample(example);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public CheckPushAccountExistVO checkPushAccountExist(ThirdPartyAccountConfigParam param) {
|
|
|
+ List<ThirdPartWeComRoom> roomList = getNeedSyncRoomList(param);
|
|
|
+ if (CollectionUtils.isEmpty(roomList)) {
|
|
|
+ return new CheckPushAccountExistVO();
|
|
|
+ }
|
|
|
+ List<String> thirdRoomIds = roomList.stream().map(ThirdPartWeComRoom::getThirdRoomId).collect(Collectors.toList());
|
|
|
+ List<ThirdPartWeComRoomUser> roomUserList = roomService.getRoomUserListByRoomIds(thirdRoomIds);
|
|
|
+ Map<String, List<ThirdPartWeComRoomUser>> roomUserMap = roomUserList.stream().collect(Collectors.groupingBy(ThirdPartWeComRoomUser::getThirdRoomId));
|
|
|
+
|
|
|
+ CheckPushAccountExistVO result = new CheckPushAccountExistVO();
|
|
|
+ result.setNotExistRooms(new ArrayList<>());
|
|
|
+ for (ThirdPartWeComRoom room : roomList) {
|
|
|
+ List<IdNameVO<Long>> notExistPushAccounts = new ArrayList<>();
|
|
|
+ List<ThirdPartWeComRoomUser> roomUsers = roomUserMap.get(room.getThirdRoomId());
|
|
|
+ if (CollectionUtils.isNotEmpty(roomUsers)) {
|
|
|
+ List<Long> thirdStaffIds = roomUsers.stream().map(ThirdPartWeComRoomUser::getUin).collect(Collectors.toList());
|
|
|
+ if (!thirdStaffIds.contains(param.getPrimaryThirdStaffId())) {
|
|
|
+ notExistPushAccounts.add(new IdNameVO<>(param.getPrimaryThirdStaffId(), param.getPrimaryThirdStaffName()));
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(param.getSecondThirdStaffId()) && !thirdStaffIds.contains(param.getSecondThirdStaffId())) {
|
|
|
+ notExistPushAccounts.add(new IdNameVO<>(param.getSecondThirdStaffId(), param.getSecondThirdStaffName()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(notExistPushAccounts)) {
|
|
|
+ CheckPushAccountExistVO.Room roomVO = new CheckPushAccountExistVO.Room();
|
|
|
+ roomVO.setRoomId(room.getId());
|
|
|
+ roomVO.setName(room.getName());
|
|
|
+ roomVO.setNotExistPushAccounts(notExistPushAccounts);
|
|
|
+ result.getNotExistRooms().add(roomVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(result.getNotExistRooms())) {
|
|
|
+ result.setPass(false);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void saveAccountConfig(ThirdPartyAccountConfigParam param) {
|
|
|
// check param
|
|
|
@@ -333,6 +368,11 @@ public class WeComThirdPartyAccountServiceImpl implements WeComThirdPartyAccount
|
|
|
}
|
|
|
|
|
|
private void syncStaffConfigToRoom(ThirdPartyAccountConfigParam param, String accountConfigId) {
|
|
|
+ List<ThirdPartWeComRoom> roomList = getNeedSyncRoomList(param);
|
|
|
+ syncConfig(param, accountConfigId, roomList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ThirdPartWeComRoom> getNeedSyncRoomList(ThirdPartyAccountConfigParam param) {
|
|
|
List<ThirdPartWeComRoom> roomList;
|
|
|
if (param.getConfigSync() == ConfigSyncEnum.ALL.getVal()) {
|
|
|
// 所有群
|
|
|
@@ -348,7 +388,7 @@ public class WeComThirdPartyAccountServiceImpl implements WeComThirdPartyAccount
|
|
|
List<ThirdPartWeComRoom> noConfigRoomList = roomMapperExt.getNoConfigRoomList(param.getAccountId());
|
|
|
noConfigRoomList.removeIf(room -> roomIds.contains(room.getId()));
|
|
|
roomList.addAll(noConfigRoomList);
|
|
|
- syncConfig(param, accountConfigId, roomList);
|
|
|
+ return roomList;
|
|
|
}
|
|
|
|
|
|
private void syncConfig(ThirdPartyAccountConfigParam param, String accountConfigId, List<ThirdPartWeComRoom> roomList) {
|
|
|
@@ -356,7 +396,11 @@ public class WeComThirdPartyAccountServiceImpl implements WeComThirdPartyAccount
|
|
|
return;
|
|
|
}
|
|
|
for (ThirdPartWeComRoom room : roomList) {
|
|
|
- roomService.saveRoomConfig(room, accountConfigId, param);
|
|
|
+ try {
|
|
|
+ roomService.saveRoomConfig(room, accountConfigId, param);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("同步群配置失败, roomId: {}, accountConfigId: {}, errorMsg: {}", room.getId(), accountConfigId, e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -376,7 +420,18 @@ public class WeComThirdPartyAccountServiceImpl implements WeComThirdPartyAccount
|
|
|
if (param.getConfigSync() == ConfigSyncEnum.SPECIFY.getVal() && CollectionUtils.isEmpty(param.getConfigSyncRoomIdList())) {
|
|
|
throw new CommonException(ExceptionEnum.PARAM_ERROR.getCode(), "指定群生效时,选定群列表不能为空");
|
|
|
}
|
|
|
+ List<String> timeList = new ArrayList<>();
|
|
|
for (ThirdPartyAccountConfigTaskParam task : param.getTaskList()) {
|
|
|
+ if (CollectionUtils.isEmpty(task.getSendTime())) {
|
|
|
+ throw new CommonException(ExceptionEnum.PARAM_ERROR.getCode(), "推送时间不能为空");
|
|
|
+ }
|
|
|
+ for (String sendTime : task.getSendTime()) {
|
|
|
+ if (timeList.contains(sendTime)) {
|
|
|
+ throw new CommonException(ExceptionEnum.PARAM_ERROR.getCode(), "推送时间不能重复: " + sendTime);
|
|
|
+ } else {
|
|
|
+ timeList.add(sendTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (Objects.nonNull(task.getRandomMin())) {
|
|
|
if (task.getRandomMin() < 0) {
|
|
|
throw new CommonException(ExceptionEnum.PARAM_ERROR.getCode(), "随机浮动分钟不能小于0");
|