| | |
| | | package cc.mrbird.febs.vip.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.mall.entity.DataDictionaryCustom; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallMemberMapper; |
| | | import cc.mrbird.febs.vip.entity.MallVipBenefits; |
| | | import cc.mrbird.febs.vip.entity.MallVipConfig; |
| | |
| | | |
| | | private final IMallVipConfigBenefitsService mallVipConfigBenefitsService; |
| | | private final MallMemberMapper mallMemberMapper; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | @Override |
| | | public IPage<MallVipConfig> vipConfigList(QueryRequest request) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addVipConfig(MallVipConfig config) { |
| | | List<MallVipConfig> configs = this.baseMapper.selectVipConfigList(); |
| | | boolean b = configs.stream().anyMatch(item -> { |
| | | return (item.getLevel().equals(config.getLevel()) || config.getCode().equals(item.getCode())); |
| | | }); |
| | | |
| | | if (b) { |
| | | throw new FebsException("会员等级或编码已存在"); |
| | | } |
| | | this.baseMapper.insert(config); |
| | | |
| | | List<MallVipConfigBenefits> configBenefitsList = new ArrayList<>(); |
| | |
| | | |
| | | @Override |
| | | public void editVipConfig(MallVipConfig config) { |
| | | MallVipConfig oldConfig = this.baseMapper.selectById(config.getId()); |
| | | |
| | | List<MallVipConfig> configs = this.baseMapper.selectVipConfigList(); |
| | | boolean b = configs.stream().anyMatch(item -> { |
| | | return !item.getId().equals(config.getId()) && (item.getLevel().equals(config.getLevel()) || config.getCode().equals(item.getCode())); |
| | | }); |
| | | |
| | | if (b) { |
| | | throw new FebsException("会员等级或编码已存在"); |
| | | } |
| | | |
| | | if (!config.getCode().equals(oldConfig.getCode())) { |
| | | LambdaQueryWrapper<MallMember> memberQuery = new LambdaQueryWrapper<>(); |
| | | memberQuery.eq(MallMember::getLevel, oldConfig.getCode()); |
| | | List<MallMember> mallMembers = mallMemberMapper.selectList(memberQuery); |
| | | if (CollUtil.isNotEmpty(mallMembers)) { |
| | | throw new FebsException("会员编码绑定了客户,请调整后修改"); |
| | | } |
| | | } |
| | | |
| | | |
| | | this.baseMapper.updateById(config); |
| | | |
| | | LambdaQueryWrapper<MallVipConfigBenefits> delQuery = new LambdaQueryWrapper<>(); |
| | |
| | | return true; |
| | | } |
| | | |
| | | DataDictionaryCustom data = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.VIP_DATE.getType(), DataDictionaryEnum.VIP_DATE.getCode()); |
| | | |
| | | String todayTime = DateUtil.format(new Date(), "MM-dd"); |
| | | // 会员日 |
| | | return item.getGainType() == 1; |
| | | return item.getGainType() == 1 && StrUtil.equals(data.getValue(), todayTime); |
| | | }).max(Comparator.comparing(MallVipBenefits::getScoreMultiple)); |
| | | |
| | | return max.orElseGet(max::get); |