From 2523e7ffb36b335d438738fd10a7dc216f668ca7 Mon Sep 17 00:00:00 2001 From: zhangyongzhangyong <2012005003@qq.coom> Date: Mon, 27 Jul 2020 13:38:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=88=B1=E5=BF=83=E4=BA=92=E5=8A=A9-=E5=B1=85?= =?UTF-8?q?=E6=B0=91=E7=AB=AF-=E5=A2=9E=E5=8A=A0=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/enums/EventEnum.java | 1 + .../form/resi/ResiActInsertLiveFormDTO.java | 6 +++ .../dto/form/resi/ResiActSignInFormDTO.java | 6 +++ .../epmet/constant/ActMessageConstant.java | 10 +++++ .../service/impl/ActLiveRecServiceImpl.java | 36 ++++++++++++++++ .../impl/ActUserRelationServiceImpl.java | 2 +- .../impl/VolunteerInfoServiceImpl.java | 43 ++++++++++++++++++- .../com/epmet/utils/ValidityVerification.java | 2 +- .../src/main/resources/mapper/ActInfoDao.xml | 17 +++++--- 9 files changed, 112 insertions(+), 11 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EventEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EventEnum.java index e1fc5cf810..68347c29f9 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EventEnum.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EventEnum.java @@ -9,6 +9,7 @@ package com.epmet.commons.tools.enums; public enum EventEnum { ACTIVE_SEND_POINT("active_send_point", "epmet_heart", "活动发放积分"), REGISTER_VOLUNTEER("register_volunteer", "epmet_heart", "认证志愿者"), + ACTIVE_INSERT_LIVE("active_insert_live", "epmet_heart", "添加活动实况"), ; private String eventClass; diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActInsertLiveFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActInsertLiveFormDTO.java index 42ee3576fe..54182f0da3 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActInsertLiveFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActInsertLiveFormDTO.java @@ -95,4 +95,10 @@ public class ResiActInsertLiveFormDTO implements Serializable { * id */ private String id; + + /** + * 客户id + */ + @NotBlank(message = "客户id不能为空", groups = {AddUserShowGroup.class }) + private String customerId; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActSignInFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActSignInFormDTO.java index 54363137f7..69c1486c7f 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActSignInFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActSignInFormDTO.java @@ -96,4 +96,10 @@ public class ResiActSignInFormDTO implements Serializable { * 用户id */ private String userId; + + /** + * 客户id + */ + @NotBlank(message = "客户id不能为空", groups = {AddUserShowGroup.class }) + private String customerId; } 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 c025257c6f..ac8ba13bfc 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 @@ -22,4 +22,14 @@ public interface ActMessageConstant { String ACT_CANCELED="您报名的活动%s,已取消,原因:%s"; String ACT_POINTS_EVENT_REMARK="参与%s"; + + /** + * 居民端-用户认证志愿者,发送消息 + */ + String POINTS_EVENT_VOLUNTEER_AUTHENTICATE="用户%s,认证志愿者"; + + /** + * 居民端-添加实况,发送消息 + */ + String ACT_POINTS_EVENT_VOLUNTEER_LIVE="用户%s,添加活动实况,活动:%s"; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActLiveRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActLiveRecServiceImpl.java index 45e15e53e6..1eb66ab5f8 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActLiveRecServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActLiveRecServiceImpl.java @@ -17,10 +17,17 @@ package com.epmet.service.impl; +import com.alibaba.fastjson.JSON; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.MqConstant; import com.epmet.commons.tools.constant.NumConstant; +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.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.SendMqMsgUtils; +import com.epmet.constant.ActMessageConstant; import com.epmet.dao.ActLivePicDao; import com.epmet.dao.ActLiveRecDao; import com.epmet.dto.ActLivePicDTO; @@ -34,6 +41,8 @@ import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.redis.ActLiveRecRedis; import com.epmet.service.ActLiveRecService; import com.epmet.utils.ValidityVerification; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -48,6 +57,7 @@ import java.util.*; */ @Service public class ActLiveRecServiceImpl extends BaseServiceImpl implements ActLiveRecService { + private Logger logger = LogManager.getLogger(VolunteerInfoServiceImpl.class); @Autowired private ActLiveRecRedis actLiveRecRedis; @@ -121,6 +131,32 @@ public class ActLiveRecServiceImpl extends BaseServiceImpl().ok(uuid); } + + private void grantActPoints(ResiActInsertLiveFormDTO formDTO){ + //备注 + String remark=String.format(ActMessageConstant.ACT_POINTS_EVENT_VOLUNTEER_LIVE,formDTO.getUserId(),formDTO.getActId()); + MqBaseMsgDTO mqBaseMsgDTO=new MqBaseMsgDTO(); + //mq的事件类型 + mqBaseMsgDTO.setEventClass(EventEnum.ACTIVE_INSERT_LIVE.getEventClass()); + //事件code + mqBaseMsgDTO.setEventTag(EventEnum.ACTIVE_INSERT_LIVE.getEventTag()); + List actPointEventMsgList=new ArrayList<>(); + ActPointEventMsg actPointEventMsg=new ActPointEventMsg(); + actPointEventMsg.setCustomerId(formDTO.getCustomerId()); + actPointEventMsg.setUserId(formDTO.getUserId()); + actPointEventMsg.setActionFlag(MqConstant.PLUS); + actPointEventMsg.setIsCommon(false); + actPointEventMsg.setRemark(remark); + actPointEventMsgList.add(actPointEventMsg); + + mqBaseMsgDTO.setMsg(JSON.toJSONString(actPointEventMsgList)); + Result result= SendMqMsgUtils.sendMsg(mqBaseMsgDTO); + if(!result.success()){ + logger.error("添加活动实况,事件发送失败"); + } + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java index 53bc8a11f0..dbdb98eee5 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java @@ -202,7 +202,7 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl0 当前用户是志愿者 - Integer volunteerFlag = volunteerInfoDao.queryVolunteerFlagByUserId(formDTO.getActId()); + Integer volunteerFlag = volunteerInfoDao.queryVolunteerFlagByUserId(formDTO.getUserId()); if (actInfoDTO.getVolunteerLimit()){ // 活动只能志愿者参加, 当前用户是否满足条件 satisfy = this.volunteerParticipationAct(volunteerFlag); diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java index 3429acbb2f..182da8e261 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java @@ -17,24 +17,37 @@ package com.epmet.service.impl; +import com.alibaba.fastjson.JSON; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.MqConstant; import com.epmet.commons.tools.constant.NumConstant; +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.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.SendMqMsgUtils; +import com.epmet.constant.ActMessageConstant; import com.epmet.dao.VolunteerInfoDao; import com.epmet.dto.HeartUserInfoDTO; import com.epmet.dto.form.WxUserInfoFormDTO; import com.epmet.dto.form.resi.ResiVolunteerAuthenticateFormDTO; +import com.epmet.entity.ActUserRelationEntity; import com.epmet.entity.VolunteerInfoEntity; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.redis.VolunteerInfoRedis; import com.epmet.service.HeartUserInfoService; import com.epmet.service.VolunteerInfoService; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.List; + /** * 志愿者信息 * @@ -43,6 +56,7 @@ import org.springframework.transaction.annotation.Transactional; */ @Service public class VolunteerInfoServiceImpl extends BaseServiceImpl implements VolunteerInfoService { + private Logger logger = LogManager.getLogger(VolunteerInfoServiceImpl.class); @Autowired private VolunteerInfoRedis volunteerInfoRedis; @@ -66,17 +80,42 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl actPointEventMsgList=new ArrayList<>(); + ActPointEventMsg actPointEventMsg=new ActPointEventMsg(); + actPointEventMsg.setCustomerId(formDTO.getCustomerId()); + actPointEventMsg.setUserId(formDTO.getUserId()); + actPointEventMsg.setActionFlag(MqConstant.PLUS); + actPointEventMsg.setIsCommon(false); + actPointEventMsg.setRemark(remark); + actPointEventMsgList.add(actPointEventMsg); + + mqBaseMsgDTO.setMsg(JSON.toJSONString(actPointEventMsgList)); + Result result= SendMqMsgUtils.sendMsg(mqBaseMsgDTO); + if(!result.success()){ + logger.error("志愿者认证事件发送失败"); + } + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/utils/ValidityVerification.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/utils/ValidityVerification.java index 48deaa99b9..4bb60ab49f 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/utils/ValidityVerification.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/utils/ValidityVerification.java @@ -71,7 +71,7 @@ public class ValidityVerification { * @Date 14:42 2020-07-15 **/ public void imgScanVerification(List imgList, String businessEnum){ - if (NumConstant.ZERO != imgList.size()){ + if (null != imgList && NumConstant.ZERO != imgList.size()){ ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); imgList.forEach(url -> { ImgTaskDTO task = new ImgTaskDTO(); 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 4d54cbd05e..784972957b 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 @@ -66,9 +66,10 @@ IF(u.USER_ID = #{userId},'signed_up','no_signed_up') as signupFlag FROM act_info i LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' - LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID + LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' AND (re.`STATUS` = 'auditing' OR re.`STATUS` = 'passed') GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID WHERE i.DEL_FLAG = '0' AND i.ACT_STATUS = 'published' + AND = ]]> NOW() -- 报名截止时间 >= 当前时间 AND (i.ACT_QUOTA_CATEGORY = 0 OR i.ACT_QUOTA > IFNULL(c.signupNum, 0)) -- 不限名额或者报名人数未报满 AND i.CUSTOMER_ID = #{customerId} ORDER BY i.ACT_QUOTA_CATEGORY DESC,i.CREATED_TIME DESC @@ -91,9 +92,10 @@ IF(u.USER_ID = #{userId},'signed_up','no_signed_up') as signupFlag FROM act_info i LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' - LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID + LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' AND (re.`STATUS` = 'auditing' OR re.`STATUS` = 'passed') GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID WHERE i.DEL_FLAG = '0' AND i.ACT_STATUS = 'published' + AND = ]]> NOW() -- 报名截止时间 >= 当前时间 AND i.ACT_QUOTA_CATEGORY = 1 -- 固定名额 AND i.ACT_QUOTA = IFNULL(c.signupNum, 0) -- 名额已满 AND i.CUSTOMER_ID = #{customerId} @@ -117,7 +119,7 @@ IF(u.USER_ID = #{userId},'signed_up','no_signed_up') as signupFlag FROM act_info i LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' - LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID + LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' AND (re.`STATUS` = 'auditing' OR re.`STATUS` = 'passed') GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID WHERE i.DEL_FLAG = '0' -- 活动开始时间 > 当前时间 并且 报名截止时间 < 当前时间 报名已结束,活动未开始 未开始 AND ( ]]> NOW() AND NOW() ) @@ -143,10 +145,10 @@ IF(u.USER_ID = #{userId},'1','0') as signupFlag -- 用户报名状态(0-未报名,1已报名) FROM act_info i LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' - LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID + LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' AND re.`STATUS` = 'passed' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID WHERE i.DEL_FLAG = '0' -- 活动开始时间 <= 当前时间 并且活动结束时间 >= 当前时间 进行中 - AND ( NOW() AND = ]]> NOW() ) + AND ( NOW() AND = ]]> NOW() ) AND i.ACT_STATUS != 'canceled' AND i.CUSTOMER_ID = #{customerId} ORDER BY i.CREATED_TIME DESC @@ -169,9 +171,10 @@ IF(u.USER_ID = #{userId},'1','0') as signupFlag -- 用户报名状态(0-未报名,1已报名) FROM act_info i LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' - LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID + LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' AND re.`STATUS` = 'passed' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID WHERE i.DEL_FLAG = '0' - AND i.ACT_STATUS = 'finished' + AND i.ACT_STATUS != 'canceled' + AND NOW() AND i.CUSTOMER_ID = #{customerId} ORDER BY i.CREATED_TIME DESC LIMIT #{pageNo}, #{pageSize}