ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java
@@ -137,17 +137,28 @@ Long userId = tokenService.getLoginUser().getUserId(); TCrmBranch crmBranch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getUserId, userId) .eq(TCrmBranch::getPersonType, 1) .eq(TCrmBranch::getStatus, 1) .last("LIMIT 1")); if(Objects.isNull(crmBranch)){ return R.ok(new ArrayList<>()); } List<TCrmBranch> crmBranches = crmBranchService.list(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getProvinceBranchId, crmBranch.getId()) .eq(TCrmBranch::getStatus, 1) .orderByDesc(TCrmBranch::getCreateTime)); return R.ok(crmBranches); if(crmBranch.getPersonType() == 1){ List<TCrmBranch> crmBranches = crmBranchService.list(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getProvinceBranchId, crmBranch.getId()) .eq(TCrmBranch::getStatus, 1) .orderByDesc(TCrmBranch::getCreateTime)); crmBranches.add(crmBranch); return R.ok(crmBranches); } if(crmBranch.getPersonType() == 2){ List<TCrmBranch> crmBranches = crmBranchService.list(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getCorrelationPersonId, userId) .eq(TCrmBranch::getStatus, 1) .orderByDesc(TCrmBranch::getCreateTime)); crmBranches.add(crmBranch); return R.ok(crmBranches); } return R.ok(); } /** ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmSalespersonController.java
@@ -28,6 +28,7 @@ import org.apache.poi.ss.usermodel.Workbook; 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.*; @@ -35,6 +36,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -78,8 +80,32 @@ // 查询分公司信息 TCrmBranch crmBranch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getUserId, userId) .eq(TCrmBranch::getStatus, 1) .last("LIMIT 1")); query.setBranchId(crmBranch.getId()); List<String> branchIds = new ArrayList<>(); if(crmBranch.getPersonType() == 1){ List<TCrmBranch> crmBranches = crmBranchService.list(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getProvinceBranchId, crmBranch.getId())); branchIds.add(crmBranch.getId()); if(!CollectionUtils.isEmpty(crmBranches)){ List<String> branchIdList = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList()); branchIds.addAll(branchIdList); query.setBranchIds(branchIds); } } if(crmBranch.getPersonType() == 2){ List<TCrmBranch> crmBranches = crmBranchService.list(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getCorrelationPersonId, crmBranch.getId())); branchIds.add(crmBranch.getId()); if(!CollectionUtils.isEmpty(crmBranches)){ List<String> branchIdList = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList()); branchIds.addAll(branchIdList); query.setBranchIds(branchIds); } } if(crmBranch.getPersonType() == 3){ branchIds.add(crmBranch.getId()); } } return R.ok(crmSalespersonService.pageList(query)); } @@ -113,6 +139,19 @@ } /** * 获取crm业务员管理管理列表 */ @ApiOperation(value = "获取crm业务员管理列表") @GetMapping(value = "/listByBranchId") public R<List<TCrmSalesperson>> listByBranchId(@RequestParam String branchId) { LambdaQueryWrapper<TCrmSalesperson> wrapper = new LambdaQueryWrapper<>(); wrapper.eq(TCrmSalesperson::getBranchId,branchId); wrapper.eq(TCrmSalesperson::getStatus,1) .orderByDesc(TCrmSalesperson::getCreateTime); return R.ok(crmSalespersonService.list(wrapper)); } /** * 添加crm业务员管理管理 */ @Log(title = "crm业务员管理信息-新增crm业务员管理", businessType = BusinessType.INSERT) ruoyi-system/src/main/java/com/ruoyi/system/query/TCrmSalespersonQuery.java
@@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; @Data @ApiModel(value = "crm业务员管理查询参数TCrmSalespersonQuery") public class TCrmSalespersonQuery extends BasePage { @@ -21,4 +23,7 @@ @ApiModelProperty(value = "状态 1=使用中 2=已冻结") private Integer status; @ApiModelProperty(value = "分公司id集合") private List<String> branchIds; } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmBranchServiceImpl.java
@@ -256,6 +256,9 @@ } } } if(dto.getAuditStatus() == 3){ dto.setAuditStatus(1); } this.updateById(dto); // 删除区域 crmBranchAreaService.remove(Wrappers.lambdaQuery(TCrmBranchArea.class).eq(TCrmBranchArea::getBranchId, dto.getId())); ruoyi-system/src/main/resources/mapper/system/TCrmSalespersonMapper.xml
@@ -43,6 +43,12 @@ <if test="query.status != null"> and tcs.status = #{query.status} </if> <if test="query.branchIds != null and query.branchIds.size() > 0"> and tcs.branch_id in <foreach item="item" collection="query.branchIds" separator="," open="(" close=")"> #{item} </foreach> </if> AND tcs.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} </where> ORDER BY tcs.create_time DESC