|
|
@ -1,9 +1,6 @@ |
|
|
|
package com.epmet.modules.group.service.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
|
import com.epmet.commons.tools.constant.Constant; |
|
|
|
import com.epmet.commons.tools.constant.EpmetRoleKeyConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.*; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dto.form.UserRoleFormDTO; |
|
|
@ -23,13 +20,18 @@ import com.epmet.modules.member.dao.ExitGroupRecordDao; |
|
|
|
import com.epmet.modules.member.dao.GroupMemeberOperationDao; |
|
|
|
import com.epmet.modules.member.dao.ResiGroupMemberDao; |
|
|
|
import com.epmet.modules.member.entity.ExitGroupRecordEntity; |
|
|
|
import com.epmet.modules.member.service.GroupMemeberOperationService; |
|
|
|
import com.epmet.modules.member.service.ResiGroupMemberService; |
|
|
|
import com.epmet.modules.topic.dao.ResiTopicCommentDao; |
|
|
|
import com.epmet.modules.topic.dao.ResiTopicDao; |
|
|
|
import com.epmet.modules.topic.entity.ResiTopicOperationEntity; |
|
|
|
import com.epmet.modules.topic.service.ResiTopicOperationService; |
|
|
|
import com.epmet.modules.utils.ModuleConstant; |
|
|
|
import com.epmet.resi.group.constant.TopicConstant; |
|
|
|
import com.epmet.resi.group.dto.group.form.ExitGroupFormDTO; |
|
|
|
import com.epmet.resi.group.dto.group.form.MemExitGroupFormDTO; |
|
|
|
import com.epmet.resi.group.dto.member.GroupMemeberOperationDTO; |
|
|
|
import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -37,6 +39,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -72,6 +75,10 @@ public class ExitGroupServiceImpl implements ExitGroupService { |
|
|
|
private ResiGroupDao resiGroupDao; |
|
|
|
@Autowired |
|
|
|
private GroupMessageDao groupMessageDao; |
|
|
|
@Autowired |
|
|
|
private ResiGroupMemberService resiGroupMemberService; |
|
|
|
@Autowired |
|
|
|
private GroupMemeberOperationService groupMemeberOperationService; |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
@ -205,4 +212,89 @@ public class ExitGroupServiceImpl implements ExitGroupService { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 组员退出小组 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public void memExitGroup(MemExitGroupFormDTO formDTO) { |
|
|
|
//1、当前组员是否还在群里?
|
|
|
|
ResiGroupMemberDTO resiGroupMemberDTO=resiGroupMemberDao.selectGroupMemberInfo(formDTO.getGroupId(),formDTO.getUserId()); |
|
|
|
if(null == resiGroupMemberDTO){ |
|
|
|
throw new RenException("已退出当前小组,请勿重复操作"); |
|
|
|
} |
|
|
|
//2、组长不允许退群,提示:请先转移组长身份后再退组
|
|
|
|
if(ModuleConstant.GROUP_LEADER.equals(resiGroupMemberDTO.getGroupLeaderFlag())){ |
|
|
|
//改成错误码
|
|
|
|
throw new RenException("请先转移组长身份后再退组"); |
|
|
|
} |
|
|
|
//3.修改组成员出入群记录表数据状态、删除组成员关系表数据、新增退群记录表数据
|
|
|
|
//3.1.修改组成员出入群记录表数据状态 group_memeber_operation
|
|
|
|
// TODO ???
|
|
|
|
GroupMemeberOperationDTO lastRec=groupMemeberOperationService.selectLatestRecord(formDTO.getGroupId(),formDTO.getUserId()); |
|
|
|
GroupMemeberOperationDTO operationDTO = new GroupMemeberOperationDTO(); |
|
|
|
operationDTO.setCustomerId(formDTO.getCustomerId()); |
|
|
|
operationDTO.setCustomerUserId(formDTO.getUserId()); |
|
|
|
operationDTO.setGroupId(formDTO.getGroupId()); |
|
|
|
operationDTO.setOperateUserId(formDTO.getUserId()); |
|
|
|
operationDTO.setOperateStatus("exit"); |
|
|
|
operationDTO.setEnterGroupType(null != lastRec ? lastRec.getEnterGroupType() : StrConstant.EPMETY_STR); |
|
|
|
groupMemeberOperationService.save(operationDTO); |
|
|
|
|
|
|
|
//3.2.删除组成员关系表数据并修改状态 resi_group_member
|
|
|
|
resiGroupMemberDTO.setStatus("exit"); |
|
|
|
resiGroupMemberDTO.setUpdatedBy(formDTO.getUserId()); |
|
|
|
resiGroupMemberDTO.setDelFlag(NumConstant.ONE_STR); |
|
|
|
resiGroupMemberDTO.setUpdatedTime(new Date()); |
|
|
|
resiGroupMemberService.update(resiGroupMemberDTO); |
|
|
|
|
|
|
|
//3.3.新增退群记录表数据 exit_group_record
|
|
|
|
ExitGroupRecordEntity entity = new ExitGroupRecordEntity(); |
|
|
|
entity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
entity.setGroupId(formDTO.getGroupId()); |
|
|
|
entity.setMemberUserId(formDTO.getUserId()); |
|
|
|
//默认不 屏蔽他的话题及评论
|
|
|
|
entity.setShieldFlag(Constant.NO); |
|
|
|
//0:组长移除; 1:自主退群
|
|
|
|
entity.setLeaveType(NumConstant.ONE_STR); |
|
|
|
exitGroupRecordDao.insert(entity); |
|
|
|
|
|
|
|
//4.群组统计表修改数据
|
|
|
|
//4.1.获取被删人员当前网格居民端角色信息
|
|
|
|
ResiGroupEntity groupEntity = resiGroupDao.selectById(formDTO.getGroupId()); |
|
|
|
UserRoleFormDTO dto = new UserRoleFormDTO(); |
|
|
|
dto.setApp(AppClientConstant.APP_RESI); |
|
|
|
dto.setUserId(formDTO.getUserId()); |
|
|
|
dto.setCustomerId(formDTO.getCustomerId()); |
|
|
|
dto.setGridId(groupEntity.getGridId()); |
|
|
|
Result<List<UserRoleResultDTO>> resultUser = epmetUserOpenFeignClient.getUserRoleInfo(dto); |
|
|
|
if (!resultUser.success()) { |
|
|
|
throw new RenException(resultUser.getInternalMsg()); |
|
|
|
} |
|
|
|
List<UserRoleResultDTO> roleList = resultUser.getData(); |
|
|
|
//4.2.群组统计表数据修改,缓存数据修改
|
|
|
|
ResiGroupStatisticalEntity statisticalEntity = resiGroupStatisticalDao.selectByResiGroupId(formDTO.getGroupId()); |
|
|
|
if (null == statisticalEntity) { |
|
|
|
throw new RenException("未查询到群组统计数据,删除失败"); |
|
|
|
} |
|
|
|
statisticalEntity.setTotalMembers(statisticalEntity.getTotalMembers() - 1); |
|
|
|
statisticalEntity.setTotalNormalMemebers(statisticalEntity.getTotalNormalMemebers() - 1); |
|
|
|
roleList.forEach(r -> { |
|
|
|
if (EpmetRoleKeyConstant.PARTYMEMBER.equals(r.getRoleKey())) {//党员总数减一
|
|
|
|
statisticalEntity.setTotalPartyMembers(statisticalEntity.getTotalPartyMembers() - 1); |
|
|
|
} |
|
|
|
if (EpmetRoleKeyConstant.WARMHEARTED.equals(r.getRoleKey())) {//热心居民总数减一
|
|
|
|
statisticalEntity.setTotalEarnestMemebers(statisticalEntity.getTotalEarnestMemebers() - 1); |
|
|
|
} |
|
|
|
}); |
|
|
|
resiGroupStatisticalDao.updateById(statisticalEntity); |
|
|
|
|
|
|
|
resiGroupRedis.delGroup(formDTO.getGroupId()); |
|
|
|
|
|
|
|
resiGroupRedis.get(formDTO.getGroupId()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|