Browse Source

修改消费消息问题

master
jianjun 5 years ago
parent
commit
9aa849fd33
  1. 6
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml
  2. 2
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/MqSubcribeConfig.java
  3. 10
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/MqPointCallbackController.java
  4. 2
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointActionLogService.java
  5. 73
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointActionLogServiceImpl.java
  6. 7
      epmet-module/epmet-point/epmet-point-server/src/main/resources/bootstrap.yml

6
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml

@ -133,4 +133,8 @@ elink:
appId: @elink.mq.appId@ #项目接入亿联云的应用Id
token: @elink.mq.token@ #项目接入亿联云的应用token 相当于secret
host: @elink.mq.host@ #亿联云消息网关服务地址
sendMsgPath: @elink.mq.sendMsgPath@ #发送消息路径
sendMsgPath: @elink.mq.sendMsgPath@ #发送消息路径
dingTalk:
robot:
webHook: @dingTalk.robot.webHook@
secret: @dingTalk.robot.secret@

2
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/MqSubcribeConfig.java

@ -40,6 +40,6 @@ public class MqSubcribeConfig {
param.put("mqSubscribeList", subscribeFormDTOList);
String jsonStrParam = JSON.toJSONString(param);
Result<String> result = HttpClientManager.getInstance().sendPostByHttps(mqServer, JSON.toJSONString(param));
logger.error("subscriber==jsonStrParam:{}=====result:{}" ,jsonStrParam, JSON.toJSONString(result));
logger.info("subscriber==jsonStrParam:{}=====result:{}" ,jsonStrParam, JSON.toJSONString(result));
}
}

10
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/MqPointCallbackController.java

@ -17,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* desc: 积分相关消息回调controller
*
@ -45,11 +47,11 @@ public class MqPointCallbackController {
log.warn("activeSendPoint mqMsg is empty");
return "success";
}
SendPointFormDTO formDTO = ConvertUtils.sourceToTarget(mqMsg.getMsg(), SendPointFormDTO.class);
List<SendPointFormDTO> formDTO = JSON.parseArray(mqMsg.getMsg(), SendPointFormDTO.class);
try {
userPointActionLogService.grantPoint(formDTO);
} catch (Exception e) {
logger.error("activeSendPoint consume fail,msg:{}",JSON.toJSONString(mqMsg.getMsg()));
logger.error("activeSendPoint consume fail", e);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getMsg());
}
log.info("activeSendPoint consumer success,formDTO:{}", JSON.toJSONString(formDTO));
@ -73,7 +75,7 @@ public class MqPointCallbackController {
try {
//TODO 调用调整积分方法去给用户加减积分 userPointActionLogService.
} catch (Exception e) {
logger.error("registerVolunteer consume fail,msg:{}",JSON.toJSONString(mqMsg.getMsg()));
logger.error("registerVolunteer consume fail", e);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getMsg());
}
log.info("registerVolunteer consumer success,formDTO:{}", JSON.toJSONString(formDTO));
@ -97,7 +99,7 @@ public class MqPointCallbackController {
try {
//TODO 调用调整积分方法去给用户加减积分 userPointActionLogService.
} catch (Exception e) {
logger.error("pubActiveLive consume fail,msg:{}",JSON.toJSONString(mqMsg.getMsg()));
logger.error("pubActiveLive consume fail", e);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getMsg());
}
log.info("pubActiveLive consumer success,formDTO:{}", JSON.toJSONString(formDTO));

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

@ -112,6 +112,6 @@ public interface UserPointActionLogService extends BaseService<UserPointActionLo
* @author wangc
* @date 2020.07.29 09:11
**/
void grantPoint(SendPointFormDTO grantPointParam);
void grantPoint(List<SendPointFormDTO> grantPointParam);
}

73
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointActionLogServiceImpl.java

@ -20,11 +20,11 @@ package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.EventEnum;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.UserPointActionLogDao;
import com.epmet.dto.UserPointActionLogDTO;
import com.epmet.dto.form.CommonPageUserFormDTO;
@ -41,10 +41,12 @@ import com.epmet.utils.ModuleConstant;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Maps;
import dto.form.SendPointFormDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
@ -55,6 +57,7 @@ import java.util.stream.Collectors;
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-07-20
*/
@Slf4j
@Service
public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActionLogDao, UserPointActionLogEntity> implements UserPointActionLogService {
@ -147,59 +150,71 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi
/**
* @Description 消息网关回调进行积分发放
* @param grantPointParam
* @param grantPointList
* @return
* @author wangc
* @date 2020.07.29 09:11
**/
@Override
public void grantPoint(SendPointFormDTO grantPointParam){
if(StringUtils.equals(ModuleConstant.OPERATION_TYPE_MINUS,grantPointParam.getActionFlag())){
@Transactional(rollbackFor = Exception.class)
public void grantPoint(List<SendPointFormDTO> grantPointList){
if (CollectionUtils.isEmpty(grantPointList)){
log.warn("grantPoint param is empty");
return;
}
grantPointList.forEach(grantPoint->{
plusPoint(grantPoint);
});
}
private void plusPoint(SendPointFormDTO grantPoint) {
if(StringUtils.equals(ModuleConstant.OPERATION_TYPE_MINUS,grantPoint.getActionFlag())){
//减
if(grantPointParam.getPoint() > NumConstant.ZERO){
if(grantPoint.getPoint() > NumConstant.ZERO){
//保证负数
grantPointParam.setPoint(grantPointParam.getPoint() * NumConstant.ONE_NEG);
grantPoint.setPoint(grantPoint.getPoint() * NumConstant.ONE_NEG);
}
}else{
//加
if(grantPointParam.getPoint() < NumConstant.ZERO){
if(grantPoint.getPoint() < NumConstant.ZERO){
//保证正数
grantPointParam.setPoint(grantPointParam.getPoint() * NumConstant.ONE_NEG);
grantPoint.setPoint(grantPoint.getPoint() * NumConstant.ONE_NEG);
}
}
//1.新增用户积分行为记录
UserPointActionLogEntity action = new UserPointActionLogEntity();
action.setCustomerId(grantPointParam.getCustomerId());
action.setPoint(grantPointParam.getPoint());
action.setEventStatement(grantPointParam.getPointDesc());
action.setCustomerId(grantPoint.getCustomerId());
action.setPoint(grantPoint.getPoint());
action.setEventStatement(grantPoint.getPointDesc());
action.setEventName(EventEnum.ACTIVE_SEND_POINT.getEventDesc());
action.setEventId(EventEnum.ACTIVE_INSERT_LIVE.getEventTag());
action.setActionFlag(grantPointParam.getActionFlag());
action.setUserId(grantPointParam.getUserId());
action.setCreatedBy(grantPointParam.getOperatorId());
action.setUpdatedBy(grantPointParam.getOperatorId());
action.setSourceId(grantPointParam.getSourceId());
action.setOperatorAgencyId(grantPointParam.getOpAgencyId());
action.setActionFlag(grantPoint.getActionFlag());
action.setUserId(grantPoint.getUserId());
action.setCreatedBy(grantPoint.getOperatorId());
action.setUpdatedBy(grantPoint.getOperatorId());
action.setSourceId(grantPoint.getSourceId());
action.setOperatorAgencyId(grantPoint.getOpAgencyId());
baseDao.insert(action);
//2.新增/修改用户积分日统计
DimIdGenerator.DimIdBean dimVal = DimIdGenerator.getDimIdBean(new Date());
UserPointStatisticalDailyEntity statistical = ConvertUtils.sourceToTarget(dimVal,UserPointStatisticalDailyEntity.class);
statistical.setPointChange(grantPointParam.getPoint());
statistical.setActionFlag(grantPointParam.getActionFlag());
statistical.setCustomerId(grantPointParam.getCustomerId());
statistical.setUserId(grantPointParam.getUserId());
statistical.setCreatedBy(grantPointParam.getOperatorId());
statistical.setUpdatedBy(grantPointParam.getOperatorId());
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(grantPointParam.getCustomerId());
point.setUserId(grantPointParam.getUserId());
point.setTotalPoint(grantPointParam.getPoint());
point.setUsablePoint(grantPointParam.getPoint());
point.setCustomerId(grantPoint.getCustomerId());
point.setUserId(grantPoint.getUserId());
point.setTotalPoint(grantPoint.getPoint());
point.setUsablePoint(grantPoint.getPoint());
point.setUsedPoint(NumConstant.ZERO);
point.setCreatedBy(grantPointParam.getOperatorId());
point.setUpdatedBy(grantPointParam.getOperatorId());
point.setCreatedBy(grantPoint.getOperatorId());
point.setUpdatedBy(grantPoint.getOperatorId());
userPointTotalService.insertOrUpdate(point);
}

7
epmet-module/epmet-point/epmet-point-server/src/main/resources/bootstrap.yml

@ -116,4 +116,9 @@ ribbon:
#pageHelper分页插件
pagehelper:
helper-dialect: mysql
reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1
reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1
dingTalk:
robot:
webHook: @dingTalk.robot.webHook@
secret: @dingTalk.robot.secret@
Loading…
Cancel
Save