yinzuomei 4 years ago
parent
commit
4e0650ceee
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/MqConstant.java
  2. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/eventmsg/BasePointEventMsg.java
  3. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EventEnum.java
  4. 7
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/FinishResultDTO.java
  5. 2
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/UserDemandConstant.java
  6. 26
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java
  7. 27
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiDemandController.java
  8. 13
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java
  9. 1
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/mq/RocketMQConsumerRegister.java
  10. 17
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/mq/listener/PointListener.java
  11. 6
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointActionLogService.java
  12. 65
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointActionLogServiceImpl.java

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/MqConstant.java

@ -17,4 +17,6 @@ public interface MqConstant {
* 减分标识 minus * 减分标识 minus
*/ */
String MINUS="minus"; String MINUS="minus";
String SOURCE_TYPE_DEMAND="demand";
} }

2
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 eventTag;
private String eventClass; private String eventClass;
private String objectId;
private String eventName;
} }

1
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","转话题为议题(将自建小组中话题转为议题)"), SHIFT_TOPIC_TO_ISSUE("shift_topic_to_issue","resi_group","转话题为议题(将自建小组中话题转为议题)"),
TOPIC_SHIFTED_TO_PROJECT("topic_to_project","resi_group","话题被转为项目"), TOPIC_SHIFTED_TO_PROJECT("topic_to_project","resi_group","话题被转为项目"),
LEADER_RESOLVE_TOPIC("leader_resolve_topic","resi_group","组长解决组内话题"), LEADER_RESOLVE_TOPIC("leader_resolve_topic","resi_group","组长解决组内话题"),
FINISH_USER_DEMAND("finish_user_demand","community_service","服务完成"),
; ;
private String eventClass; private String eventClass;

7
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时才发放积分 * 奖励积分只有服务方是志愿者且积分大于0时才发放积分
*/ */
private Integer awardPoint; private Integer awardPoint;
/**
* 完成了XXX的需求
*/
private String remark;
private String firstCategoryName;
private String categoryCode;
} }

2
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_PUBLISHER="publisher";
String DEMAND_SERVER="server"; String DEMAND_SERVER="server";
String GRANT_POINT_REMARK="完成了%s的需求";
} }

26
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.rocketmq.messages.ServerSatisfactionCalFormDTO;
import com.epmet.commons.tools.annotation.LoginUser; 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.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.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ExcelUtils; 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 org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -200,8 +204,28 @@ public class IcUserDemandRecController {
form.setContent(mqMsg); form.setContent(mqMsg);
epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); epmetMessageOpenFeignClient.sendSystemMsgByMQ(form);
} else if (UserDemandConstant.VOLUNTEER.equals(finishResultDTO.getServiceType()) && finishResultDTO.getAwardPoint() > NumConstant.ZERO) { } else if (UserDemandConstant.VOLUNTEER.equals(finishResultDTO.getServiceType()) && finishResultDTO.getAwardPoint() > NumConstant.ZERO) {
// todo
// 志愿者发放积分 // 志愿者发放积分
List<BasePointEventMsg> 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(); return new Result();
} }

27
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.rocketmq.messages.ServerSatisfactionCalFormDTO;
import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit; 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.constant.NumConstant;
import com.epmet.commons.tools.dto.form.PageFormDTO; 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.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -131,9 +135,28 @@ public class ResiDemandController {
form.setContent(mqMsg); form.setContent(mqMsg);
epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); epmetMessageOpenFeignClient.sendSystemMsgByMQ(form);
} else if (UserDemandConstant.VOLUNTEER.equals(finishResultDTO.getServiceType()) && finishResultDTO.getAwardPoint() > NumConstant.ZERO) { } else if (UserDemandConstant.VOLUNTEER.equals(finishResultDTO.getServiceType()) && finishResultDTO.getAwardPoint() > NumConstant.ZERO) {
// todo
// 志愿者发放积分 // 志愿者发放积分
List<BasePointEventMsg> 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(); return new Result();
} }

13
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<IcUserDemandRecD
finishResultDTO.setServerId(serviceEntity.getServerId()); finishResultDTO.setServerId(serviceEntity.getServerId());
finishResultDTO.setServiceType(serviceEntity.getServiceType()); finishResultDTO.setServiceType(serviceEntity.getServiceType());
finishResultDTO.setAwardPoint(entity.getAwardPoint()); finishResultDTO.setAwardPoint(entity.getAwardPoint());
finishResultDTO.setCategoryCode(entity.getCategoryCode());
if(StringUtils.isBlank(entity.getParentCode())||NumConstant.ZERO_STR.equals(entity.getParentCode())){
finishResultDTO.setFirstCategoryName(demandDictService.getCategoryName(entity.getCustomerId(),entity.getCategoryCode()));
}else{
finishResultDTO.setFirstCategoryName(demandDictService.getCategoryName(entity.getCustomerId(),entity.getParentCode()));
}
finishResultDTO.setRemark(String.format(UserDemandConstant.GRANT_POINT_REMARK,entity.getDemandUserName()));
// 5、如果是居民端用户提出的需求,发消息:您提出的需求已完成,请进行服务评价。 // 5、如果是居民端用户提出的需求,发消息:您提出的需求已完成,请进行服务评价。
sendDemandUserFinished(entity); sendDemandUserFinished(entity);
return finishResultDTO; return finishResultDTO;
@ -1073,6 +1080,12 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl<IcUserDemandRecD
finishResultDTO.setServerId(serviceEntity.getServerId()); finishResultDTO.setServerId(serviceEntity.getServerId());
finishResultDTO.setServiceType(serviceEntity.getServiceType()); finishResultDTO.setServiceType(serviceEntity.getServiceType());
finishResultDTO.setAwardPoint(entity.getAwardPoint()); finishResultDTO.setAwardPoint(entity.getAwardPoint());
if(StringUtils.isBlank(entity.getParentCode())||NumConstant.ZERO_STR.equals(entity.getParentCode())){
finishResultDTO.setFirstCategoryName(demandDictService.getCategoryName(entity.getCustomerId(),entity.getCategoryCode()));
}else{
finishResultDTO.setFirstCategoryName(demandDictService.getCategoryName(entity.getCustomerId(),entity.getParentCode()));
}
finishResultDTO.setRemark(String.format(UserDemandConstant.GRANT_POINT_REMARK,entity.getDemandUserName()));
//5、我的需求-评价:如果服务方是志愿者,通知它: 您收到来自XXX(需求人姓名)的评价,请查看。 //5、我的需求-评价:如果服务方是志愿者,通知它: 您收到来自XXX(需求人姓名)的评价,请查看。
sendVolunnterEvaluated(entity); sendVolunnterEvaluated(entity);
return finishResultDTO; return finishResultDTO;

1
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/mq/RocketMQConsumerRegister.java

@ -21,6 +21,7 @@ public class RocketMQConsumerRegister extends MQAbstractRegister {
// 客户初始化监听器注册 // 客户初始化监听器注册
register(consumerProperties, ConsomerGroupConstants.RESI_GROUP_POINT_OPERATION_GROUP, MessageModel.CLUSTERING, TopicConstants.RESI_GROUP, "*", new PointListener(userPointActionLogService)); register(consumerProperties, ConsomerGroupConstants.RESI_GROUP_POINT_OPERATION_GROUP, MessageModel.CLUSTERING, TopicConstants.RESI_GROUP, "*", new PointListener(userPointActionLogService));
register(consumerProperties, ConsomerGroupConstants.EPMET_HEART_POINT_OPERATION_GROUP, MessageModel.CLUSTERING, TopicConstants.EPMET_HEART, "*", new PointListener(userPointActionLogService)); register(consumerProperties, ConsomerGroupConstants.EPMET_HEART_POINT_OPERATION_GROUP, MessageModel.CLUSTERING, TopicConstants.EPMET_HEART, "*", new PointListener(userPointActionLogService));
register(consumerProperties, ConsomerGroupConstants.COMMUNITY_SERVICE_POINT_OPERATION_GROUP, MessageModel.CLUSTERING, TopicConstants.COMMUNITY_SERVICE, "*", new PointListener(userPointActionLogService));
// ...其他监听器类似 // ...其他监听器类似
} }

17
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/mq/listener/PointListener.java

@ -2,16 +2,13 @@ package com.epmet.mq.listener;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.epmet.commons.rocketmq.constants.MQUserPropertys; import com.epmet.commons.rocketmq.constants.MQUserPropertys;
import com.epmet.commons.rocketmq.messages.LoginMQMsg;
import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.dto.form.mq.eventmsg.BasePointEventMsg; import com.epmet.commons.tools.dto.form.mq.eventmsg.BasePointEventMsg;
import com.epmet.commons.tools.enums.EventEnum; import com.epmet.commons.tools.enums.EventEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.commons.tools.utils.SpringContextUtils;
import com.epmet.constant.SystemMessageType; import com.epmet.constant.SystemMessageType;
import com.epmet.service.UserPointActionLogService; import com.epmet.service.UserPointActionLogService;
@ -23,8 +20,6 @@ import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.common.message.MessageExt; import org.apache.rocketmq.common.message.MessageExt;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -114,6 +109,10 @@ public class PointListener implements MessageListenerConcurrently {
case SystemMessageType.LEADER_RESOLVE_TOPIC: case SystemMessageType.LEADER_RESOLVE_TOPIC:
leaderResolveTopic(msg); leaderResolveTopic(msg);
break; break;
case SystemMessageType.FINISH_USER_DEMAND:
//给需求服务方(志愿者)发放积分
grantServerPoint(msg);
break;
} }
} catch (RenException e) { } catch (RenException e) {
@ -219,6 +218,14 @@ public class PointListener implements MessageListenerConcurrently {
}); });
} }
/**
* 需求完成给志愿者发放积分
* @param msg
*/
private void grantServerPoint(String msg) {
List<BasePointEventMsg> formDTO = JSON.parseArray(msg, BasePointEventMsg.class);
userPointActionLogService.grantServerPoint(formDTO);
}
/** /**
* @description * @description

6
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointActionLogService.java

@ -119,6 +119,12 @@ public interface UserPointActionLogService extends BaseService<UserPointActionLo
**/ **/
void grantPoint(List<SendPointFormDTO> grantPointParam); void grantPoint(List<SendPointFormDTO> grantPointParam);
/**
* 需求完成-志愿者发放积分
* @param grantPointParam
*/
void grantServerPoint(List<BasePointEventMsg> grantPointParam);
/** /**
* @Description 通过事件推送进行积分加减 * @Description 通过事件推送进行积分加减
* @param event * @param event

65
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<UserPointActi
formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectPageResiPoin(formDTO)); formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectPageResiPoin(formDTO));
return new PageData<>(pageInfo.getList(), pageInfo.getTotal()); return new PageData<>(pageInfo.getList(), pageInfo.getTotal());
} }
/**
* 需求完成给志愿者发放积分
* @param list
*/
@Override
public void grantServerPoint(List<BasePointEventMsg> 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);
});
}
} }
Loading…
Cancel
Save