|
|
@ -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; |
|
|
|
} |
|
|
|
} |