Browse Source

修改消费消息问题

master
jianjun 5 years ago
parent
commit
9aa849fd33
  1. 4
      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. 5
      epmet-module/epmet-point/epmet-point-server/src/main/resources/bootstrap.yml

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

@ -134,3 +134,7 @@ elink:
token: @elink.mq.token@ #项目接入亿联云的应用token 相当于secret token: @elink.mq.token@ #项目接入亿联云的应用token 相当于secret
host: @elink.mq.host@ #亿联云消息网关服务地址 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); param.put("mqSubscribeList", subscribeFormDTOList);
String jsonStrParam = JSON.toJSONString(param); String jsonStrParam = JSON.toJSONString(param);
Result<String> result = HttpClientManager.getInstance().sendPostByHttps(mqServer, 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* desc: 积分相关消息回调controller * desc: 积分相关消息回调controller
* *
@ -45,11 +47,11 @@ public class MqPointCallbackController {
log.warn("activeSendPoint mqMsg is empty"); log.warn("activeSendPoint mqMsg is empty");
return "success"; return "success";
} }
SendPointFormDTO formDTO = ConvertUtils.sourceToTarget(mqMsg.getMsg(), SendPointFormDTO.class); List<SendPointFormDTO> formDTO = JSON.parseArray(mqMsg.getMsg(), SendPointFormDTO.class);
try { try {
userPointActionLogService.grantPoint(formDTO); userPointActionLogService.grantPoint(formDTO);
} catch (Exception e) { } 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()); throw new RenException(EpmetErrorCode.SERVER_ERROR.getMsg());
} }
log.info("activeSendPoint consumer success,formDTO:{}", JSON.toJSONString(formDTO)); log.info("activeSendPoint consumer success,formDTO:{}", JSON.toJSONString(formDTO));
@ -73,7 +75,7 @@ public class MqPointCallbackController {
try { try {
//TODO 调用调整积分方法去给用户加减积分 userPointActionLogService. //TODO 调用调整积分方法去给用户加减积分 userPointActionLogService.
} catch (Exception e) { } 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()); throw new RenException(EpmetErrorCode.SERVER_ERROR.getMsg());
} }
log.info("registerVolunteer consumer success,formDTO:{}", JSON.toJSONString(formDTO)); log.info("registerVolunteer consumer success,formDTO:{}", JSON.toJSONString(formDTO));
@ -97,7 +99,7 @@ public class MqPointCallbackController {
try { try {
//TODO 调用调整积分方法去给用户加减积分 userPointActionLogService. //TODO 调用调整积分方法去给用户加减积分 userPointActionLogService.
} catch (Exception e) { } 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()); throw new RenException(EpmetErrorCode.SERVER_ERROR.getMsg());
} }
log.info("pubActiveLive consumer success,formDTO:{}", JSON.toJSONString(formDTO)); 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 * @author wangc
* @date 2020.07.29 09:11 * @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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; 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.constant.NumConstant;
import com.epmet.commons.tools.enums.EventEnum; 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.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.UserPointActionLogDao; import com.epmet.dao.UserPointActionLogDao;
import com.epmet.dto.UserPointActionLogDTO; import com.epmet.dto.UserPointActionLogDTO;
import com.epmet.dto.form.CommonPageUserFormDTO; import com.epmet.dto.form.CommonPageUserFormDTO;
@ -41,10 +41,12 @@ import com.epmet.utils.ModuleConstant;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import dto.form.SendPointFormDTO; import dto.form.SendPointFormDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -55,6 +57,7 @@ import java.util.stream.Collectors;
* @author generator generator@elink-cn.com * @author generator generator@elink-cn.com
* @since v1.0.0 2020-07-20 * @since v1.0.0 2020-07-20
*/ */
@Slf4j
@Service @Service
public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActionLogDao, UserPointActionLogEntity> implements UserPointActionLogService { public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActionLogDao, UserPointActionLogEntity> implements UserPointActionLogService {
@ -147,59 +150,71 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi
/** /**
* @Description 消息网关回调进行积分发放 * @Description 消息网关回调进行积分发放
* @param grantPointParam * @param grantPointList
* @return * @return
* @author wangc * @author wangc
* @date 2020.07.29 09:11 * @date 2020.07.29 09:11
**/ **/
@Override @Override
public void grantPoint(SendPointFormDTO grantPointParam){ @Transactional(rollbackFor = Exception.class)
if(StringUtils.equals(ModuleConstant.OPERATION_TYPE_MINUS,grantPointParam.getActionFlag())){ 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{ }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.新增用户积分行为记录 //1.新增用户积分行为记录
UserPointActionLogEntity action = new UserPointActionLogEntity(); UserPointActionLogEntity action = new UserPointActionLogEntity();
action.setCustomerId(grantPointParam.getCustomerId()); action.setCustomerId(grantPoint.getCustomerId());
action.setPoint(grantPointParam.getPoint()); action.setPoint(grantPoint.getPoint());
action.setEventStatement(grantPointParam.getPointDesc()); action.setEventStatement(grantPoint.getPointDesc());
action.setEventName(EventEnum.ACTIVE_SEND_POINT.getEventDesc()); action.setEventName(EventEnum.ACTIVE_SEND_POINT.getEventDesc());
action.setEventId(EventEnum.ACTIVE_INSERT_LIVE.getEventTag()); action.setEventId(EventEnum.ACTIVE_INSERT_LIVE.getEventTag());
action.setActionFlag(grantPointParam.getActionFlag()); action.setActionFlag(grantPoint.getActionFlag());
action.setUserId(grantPointParam.getUserId()); action.setUserId(grantPoint.getUserId());
action.setCreatedBy(grantPointParam.getOperatorId()); action.setCreatedBy(grantPoint.getOperatorId());
action.setUpdatedBy(grantPointParam.getOperatorId()); action.setUpdatedBy(grantPoint.getOperatorId());
action.setSourceId(grantPointParam.getSourceId()); action.setSourceId(grantPoint.getSourceId());
action.setOperatorAgencyId(grantPointParam.getOpAgencyId()); action.setOperatorAgencyId(grantPoint.getOpAgencyId());
baseDao.insert(action); baseDao.insert(action);
//2.新增/修改用户积分日统计 //2.新增/修改用户积分日统计
DimIdGenerator.DimIdBean dimVal = DimIdGenerator.getDimIdBean(new Date()); DimIdGenerator.DimIdBean dimVal = DimIdGenerator.getDimIdBean(new Date());
UserPointStatisticalDailyEntity statistical = ConvertUtils.sourceToTarget(dimVal,UserPointStatisticalDailyEntity.class); UserPointStatisticalDailyEntity statistical = ConvertUtils.sourceToTarget(dimVal,UserPointStatisticalDailyEntity.class);
statistical.setPointChange(grantPointParam.getPoint()); statistical.setPointChange(grantPoint.getPoint());
statistical.setActionFlag(grantPointParam.getActionFlag()); statistical.setActionFlag(grantPoint.getActionFlag());
statistical.setCustomerId(grantPointParam.getCustomerId()); statistical.setCustomerId(grantPoint.getCustomerId());
statistical.setUserId(grantPointParam.getUserId()); statistical.setUserId(grantPoint.getUserId());
statistical.setCreatedBy(grantPointParam.getOperatorId()); statistical.setCreatedBy(grantPoint.getOperatorId());
statistical.setUpdatedBy(grantPointParam.getOperatorId()); statistical.setUpdatedBy(grantPoint.getOperatorId());
userPointStatisticalDailyService.insertOrUpdate(statistical); userPointStatisticalDailyService.insertOrUpdate(statistical);
//3.新增/修改用户总积分 //3.新增/修改用户总积分
UserPointTotalEntity point = new UserPointTotalEntity(); UserPointTotalEntity point = new UserPointTotalEntity();
point.setCustomerId(grantPointParam.getCustomerId()); point.setCustomerId(grantPoint.getCustomerId());
point.setUserId(grantPointParam.getUserId()); point.setUserId(grantPoint.getUserId());
point.setTotalPoint(grantPointParam.getPoint()); point.setTotalPoint(grantPoint.getPoint());
point.setUsablePoint(grantPointParam.getPoint()); point.setUsablePoint(grantPoint.getPoint());
point.setUsedPoint(NumConstant.ZERO); point.setUsedPoint(NumConstant.ZERO);
point.setCreatedBy(grantPointParam.getOperatorId()); point.setCreatedBy(grantPoint.getOperatorId());
point.setUpdatedBy(grantPointParam.getOperatorId()); point.setUpdatedBy(grantPoint.getOperatorId());
userPointTotalService.insertOrUpdate(point); userPointTotalService.insertOrUpdate(point);
} }

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

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