ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java
@@ -18,6 +18,7 @@ import io.swagger.annotations.ApiOperation; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -192,6 +193,13 @@ // 冻结 sysUser.setStatus("1"); sysUserService.updateUser(sysUser); // 查询业务员 List<TCrmSalesperson> crmSalespersons = crmSalespersonService.list(Wrappers.lambdaQuery(TCrmSalesperson.class) .eq(TCrmSalesperson::getBranchId, id)); if(!CollectionUtils.isEmpty(crmSalespersons)){ List<Long> userIds = crmSalespersons.stream().map(TCrmSalesperson::getUserId).collect(Collectors.toList()); sysUserService.updateUserStatusByUserIds(userIds, "1"); } break; } return R.ok(); ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmClinicController.java
@@ -68,9 +68,23 @@ public R<PageInfo<TCrmClinicVO>> pageList(@RequestBody TCrmClinicQuery query) { Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); Long userId = tokenService.getLoginUser().getUserId(); if(roleType == 2 || roleType == 3){ if(roleType == 2){ query.setUserId(userId); query.setRoleType(roleType); // 查询账号绑定的分公司 TCrmBranch crmBranch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getUserId,userId) .last("LIMIT 1")); query.setBranchId(crmBranch.getId()); } if(roleType == 3){ query.setUserId(userId); query.setRoleType(roleType); // 查询账号绑定的业务员 TCrmSalesperson crmSalesperson = crmSalespersonService.getOne(Wrappers.lambdaQuery(TCrmSalesperson.class) .eq(TCrmSalesperson::getUserId,userId) .last("LIMIT 1")); query.setSalespersonId(crmSalesperson.getId()); } return R.ok(crmClinicService.pageList(query)); } ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
@@ -179,5 +179,5 @@ List<SysUser> selectBatchIds(@Param("personIds") List<Integer> personIds); void updateUserStatusByUserIds(@Param("userIds")List<Long> userIds, @Param("status")String status); } ruoyi-system/src/main/java/com/ruoyi/system/query/TCrmDeviceQuery.java
@@ -12,6 +12,9 @@ @ApiModelProperty(value = "诊所id") private String clinicId; @ApiModelProperty(value = "诊所名称") private String clinicName; @ApiModelProperty(value = "设备识别码") private String deviceCode; ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
@@ -261,4 +261,6 @@ void updatePassword(Long id, String s); long selectIdByPhone(String phonenumber); void updateUserStatusByUserIds(List<Long> userIds, String status); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
@@ -664,6 +664,11 @@ return userMapper.selectIdByPhone(phonenumber); } @Override public void updateUserStatusByUserIds(List<Long> userIds, String status) { userMapper.updateUserStatusByUserIds(userIds, status); } // @Override // public UserInfoVo userInfo(Long userId) { // return userMapper.userInfo(userId); 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,19 @@ 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()); 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 +149,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); // 删除职位薪资 ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -361,6 +361,12 @@ <update id="updatePassword"> update sys_user set password = #{s} where user_id = #{id} </update> <update id="updateUserStatusByUserIds"> update sys_user set status = #{status} where user_id IN <foreach collection="userIds" separator="," item="userId" open="(" close=")"> #{userId} </foreach> </update> <delete id="deleteUserById" parameterType="Long"> update sys_user set del_flag = '2' where user_id = #{userId} ruoyi-system/src/main/resources/mapper/system/TCrmClinicMapper.xml
@@ -61,11 +61,11 @@ <if test="query.status != null"> and tcc.status = #{query.status} </if> <if test="query.userId != null and query.userId == 2"> and tcc.branch_id = #{query.userId} <if test="query.branchId != null and query.userId == 2"> and tcc.branch_id = #{query.branchId} </if> <if test="query.userId != null and query.userId == 3"> and tcc.salesperson_id = #{query.userId} <if test="query.salespersonId != null and query.userId == 3"> and tcc.salesperson_id = #{query.salespersonId} </if> AND tcc.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} </where> ruoyi-system/src/main/resources/mapper/system/TCrmDeviceMapper.xml
@@ -30,6 +30,9 @@ <if test="query.deviceCode != null and query.deviceCode != ''"> and tcd.device_code LIKE concat('%',#{query.deviceCode},'%') </if> <if test="query.clinicName != null and query.clinicName != ''"> and tcc.clinic_name LIKE concat('%',#{query.clinicName},'%') </if> AND tcd.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} </where> ORDER BY tcd.create_time DESC