From be1dad48a522d05dadfc816209d0270548cbbc50 Mon Sep 17 00:00:00 2001 From: Hentua <wangdoubleone@gmail.com> Date: Thu, 25 Jan 2024 23:21:10 +0800 Subject: [PATCH] fix --- src/main/java/cc/mrbird/febs/vip/service/impl/MallVipConfigServiceImpl.java | 29 +++++++++++++++++++++++++++++ src/main/resources/templates/febs/views/modules/vip/vipConfig-add.html | 9 +++++++++ src/main/resources/templates/febs/views/modules/vip/vipConfig-edit.html | 11 +++++++++++ 3 files changed, 49 insertions(+), 0 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/vip/service/impl/MallVipConfigServiceImpl.java b/src/main/java/cc/mrbird/febs/vip/service/impl/MallVipConfigServiceImpl.java index e3d030d..c1a15ae 100644 --- a/src/main/java/cc/mrbird/febs/vip/service/impl/MallVipConfigServiceImpl.java +++ b/src/main/java/cc/mrbird/febs/vip/service/impl/MallVipConfigServiceImpl.java @@ -52,6 +52,14 @@ @Override @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<>(); @@ -68,6 +76,27 @@ @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<>(); diff --git a/src/main/resources/templates/febs/views/modules/vip/vipConfig-add.html b/src/main/resources/templates/febs/views/modules/vip/vipConfig-add.html index b69b68e..2ce47af 100644 --- a/src/main/resources/templates/febs/views/modules/vip/vipConfig-add.html +++ b/src/main/resources/templates/febs/views/modules/vip/vipConfig-add.html @@ -38,6 +38,15 @@ </div> </div> </div> + <div class="layui-form-item"> + + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">会员编码:</label> + <div class="layui-input-block"> + <input type="text" name="code" lay-verify="required" autocomplete="off" class="layui-input" > + </div> + </div> + </div> <div class="layui-form-item"> <label class="layui-form-label">主图:</label> diff --git a/src/main/resources/templates/febs/views/modules/vip/vipConfig-edit.html b/src/main/resources/templates/febs/views/modules/vip/vipConfig-edit.html index ee32f49..2c7cd52 100644 --- a/src/main/resources/templates/febs/views/modules/vip/vipConfig-edit.html +++ b/src/main/resources/templates/febs/views/modules/vip/vipConfig-edit.html @@ -40,6 +40,16 @@ </div> <div class="layui-form-item"> + + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">会员编码:</label> + <div class="layui-input-block"> + <input type="text" name="code" lay-verify="required" autocomplete="off" class="layui-input" > + </div> + </div> + </div> + + <div class="layui-form-item"> <label class="layui-form-label">主图:</label> <div class="layui-input-block"> <button type="button" class="layui-btn" id="imageUpload" style="background-color: #009688; margin-bottom: 2px">图片上传</button> @@ -258,6 +268,7 @@ "targetId":vipConfigData.targetId, "times" : vipConfigData.times, "amount" : vipConfigData.amount, + "code" : vipConfigData.code, }); $('#thumbImage').html('<img src="'+ vipConfigData.thumb +'" class="layui-upload-img" style="width: 100px">') -- Gitblit v1.9.1