| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -20,10 +20,7 @@ package com.epmet.modules.invitation.service.impl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.baomidou.mybatisplus.core.metadata.IPage; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.constant.AppClientConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.constant.Constant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.constant.FieldConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.constant.NumConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.constant.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.exception.EpmetErrorCode; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.exception.RenException; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.page.PageData; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -160,7 +157,7 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @Date 2020/3/31 22:50 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						@Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public Result<CreateGroupInvitationResultDTO> createGroupInvitation(CreateGroupInvitationFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public CreateGroupInvitationResultDTO createGroupInvitation(CreateGroupInvitationFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//1、只有群主可以邀请新成员(这块界面限制死了,只有群主才能看到邀请新成员按钮)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//2、审核通过(讨论中)的群才可以分享邀请连接
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							ResiGroupDTO resiGroupDTO = resiGroupService.get(formDTO.getGroupId()); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -181,7 +178,7 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							insert(groupInvitationEntity); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							CreateGroupInvitationResultDTO resultDTO = new CreateGroupInvitationResultDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							resultDTO.setInvitationId(groupInvitationEntity.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return new Result<CreateGroupInvitationResultDTO>().ok(resultDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return resultDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						/** | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -192,13 +189,9 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @Date 2020/3/31 23:20 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						@Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public Result<LinkGroupInfoResultDTO> getLinkGroupInfo(LinkGroupInfoFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public LinkGroupInfoResultDTO getLinkGroupInfo(LinkGroupInfoFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//0、校验是否存在该邀请连接(判断是会否被删除连接、是否失效、群状态)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							Result<GroupInvitationDTO> validResult = this.checkLinkValid(formDTO.getInvitationId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (!validResult.success()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								return new Result<LinkGroupInfoResultDTO>().error(validResult.getCode(), validResult.getMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							GroupInvitationDTO groupInvitationDTO=validResult.getData(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							GroupInvitationDTO groupInvitationDTO=this.checkLinkValid(formDTO.getInvitationId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							LinkGroupInfoResultDTO linkGroupInfoResultDTO = new LinkGroupInfoResultDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//1、查询是否在群内
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							ResiGroupMemberDTO resiGroupMemberDTO = resiGroupMemberDao.selectGroupMemberInfo(groupInvitationDTO.getResiGroupId(), formDTO.getUserId()); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -214,12 +207,12 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (groupLeaderUserInfo.success() && null != groupLeaderUserInfo.getData()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								groupInfo.setLeaderName(groupLeaderUserInfo.getData().getShowName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.info("组长注册信息查询失败" + groupLeaderUserInfo.getMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.error(String.format("居民端用户【%s】根据链接【%s】查看群邀请信息调用%s服务,获取组长信息异常,错误码:%s,错误提示:%s",formDTO.getUserId(),formDTO.getInvitationId(), ServiceConstant.EPMET_USER_SERVER,groupLeaderUserInfo.getCode(), groupLeaderUserInfo.getMsg())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							linkGroupInfoResultDTO.setGroupInfo(groupInfo); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//4、记录用户邀请关系
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							this.saveUserInvitation(groupInvitationDTO,formDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return new Result<LinkGroupInfoResultDTO>().ok(linkGroupInfoResultDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return linkGroupInfoResultDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						/** | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -240,9 +233,9 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							userInvitationFormDTO.setInviteSourceId(formDTO.getInvitationId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							Result result = epmetUserFeignClient.saveUserInvitation(userInvitationFormDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (!result.success()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.info("人员邀请关系记录失败" + result.getMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.error("人员邀请关系记录失败" + result.getMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.info("人员邀请关系记录成功"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.error("人员邀请关系记录成功"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return result; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -270,17 +263,19 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return epmetUserFeignClient.getUserResiInfoDTO(resiUserInfoFormDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private Result<GroupInvitationDTO> checkLinkValid(String invitationId) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private GroupInvitationDTO checkLinkValid(String invitationId) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//校验是否存在该邀请连接
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							GroupInvitationDTO groupInvitationDTO = this.get(invitationId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//Date1.after(Date2),当Date1大于Date2时,返回TRUE,当小于等于时,返回false;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (null == groupInvitationDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								return new Result<GroupInvitationDTO>().error(EpmetErrorCode.LOSE_EFFICACY.getCode(), EpmetErrorCode.LOSE_EFFICACY.getMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.error(String.format("根据链接【%s】查看群邀请信息异常,错误码:%s,错误提示:%s",invitationId,EpmetErrorCode.LOSE_EFFICACY.getCode(), EpmetErrorCode.LOSE_EFFICACY.getMsg())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								throw new RenException(EpmetErrorCode.LOSE_EFFICACY.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (null != groupInvitationDTO && !groupInvitationDTO.getValidEndTime().after(new Date())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								return new Result<GroupInvitationDTO>().error(EpmetErrorCode.LOSE_EFFICACY.getCode(), EpmetErrorCode.LOSE_EFFICACY.getMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.error(String.format("根据链接【%s】查看群邀请信息异常,错误码:%s,错误提示:%s",invitationId,EpmetErrorCode.LOSE_EFFICACY.getCode(), EpmetErrorCode.LOSE_EFFICACY.getMsg())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								throw new RenException(EpmetErrorCode.LOSE_EFFICACY.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							ResiGroupEntity resiGroupEntity = resiGroupDao.selectById(groupInvitationDTO.getResiGroupId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							/*ResiGroupEntity resiGroupEntity = resiGroupDao.selectById(groupInvitationDTO.getResiGroupId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (null == resiGroupEntity) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.info("组不存在"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//TODO
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -290,8 +285,8 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} else if (null != resiGroupEntity && GroupStateConstant.GROUP_HIDDEN.equals(resiGroupEntity.getState())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.info("组已屏蔽"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//TODO
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return new Result<GroupInvitationDTO>().ok(groupInvitationDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							}*/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return groupInvitationDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						/** | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -302,13 +297,9 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @Date 2020/3/31 23:47 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						@Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public Result accetInvitation(AccetInvitationFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public void accetInvitation(AccetInvitationFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//1、申请是否有效
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							Result<GroupInvitationDTO> validResult = this.checkLinkValid(formDTO.getInvitationId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (!validResult.success()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								return new Result<LinkGroupInfoResultDTO>().error(validResult.getCode(), validResult.getMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							GroupInvitationDTO groupInvitationDTO=validResult.getData(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							GroupInvitationDTO groupInvitationDTO=this.checkLinkValid(formDTO.getInvitationId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//2、校验是否已经注册居民
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							ResiGroupDTO resiGroupDTO = resiGroupService.get(groupInvitationDTO.getResiGroupId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							UserRoleDTO userRoleDTO=new UserRoleDTO(); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -319,7 +310,8 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										resiGroupDTO.getCustomerId(), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										resiGroupDTO.getGridId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if (NumConstant.ZERO_STR.equals(userRoleDTO.getRegisteredResiFlag())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									return new Result().error(EpmetErrorCode.CANNOT_JOIN_GROUP.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									logger.error(String.format("居民端用户【%s】同意邀请进组失败,错误码:%s,错误提示:%s",formDTO.getUserId(),EpmetErrorCode.CANNOT_JOIN_GROUP.getCode(),EpmetErrorCode.CANNOT_JOIN_GROUP.getMsg())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									throw new RenException(EpmetErrorCode.CANNOT_JOIN_GROUP.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//3、新增一条邀请入群、直接审核通过的入群记录
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -348,7 +340,6 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							resiGroupMemberDao.updateResiGroupStatistical(groupMemeberOperation.getGroupId(), userRoleDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//6、发送消息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							this.sendMessageToLeader(formDTO, resiGroupDTO,groupInvitationDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return new Result(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						/** | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -384,7 +375,7 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (result.success()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.info("通知群主有新成员入群成功"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.info("通知群主有新成员入群失败" + result.getMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.error("通知群主有新成员入群失败" + result.getMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return result; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |