| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -27,6 +27,7 @@ import com.epmet.commons.tools.constant.NumConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.constant.StrConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.enums.CommonOperateTypeEnum; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.enums.EventEnum; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.exception.EpmetErrorCode; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.exception.ExceptionUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.exception.RenException; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.security.dto.TokenDto; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -146,15 +147,31 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return resultDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						/** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @Description  积分规则修改 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @Param tokenDTO | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @Param formDTO | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						@Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						@Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public void update(TokenDto tokenDTO, PointRuleFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							// 积分规则开启状态参数校验
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							validateEnableFlag(formDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							PointRuleEntity entityDB = baseDao.selectById(formDTO.getRuleId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//数据库不存在或者客户Id不相等 则抛出异常
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (entityDB == null || !entityDB.getCustomerId().equals(formDTO.getCustomerId())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								throw new RenException(SysResponseEnum.POINT_RULE_IS_NOT_EXIST.getCode(), SysResponseEnum.POINT_RULE_IS_NOT_EXIST.getMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							// 校验规则是否有重复名字
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							Integer sameCount = baseDao.checkSameName(formDTO.getRuleName(), formDTO.getCustomerId(), formDTO.getRuleId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (sameCount > NumConstant.ZERO){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								throw new RenException(EpmetErrorCode.SAME_RULE_NAME.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							// 检验积分上限是不是单位积分的整数倍
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							Integer remainder = formDTO.getUpLimit() % formDTO.getPoint(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (remainder > NumConstant.ZERO){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								throw new RenException(EpmetErrorCode.UP_LIMIT_POINT.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							PointRuleEntity entityNew = ConvertUtils.sourceToTarget(formDTO, PointRuleEntity.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							entityNew.setId(formDTO.getRuleId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							entityNew.setEnabledFlag(StrConstant.TRUE.equals(formDTO.getEnabledFlag()) ? "1" : "0"); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -164,6 +181,41 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							baseDao.updateByCustomerId(entityNew); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							insertOperateRecord(tokenDTO, entityNew, entityDB, CommonOperateTypeEnum.EDIT.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							// 系统日志记录
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							List<String> messages = disposeLog(formDTO, entityDB); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							// TODO add
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						/** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @Description  变更处理 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @Param f | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @Param e | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @author zxc | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @date 2021/6/18 3:14 下午 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private List<String> disposeLog(PointRuleFormDTO f,PointRuleEntity e){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							List<String> result = new ArrayList<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							// 单位积分
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (!e.getPoint().equals(f.getPoint())){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								String s = String.format(StrConstant.POINT_CHANGE, e.getRuleName(), e.getPoint(), f.getPoint()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								result.add(s); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							// 积分上限
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (!e.getUpLimit().equals(f.getUpLimit())){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								String s = String.format(StrConstant.POINT_CHANGE, e.getRuleName(), e.getUpLimit(), f.getUpLimit()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								result.add(s); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							// 积分事件
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (!e.getRuleName().equals(f.getRuleName())){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								String s = String.format(StrConstant.POINT_CHANGE, e.getRuleName(), e.getRuleName(), f.getRuleName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								result.add(s); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							// 积分说明
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (!e.getRuleDesc().equals(f.getRuleDesc())){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								String s = String.format(StrConstant.POINT_CHANGE, e.getRuleName(), e.getRuleDesc(), f.getRuleDesc()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								result.add(s); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return result; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private void validateEnableFlag(PointRuleFormDTO formDTO) { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |