| | |
| | | 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 { |
| | | // 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("会员等级名称不能为空"); |
| | |
| | | throw new ValidationException("会员折扣百分比不能大于100"); |
| | | } |
| | | } |
| | | //区间交集判断 |
| | | //查询所有等级 |
| | | List<Member> allMember = memberMapper.getAllMember(); |
| | | allMember.forEach(a -> { |
| | | if (a.getStartPoint() < memberDTO.getEndPoint() && a.getEndPoint() > memberDTO.getStartPoint()) { |
| | | throw new ValidationException("存在交集,不允许保存"); |
| | | } |
| | | }); |
| | | if (!StringUtils.isEmpty(memberDTO.getDiscountAmount())) { |
| | | int discountAmount = memberDTO.getDiscountAmount().compareTo(BigDecimal.ZERO); |
| | | if (discountAmount == -1) { |
| | |
| | | if (memberDTO.getStartPoint() > memberDTO.getEndPoint()) { |
| | | throw new ValidationException("成长点开始不能大于结束"); |
| | | } |
| | | //区间交集判断 |
| | | //查询所有等级 |
| | | List<Member> allMember = memberMapper.getOtherAllMember(memberDTO.getId()); |
| | | allMember.forEach(a -> { |
| | | if (a.getStartPoint() < memberDTO.getEndPoint() && a.getEndPoint() > memberDTO.getStartPoint()) { |
| | | throw new ValidationException("存在交集,不允许修改"); |
| | | } |
| | | }); |
| | | |
| | | //更新会员等级 |
| | | if (memberInfo.getStartPoint() != memberDTO.getStartPoint() || memberInfo.getEndPoint() != memberDTO.getEndPoint()) { |
| | | customerMapper.updateMemberLevelByPoint(memberInfo.getId(), memberInfo.getStartPoint(), memberInfo.getEndPoint()); |