From 2dd2c7fd113981b356c4b0314cd04ae756289c83 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 27 Jul 2020 10:24:42 +0800 Subject: [PATCH] =?UTF-8?q?heart-work:=E7=A7=AF=E5=88=86=E5=8F=91=E6=94=BE?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B6=88=E6=81=AF=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/tools/constant/MqConstant.java | 20 ++++++ .../form/mq/eventmsg/ActPointEventMsg.java | 18 +++++ .../work/CanceledActDetailResultDTO.java | 8 +++ .../work/FinishedActDetailResultDTO.java | 7 ++ .../work/InProgressActDetailResultDTO.java | 9 +++ .../epmet/constant/ActMessageConstant.java | 2 + .../service/impl/WorkActServiceImpl.java | 68 ++++++++++++++++++- .../src/main/resources/mapper/ActInfoDao.xml | 9 ++- 8 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/MqConstant.java create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/eventmsg/ActPointEventMsg.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/MqConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/MqConstant.java new file mode 100644 index 0000000000..8ccaba98b4 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/MqConstant.java @@ -0,0 +1,20 @@ +package com.epmet.commons.tools.constant; + +/** + * 消息常亮 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/27 9:58 + */ +public interface MqConstant { + + /** + * 加分 plus + */ + String PLUS="plus"; + + /** + * 减分标识 minus + */ + String MINUS="minus"; +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/eventmsg/ActPointEventMsg.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/eventmsg/ActPointEventMsg.java new file mode 100644 index 0000000000..60db245a07 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/eventmsg/ActPointEventMsg.java @@ -0,0 +1,18 @@ +package com.epmet.commons.tools.dto.form.mq.eventmsg; + +import lombok.Data; + +/** + * 结束活动,发放活动积分消息体 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/27 9:26 + */ +@Data +public class ActPointEventMsg extends BasePointEventMsg{ + /** + * 参与活动的备注 + */ + private String remark; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActDetailResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActDetailResultDTO.java index a361a5511e..3239a78ced 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActDetailResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActDetailResultDTO.java @@ -1,6 +1,7 @@ package com.epmet.dto.result.work; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; @@ -94,6 +95,13 @@ public class CanceledActDetailResultDTO implements Serializable { * 活动详情 */ private List actContent; + /** + * true,我发布的,false,其他人发布的 + */ + private Boolean isMyPublish; + + @JsonIgnore + private String createdBy; @Override public String toString() { diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActDetailResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActDetailResultDTO.java index dceee4956d..5e9d4a991d 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActDetailResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActDetailResultDTO.java @@ -1,6 +1,7 @@ package com.epmet.dto.result.work; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; @@ -105,5 +106,11 @@ public class FinishedActDetailResultDTO implements Serializable { */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date actualEndTime; + /** + * true,我发布的,false,其他人发布的 + */ + private Boolean isMyPublish; + @JsonIgnore + private String createdBy; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActDetailResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActDetailResultDTO.java index c1c0ed4515..cc9e66a9bf 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActDetailResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActDetailResultDTO.java @@ -1,6 +1,7 @@ package com.epmet.dto.result.work; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; @@ -89,4 +90,12 @@ public class InProgressActDetailResultDTO implements Serializable { * 活动详情 */ private List actContent; + + /** + * true,我发布的,false,其他人发布的 + */ + private Boolean isMyPublish; + + @JsonIgnore + private String createdBy; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/ActMessageConstant.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/ActMessageConstant.java index b7bf8cce40..c025257c6f 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/ActMessageConstant.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/ActMessageConstant.java @@ -20,4 +20,6 @@ public interface ActMessageConstant { * 活动被取消,给已经通过审核的居民端用户,发送消息 */ String ACT_CANCELED="您报名的活动%s,已取消,原因:%s"; + + String ACT_POINTS_EVENT_REMARK="参与%s"; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java index 3c6407fb1c..98313d7d6c 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java @@ -1,8 +1,14 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.tools.constant.AppClientConstant; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.constant.MqConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.form.mq.MqBaseMsgDTO; +import com.epmet.commons.tools.dto.form.mq.eventmsg.ActPointEventMsg; +import com.epmet.commons.tools.enums.EventEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.scan.param.ImgScanParamDTO; @@ -24,6 +30,7 @@ import com.epmet.dto.result.work.*; import com.epmet.entity.ActContentEntity; import com.epmet.entity.ActInfoEntity; import com.epmet.entity.ActOperationRecEntity; +import com.epmet.entity.ActUserRelationEntity; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.service.*; @@ -566,6 +573,11 @@ public class WorkActServiceImpl implements WorkActService { CanceledActDetailResultDTO canceledActDetailResultDTO=actInfoDao.selectCanceledActInfo(actId); if(null!=canceledActDetailResultDTO){ canceledActDetailResultDTO.setActContent(actContentDao.selectByActId(actId)); + if(canceledActDetailResultDTO.getCreatedBy().equals(loginUserUtil.getLoginUserId())){ + canceledActDetailResultDTO.setIsMyPublish(true); + }else{ + canceledActDetailResultDTO.setIsMyPublish(false); + } } return canceledActDetailResultDTO; } @@ -604,6 +616,11 @@ public class WorkActServiceImpl implements WorkActService { if (null != resultDTO) { List list = actContentDao.selectByActId(formDTO.getActId()); resultDTO.setActContent(list); + if(resultDTO.getCreatedBy().equals(loginUserUtil.getLoginUserId())){ + resultDTO.setIsMyPublish(true); + }else{ + resultDTO.setIsMyPublish(false); + } } return resultDTO; } @@ -621,6 +638,11 @@ public class WorkActServiceImpl implements WorkActService { if (null != resultDTO) { List list = actContentDao.selectByActId(actId); resultDTO.setActContent(list); + if(resultDTO.getCreatedBy().equals(loginUserUtil.getLoginUserId())){ + resultDTO.setIsMyPublish(true); + }else{ + resultDTO.setIsMyPublish(false); + } } return resultDTO; } @@ -646,7 +668,51 @@ public class WorkActServiceImpl implements WorkActService { this.saveActOperationRec(actId); //生成统计表 this.saveActStatistical(actId); - //发放积分调用事件 TODO + //发放积分调用事件 + if(actInfoDTO.getReward()>0){ + this.grantActPoints(actInfoDTO); + } + } + + private void grantActPoints(ActInfoDTO actInfoDTO) { + //查询已经给分的用户 + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(actInfoDTO.getId()), FieldConstant.ID, actInfoDTO.getId()) + .eq("PROCESS_FLAG",ActConstant.HANDLED) + .eq("REWARD_FLAG",ActConstant.ACT_USER_STATUS_AGREE); + List actUserRelationEntityList=actUserRelationDao.selectList(wrapper); + if(null==actUserRelationEntityList||actUserRelationEntityList.size()<1){ + logger.info("不存在给分的记录,无需发送消息时间"); + return; + } + Result userResult=govOrgOpenFeignClient.getAgencyByStaff(loginUserUtil.getLoginUserId()); + if(!userResult.success()||null==userResult.getData()){ + logger.error(String.format("根据staffId查询所属的组织机构失败,staffId=%s",loginUserUtil.getLoginUserId())); + } + String opAgencyId=userResult.getData().getId(); + String remark=String.format(ActMessageConstant.ACT_POINTS_EVENT_REMARK,actInfoDTO.getTitle()); + MqBaseMsgDTO mqBaseMsgDTO=new MqBaseMsgDTO(); + //mq的事件类型 + mqBaseMsgDTO.setEventClass(EventEnum.ACTIVE_SEND_POINT.getEventClass()); + //事件code + mqBaseMsgDTO.setEventTag(EventEnum.ACTIVE_SEND_POINT.getEventTag()); + List actPointEventMsgList=new ArrayList<>(); + for(ActUserRelationEntity actUserRelationEntity:actUserRelationEntityList){ + ActPointEventMsg actPointEventMsg=new ActPointEventMsg(); + actPointEventMsg.setOpAgencyId(opAgencyId); + actPointEventMsg.setCustomerId(actInfoDTO.getCustomerId()); + actPointEventMsg.setUserId(actUserRelationEntity.getUserId()); + actPointEventMsg.setActionFlag(MqConstant.PLUS); + actPointEventMsg.setPoint(actInfoDTO.getReward()); + actPointEventMsg.setIsCommon(true); + actPointEventMsg.setRemark(remark); + actPointEventMsgList.add(actPointEventMsg); + } + mqBaseMsgDTO.setMsg(JSON.toJSONString(actPointEventMsgList)); + Result result=SendMqMsgUtils.sendMsg(mqBaseMsgDTO); + if(!result.success()){ + logger.error("活动积分发放失败"); + } } private void updateHeartUserInfo(ActInfoDTO actInfoDTO) { diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml index 644e5864f4..4d54cbd05e 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml @@ -597,7 +597,8 @@ ai.SPONSOR_NAME AS sponsorName, ai.REQUIREMENT AS requirement, ai.CANCEL_TIME AS cancelTime, - ai.CANCEL_REASON AS cancelReason + ai.CANCEL_REASON AS cancelReason, + ai.CREATED_BY as createdBy FROM act_info ai WHERE @@ -625,7 +626,8 @@ ai.REQUIREMENT AS requirement, AI.SUMMARY_FLAG AS summaryFlag, AI.ACTUAL_START_TIME AS actualStartTime, - AI.ACTUAL_END_TIME AS actualEndTime + AI.ACTUAL_END_TIME AS actualEndTime, + ai.CREATED_BY as createdBy FROM act_info ai WHERE @@ -649,7 +651,8 @@ ai.SPONSOR_TEL AS sponsorTel, ai.REWARD AS reward, ai.SPONSOR_NAME AS sponsorName, - ai.REQUIREMENT AS requirement + ai.REQUIREMENT AS requirement, + ai.CREATED_BY as createdBy FROM act_info ai WHERE