|  | @ -28,6 +28,7 @@ import com.epmet.commons.tools.enums.EventEnum; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.exception.RenException; |  |  | import com.epmet.commons.tools.exception.RenException; | 
			
		
	
		
		
			
				
					|  |  | 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.utils.DateUtils; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.validator.ValidatorUtils; |  |  | import com.epmet.commons.tools.validator.ValidatorUtils; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dao.UserPointActionLogDao; |  |  | import com.epmet.dao.UserPointActionLogDao; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.UserPointActionLogDTO; |  |  | import com.epmet.dto.UserPointActionLogDTO; | 
			
		
	
	
		
		
			
				
					|  | @ -43,6 +44,7 @@ import com.epmet.service.UserPointStatisticalDailyService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.UserPointTotalService; |  |  | import com.epmet.service.UserPointTotalService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.utils.DimIdGenerator; |  |  | import com.epmet.utils.DimIdGenerator; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.utils.ModuleConstant; |  |  | import com.epmet.utils.ModuleConstant; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.utils.RuleCycleEnum; | 
			
		
	
		
		
			
				
					|  |  | 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 dto.form.SendPointFormDTO; | 
			
		
	
	
		
		
			
				
					|  | @ -55,6 +57,7 @@ import org.springframework.stereotype.Service; | 
			
		
	
		
		
			
				
					|  |  | import org.springframework.transaction.annotation.Transactional; |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
		
			
				
					|  |  | import org.springframework.util.CollectionUtils; |  |  | import org.springframework.util.CollectionUtils; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import java.text.SimpleDateFormat; | 
			
		
	
		
		
			
				
					|  |  | import java.util.*; |  |  | import java.util.*; | 
			
		
	
		
		
			
				
					|  |  | import java.util.stream.Collectors; |  |  | import java.util.stream.Collectors; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -193,23 +196,57 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi | 
			
		
	
		
		
			
				
					|  |  |         PointRuleEntity ruleInfo = pointRuleService.getByEventCodeAndCustomerId(event.getCustomerId(),eventCode); |  |  |         PointRuleEntity ruleInfo = pointRuleService.getByEventCodeAndCustomerId(event.getCustomerId(),eventCode); | 
			
		
	
		
		
			
				
					|  |  |         if(null != ruleInfo && StringUtils.equals(NumConstant.ONE_STR,ruleInfo.getEnabledFlag())){ |  |  |         if(null != ruleInfo && StringUtils.equals(NumConstant.ONE_STR,ruleInfo.getEnabledFlag())){ | 
			
		
	
		
		
			
				
					|  |  |             Date dateCheck = null; |  |  |             Date dateCheck = null; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             Calendar calendar = Calendar.getInstance(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             calendar.setTime(new Date()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             calendar.set(Calendar.MINUTE, NumConstant.ZERO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             calendar.set(Calendar.SECOND, NumConstant.ZERO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             //先判断周期,是否超过限值
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             RuleCycleEnum cycle = RuleCycleEnum.getEnum(ruleInfo.getRulePeriod()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             switch(cycle){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             //当周期为首次或无限制时,不需要传时间参数
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |            //     case UNLIMITED:
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |            //         break;
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |            //     case FIRST:
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |            //         break;
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 case DAILY: | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     //今天零点
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     dateCheck = calendar.getTime(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     break; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 case WEEKLY: | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     //本周第一天零点
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     calendar.add(Calendar.WEEK_OF_MONTH, 0); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     calendar.set(Calendar.DAY_OF_WEEK, 2); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     dateCheck = calendar.getTime(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     break; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 case MONTHLY: | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     //本月第一天零点
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     calendar.add(Calendar.MONTH, 0); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     calendar.set(Calendar.DAY_OF_MONTH, 1); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     dateCheck = calendar.getTime(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     break; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 case YEARLY: | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     //本年第一天零点
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     int dayOfYear = Calendar.getInstance().get(Calendar.DAY_OF_YEAR); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     calendar.add(Calendar.DAY_OF_YEAR, -dayOfYear + 1); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     dateCheck = calendar.getTime(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     break; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 default: | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |             //判断积分规则的积分单位 次、天、分钟、小时
 |  |  |             //判断积分规则的积分单位 次、天、分钟、小时
 | 
			
		
	
		
		
			
				
					
					|  |  |             if(StringUtils.equals(ModuleConstant.POINT_UNIT_TIME,ruleInfo.getPointUnit())){ |  |  |             if(!StringUtils.equals(ModuleConstant.POINT_UNIT_TIME,ruleInfo.getPointUnit()) && !StringUtils.equals(ModuleConstant.POINT_UNIT_DAY,ruleInfo.getPointUnit())){ | 
			
				
				
			
		
	
		
		
			
				
					|  |  |                 //次
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             }else if(StringUtils.equals(ModuleConstant.POINT_UNIT_DAY,ruleInfo.getPointUnit())){ |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 //天
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 //在selectSumByEvent时要校验时间区间
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 Calendar calendar = Calendar.getInstance(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 calendar.setTime(new Date()); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 calendar.set(Calendar.MINUTE, NumConstant.ZERO); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 calendar.set(Calendar.SECOND, NumConstant.ZERO); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 dateCheck = calendar.getTime(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             }else{ |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					|  |  |                 //其余积分单位
 |  |  |                 //其余积分单位
 | 
			
		
	
		
		
			
				
					|  |  |                 //TODO..
 |  |  |                 //TODO..
 | 
			
		
	
		
		
			
				
					|  |  |                 logger.warn(String.format("当前规则属于按%s计分,系统尚不支持响应此类积分规则的事件"),ruleInfo.getPointUnit()); |  |  |                 logger.warn(String.format("当前规则属于按%s计分,系统尚不支持响应此类积分规则的事件"),ruleInfo.getPointUnit()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 return ; | 
			
		
	
		
		
			
				
					|  |  |             } |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |             //校验是否达到上限
 |  |  |             //校验是否达到上限
 | 
			
		
	
		
		
			
				
					|  |  |             if(ruleInfo.getUpLimit() > NumConstant.ZERO){ |  |  |             if(ruleInfo.getUpLimit() > NumConstant.ZERO){ | 
			
		
	
		
		
			
				
					|  |  |                 //不按照sourceId查询,查询指定日期内的相关积分规则的总和
 |  |  |                 //不按照sourceId查询,查询指定日期内的相关积分规则的总和
 | 
			
		
	
	
		
		
			
				
					|  | @ -325,7 +362,7 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi | 
			
		
	
		
		
			
				
					|  |  |         action.setPoint(grantPoint.getPoint()); |  |  |         action.setPoint(grantPoint.getPoint()); | 
			
		
	
		
		
			
				
					|  |  |         action.setEventStatement(grantPoint.getRemark()); |  |  |         action.setEventStatement(grantPoint.getRemark()); | 
			
		
	
		
		
			
				
					|  |  |         action.setEventName(EventEnum.ACTIVE_SEND_POINT.getEventDesc()); |  |  |         action.setEventName(EventEnum.ACTIVE_SEND_POINT.getEventDesc()); | 
			
		
	
		
		
			
				
					
					|  |  |         action.setEventId(EventEnum.ACTIVE_INSERT_LIVE.getEventTag()); |  |  |         action.setEventId(ModuleConstant.COMMON_EVENT_ID); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         action.setActionFlag(grantPoint.getActionFlag()); |  |  |         action.setActionFlag(grantPoint.getActionFlag()); | 
			
		
	
		
		
			
				
					|  |  |         action.setUserId(grantPoint.getUserId()); |  |  |         action.setUserId(grantPoint.getUserId()); | 
			
		
	
		
		
			
				
					|  |  |         action.setCreatedBy(grantPoint.getOperatorId()); |  |  |         action.setCreatedBy(grantPoint.getOperatorId()); | 
			
		
	
	
		
		
			
				
					|  | @ -355,4 +392,5 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi | 
			
		
	
		
		
			
				
					|  |  |         userPointTotalService.insertOrUpdate(point); |  |  |         userPointTotalService.insertOrUpdate(point); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } |