diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml index 72477fb20d..c6e70a0bc3 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml +++ b/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@ #发送消息路径 \ No newline at end of file + sendMsgPath: @elink.mq.sendMsgPath@ #发送消息路径 +dingTalk: + robot: + webHook: @dingTalk.robot.webHook@ + secret: @dingTalk.robot.secret@ diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/MqSubcribeConfig.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/MqSubcribeConfig.java index d8e6ceac75..0a9c628604 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/MqSubcribeConfig.java +++ b/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 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)); } } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/MqPointCallbackController.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/MqPointCallbackController.java index 7f32946939..1de8982e48 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/MqPointCallbackController.java +++ b/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 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)); 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 81873314f7..8498b04eb7 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 @@ -112,6 +112,6 @@ public interface UserPointActionLogService extends BaseService grantPointParam); } \ No newline at end of file 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 83200db0ff..fa05c63f37 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 @@ -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 implements UserPointActionLogService { @@ -147,59 +150,71 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl 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); } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-point/epmet-point-server/src/main/resources/bootstrap.yml index 06e24d34cc..bf7eb31f91 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/resources/bootstrap.yml +++ b/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 \ No newline at end of file + reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1 + +dingTalk: + robot: + webHook: @dingTalk.robot.webHook@ + secret: @dingTalk.robot.secret@ \ No newline at end of file