From c8f6f175a23e15b40309cf31850ee170d8d946ca Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期二, 30 九月 2025 14:33:43 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/haizhentong --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmBranchServiceImpl.java | 35 ++++++++++++++++++++++++++++++----- 1 files changed, 30 insertions(+), 5 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmBranchServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmBranchServiceImpl.java index 72ee816..703cb8e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmBranchServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmBranchServiceImpl.java @@ -48,21 +48,23 @@ @Override public PageInfo<TCrmBranchVO> pageList(TCrmBranchQuery query) { + PageInfo<TCrmBranchVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); List<TCrmBranchArea> crmBranchAreas = new ArrayList<>(); if(StringUtils.isNotEmpty(query.getCityCode())){ crmBranchAreas = crmBranchAreaService.list(Wrappers.lambdaQuery(TCrmBranchArea.class) .eq(TCrmBranchArea::getCityCode, query.getCityCode())); } - if(!StringUtils.isNotEmpty(query.getCityCode()) && StringUtils.isNotEmpty(query.getProvinceCode())){ + if(StringUtils.isNotEmpty(query.getProvinceCode())){ crmBranchAreas = crmBranchAreaService.list(Wrappers.lambdaQuery(TCrmBranchArea.class) .eq(TCrmBranchArea::getProvinceCode, query.getProvinceCode())); } if(!CollectionUtils.isEmpty(crmBranchAreas)){ List<String> branchIds = crmBranchAreas.stream().map(TCrmBranchArea::getBranchId).collect(Collectors.toList()); query.setBranchIds(branchIds); + }else { + return pageInfo; } - PageInfo<TCrmBranchVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); List<TCrmBranchVO> list = this.baseMapper.pageList(query,pageInfo); if(CollectionUtils.isEmpty(list)){ return pageInfo; @@ -90,9 +92,21 @@ if(Objects.nonNull(sysUser)){ return R.fail(dto.getPhone()+"-账号已存在"); } + List<TCrmBranchArea> branchAreas = dto.getBranchAreas(); + // 判断是否已存在这些区域 + if(!CollectionUtils.isEmpty(branchAreas)){ + List<String> branchAreaCityCodes = branchAreas.stream().map(TCrmBranchArea::getCityCode).collect(Collectors.toList()); + + if(!CollectionUtils.isEmpty(branchAreaCityCodes)){ + long count = crmBranchAreaService.count(Wrappers.lambdaQuery(TCrmBranchArea.class).in(TCrmBranchArea::getCityCode, branchAreaCityCodes)); + if(count > 0){ + return R.fail("区域已存在"); + } + } + } + this.save(dto); // 添加区域 - List<TCrmBranchArea> branchAreas = dto.getBranchAreas(); branchAreas.forEach(t -> t.setBranchId(dto.getId())); crmBranchAreaService.saveBatch(branchAreas); // 添加职位薪资 @@ -137,11 +151,20 @@ return R.fail(dto.getPhone()+"-账号已存在"); } SysUser user = sysUserService.selectUserById(dto.getUserId()); + List<TCrmBranchArea> branchAreas = dto.getBranchAreas(); + // 判断是否已存在这些区域 + if(!CollectionUtils.isEmpty(branchAreas)){ + List<String> branchAreaCityCodes = branchAreas.stream().map(TCrmBranchArea::getCityCode).collect(Collectors.toList()); + long count = crmBranchAreaService.count(Wrappers.lambdaQuery(TCrmBranchArea.class).in(TCrmBranchArea::getCityCode, branchAreaCityCodes) + .ne(TCrmBranchArea::getBranchId, dto.getId())); + if(count > 0){ + return R.fail("区域存在重复"); + } + } this.updateById(dto); // 删除区域 crmBranchAreaService.remove(Wrappers.lambdaQuery(TCrmBranchArea.class).eq(TCrmBranchArea::getBranchId, dto.getId())); // 添加区域 - List<TCrmBranchArea> branchAreas = dto.getBranchAreas(); branchAreas.forEach(t -> t.setBranchId(dto.getId())); crmBranchAreaService.saveBatch(branchAreas); // 删除职位薪资 @@ -155,7 +178,9 @@ user.setPhonenumber(dto.getPhone()); user.setUserName(dto.getPhone()); user.setNickName(dto.getUserName()); - user.setPassword(SecurityUtils.encryptPassword(dto.getPassword())); + if(StringUtils.isNotEmpty(dto.getPassword())){ + user.setPassword(SecurityUtils.encryptPassword(dto.getPassword())); + } sysUserService.updateUser(user); } // if(Objects.nonNull(user) && user.getUserName().equals(dto.getPhone()) && StringUtils.isNotEmpty(dto.getPassword())) { -- Gitblit v1.7.1