| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.TCrmSalespersonDTO; |
| | | import com.ruoyi.system.model.TCrmBranch; |
| | | import com.ruoyi.system.model.TCrmChangePoints; |
| | |
| | | private final ISysUserService sysUserService; |
| | | private final TCrmChangePointsService crmChangePointsService; |
| | | private final TCrmBranchService crmBranchService; |
| | | private final TokenService tokenService; |
| | | @Autowired |
| | | public TCrmSalespersonController(TCrmSalespersonService crmSalespersonService, ISysUserService sysUserService, TCrmChangePointsService crmChangePointsService, TCrmBranchService crmBranchService) { |
| | | public TCrmSalespersonController(TCrmSalespersonService crmSalespersonService, ISysUserService sysUserService, TCrmChangePointsService crmChangePointsService, TCrmBranchService crmBranchService, TokenService tokenService) { |
| | | this.crmSalespersonService = crmSalespersonService; |
| | | this.sysUserService = sysUserService; |
| | | this.crmChangePointsService = crmChangePointsService; |
| | | this.crmBranchService = crmBranchService; |
| | | this.tokenService = tokenService; |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "获取crm业务员管理分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public R<PageInfo<TCrmSalespersonVO>> pageList(@RequestBody TCrmSalespersonQuery query) { |
| | | Long userId = tokenService.getLoginUser().getUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | if(roleType == 2){ |
| | | // 查询分公司信息 |
| | | TCrmBranch crmBranch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class) |
| | | .eq(TCrmBranch::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | query.setBranchId(crmBranch.getId()); |
| | | } |
| | | return R.ok(crmSalespersonService.pageList(query)); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "获取crm业务员管理列表") |
| | | @PostMapping(value = "/list") |
| | | public R<List<TCrmSalesperson>> list() { |
| | | return R.ok(crmSalespersonService.list(Wrappers.lambdaQuery(TCrmSalesperson.class) |
| | | .eq(TCrmSalesperson::getStatus,1) |
| | | .orderByDesc(TCrmSalesperson::getCreateTime))); |
| | | Long userId = tokenService.getLoginUser().getUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | LambdaQueryWrapper<TCrmSalesperson> wrapper = new LambdaQueryWrapper<>(); |
| | | if(roleType == 2){ |
| | | // 查询分公司信息 |
| | | TCrmBranch crmBranch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class) |
| | | .eq(TCrmBranch::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | wrapper.eq(TCrmSalesperson::getBranchId,crmBranch.getId()); |
| | | } |
| | | wrapper.eq(TCrmSalesperson::getStatus,1) |
| | | .orderByDesc(TCrmSalesperson::getCreateTime); |
| | | return R.ok(crmSalespersonService.list(wrapper)); |
| | | } |
| | | |
| | | /** |