|
|
@ -19,6 +19,7 @@ package com.epmet.modules.act.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
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.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
@ -33,8 +34,11 @@ import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.utils.ScanContentUtils; |
|
|
|
import com.epmet.constant.ReadFlagConstant; |
|
|
|
import com.epmet.dto.form.UserMessageFormDTO; |
|
|
|
import com.epmet.dto.result.GridInfoResultDTO; |
|
|
|
import com.epmet.dto.result.UserBaseInfoResultDTO; |
|
|
|
import com.epmet.feign.EpmetMessageOpenFeignClient; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.modules.act.dao.ActOperationRecordDao; |
|
|
@ -49,16 +53,17 @@ import com.epmet.modules.act.service.ActCategoryDictService; |
|
|
|
import com.epmet.modules.act.service.ActSignInRecordService; |
|
|
|
import com.epmet.modules.act.service.GroupActInfoService; |
|
|
|
import com.epmet.modules.constant.GroupActConstant; |
|
|
|
import com.epmet.modules.constant.UserMessageConstant; |
|
|
|
import com.epmet.modules.group.service.ResiGroupService; |
|
|
|
import com.epmet.modules.invitation.service.InvitationRecordService; |
|
|
|
import com.epmet.modules.member.service.ResiGroupMemberService; |
|
|
|
import com.epmet.resi.group.dto.act.GroupActIdDTO; |
|
|
|
import com.epmet.resi.group.dto.act.GroupActInfoDTO; |
|
|
|
import com.epmet.resi.group.dto.act.form.ActDetailFormDTO; |
|
|
|
import com.epmet.resi.group.dto.act.form.ActReadViewFormDTO; |
|
|
|
import com.epmet.resi.group.dto.act.form.CancelActFormDTO; |
|
|
|
import com.epmet.resi.group.dto.act.form.PublishGroupActFormDTO; |
|
|
|
import com.epmet.resi.group.dto.act.form.*; |
|
|
|
import com.epmet.resi.group.dto.act.result.ActDetailByLinkResultDTO; |
|
|
|
import com.epmet.resi.group.dto.act.result.ActDetailResultDTO; |
|
|
|
import com.epmet.resi.group.dto.group.ResiGroupDTO; |
|
|
|
import com.epmet.resi.group.dto.invitation.InvitationRecordDTO; |
|
|
|
import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; |
|
|
|
import com.epmet.resi.group.dto.notice.result.NoticeReadListResultDTO; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -108,6 +113,11 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private ActSignInRecordService actSignInRecordService; |
|
|
|
@Autowired |
|
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private InvitationRecordService invitationRecordService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 003、发布(编辑)组织活动 |
|
|
|
* |
|
|
@ -145,11 +155,13 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr |
|
|
|
//构造活动内容表
|
|
|
|
List<GroupActContentEntity> contentList = constructText(groupActInfoEntity.getId(), formDTO.getCustomerId(), formDTO.getTextList()); |
|
|
|
List<GroupActContentEntity> imgList = constructImg(groupActInfoEntity.getId(), formDTO.getCustomerId(), formDTO.getImgList()); |
|
|
|
List<ResiGroupMemberDTO> memberDTOList=resiGroupMemberService.getMemberList(formDTO.getGroupId()); |
|
|
|
List<ActReadRecordEntity> readRecordEntityList=constructReadRec(groupActInfoEntity.getId(), |
|
|
|
formDTO.getCustomerId(), |
|
|
|
formDTO.getGroupId(), |
|
|
|
formDTO.getPublishUserId(), |
|
|
|
groupDTO.getGridId()); |
|
|
|
groupDTO.getGridId(), |
|
|
|
memberDTOList); |
|
|
|
//2、插入活动内容
|
|
|
|
contentList.forEach(textContentEntity->{ |
|
|
|
groupActContentDao.insert(textContentEntity); |
|
|
@ -163,14 +175,44 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr |
|
|
|
readRecordEntityList.forEach(readRecordEntity->{ |
|
|
|
actReadRecordDao.insert(readRecordEntity); |
|
|
|
}); |
|
|
|
//5、发送站内信
|
|
|
|
sendMessage(memberDTOList,formDTO,groupActInfoEntity,groupDTO); |
|
|
|
|
|
|
|
result.setGroupActId(groupActInfoEntity.getId()); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private List<ActReadRecordEntity> constructReadRec(String groupActId, String customerId, String groupId,String publishUserId,String gridId) { |
|
|
|
private void sendMessage(List<ResiGroupMemberDTO> memberDTOList, PublishGroupActFormDTO formDTO, GroupActInfoEntity groupActInfoEntity,ResiGroupDTO resiGroupDTO) { |
|
|
|
|
|
|
|
List<UserMessageFormDTO> list = new ArrayList<>(); |
|
|
|
memberDTOList.forEach(memberDTO -> { |
|
|
|
//不需要给当前操作人发送
|
|
|
|
if (!formDTO.getPublishUserId().equals(memberDTO.getCustomerUserId())) { |
|
|
|
UserMessageFormDTO userMessageFormDTO = new UserMessageFormDTO(); |
|
|
|
userMessageFormDTO.setCustomerId(formDTO.getCustomerId()); |
|
|
|
userMessageFormDTO.setUserId(memberDTO.getCustomerUserId()); |
|
|
|
userMessageFormDTO.setGridId(resiGroupDTO.getGridId()); |
|
|
|
userMessageFormDTO.setApp(AppClientConstant.APP_RESI); |
|
|
|
userMessageFormDTO.setTitle(UserMessageConstant.GROUP_TITLE); |
|
|
|
userMessageFormDTO.setReadFlag(ReadFlagConstant.UN_READ); |
|
|
|
if(StringUtils.isNotBlank(formDTO.getGroupActId())){ |
|
|
|
// 活动修改后,站内信通知全组成员“您有一条小组消息 【某某小组】更新了********活动详情,请查看。
|
|
|
|
userMessageFormDTO.setMessageContent(String.format(UserMessageConstant.CHANGED_GROUP_ACT, resiGroupDTO.getGroupName(), groupActInfoEntity.getTitle())); |
|
|
|
}else{ |
|
|
|
// 活动发布,站内信通知全组成员“您有一条小组消息 【某某小组】发布了*******活动,请查看。
|
|
|
|
userMessageFormDTO.setMessageContent(String.format(UserMessageConstant.PUBLISH_GROUP_ACT, resiGroupDTO.getGroupName(), groupActInfoEntity.getTitle())); |
|
|
|
} |
|
|
|
list.add(userMessageFormDTO); |
|
|
|
} |
|
|
|
}); |
|
|
|
Result sendMessageRes = epmetMessageOpenFeignClient.saveUserMessageList(list); |
|
|
|
if (!sendMessageRes.success()) { |
|
|
|
log.warn("发布(编辑)组织活动,发送站内信异常"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private List<ActReadRecordEntity> constructReadRec(String groupActId, String customerId, String groupId,String publishUserId,String gridId,List<ResiGroupMemberDTO> memberDTOList) { |
|
|
|
List<ActReadRecordEntity> list=new ArrayList<>(); |
|
|
|
List<ResiGroupMemberDTO> memberDTOList=resiGroupMemberService.getMemberList(groupId); |
|
|
|
memberDTOList.forEach(memberDTO->{ |
|
|
|
ActReadRecordEntity actReadRecordEntity=new ActReadRecordEntity(); |
|
|
|
actReadRecordEntity.setCustomerId(customerId); |
|
|
@ -376,6 +418,10 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr |
|
|
|
@Override |
|
|
|
public ActDetailResultDTO queryActDetail(ActDetailFormDTO formDTO) { |
|
|
|
GroupActInfoEntity groupActInfoEntity=baseDao.selectById(formDTO.getGroupActId()); |
|
|
|
if(null==groupActInfoEntity){ |
|
|
|
throw new RenException(String.format("根据groupActId:%s,查询活动信息为null",formDTO.getGroupActId())); |
|
|
|
} |
|
|
|
//当前内容仅允许组内成员查看
|
|
|
|
ResiGroupMemberDTO resiGroupMemberDTO=resiGroupMemberService.getResiGroupMember(groupActInfoEntity.getGroupId(),formDTO.getUserId()); |
|
|
|
if(null==resiGroupMemberDTO){ |
|
|
|
throw new RenException(EpmetErrorCode.NOT_IN_GROUP_CAN_NOT_VIEW.getCode(), EpmetErrorCode.NOT_IN_GROUP_CAN_NOT_VIEW.getMsg()); |
|
|
@ -385,7 +431,9 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr |
|
|
|
resultDTO.setTextList(groupActContentDao.selectContentList(formDTO.getGroupActId(),GroupActConstant.TEXT)); |
|
|
|
resultDTO.setImgList(groupActContentDao.selectContentList(formDTO.getGroupActId(),GroupActConstant.IMG)); |
|
|
|
resultDTO.setCanceledReason(GroupActConstant.CANCELED.equals(resultDTO.getStatus()) ? actOperationRecordDao.selectCanceledReason(formDTO.getGroupActId()) : StrConstant.EPMETY_STR); |
|
|
|
|
|
|
|
handleSignInDesc(resultDTO,formDTO.getUserId()); |
|
|
|
|
|
|
|
resultDTO.setUserRole(resiGroupMemberDTO.getGroupLeaderFlag()); |
|
|
|
// 有签到后不可以修改活动时间:true可以修改,false不可以,
|
|
|
|
resultDTO.setStartTimeEditFlag(groupActInfoEntity.getSignedInNum()>NumConstant.ZERO?false:true); |
|
|
@ -589,12 +637,40 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr |
|
|
|
actOperationRecordEntity.setNote(formDTO.getReason()); |
|
|
|
actOperationRecordDao.insert(actOperationRecordEntity); |
|
|
|
|
|
|
|
baseDao.updateById(actInfoEntity); |
|
|
|
//6、发送站内信
|
|
|
|
sendUserMessageForCancelAct(actInfoEntity,formDTO.getUserId()); |
|
|
|
|
|
|
|
GroupActIdDTO resultDTO=new GroupActIdDTO(); |
|
|
|
resultDTO.setGroupActId(formDTO.getGroupActId()); |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
private void sendUserMessageForCancelAct(GroupActInfoEntity actInfoEntity,String currentUserId) { |
|
|
|
ResiGroupDTO resiGroupDTO = resiGroupService.get(actInfoEntity.getGroupId()); |
|
|
|
if (null != resiGroupDTO) { |
|
|
|
List<ResiGroupMemberDTO> memberDTOList = resiGroupMemberService.getMemberList(actInfoEntity.getGroupId()); |
|
|
|
List<UserMessageFormDTO> list = new ArrayList<>(); |
|
|
|
memberDTOList.forEach(memberDTO -> { |
|
|
|
//不需要给当前操作人发送
|
|
|
|
if (!currentUserId.equals(memberDTO.getCustomerUserId())) { |
|
|
|
UserMessageFormDTO userMessageFormDTO = new UserMessageFormDTO(); |
|
|
|
userMessageFormDTO.setCustomerId(actInfoEntity.getCustomerId()); |
|
|
|
userMessageFormDTO.setUserId(memberDTO.getCustomerUserId()); |
|
|
|
userMessageFormDTO.setGridId(actInfoEntity.getGridId()); |
|
|
|
userMessageFormDTO.setApp(AppClientConstant.APP_RESI); |
|
|
|
userMessageFormDTO.setTitle(UserMessageConstant.GROUP_TITLE); |
|
|
|
userMessageFormDTO.setReadFlag(ReadFlagConstant.UN_READ); |
|
|
|
userMessageFormDTO.setMessageContent(String.format(UserMessageConstant.CANCEL_GROUP_ACT, resiGroupDTO.getGroupName(), actInfoEntity.getTitle())); |
|
|
|
list.add(userMessageFormDTO); |
|
|
|
} |
|
|
|
}); |
|
|
|
Result sendMessageRes = epmetMessageOpenFeignClient.saveUserMessageList(list); |
|
|
|
if (!sendMessageRes.success()) { |
|
|
|
log.warn("发布(编辑)组织活动,发送站内信异常"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询活动主信息 |
|
|
|
* |
|
|
@ -605,4 +681,28 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl<GroupActInfoDao, Gr |
|
|
|
public GroupActInfoDTO getGroupActInfoDTO(String groupActId) { |
|
|
|
return ConvertUtils.sourceToTarget(baseDao.selectById(groupActId), GroupActInfoDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 015、点击分享链接,查看活动详情 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return com.epmet.resi.group.dto.act.result.ActDetailByLinkResultDTO |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public ActDetailByLinkResultDTO queryActDetailByLink(ActDetailByLinkFormDTO formDTO) { |
|
|
|
InvitationRecordDTO invitationRecordDTO = invitationRecordService.get(formDTO.getInvitationRecordId()); |
|
|
|
if (null == invitationRecordDTO) { |
|
|
|
log.warn("invitation_record is null invitationRecordId=" + formDTO.getInvitationRecordId()); |
|
|
|
throw new RenException(EpmetErrorCode.INVITATION_NOT_EXIST.getCode(), EpmetErrorCode.INVITATION_NOT_EXIST.getMsg()); |
|
|
|
} |
|
|
|
ActDetailFormDTO actDetailFormDTO = new ActDetailFormDTO(); |
|
|
|
actDetailFormDTO.setUserId(formDTO.getUserId()); |
|
|
|
actDetailFormDTO.setGroupActId(invitationRecordDTO.getSourceId()); |
|
|
|
//调用查看活动详情接口
|
|
|
|
ActDetailResultDTO actDetailResultDTO = queryActDetail(actDetailFormDTO); |
|
|
|
|
|
|
|
ActDetailByLinkResultDTO resultDTO = ConvertUtils.sourceToTarget(actDetailResultDTO, ActDetailByLinkResultDTO.class); |
|
|
|
resultDTO.setInvitationRecordId(formDTO.getInvitationRecordId()); |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
} |