Browse Source

Merge branch 'dev_group_point' into dev_temp

master
zhaoqifeng 4 years ago
parent
commit
32b7eea80e
  1. 27
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/BizTypeEnum.java
  2. 30
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/SourceTypeEnum.java
  3. 10
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/UserPointActionLogDTO.java
  4. 10
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/UserPointActionLogEntity.java
  5. 6
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointUserTotalDetailServiceImpl.java
  6. 61
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointActionLogServiceImpl.java

27
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/BizTypeEnum.java

@ -0,0 +1,27 @@
package com.epmet.commons.tools.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author zhaoqifeng
* @dscription
* @date 2021/4/25 15:49
*/
@Getter
@AllArgsConstructor
public enum BizTypeEnum {
//枚举类型
GROUP("group", "小组"),
ACTIVITY("activity", "活动");
/**
* 类型
*/
private String type;
/**
* 描述
*/
private String typeDesc;
}

30
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/SourceTypeEnum.java

@ -0,0 +1,30 @@
package com.epmet.commons.tools.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author zhaoqifeng
* @dscription
* @date 2021/4/25 16:23
*/
@Getter
@AllArgsConstructor
public enum SourceTypeEnum {
//枚举类型
ACTIVITY("activity", "活动"),
TOPIC("topic", "话题"),
ISSUE("issue", "议题"),
PROJECT("project", "项目"),
INVITE("invite", "邀请进组"),
VOLUNTEER("volunteer", "志愿者");
/**
* 类型
*/
private String type;
/**
* 描述
*/
private String typeDesc;
}

10
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/UserPointActionLogDTO.java

@ -53,6 +53,16 @@ public class UserPointActionLogDTO implements Serializable {
*/
private String actionFlag;
/**
* 业务类型小组group
*/
private String bizType;
/**
* 业务类型的对象id
*/
private String objectId;
private String sourceType;
/**

10
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/entity/UserPointActionLogEntity.java

@ -58,6 +58,16 @@ public class UserPointActionLogEntity extends BaseEpmetEntity {
*/
private String eventId;
/**
* 业务类型小组group
*/
private String bizType;
/**
* 业务类型的对象id
*/
private String objectId;
private String sourceType;
/**

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

@ -21,6 +21,8 @@ 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.NumConstant;
import com.epmet.commons.tools.enums.BizTypeEnum;
import com.epmet.commons.tools.enums.EventEnum;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
@ -158,6 +160,10 @@ public class BizPointUserTotalDetailServiceImpl extends BaseServiceImpl<BizPoint
return entity.getTotalPoint();
}
public static void main(String[] args) {
System.out.println(BizTypeEnum.ACTIVITY.getType());
}
/**
* 小组积分贡献榜
*

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

@ -37,10 +37,7 @@ import com.epmet.dto.UserPointActionLogDTO;
import com.epmet.dto.form.CommonPageUserFormDTO;
import com.epmet.dto.result.ResiPointLogListResultDTO;
import com.epmet.dto.result.ResiPointLogPeriodResultDTO;
import com.epmet.entity.PointRuleEntity;
import com.epmet.entity.UserPointActionLogEntity;
import com.epmet.entity.UserPointStatisticalDailyEntity;
import com.epmet.entity.UserPointTotalEntity;
import com.epmet.entity.*;
import com.epmet.service.*;
import com.epmet.utils.DimIdGenerator;
import com.epmet.utils.ModuleConstant;
@ -326,6 +323,13 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi
action.setSourceType(event.getSourceType());
action.setSourceId(event.getSourceId());
action.setOperatorAgencyId(event.getOpAgencyId());
if (("resi_group").equals(event.getEventClass())) {
action.setBizType("group");
action.setObjectId(event.getGroupId());
} else {
action.setBizType("activity");
action.setObjectId(event.getSourceId());
}
baseDao.insert(action);
//2.新增/修改用户积分日统计
DimIdGenerator.DimIdBean dimVal = DimIdGenerator.getDimIdBean(new Date());
@ -355,6 +359,7 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi
//个人小组积分
BizPointUserTotalDetailDTO userTotalDetailDTO = bizPointUserTotalDetailService.getDataByObject("group", event.getGroupId(),
event.getUserId());
Integer userTotal = getUserTotalByObject("group", event.getGroupId(), event.getUserId());
if (null == userTotalDetailDTO) {
userTotalDetailDTO = new BizPointUserTotalDetailDTO();
userTotalDetailDTO.setCustomerId(event.getCustomerId());
@ -363,17 +368,17 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi
userTotalDetailDTO.setUserId(event.getUserId());
userTotalDetailDTO.setBizType("group");
userTotalDetailDTO.setObjectId(event.getGroupId());
userTotalDetailDTO.setTotalPoint(ruleInfo.getPoint());
userTotalDetailDTO.setTotalPoint(userTotal);
bizPointUserTotalDetailService.save(userTotalDetailDTO);
} else {
userTotalDetailDTO.setTotalPoint(userTotalDetailDTO.getTotalPoint() + ruleInfo.getPoint());
userTotalDetailDTO.setTotalPoint(userTotal);
userTotalDetailDTO.setUpdatedTime(new Date());
bizPointUserTotalDetailService.update(userTotalDetailDTO);
}
//小组总积分
BizPointTotalDetailDTO totalDetailDTO = bizPointTotalDetailService.getDataByObject("group", event.getGroupId());
Integer total = bizPointUserTotalDetailService.getTotalByObject("group", event.getGroupId());
Integer total = getTotalByObject("group", event.getGroupId());
if (null == totalDetailDTO) {
totalDetailDTO = new BizPointTotalDetailDTO();
totalDetailDTO.setCustomerId(event.getCustomerId());
@ -451,4 +456,46 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi
point.setUpdatedBy(grantPoint.getOperatorId());
userPointTotalService.insertOrUpdate(point);
}
private Integer getTotalByObject(String type, String objectId) {
QueryWrapper<UserPointActionLogEntity> wrapper = new QueryWrapper<>();
wrapper.select("IFNULL(SUM(POINT), 0) as POINT")
.eq("BIZ_TYPE", type)
.eq("OBJECT_ID", objectId)
.eq("ACTION_FLAG", "plus")
.eq("DEL_FLAG", NumConstant.ZERO_STR);
UserPointActionLogEntity entity1 = baseDao.selectOne(wrapper);
int plusTotal = null == entity1? NumConstant.ZERO : entity1.getPoint();
wrapper = new QueryWrapper<>();
wrapper.select("IFNULL(SUM(POINT), 0) as POINT")
.eq("BIZ_TYPE", type)
.eq("OBJECT_ID", objectId)
.eq("ACTION_FLAG", "minus")
.eq("DEL_FLAG", NumConstant.ZERO_STR);
UserPointActionLogEntity entity2 = baseDao.selectOne(wrapper);
int minusTotal = null == entity2? NumConstant.ZERO : entity2.getPoint();
return plusTotal - minusTotal;
}
private Integer getUserTotalByObject(String type, String objectId, String userId) {
QueryWrapper<UserPointActionLogEntity> wrapper = new QueryWrapper<>();
wrapper.select("IFNULL(SUM(POINT), 0) as POINT")
.eq("BIZ_TYPE", type)
.eq("OBJECT_ID", objectId)
.eq("USER_ID", userId)
.eq("ACTION_FLAG", "plus")
.eq("DEL_FLAG", NumConstant.ZERO_STR);
UserPointActionLogEntity entity1 = baseDao.selectOne(wrapper);
int plusTotal = null == entity1? NumConstant.ZERO : entity1.getPoint();
wrapper = new QueryWrapper<>();
wrapper.select("IFNULL(SUM(POINT), 0) as POINT")
.eq("BIZ_TYPE", type)
.eq("OBJECT_ID", objectId)
.eq("USER_ID", userId)
.eq("ACTION_FLAG", "minus")
.eq("DEL_FLAG", NumConstant.ZERO_STR);
UserPointActionLogEntity entity2 = baseDao.selectOne(wrapper);
int minusTotal = null == entity2? NumConstant.ZERO : entity2.getPoint();
return plusTotal - minusTotal;
}
}
Loading…
Cancel
Save