|
@ -20,6 +20,8 @@ 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.NumConstant; |
|
|
|
|
|
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.commons.tools.constant.FieldConstant; |
|
@ -29,10 +31,18 @@ import com.epmet.dto.form.CommonPageUserFormDTO; |
|
|
import com.epmet.dto.result.ResiPointLogListResultDTO; |
|
|
import com.epmet.dto.result.ResiPointLogListResultDTO; |
|
|
import com.epmet.dto.result.ResiPointLogPeriodResultDTO; |
|
|
import com.epmet.dto.result.ResiPointLogPeriodResultDTO; |
|
|
import com.epmet.entity.UserPointActionLogEntity; |
|
|
import com.epmet.entity.UserPointActionLogEntity; |
|
|
|
|
|
import com.epmet.entity.UserPointStatisticalDailyEntity; |
|
|
|
|
|
import com.epmet.entity.UserPointTotalEntity; |
|
|
import com.epmet.service.UserPointActionLogService; |
|
|
import com.epmet.service.UserPointActionLogService; |
|
|
|
|
|
import com.epmet.service.UserPointStatisticalDailyService; |
|
|
|
|
|
import com.epmet.service.UserPointTotalService; |
|
|
|
|
|
import com.epmet.utils.DimIdGenerator; |
|
|
|
|
|
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 org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
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; |
|
|
|
|
|
|
|
@ -48,6 +58,10 @@ import java.util.stream.Collectors; |
|
|
@Service |
|
|
@Service |
|
|
public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActionLogDao, UserPointActionLogEntity> implements UserPointActionLogService { |
|
|
public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActionLogDao, UserPointActionLogEntity> implements UserPointActionLogService { |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private UserPointTotalService userPointTotalService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private UserPointStatisticalDailyService userPointStatisticalDailyService; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageData<UserPointActionLogDTO> page(Map<String, Object> params) { |
|
|
public PageData<UserPointActionLogDTO> page(Map<String, Object> params) { |
|
@ -131,4 +145,62 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description 消息网关回调进行积分发放 |
|
|
|
|
|
* @param grantPointParam |
|
|
|
|
|
* @return |
|
|
|
|
|
* @author wangc |
|
|
|
|
|
* @date 2020.07.29 09:11 |
|
|
|
|
|
**/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public void grantPoint(SendPointFormDTO grantPointParam){ |
|
|
|
|
|
if(StringUtils.equals(ModuleConstant.OPERATION_TYPE_MINUS,grantPointParam.getActionFlag())){ |
|
|
|
|
|
//减
|
|
|
|
|
|
if(grantPointParam.getPoint() > NumConstant.ZERO){ |
|
|
|
|
|
//保证负数
|
|
|
|
|
|
grantPointParam.setPoint(grantPointParam.getPoint() * NumConstant.ONE_NEG); |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
//加
|
|
|
|
|
|
if(grantPointParam.getPoint() < NumConstant.ZERO){ |
|
|
|
|
|
//保证正数
|
|
|
|
|
|
grantPointParam.setPoint(grantPointParam.getPoint() * NumConstant.ONE_NEG); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//1.新增用户积分行为记录
|
|
|
|
|
|
UserPointActionLogEntity action = new UserPointActionLogEntity(); |
|
|
|
|
|
action.setCustomerId(grantPointParam.getCustomerId()); |
|
|
|
|
|
action.setPoint(grantPointParam.getPoint()); |
|
|
|
|
|
action.setEventStatement(grantPointParam.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()); |
|
|
|
|
|
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()); |
|
|
|
|
|
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.setUsedPoint(NumConstant.ZERO); |
|
|
|
|
|
point.setCreatedBy(grantPointParam.getOperatorId()); |
|
|
|
|
|
point.setUpdatedBy(grantPointParam.getOperatorId()); |
|
|
|
|
|
userPointTotalService.insertOrUpdate(point); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |