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 index 8ccaba98b4..8d458c4a60 100644 --- 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 @@ -17,4 +17,6 @@ public interface MqConstant { * 减分标识 minus */ String MINUS="minus"; + + String SOURCE_TYPE_DEMAND="demand"; } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/eventmsg/BasePointEventMsg.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/eventmsg/BasePointEventMsg.java index 9235fe77a7..ff2849d331 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/eventmsg/BasePointEventMsg.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/eventmsg/BasePointEventMsg.java @@ -92,4 +92,6 @@ public class BasePointEventMsg implements Serializable { private String eventTag; private String eventClass; + private String objectId; + private String eventName; } 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 44d229ec3b..3cccd74d7a 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 @@ -18,6 +18,7 @@ public enum EventEnum { SHIFT_TOPIC_TO_ISSUE("shift_topic_to_issue","resi_group","转话题为议题(将自建小组中话题转为议题)"), TOPIC_SHIFTED_TO_PROJECT("topic_to_project","resi_group","话题被转为项目"), LEADER_RESOLVE_TOPIC("leader_resolve_topic","resi_group","组长解决组内话题"), + FINISH_USER_DEMAND("finish_user_demand","community_service","服务完成"), ; private String eventClass; diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/FinishResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/FinishResultDTO.java index fb0ac6327a..53ae15ba01 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/FinishResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/FinishResultDTO.java @@ -21,4 +21,11 @@ public class FinishResultDTO implements Serializable { * 奖励积分:只有服务方是志愿者且积分大于0时,才发放积分 */ private Integer awardPoint; + + /** + * 完成了XXX的需求 + */ + private String remark; + private String firstCategoryName; + private String categoryCode; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/UserDemandConstant.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/UserDemandConstant.java index 9b4cf5ee00..4a78599455 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/UserDemandConstant.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/UserDemandConstant.java @@ -76,4 +76,6 @@ public interface UserDemandConstant { String DEMAND_PUBLISHER="publisher"; String DEMAND_SERVER="server"; + + String GRANT_POINT_REMARK="完成了%s的需求"; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java index 97e013eafc..2aec455511 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java @@ -19,7 +19,10 @@ package com.epmet.controller; import com.epmet.commons.rocketmq.messages.ServerSatisfactionCalFormDTO; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.constant.MqConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.form.mq.eventmsg.BasePointEventMsg; +import com.epmet.commons.tools.enums.EventEnum; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ExcelUtils; @@ -41,6 +44,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; import java.util.List; @@ -200,8 +204,28 @@ public class IcUserDemandRecController { form.setContent(mqMsg); epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); } else if (UserDemandConstant.VOLUNTEER.equals(finishResultDTO.getServiceType()) && finishResultDTO.getAwardPoint() > NumConstant.ZERO) { - // todo // 志愿者发放积分 + List actPointEventMsgList = new ArrayList<>(); + BasePointEventMsg actPointEventMsg = new BasePointEventMsg(); + actPointEventMsg.setCustomerId(formDTO.getCustomerId()); + actPointEventMsg.setSourceType(MqConstant.SOURCE_TYPE_DEMAND); + actPointEventMsg.setSourceId(formDTO.getDemandRecId()); + actPointEventMsg.setUserId(finishResultDTO.getServerId()); + actPointEventMsg.setActionFlag(MqConstant.PLUS); + actPointEventMsg.setIsCommon(false); + actPointEventMsg.setRemark(finishResultDTO.getRemark()); + actPointEventMsg.setEventTag(EventEnum.FINISH_USER_DEMAND.getEventTag()); + actPointEventMsg.setEventClass(EventEnum.FINISH_USER_DEMAND.getEventClass()); + actPointEventMsg.setEventName(finishResultDTO.getFirstCategoryName()); + actPointEventMsg.setObjectId(finishResultDTO.getCategoryCode()); + actPointEventMsgList.add(actPointEventMsg); + SystemMsgFormDTO sendMsgForm = new SystemMsgFormDTO(); + sendMsgForm.setContent(actPointEventMsgList); + sendMsgForm.setMessageType(SystemMessageType.FINISH_USER_DEMAND); + Result mqResult = epmetMessageOpenFeignClient.sendSystemMsgByMQ(sendMsgForm); + if (!mqResult.success()) { + log.error(String.format("demandRecId:%s,给志愿者发放积分失败", formDTO.getDemandRecId())); + } } return new Result(); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiDemandController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiDemandController.java index 1cc774248f..f870444ee9 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiDemandController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiDemandController.java @@ -4,8 +4,11 @@ package com.epmet.controller; import com.epmet.commons.rocketmq.messages.ServerSatisfactionCalFormDTO; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.constant.MqConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.epmet.commons.tools.dto.form.mq.eventmsg.BasePointEventMsg; +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.validator.ValidatorUtils; @@ -24,6 +27,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; import java.util.List; @@ -131,9 +135,28 @@ public class ResiDemandController { form.setContent(mqMsg); epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); } else if (UserDemandConstant.VOLUNTEER.equals(finishResultDTO.getServiceType()) && finishResultDTO.getAwardPoint() > NumConstant.ZERO) { - // todo // 志愿者发放积分 - + List actPointEventMsgList = new ArrayList<>(); + BasePointEventMsg actPointEventMsg = new BasePointEventMsg(); + actPointEventMsg.setCustomerId(formDTO.getCustomerId()); + actPointEventMsg.setSourceType(MqConstant.SOURCE_TYPE_DEMAND); + actPointEventMsg.setSourceId(formDTO.getDemandRecId()); + actPointEventMsg.setUserId(finishResultDTO.getServerId()); + actPointEventMsg.setActionFlag(MqConstant.PLUS); + actPointEventMsg.setIsCommon(false); + actPointEventMsg.setRemark(finishResultDTO.getRemark()); + actPointEventMsg.setEventTag(EventEnum.FINISH_USER_DEMAND.getEventTag()); + actPointEventMsg.setEventClass(EventEnum.FINISH_USER_DEMAND.getEventClass()); + actPointEventMsg.setEventName(finishResultDTO.getFirstCategoryName()); + actPointEventMsg.setObjectId(finishResultDTO.getCategoryCode()); + actPointEventMsgList.add(actPointEventMsg); + SystemMsgFormDTO sendMsgForm = new SystemMsgFormDTO(); + sendMsgForm.setContent(actPointEventMsgList); + sendMsgForm.setMessageType(SystemMessageType.FINISH_USER_DEMAND); + Result mqResult = epmetMessageOpenFeignClient.sendSystemMsgByMQ(sendMsgForm); + if (!mqResult.success()) { + log.error(String.format("需求评价完成:demandRecId:%s,给志愿者发放积分失败", formDTO.getDemandRecId())); + } } return new Result(); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java index 8d17d2f3c7..2233765ddc 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java @@ -451,6 +451,13 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl formDTO = JSON.parseArray(msg, BasePointEventMsg.class); + userPointActionLogService.grantServerPoint(formDTO); + } /** * @description diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointActionLogService.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointActionLogService.java index b156816c80..360edcb9cb 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointActionLogService.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointActionLogService.java @@ -119,6 +119,12 @@ public interface UserPointActionLogService extends BaseService grantPointParam); + /** + * 需求完成-志愿者发放积分 + * @param grantPointParam + */ + void grantServerPoint(List grantPointParam); + /** * @Description 通过事件推送进行积分加减 * @param event diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointActionLogServiceImpl.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointActionLogServiceImpl.java index 45bbb65790..4ede07c03d 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointActionLogServiceImpl.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointActionLogServiceImpl.java @@ -578,4 +578,69 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl baseDao.selectPageResiPoin(formDTO)); return new PageData<>(pageInfo.getList(), pageInfo.getTotal()); } + + /** + * 需求完成,给志愿者发放积分 + * @param list + */ + @Override + public void grantServerPoint(List list){ + if (CollectionUtils.isEmpty(list)){ + return; + } + list.forEach(grantPoint->{ + if(StringUtils.equals(ModuleConstant.OPERATION_TYPE_MINUS,grantPoint.getActionFlag())){ + //减 + if(grantPoint.getPoint() > NumConstant.ZERO){ + //保证负数 + grantPoint.setPoint(grantPoint.getPoint() * NumConstant.ONE_NEG); + } + }else{ + //加 + if(grantPoint.getPoint() < NumConstant.ZERO){ + //保证正数 + grantPoint.setPoint(grantPoint.getPoint() * NumConstant.ONE_NEG); + } + } + //1.新增用户积分行为记录 + UserPointActionLogEntity action = new UserPointActionLogEntity(); + action.setCustomerId(grantPoint.getCustomerId()); + action.setPoint(grantPoint.getPoint()); + //完成了XXX的需求 + action.setEventStatement(grantPoint.getRemark()); + //需求分类表中一级分类的名称 + action.setEventId(EventEnum.FINISH_USER_DEMAND.getEventTag()); + action.setActionFlag(grantPoint.getActionFlag()); + action.setUserId(grantPoint.getUserId()); + action.setCreatedBy(grantPoint.getOperatorId()); + action.setUpdatedBy(grantPoint.getOperatorId()); + action.setSourceType(grantPoint.getSourceType()); + action.setSourceId(grantPoint.getSourceId()); + // 需求所属分类编码,对应objectId + action.setObjectId(grantPoint.getObjectId()); + //需求所属分类-一级分类名称 + action.setEventName(grantPoint.getEventName()); + baseDao.insert(action); + //2.新增/修改用户积分日统计 + DimIdGenerator.DimIdBean dimVal = DimIdGenerator.getDimIdBean(new Date()); + UserPointStatisticalDailyEntity statistical = ConvertUtils.sourceToTarget(dimVal,UserPointStatisticalDailyEntity.class); + statistical.setPointChange(grantPoint.getPoint()); + statistical.setActionFlag(grantPoint.getActionFlag()); + statistical.setCustomerId(grantPoint.getCustomerId()); + statistical.setUserId(grantPoint.getUserId()); + statistical.setCreatedBy(grantPoint.getOperatorId()); + statistical.setUpdatedBy(grantPoint.getOperatorId()); + userPointStatisticalDailyService.insertOrUpdate(statistical); + //3.新增/修改用户积分日统计 + UserPointTotalEntity point = new UserPointTotalEntity(); + point.setCustomerId(grantPoint.getCustomerId()); + point.setUserId(grantPoint.getUserId()); + point.setTotalPoint(grantPoint.getPoint()); + point.setUsablePoint(grantPoint.getPoint()); + point.setUsedPoint(NumConstant.ZERO); + point.setCreatedBy(grantPoint.getOperatorId()); + point.setUpdatedBy(grantPoint.getOperatorId()); + userPointTotalService.insertOrUpdate(point); + }); + } } \ No newline at end of file