From 0eb83b49a381c31a51b8c8cec9e4d9d88fd5d16f Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Mon, 25 Jan 2021 10:47:12 +0800 Subject: [PATCH] Merge branch 'api' of https://gitee.com/jyyforjava/zq-erp into api --- zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java | 39 ++++++++++++++++++++------------------- 1 files changed, 20 insertions(+), 19 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java index 8a6f81e..30e4893 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java @@ -439,9 +439,11 @@ public int apiAddVip(AddVipDto addVipDto) { SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); - if (serviceUtil.addCheckRepeatTowColumn(TableMapping.SYS_VIP_INFO, "VIP_NO", addVipDto.getVipNo(), - "company_id",user.getCompanyId())) { - throw new GlobleException("编号已存在!"); + if (StringUtils.isNotBlank(addVipDto.getVipNo())) { + if (serviceUtil.addCheckRepeatTowColumn(TableMapping.SYS_VIP_INFO, "VIP_NO", addVipDto.getVipNo(), + "company_id", user.getCompanyId())) { + throw new GlobleException("编号已存在!"); + } } if (serviceUtil.addCheckRepeatTowColumn(TableMapping.SYS_VIP_INFO, "PHONE", addVipDto.getPhone(), @@ -485,7 +487,7 @@ int i=sysVipInfoDao.insert(vipInfo); if (CollectionUtils.isNotEmpty(addVipDto.getLabels())) { - batchInsertLabel(addVipDto.getLabels(), user.getSuName(), vipInfo.getId()); + batchInsertLabel(addVipDto.getLabels(), vipInfo.getId()); } //创建用户默认储值卡 @@ -502,10 +504,12 @@ throw new GlobleException("用户不存在"); } - if (!modifyVipDto.getVipNo().equals(vipInfo.getVipNo())) { - if (serviceUtil.addCheckRepeatTowColumn(TableMapping.SYS_VIP_INFO, "VIP_NO", modifyVipDto.getVipNo(), - "company_id",user.getCompanyId())) { - throw new GlobleException("编号已存在!"); + if (StringUtils.isNotBlank(modifyVipDto.getVipNo())) { + if (!modifyVipDto.getVipNo().equals(vipInfo.getVipNo())) { + if (serviceUtil.addCheckRepeatTowColumn(TableMapping.SYS_VIP_INFO, "VIP_NO", modifyVipDto.getVipNo(), + "company_id", user.getCompanyId())) { + throw new GlobleException("编号已存在!"); + } } } @@ -536,23 +540,20 @@ int i = sysVipInfoDao.update(vipInfo); if (CollectionUtils.isNotEmpty(modifyVipDto.getLabels())) { - sysVipLabelDao.deleteByVipId(modifyVipDto.getVipId()); - - batchInsertLabel(modifyVipDto.getLabels(), user.getSuName(), vipInfo.getId()); + sysVipLabelDao.deleteRelateByVipId(modifyVipDto.getVipId()); + batchInsertLabel(modifyVipDto.getLabels(), vipInfo.getId()); } return i; } - private void batchInsertLabel(List<String> labelList, String suName, Long id) { + private void batchInsertLabel(List<String> labelList, Long id) { Set<String> labels = new HashSet<>(labelList); Iterator<String> iterator = labels.iterator(); - if (iterator.hasNext()) { - SysVipLabel sysVipLabel = new SysVipLabel(); - sysVipLabel.setCreateTime(new Date()); - sysVipLabel.setCreateBy(suName); - sysVipLabel.setLabel(iterator.next()); - sysVipLabel.setVipId(id); - sysVipLabelDao.insert(sysVipLabel); + while (iterator.hasNext()) { + SysVipLabelRelate relate = new SysVipLabelRelate(); + relate.setLabelId(Long.parseLong(iterator.next())); + relate.setVipId(id); + sysVipLabelDao.insertRelate(relate); } } -- Gitblit v1.9.1