xuhy
3 天以前 4d1f7143f73456c142fd532248a6327021d04de8
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.*;
@@ -44,15 +45,17 @@
    private final ISysUserService sysUserService;
    private final TCrmChangePointsService crmChangePointsService;
    private final TCrmPositionService crmPositionService;
    private final TCrmSalespersonService crmSalespersonService;
    private final TokenService tokenService;
    @Autowired
    public TCrmBranchController(TCrmBranchService crmBranchService, TCrmBranchAreaService crmBranchAreaService, TCrmBranchSalaryService crmBranchSalaryService, ISysUserService sysUserService, TCrmChangePointsService crmChangePointsService, TCrmPositionService crmPositionService, TokenService tokenService) {
    public TCrmBranchController(TCrmBranchService crmBranchService, TCrmBranchAreaService crmBranchAreaService, TCrmBranchSalaryService crmBranchSalaryService, ISysUserService sysUserService, TCrmChangePointsService crmChangePointsService, TCrmPositionService crmPositionService, TCrmSalespersonService crmSalespersonService, TokenService tokenService) {
        this.crmBranchService = crmBranchService;
        this.crmBranchAreaService = crmBranchAreaService;
        this.crmBranchSalaryService = crmBranchSalaryService;
        this.sysUserService = sysUserService;
        this.crmChangePointsService = crmChangePointsService;
        this.crmPositionService = crmPositionService;
        this.crmSalespersonService = crmSalespersonService;
        this.tokenService = tokenService;
    }
@@ -74,8 +77,17 @@
        Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
        Long userId = tokenService.getLoginUser().getUserId();
        LambdaQueryWrapper<TCrmBranch> wrapper = new LambdaQueryWrapper<>();
        if (roleType == 1) {
        if (roleType == 2) {
            wrapper.eq(TCrmBranch::getUserId, userId);
        }
        if(roleType == 3){
            // 查询业务员信息
            TCrmSalesperson crmSalesperson = crmSalespersonService.getOne(Wrappers.lambdaQuery(TCrmSalesperson.class)
                    .eq(TCrmSalesperson::getUserId, userId)
                    .last("LIMIT 1"));
            if(Objects.nonNull(crmSalesperson)){
                wrapper.eq(TCrmBranch::getId, crmSalesperson.getBranchId());
            }
        }
        wrapper.eq(TCrmBranch::getStatus,1).orderByDesc(TCrmBranch::getCreateTime);
        return R.ok(crmBranchService.list(wrapper));
@@ -181,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();