| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -32,7 +32,6 @@ import com.epmet.commons.tools.validator.ValidatorUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dao.UserPointActionLogDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.UserPointActionLogDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.form.CommonPageUserFormDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.form.PointRuleListFormDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.result.ResiPointLogListResultDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.result.ResiPointLogPeriodResultDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.entity.PointRuleEntity; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -49,8 +48,6 @@ import com.google.common.collect.Maps; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import dto.form.SendPointFormDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import lombok.extern.slf4j.Slf4j; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.commons.lang3.StringUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.commons.lang3.Validate; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.bouncycastle.math.raw.Mod; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.slf4j.Logger; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.slf4j.LoggerFactory; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.beans.factory.annotation.Autowired; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -193,7 +190,6 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            logger.error(String.format("无法识别事件类型与积分规则,消息体->【%s】", JSON.toJSON(event))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            throw new RenException("无法识别事件类型与积分规则"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        PointRuleEntity ruleInfo = pointRuleService.getByEventCodeAndCustomerId(event.getCustomerId(),eventCode); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if(null != ruleInfo && StringUtils.equals(NumConstant.ONE_STR,ruleInfo.getEnabledFlag())){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Date dateCheck = null; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -219,22 +215,22 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                Integer sum = baseDao.selectSumByEvent(event.getUserId(),eventCode,event.getSourceId(),event.getCustomerId(),dateCheck); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if(null == sum) sum = NumConstant.ZERO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if(StringUtils.equals(ModuleConstant.OPERATION_TYPE_PLUS,ruleInfo.getOperateType())){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                   sum += ruleInfo.getPoint(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                   if(ruleInfo.getPoint() < NumConstant.ZERO){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                       //保证要加的积分是正数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                       ruleInfo.setPoint(ruleInfo.getPoint() * NumConstant.ONE_NEG); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                   } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                   sum += ruleInfo.getPoint(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                }else{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    //actionLog中存的是正负数,如果是减操作,则算出来的是负数相加
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    sum -= ruleInfo.getPoint() * NumConstant.ONE_NEG; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    sum *= NumConstant.ONE_NEG; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if(ruleInfo.getPoint() > NumConstant.ZERO){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        //保证要扣减的积分是负数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        ruleInfo.setPoint(ruleInfo.getPoint() * NumConstant.ONE_NEG); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    sum += ruleInfo.getPoint(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    sum *= NumConstant.ONE_NEG; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                //这里sum一定是正数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if(ruleInfo.getUpLimit() < (sum + ruleInfo.getPoint())){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if(ruleInfo.getUpLimit() < sum){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    log.info(String.format("该用户获取此类事件的积分已达上限,详细数据->【%s】", JSON.toJSON(event))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    return ; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -242,14 +238,27 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //完成校验,可以进行积分操作
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //根据事件的类型,提前定义好EventName、EventStatement等属性
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String eventName = ModuleConstant.EMPTY_STR; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String eventStatement = eventName; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if(EventEnum.ACTIVE_INSERT_LIVE.getEventTag().equals(eventCode)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                eventName = ModuleConstant.EVENT_NAME_VOLUNTEER; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }else if(EventEnum.REGISTER_VOLUNTEER.getEventTag().equals(eventCode)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                eventName = ModuleConstant.EVENT_NAME_PARTICIPATED_ACT; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                eventStatement = event.getRemark(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }else{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                eventName = EventEnum.getEnum(eventCode).getEventDesc(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                eventStatement = event.getRemark(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //1.新增用户积分行为记录
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            UserPointActionLogEntity action = new UserPointActionLogEntity(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            action.setCustomerId(event.getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //正负数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            action.setPoint(ruleInfo.getPoint()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            action.setEventStatement(event.getRemark()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            action.setEventName(EventEnum.getEnum(eventCode).getEventDesc()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            action.setEventStatement(eventStatement); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            action.setEventName(eventName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            action.setEventId(eventCode); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            action.setActionFlag(event.getActionFlag()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            action.setUserId(event.getUserId()); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -261,6 +270,7 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //2.新增/修改用户积分日统计
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            DimIdGenerator.DimIdBean dimVal = DimIdGenerator.getDimIdBean(new Date()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            UserPointStatisticalDailyEntity statistical = ConvertUtils.sourceToTarget(dimVal,UserPointStatisticalDailyEntity.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //正负数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            statistical.setPointChange(ruleInfo.getPoint()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            statistical.setActionFlag(event.getActionFlag()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            statistical.setCustomerId(event.getCustomerId()); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -272,6 +282,7 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            UserPointTotalEntity point = new UserPointTotalEntity(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            point.setCustomerId(event.getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            point.setUserId(event.getUserId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //正负数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            point.setTotalPoint(ruleInfo.getPoint()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            point.setUsablePoint(ruleInfo.getPoint()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            point.setUsedPoint(NumConstant.ZERO); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |