| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -46,6 +46,7 @@ import com.epmet.modules.member.dao.ResiGroupMemberDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.modules.member.service.GroupMemeberOperationService; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.modules.member.service.ResiGroupMemberService; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.modules.member.service.impl.ResiGroupMemberServiceImpl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.resi.group.constant.EnterGroupTypeConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.resi.group.constant.GroupStateConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.resi.group.constant.LeaderFlagConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.resi.group.constant.MemberStateConstant; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -356,7 +357,91 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @Date 2020/3/31 23:47 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						@Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public AcceptInvitationResultDTO accetInvitation(AccetInvitationFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public void accetInvitation(AccetInvitationFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//1、申请是否有效
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							GroupInvitationDTO groupInvitationDTO=this.checkLinkValid(formDTO.getInvitationId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//2、查询是否在群内
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							ResiGroupMemberDTO groupMember = resiGroupMemberDao.selectGroupMemberInfo(groupInvitationDTO.getResiGroupId(), formDTO.getUserId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (null != groupMember && !MemberStateConstant.REMOVED.equals(groupMember.getStatus())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.info("已经在群内,直接返回成功"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								return; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//3、进入小组所在的网格
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							ResiGroupDTO resiGroupDTO = resiGroupService.get(groupInvitationDTO.getResiGroupId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if(null==resiGroupDTO){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.error(String.format("用户同意邀请进组,查询组信息失败。入参:userId【%s】、invitationId【%s】、groupId【%s】。",formDTO.getUserId(),formDTO.getInvitationId(),groupInvitationDTO.getResiGroupId())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								throw new RenException(EpmetErrorCode.LOSE_EFFICACY.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							UserEnterGridFormDTO userEnterGridFormDTO=new UserEnterGridFormDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							userEnterGridFormDTO.setCustomerId(resiGroupDTO.getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							userEnterGridFormDTO.setGridId(resiGroupDTO.getGridId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							Result<UserInfoOnEnterGridResultDTO> result=resiGuideFeignClient.enterGrid(userEnterGridFormDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (!result.success() || null == result.getData()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.error(String.format("用户同意邀请进组,进入网格失败。入参:userId【%s】、invitationId【%s】、groupId【%s】、customerId【%s】、gridId【%s】", | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										formDTO.getUserId(), formDTO.getInvitationId(), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										groupInvitationDTO.getResiGroupId()), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										resiGroupDTO.getCustomerId(), resiGroupDTO.getGridId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.error(String.format("用户同意邀请进组,进入网格失败。当前接口返回8000,调用enterGrid接口返回", result.toString())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//4、校验是否已经注册居民
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if(null==result.getData().getUserRoleList()||result.getData().getUserRoleList().size()==0){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								logger.error(String.format("用户同意邀请进组失败,返回角色列表为空错误编码%s,错误提示%s",EpmetErrorCode.CANNOT_JOIN_GROUP.getCode(),EpmetErrorCode.CANNOT_JOIN_GROUP.getMsg())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								throw new RenException(EpmetErrorCode.CANNOT_JOIN_GROUP.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							UserRoleDTO userRoleDTO=this.getUserRoleDTO(result.getData().getUserRoleList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//5、新增一条邀请入群、直接审核通过的入群记录
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							GroupMemeberOperationDTO groupMemeberOperation = new GroupMemeberOperationDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							groupMemeberOperation.setGroupId(resiGroupDTO.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							groupMemeberOperation.setCustomerUserId(formDTO.getUserId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							groupMemeberOperation.setOperateStatus(MemberStateConstant.APPROVED); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							groupMemeberOperation.setEnterGroupType(EnterGroupTypeConstant.INVITED); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							groupMemeberOperation.setOperateUserId(formDTO.getUserId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							groupMemeberOperationService.accetInvitation(groupMemeberOperation); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//6、直接加入群成员关系表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//如果是之前被移除的,则修改resi_group_member记录
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							ResiGroupMemberDTO resiGroupMemberDTO = new ResiGroupMemberDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							ResiGroupMemberDTO resiGroupMember = resiGroupMemberDao.selectGroupMemberInfo(groupInvitationDTO.getResiGroupId(), formDTO.getUserId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (null != resiGroupMember) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								resiGroupMemberDTO.setId(resiGroupMember.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							resiGroupMemberDTO.setCustomerUserId(groupMemeberOperation.getCustomerUserId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							resiGroupMemberDTO.setResiGroupId(groupMemeberOperation.getGroupId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							resiGroupMemberDTO.setGroupLeaderFlag(LeaderFlagConstant.GROUP_MEMBER); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							resiGroupMemberDTO.setEnterGroupType(groupMemeberOperation.getEnterGroupType()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							resiGroupMemberDTO.setStatus(MemberStateConstant.APPROVED); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							resiGroupMemberDTO.setCreatedBy(groupMemeberOperation.getCustomerUserId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							resiGroupMemberService.saveOrUpdate(resiGroupMemberDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//7、修改群统计值
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							resiGroupMemberDao.updateResiGroupStatistical(groupMemeberOperation.getGroupId(), userRoleDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							ResiGroupInfoRedisDTO groupCache = | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									resiGroupRedis.get(groupInvitationDTO.getResiGroupId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if(null != groupCache && null != groupCache.getGroupStatisticalInfo()){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								groupCache.getGroupStatisticalInfo().setTotalMembers( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										null == groupCache.getGroupStatisticalInfo().getTotalMembers() ? NumConstant.TWO : groupCache.getGroupStatisticalInfo().getTotalMembers() +NumConstant.ONE | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if(StringUtils.equals(userRoleDTO.getPartymemberFlag(),NumConstant.ONE_STR)) groupCache.getGroupStatisticalInfo().setTotalPartyMembers( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										null == groupCache.getGroupStatisticalInfo().getTotalPartyMembers() ? NumConstant.ONE : groupCache.getGroupStatisticalInfo().getTotalPartyMembers()+NumConstant.ONE | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if(StringUtils.equals(userRoleDTO.getRegisteredResiFlag(),NumConstant.ONE_STR)) groupCache.getGroupStatisticalInfo().setTotalNormalMembers( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										null == groupCache.getGroupStatisticalInfo().getTotalNormalMembers() ? NumConstant.TWO : groupCache.getGroupStatisticalInfo().getTotalNormalMembers()+NumConstant.ONE | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if(StringUtils.equals(userRoleDTO.getWarmHeartedFlag(),NumConstant.ONE_STR)) groupCache.getGroupStatisticalInfo().setTotalEarnestMembers( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										null == groupCache.getGroupStatisticalInfo().getTotalEarnestMembers() ? NumConstant.ONE : groupCache.getGroupStatisticalInfo().getTotalEarnestMembers()+NumConstant.ONE | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								resiGroupRedis.set(groupCache); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//8、发送消息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							this.sendMessageToLeader(formDTO, resiGroupDTO,groupInvitationDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						/** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @param formDTO | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @Author sun | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @Description 邀请链接或扫码进组 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						@Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public AcceptInvitationResultDTO accetInvitationV2(AccetInvitationFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							AcceptInvitationResultDTO resultDTO = new AcceptInvitationResultDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//1、申请是否有效
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							GroupInvitationDTO groupInvitationDTO=this.checkLinkValid(formDTO.getInvitationId()); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |