|  |  | 
 |  |  |     private final CustomerMapper customerMapper; | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public void saveMember(Member member) { | 
 |  |  |         if (StringUtils.isEmpty(member.getName())) { | 
 |  |  |     public void saveMember(MemberDTO memberDTO) { | 
 |  |  |         //是否已经存在endpoint已经有最大值了,有的话需要删除或者修改 | 
 |  |  |         if (memberDTO.getEndPoint() == null) { | 
 |  |  |             Member pointByIntegerMaxValue = memberMapper.getEndPointByIntegerMaxValue(Integer.MAX_VALUE); | 
 |  |  |             if (!ObjectUtils.isEmpty(pointByIntegerMaxValue)) { | 
 |  |  |                 throw new ValidationException("系统中已经有一条最大值或者空值记录,请删除或者修改再保存"); | 
 |  |  |             } else { | 
 |  |  |                 memberDTO.setEndPoint(Integer.MAX_VALUE); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         if (StringUtils.isEmpty(memberDTO.getName())) { | 
 |  |  |             throw new ValidationException("会员等级名称不能为空"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (StringUtils.isEmpty(member.getDiscountType())) { | 
 |  |  |         if (StringUtils.isEmpty(memberDTO.getDiscountType())) { | 
 |  |  |             throw new ValidationException("会员折扣类型不能为空"); | 
 |  |  |         } | 
 |  |  |         if (Constants.DISCOUNT_TYPE.amount.name().equals(member.getDiscountType()) && StringUtils.isEmpty(member.getDiscountAmount())) { | 
 |  |  |         if (Constants.DISCOUNT_TYPE.amount.name().equals(memberDTO.getDiscountType()) && StringUtils.isEmpty(memberDTO.getDiscountAmount())) { | 
 |  |  |             throw new ValidationException("会员折扣固定金额不能为空"); | 
 |  |  |         } | 
 |  |  |         if (Constants.DISCOUNT_TYPE.ratio.name().equals(member.getDiscountType()) && StringUtils.isEmpty(member.getDiscountRatio())) { | 
 |  |  |         if (Constants.DISCOUNT_TYPE.ratio.name().equals(memberDTO.getDiscountType()) && StringUtils.isEmpty(memberDTO.getDiscountRatio())) { | 
 |  |  |             throw new ValidationException("会员折扣百分比不能为空"); | 
 |  |  |         } | 
 |  |  |         if (member.getStartPoint() > member.getEndPoint()) { | 
 |  |  |             throw new ValidationException("成长点开始不能大于结束"); | 
 |  |  |  | 
 |  |  |         if (memberDTO.getStartPoint() > memberDTO.getEndPoint()) { | 
 |  |  |             throw new ValidationException("成长点开始不能大于结束点"); | 
 |  |  |         } | 
 |  |  |         if (!StringUtils.isEmpty(member.getDiscountRatio())) { | 
 |  |  |             int discountRatio1 = member.getDiscountRatio().compareTo(BigDecimal.ZERO); | 
 |  |  |         if (!StringUtils.isEmpty(memberDTO.getDiscountRatio())) { | 
 |  |  |             int discountRatio1 = memberDTO.getDiscountRatio().compareTo(BigDecimal.ZERO); | 
 |  |  |             if (discountRatio1 == -1) { | 
 |  |  |                 throw new ValidationException("会员折扣百分比不能小于0"); | 
 |  |  |             } | 
 |  |  |             int discountRatio2 = member.getDiscountRatio().compareTo(new BigDecimal(100)); | 
 |  |  |             int discountRatio2 = memberDTO.getDiscountRatio().compareTo(new BigDecimal(100)); | 
 |  |  |             if (discountRatio2 == 1) { | 
 |  |  |                 throw new ValidationException("会员折扣百分比不能大于100"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         if (!StringUtils.isEmpty(member.getDiscountAmount())) { | 
 |  |  |             int discountAmount = member.getDiscountAmount().compareTo(BigDecimal.ZERO); | 
 |  |  |         if (!StringUtils.isEmpty(memberDTO.getDiscountAmount())) { | 
 |  |  |             int discountAmount = memberDTO.getDiscountAmount().compareTo(BigDecimal.ZERO); | 
 |  |  |             if (discountAmount == -1) { | 
 |  |  |                 throw new ValidationException("会员折扣固定金额不能小于0"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //保存时判断是否有重复的名称 | 
 |  |  |         Member memberByName = memberMapper.getMemberByName(member.getName()); | 
 |  |  |         Member memberByName = memberMapper.getMemberByName(memberDTO.getName()); | 
 |  |  |         if (!ObjectUtils.isEmpty(memberByName)) { | 
 |  |  |             throw new ValidationException("会员等级名称重复"); | 
 |  |  |         } | 
 |  |  |         Member member = new Member(); | 
 |  |  |         BeanUtils.copyProperties(memberDTO, member); | 
 |  |  |         member.create(SecurityUtils.getUserId()); | 
 |  |  |         memberMapper.insert(member); | 
 |  |  |         //更新会员等级 | 
 |  |  |         customerMapper.updateMemberLevelByPoint(member.getId(), member.getStartPoint(), member.getEndPoint()); | 
 |  |  | 
 |  |  |         } | 
 |  |  |         if (Constants.DISCOUNT_TYPE.ratio.name().equals(memberDTO.getDiscountType()) && StringUtils.isEmpty(memberDTO.getDiscountRatio())) { | 
 |  |  |             throw new ValidationException("会员折扣百分比不能为空"); | 
 |  |  |         } | 
 |  |  |         if (memberDTO.getStartPoint() > memberDTO.getEndPoint()) { | 
 |  |  |             throw new ValidationException("成长点开始不能大于结束"); | 
 |  |  |         } | 
 |  |  |         if (!StringUtils.isEmpty(memberDTO.getDiscountRatio())) { | 
 |  |  |             int discountRatio1 = memberDTO.getDiscountRatio().compareTo(BigDecimal.ZERO); | 
 |  |  | 
 |  |  |                 throw new ValidationException("已存在会员等级名称,无法修改"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         //是否已经存在endpoint已经有最大值了,有的话需要删除或者修改 | 
 |  |  | //        if (memberDTO.getEndPoint() == null && memberInfo.getEndPoint() != Integer.MAX_VALUE) { | 
 |  |  | //            Member pointByIntegerMaxValue = memberMapper.getEndPointByIntegerMaxValue(Integer.MAX_VALUE); | 
 |  |  | //            if (!ObjectUtils.isEmpty(pointByIntegerMaxValue)) { | 
 |  |  | //                throw new ValidationException("系统中已经有一条最大值或者空值记录,请删除或者修改再保存"); | 
 |  |  | //            } else { | 
 |  |  | //                memberDTO.setEndPoint(Integer.MAX_VALUE); | 
 |  |  | //            } | 
 |  |  | //        } else if (memberDTO.getEndPoint() == null && memberInfo.getEndPoint() == Integer.MAX_VALUE) { | 
 |  |  | //            memberDTO.setEndPoint(Integer.MAX_VALUE); | 
 |  |  | //        } | 
 |  |  |  | 
 |  |  |         if (memberDTO.getEndPoint() == null) { | 
 |  |  |             if (memberInfo.getEndPoint() != Integer.MAX_VALUE) { | 
 |  |  |                 Member pointByIntegerMaxValue = memberMapper.getEndPointByIntegerMaxValue(Integer.MAX_VALUE); | 
 |  |  |                 if (!ObjectUtils.isEmpty(pointByIntegerMaxValue)) { | 
 |  |  |                     throw new ValidationException("系统中已经有一条最大值或者空值记录,请删除或者修改再保存"); | 
 |  |  |                 } else { | 
 |  |  |                     memberDTO.setEndPoint(Integer.MAX_VALUE); | 
 |  |  |                 } | 
 |  |  |             } else { | 
 |  |  |                 memberDTO.setEndPoint(Integer.MAX_VALUE); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (memberDTO.getStartPoint() > memberDTO.getEndPoint()) { | 
 |  |  |             throw new ValidationException("成长点开始不能大于结束"); | 
 |  |  |         } | 
 |  |  |         //更新会员等级 | 
 |  |  |         if (memberInfo.getStartPoint() != memberDTO.getStartPoint() || memberInfo.getEndPoint() != memberDTO.getEndPoint()) { | 
 |  |  |             customerMapper.updateMemberLevelByPoint(memberInfo.getId(), memberInfo.getStartPoint(), memberInfo.getEndPoint()); |