xuhy
2025-09-02 416e245165e1357a2ec74365bc96cbebbe98aafb
crm分公司,业务员
12个文件已修改
9个文件已添加
773 ■■■■■ 已修改文件
generator/src/test/java/com/xizang/CodeGeneratorTests.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmChangePointsController.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmSalespersonController.java 182 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/TCrmSalespersonDTO.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TCrmChangePointsMapper.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TCrmSalespersonMapper.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TCrmBranch.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TCrmChangePoints.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TCrmSalesperson.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/query/TCrmSalespersonQuery.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TCrmBranchService.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TCrmChangePointsService.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TCrmSalespersonService.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmBranchServiceImpl.java 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmChangePointsServiceImpl.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmSalespersonServiceImpl.java 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/TCrmBranchVO.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/TCrmSalespersonVO.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TCrmChangePointsMapper.xml 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TCrmSalespersonMapper.xml 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
generator/src/test/java/com/xizang/CodeGeneratorTests.java
@@ -144,7 +144,7 @@
//         strategy.setTablePrefix(pc.getModuleName() + "");
//        strategy.setLikeTable(new LikeTable("room"));
        //strategy.setLikeTable(new LikeTable("member"));
        strategy.setLikeTable(new LikeTable("t_"));// 生成表名
        strategy.setLikeTable(new LikeTable("t_crm_change_points"));// 生成表名
//        strategy.setLikeTable(new LikeTable("t_hotel"));// 生成表名
//        strategy.setLikeTable(new LikeTable("t_scan_message"));// 生成表名
//        strategy.setNotLikeTable(new LikeTable("hotel_info"));// 不生成表名
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java
@@ -5,20 +5,23 @@
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.system.dto.TCrmBranchDTO;
import com.ruoyi.system.model.TCrmBranch;
import com.ruoyi.system.model.TErpGoods;
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.TCrmBranchQuery;
import com.ruoyi.system.service.TCrmBranchService;
import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.TCrmBranchVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
 * <p>
@@ -34,9 +37,17 @@
public class TCrmBranchController {
    private final TCrmBranchService crmBranchService;
    private final TCrmBranchAreaService crmBranchAreaService;
    private final TCrmBranchSalaryService crmBranchSalaryService;
    private final ISysUserService sysUserService;
    private final TCrmChangePointsService crmChangePointsService;
    @Autowired
    public TCrmBranchController(TCrmBranchService crmBranchService) {
    public TCrmBranchController(TCrmBranchService crmBranchService, TCrmBranchAreaService crmBranchAreaService, TCrmBranchSalaryService crmBranchSalaryService, ISysUserService sysUserService, TCrmChangePointsService crmChangePointsService) {
        this.crmBranchService = crmBranchService;
        this.crmBranchAreaService = crmBranchAreaService;
        this.crmBranchSalaryService = crmBranchSalaryService;
        this.sysUserService = sysUserService;
        this.crmChangePointsService = crmChangePointsService;
    }
    /**
@@ -64,7 +75,7 @@
    @ApiOperation(value = "添加crm分公司管理")
    @PostMapping(value = "/add")
    public R<Boolean> add(@Validated @RequestBody TCrmBranchDTO dto) {
        return crmBranchService.add(dto);
        return crmBranchService.addBranch(dto);
    }
    /**
@@ -73,8 +84,8 @@
    @Log(title = "crm分公司管理信息-修改crm分公司管理", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改crm分公司管理")
    @PostMapping(value = "/update")
    public R<Boolean> update(@Validated @RequestBody TCrmBranch dto) {
        return R.ok(crmBranchService.updateById(dto));
    public R<Boolean> update(@Validated @RequestBody TCrmBranchDTO dto) {
        return crmBranchService.updateBranch(dto);
    }
    /**
@@ -82,8 +93,17 @@
     */
    @ApiOperation(value = "查看crm分公司管理详情")
    @GetMapping(value = "/getDetailById")
    public R<TCrmBranch> getDetailById(@RequestParam String id) {
        return R.ok(crmBranchService.getById(id));
    public R<TCrmBranchVO> getDetailById(@RequestParam String id) {
        TCrmBranch crmBranch = crmBranchService.getById(id);
        TCrmBranchVO crmBranchVO = new TCrmBranchVO();
        BeanUtils.copyProperties(crmBranch, crmBranchVO);
        // 查询区域
        List<TCrmBranchArea> crmBranchAreas = crmBranchAreaService.list(Wrappers.lambdaQuery(TCrmBranchArea.class).eq(TCrmBranchArea::getBranchId, id));
        crmBranchVO.setCrmBranchAreas(crmBranchAreas);
        // 职位薪资
        List<TCrmBranchSalary> crmBranchSalaries = crmBranchSalaryService.list(Wrappers.lambdaQuery(TCrmBranchSalary.class).eq(TCrmBranchSalary::getBranchId, id));
        crmBranchVO.setCrmBranchSalaries(crmBranchSalaries);
        return R.ok(crmBranchVO);
    }
    /**
@@ -93,6 +113,13 @@
    @ApiOperation(value = "删除crm分公司管理")
    @DeleteMapping(value = "/deleteById")
    public R<Boolean> deleteById(@RequestParam String id) {
        // 删除区域
        crmBranchAreaService.remove(Wrappers.lambdaQuery(TCrmBranchArea.class).eq(TCrmBranchArea::getBranchId, id));
        // 删除职位薪资
        crmBranchSalaryService.remove(Wrappers.lambdaQuery(TCrmBranchSalary.class).eq(TCrmBranchSalary::getBranchId, id));
        // 删除账号
        TCrmBranch crmBranch = crmBranchService.getById(id);
        sysUserService.deleteUserById(crmBranch.getUserId());
        return R.ok(crmBranchService.removeById(id));
    }
@@ -103,8 +130,75 @@
    @ApiOperation(value = "批量删除crm分公司管理")
    @DeleteMapping(value = "/deleteByIds")
    public R<Boolean> deleteByIds(@RequestBody List<String> ids) {
        // 删除区域
        crmBranchAreaService.remove(Wrappers.lambdaQuery(TCrmBranchArea.class).in(TCrmBranchArea::getBranchId, ids));
        // 删除职位薪资
        crmBranchSalaryService.remove(Wrappers.lambdaQuery(TCrmBranchSalary.class).in(TCrmBranchSalary::getBranchId, ids));
        // 删除账号
        List<TCrmBranch> crmBranchList = crmBranchService.list(Wrappers.lambdaQuery(TCrmBranch.class).in(TCrmBranch::getId, ids));
        List<Long> userIds = crmBranchList.stream().map(TCrmBranch::getUserId).collect(Collectors.toList());
        sysUserService.deleteUserByIds(userIds);
        return R.ok(crmBranchService.removeByIds(ids));
    }
    /**
     * 批量删除crm分公司管理
     */
    @Log(title = "crm分公司管理信息-分公司管理解冻冻结", businessType = BusinessType.DELETE)
    @ApiOperation(value = "分公司管理解冻冻结")
    @PutMapping(value = "/thawOrFreeze")
    public R<Boolean> thawOrFreeze(@RequestParam(value = "id")String id,
                                   @RequestParam(value = "status")Integer status) {
        TCrmBranch crmBranch = crmBranchService.getById(id);
        crmBranch.setStatus(status);
        crmBranchService.updateById(crmBranch);
        // 查询用户
        SysUser sysUser = sysUserService.selectUserById(crmBranch.getUserId());
        switch (status){
            case 1:
                // 解冻
                sysUser.setStatus("0");
                sysUserService.updateUser(sysUser);
                break;
            case 2:
                // 冻结
                sysUser.setStatus("1");
                sysUserService.updateUser(sysUser);
                break;
        }
        return R.ok();
    }
    /**
     * 批量删除crm分公司管理
     */
    @Log(title = "crm分公司管理信息-分公司管理修改积分", businessType = BusinessType.DELETE)
    @ApiOperation(value = "分公司管理修改积分")
    @PutMapping(value = "/changePoints")
    public R<Boolean> changePoints(@RequestBody TCrmChangePoints changePoints) {
        // 查询分公司信息
        TCrmBranch crmBranch = crmBranchService.getById(changePoints.getBranchSalespersonId());
        if (Objects.isNull(crmBranch)) {
            return R.fail("未查询到该分公司");
        }
        switch (changePoints.getChangeType()){
            case 1:
                // 增加积分
                crmBranch.setUserPoints(crmBranch.getUserPoints() + changePoints.getChangeValue());
                break;
            case 2:
                // 减少积分
                if (crmBranch.getUserPoints() < changePoints.getChangeValue()) {
                    return R.fail("操作失败,剩余积分数不足");
                }
                crmBranch.setUserPoints(crmBranch.getUserPoints() - changePoints.getChangeValue());
                break;
        }
        crmBranchService.updateById(crmBranch);
        changePoints.setUserType(1);
        crmChangePointsService.save(changePoints);
        return R.ok();
    }
    
}
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmChangePointsController.java
New file
@@ -0,0 +1,21 @@
package com.ruoyi.web.controller.api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * <p>
 * crm修改积分记录 前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2025-09-02
 */
@RestController
@RequestMapping("/t-crm-change-points")
public class TCrmChangePointsController {
}
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmSalespersonController.java
@@ -1,8 +1,32 @@
package com.ruoyi.web.controller.api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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.system.dto.TCrmSalespersonDTO;
import com.ruoyi.system.model.TCrmBranch;
import com.ruoyi.system.model.TCrmChangePoints;
import com.ruoyi.system.model.TCrmSalesperson;
import com.ruoyi.system.query.TCrmSalespersonQuery;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.service.TCrmBranchService;
import com.ruoyi.system.service.TCrmChangePointsService;
import com.ruoyi.system.service.TCrmSalespersonService;
import com.ruoyi.system.vo.TCrmSalespersonVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
 * <p>
@@ -12,9 +36,163 @@
 * @author xiaochen
 * @since 2025-08-20
 */
@Api(tags = "crm业务员管理")
@RestController
@RequestMapping("/t-crm-salesperson")
public class TCrmSalespersonController {
    private final TCrmSalespersonService crmSalespersonService;
    private final ISysUserService sysUserService;
    private final TCrmChangePointsService crmChangePointsService;
    private final TCrmBranchService crmBranchService;
    @Autowired
    public TCrmSalespersonController(TCrmSalespersonService crmSalespersonService, ISysUserService sysUserService, TCrmChangePointsService crmChangePointsService, TCrmBranchService crmBranchService) {
        this.crmSalespersonService = crmSalespersonService;
        this.sysUserService = sysUserService;
        this.crmChangePointsService = crmChangePointsService;
        this.crmBranchService = crmBranchService;
    }
    /**
     * 获取crm业务员管理管理列表
     */
    @ApiOperation(value = "获取crm业务员管理分页列表")
    @PostMapping(value = "/pageList")
    public R<PageInfo<TCrmSalespersonVO>> pageList(@RequestBody TCrmSalespersonQuery query) {
        return R.ok(crmSalespersonService.pageList(query));
    }
    /**
     * 获取crm业务员管理管理列表
     */
    @ApiOperation(value = "获取crm业务员管理列表")
    @PostMapping(value = "/list")
    public R<List<TCrmSalesperson>> list() {
        return R.ok(crmSalespersonService.list(Wrappers.lambdaQuery(TCrmSalesperson.class).orderByDesc(TCrmSalesperson::getCreateTime)));
    }
    /**
     * 添加crm业务员管理管理
     */
    @Log(title = "crm业务员管理信息-新增crm业务员管理", businessType = BusinessType.INSERT)
    @ApiOperation(value = "添加crm业务员管理")
    @PostMapping(value = "/add")
    public R<Boolean> add(@Validated @RequestBody TCrmSalespersonDTO dto) {
        return crmSalespersonService.addSalesperson(dto);
    }
    /**
     * 修改crm业务员管理
     */
    @Log(title = "crm业务员管理信息-修改crm业务员管理", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改crm业务员管理")
    @PostMapping(value = "/update")
    public R<Boolean> update(@Validated @RequestBody TCrmSalespersonDTO dto) {
        return crmSalespersonService.updateSalesperson(dto);
    }
    /**
     * 查看crm业务员管理详情
     */
    @ApiOperation(value = "查看crm业务员管理详情")
    @GetMapping(value = "/getDetailById")
    public R<TCrmSalespersonVO> getDetailById(@RequestParam String id) {
        TCrmSalesperson crmSalesperson = crmSalespersonService.getById(id);
        TCrmSalespersonVO crmSalespersonVO = new TCrmSalespersonVO();
        BeanUtils.copyProperties(crmSalesperson, crmSalespersonVO);
        // 查询分公司
        TCrmBranch crmBranch = crmBranchService.getById(crmSalesperson.getBranchId());
        if (Objects.nonNull(crmBranch)) {
            crmSalespersonVO.setBranchName(crmBranch.getBranchName());
        }
        return R.ok(crmSalespersonVO);
    }
    /**
     * 删除crm业务员管理
     */
    @Log(title = "crm业务员管理信息-删除crm业务员管理", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除crm业务员管理")
    @DeleteMapping(value = "/deleteById")
    public R<Boolean> deleteById(@RequestParam String id) {
        // 删除账号
        TCrmSalesperson crmBranch = crmSalespersonService.getById(id);
        sysUserService.deleteUserById(crmBranch.getUserId());
        return R.ok(crmSalespersonService.removeById(id));
    }
    /**
     * 批量删除crm业务员管理
     */
    @Log(title = "crm业务员管理信息-删除crm业务员管理", businessType = BusinessType.DELETE)
    @ApiOperation(value = "批量删除crm业务员管理")
    @DeleteMapping(value = "/deleteByIds")
    public R<Boolean> deleteByIds(@RequestBody List<String> ids) {
        // 删除账号
        List<TCrmSalesperson> crmBranchList = crmSalespersonService.list(Wrappers.lambdaQuery(TCrmSalesperson.class).in(TCrmSalesperson::getId, ids));
        List<Long> userIds = crmBranchList.stream().map(TCrmSalesperson::getUserId).collect(Collectors.toList());
        sysUserService.deleteUserByIds(userIds);
        return R.ok(crmSalespersonService.removeByIds(ids));
    }
    /**
     * 批量删除crm业务员管理
     */
    @Log(title = "crm业务员管理信息-业务员管理解冻冻结", businessType = BusinessType.DELETE)
    @ApiOperation(value = "业务员管理解冻冻结")
    @PutMapping(value = "/thawOrFreeze")
    public R<Boolean> thawOrFreeze(@RequestParam(value = "id")String id,
                                   @RequestParam(value = "status")Integer status) {
        TCrmSalesperson crmSalesperson = crmSalespersonService.getById(id);
        crmSalesperson.setStatus(status);
        crmSalespersonService.updateById(crmSalesperson);
        // 查询用户
        SysUser sysUser = sysUserService.selectUserById(crmSalesperson.getUserId());
        switch (status){
            case 1:
                // 解冻
                sysUser.setStatus("0");
                sysUserService.updateUser(sysUser);
                break;
            case 2:
                // 冻结
                sysUser.setStatus("1");
                sysUserService.updateUser(sysUser);
                break;
        }
        return R.ok();
    }
    /**
     * 批量删除crm业务员管理
     */
    @Log(title = "crm业务员管理信息-业务员管理修改积分", businessType = BusinessType.DELETE)
    @ApiOperation(value = "业务员管理修改积分")
    @PutMapping(value = "/changePoints")
    public R<Boolean> changePoints(@RequestBody TCrmChangePoints changePoints) {
        // 查询分公司信息
        TCrmSalesperson crmSalesperson = crmSalespersonService.getById(changePoints.getBranchSalespersonId());
        if (Objects.isNull(crmSalesperson)) {
            return R.fail("未查询到该业务员");
        }
        switch (changePoints.getChangeType()){
            case 1:
                // 增加积分
                crmSalesperson.setUserPoints(crmSalesperson.getUserPoints() + changePoints.getChangeValue());
                break;
            case 2:
                // 减少积分
                if (crmSalesperson.getUserPoints() < changePoints.getChangeValue()) {
                    return R.fail("操作失败,剩余积分数不足");
                }
                crmSalesperson.setUserPoints(crmSalesperson.getUserPoints() - changePoints.getChangeValue());
                break;
        }
        crmSalespersonService.updateById(crmSalesperson);
        changePoints.setUserType(2);
        crmChangePointsService.save(changePoints);
        return R.ok();
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/dto/TCrmSalespersonDTO.java
New file
@@ -0,0 +1,15 @@
package com.ruoyi.system.dto;
import com.ruoyi.system.model.TCrmSalesperson;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value="crm业务员管理TCrmSalespersonDTO")
public class TCrmSalespersonDTO extends TCrmSalesperson {
    @ApiModelProperty(value = "密码")
    private String password;
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TCrmChangePointsMapper.java
New file
@@ -0,0 +1,16 @@
package com.ruoyi.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.model.TCrmChangePoints;
/**
 * <p>
 * crm修改积分记录 Mapper 接口
 * </p>
 *
 * @author xiaochen
 * @since 2025-09-02
 */
public interface TCrmChangePointsMapper extends BaseMapper<TCrmChangePoints> {
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TCrmSalespersonMapper.java
@@ -1,7 +1,13 @@
package com.ruoyi.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.system.model.TCrmSalesperson;
import com.ruoyi.system.query.TCrmSalespersonQuery;
import com.ruoyi.system.vo.TCrmSalespersonVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
 * <p>
@@ -13,4 +19,11 @@
 */
public interface TCrmSalespersonMapper extends BaseMapper<TCrmSalesperson> {
    /**
     * 列表查询
     *
     * @param query 查询参数
     * @return
     */
    List<TCrmSalespersonVO> pageList(@Param("query") TCrmSalespersonQuery query, @Param("pageInfo")PageInfo<TCrmSalespersonVO> pageInfo);
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TCrmBranch.java
@@ -32,7 +32,7 @@
    @ApiModelProperty(value = "后台用户id")
    @TableField("user_id")
    private Integer userId;
    private Long userId;
    @ApiModelProperty(value = "分公司名称")
    @TableField("branch_name")
ruoyi-system/src/main/java/com/ruoyi/system/model/TCrmChangePoints.java
New file
@@ -0,0 +1,53 @@
package com.ruoyi.system.model;
import com.baomidou.mybatisplus.annotation.*;
import com.ruoyi.common.core.domain.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
 * <p>
 * crm修改积分记录
 * </p>
 *
 * @author xiaochen
 * @since 2025-09-02
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("t_crm_change_points")
@ApiModel(value="TCrmChangePoints对象", description="crm修改积分记录")
public class TCrmChangePoints extends BaseModel {
    private static final long serialVersionUID = 1L;
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;
    @ApiModelProperty(value = "分公司id、业务员id")
    @TableField("branch_salesperson_id")
    private String branchSalespersonId;
    @ApiModelProperty(value = "用户类型 1=分公司 2=业务员")
    @TableField("user_type")
    private Integer userType;
    @ApiModelProperty(value = "变更类型 1=增加 2=减少")
    @TableField("change_type")
    private Integer changeType;
    @ApiModelProperty(value = "变更数量")
    @TableField("change_value")
    private Integer changeValue;
    @ApiModelProperty(value = "备注")
    @TableField("remarks")
    private String remarks;
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TCrmSalesperson.java
@@ -32,7 +32,7 @@
    @ApiModelProperty(value = "后台用户id")
    @TableField("user_id")
    private Integer userId;
    private Long userId;
    @ApiModelProperty(value = "业务员名称")
    @TableField("salesperson_name")
ruoyi-system/src/main/java/com/ruoyi/system/query/TCrmSalespersonQuery.java
New file
@@ -0,0 +1,24 @@
package com.ruoyi.system.query;
import com.ruoyi.common.core.domain.BasePage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "crm业务员管理查询参数TCrmSalespersonQuery")
public class TCrmSalespersonQuery extends BasePage {
    @ApiModelProperty(value = "业务员名称")
    private String salespersonName;
    @ApiModelProperty(value = "手机号")
    private String phone;
    @ApiModelProperty(value = "分公司id")
    private String branchId;
    @ApiModelProperty(value = "状态 1=使用中 2=已冻结")
    private Integer status;
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TCrmBranchService.java
@@ -31,11 +31,18 @@
     * @param dto
     * @return
     */
    R<Boolean> add(TCrmBranchDTO dto);
    R<Boolean> addBranch(TCrmBranchDTO dto);
    /**
     * 判断分类是否存在
     * 判断是否存在
     * @param dto
     * @return
     */
    boolean isExit(TCrmBranchDTO dto);
    /**
     * 修改
     * @param dto
     * @return
     */
    R<Boolean> updateBranch(TCrmBranchDTO dto);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TCrmChangePointsService.java
New file
@@ -0,0 +1,16 @@
package com.ruoyi.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.system.model.TCrmChangePoints;
/**
 * <p>
 * crm修改积分记录 服务类
 * </p>
 *
 * @author xiaochen
 * @since 2025-09-02
 */
public interface TCrmChangePointsService extends IService<TCrmChangePoints> {
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TCrmSalespersonService.java
@@ -1,7 +1,13 @@
package com.ruoyi.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.dto.TCrmBranchDTO;
import com.ruoyi.system.dto.TCrmSalespersonDTO;
import com.ruoyi.system.model.TCrmSalesperson;
import com.ruoyi.system.query.TCrmSalespersonQuery;
import com.ruoyi.system.vo.TCrmSalespersonVO;
/**
 * <p>
@@ -13,4 +19,31 @@
 */
public interface TCrmSalespersonService extends IService<TCrmSalesperson> {
    /**
     * 获取crm业务员管理分页列表
     *
     * @param query 查询参数
     * @return PageInfo<TCrmSalespersonVO>
     */
    PageInfo<TCrmSalespersonVO> pageList(TCrmSalespersonQuery query);
    /**
     * 新增crm业务员管理
     *
     * @return List<TCrmSalesperson>
     */
    R<Boolean> addSalesperson(TCrmSalespersonDTO dto);
    /**
     * 修改crm业务员管理
     *
     * @return List<TCrmSalesperson>
     */
    R<Boolean> updateSalesperson(TCrmSalespersonDTO dto);
    /**
     * 判断分类是否存在
     * @param dto
     * @return
     */
    boolean isExit(TCrmSalespersonDTO dto);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmBranchServiceImpl.java
@@ -4,14 +4,19 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.dto.TCrmBranchDTO;
import com.ruoyi.system.mapper.TCrmBranchAreaMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.mapper.TCrmBranchMapper;
import com.ruoyi.system.model.TCrmBranch;
import com.ruoyi.system.model.TCrmBranchArea;
import com.ruoyi.system.model.TCrmDevice;
import com.ruoyi.system.model.TCrmBranchSalary;
import com.ruoyi.system.query.TCrmBranchQuery;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.service.TCrmBranchAreaService;
import com.ruoyi.system.service.TCrmBranchSalaryService;
import com.ruoyi.system.service.TCrmBranchService;
import com.ruoyi.system.vo.TCrmBranchVO;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +25,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@@ -34,18 +40,22 @@
public class TCrmBranchServiceImpl extends ServiceImpl<TCrmBranchMapper, TCrmBranch> implements TCrmBranchService {
    @Autowired
    private TCrmBranchAreaMapper crmBranchAreaMapper;
    private TCrmBranchAreaService crmBranchAreaService;
    @Autowired
    private TCrmBranchSalaryService crmBranchSalaryService;
    @Autowired
    private ISysUserService sysUserService;
    @Override
    public PageInfo<TCrmBranchVO> pageList(TCrmBranchQuery query) {
        List<TCrmBranchArea> crmBranchAreas = new ArrayList<>();
        if(StringUtils.isNotEmpty(query.getCityCode())){
            crmBranchAreas = crmBranchAreaMapper.selectList(Wrappers.lambdaQuery(TCrmBranchArea.class)
            crmBranchAreas = crmBranchAreaService.list(Wrappers.lambdaQuery(TCrmBranchArea.class)
                    .eq(TCrmBranchArea::getCityCode, query.getCityCode()));
        }
        if(!StringUtils.isNotEmpty(query.getCityCode()) && StringUtils.isNotEmpty(query.getProvinceCode())){
            crmBranchAreas = crmBranchAreaMapper.selectList(Wrappers.lambdaQuery(TCrmBranchArea.class)
            crmBranchAreas = crmBranchAreaService.list(Wrappers.lambdaQuery(TCrmBranchArea.class)
                    .eq(TCrmBranchArea::getProvinceCode, query.getProvinceCode()));
        }
        if(!CollectionUtils.isEmpty(crmBranchAreas)){
@@ -58,7 +68,7 @@
            return pageInfo;
        }
        List<String> branchIds = list.stream().map(TCrmBranchVO::getId).collect(Collectors.toList());
        List<TCrmBranchArea> crmBranchAreaList = crmBranchAreaMapper.selectList(Wrappers.lambdaQuery(TCrmBranchArea.class)
        List<TCrmBranchArea> crmBranchAreaList = crmBranchAreaService.list(Wrappers.lambdaQuery(TCrmBranchArea.class)
                .in(TCrmBranchArea::getBranchId, branchIds));
        for (TCrmBranchVO tCrmBranchVO : list) {
            List<TCrmBranchArea> tCrmBranchAreas = crmBranchAreaList.stream().filter(t -> t.getBranchId().equals(tCrmBranchVO.getId())).collect(Collectors.toList());
@@ -71,11 +81,38 @@
    }
    @Override
    public R<Boolean> add(TCrmBranchDTO dto) {
    public R<Boolean> addBranch(TCrmBranchDTO dto) {
        if (isExit(dto)) {
            return R.fail("crm分公司管理名称已存在");
        }
        return null;
        // 判断账号是否已存在
        SysUser sysUser = sysUserService.selectUserByUserName(dto.getPhone());
        if(Objects.nonNull(sysUser)){
            return R.fail(dto.getPhone()+"-账号已存在");
        }
        this.save(dto);
        // 添加区域
        List<TCrmBranchArea> branchAreas = dto.getBranchAreas();
        branchAreas.forEach(t -> t.setBranchId(dto.getId()));
        crmBranchAreaService.saveBatch(branchAreas);
        // 添加职位薪资
        List<TCrmBranchSalary> branchSalaries = dto.getBranchSalaries();
        branchSalaries.forEach(t -> t.setBranchId(dto.getId()));
        crmBranchSalaryService.saveBatch(branchSalaries);
        // 添加账号
        SysUser user = new SysUser();
        user.setUserName(dto.getPhone());
        user.setPhonenumber(dto.getPhone());
        user.setNickName(dto.getUserName());
        user.setPassword(SecurityUtils.encryptPassword(dto.getPassword()));
        user.setStatus("0");
        user.setDelFlag("0");
        user.setRoleType(2);
        user.setRoleId(2L);
        sysUserService.insertUser(user);
        dto.setUserId(user.getUserId());
        this.updateById(dto);
        return R.ok();
    }
    @Override
@@ -88,4 +125,44 @@
            return this.count(Wrappers.lambdaQuery(TCrmBranch.class).eq(TCrmBranch::getBranchName, dto.getBranchName())) > 0;
        }
    }
    @Override
    public R<Boolean> updateBranch(TCrmBranchDTO dto) {
        if (isExit(dto)) {
            return R.fail("crm分公司管理名称已存在");
        }
        // 判断账号是否已存在
        SysUser sysUser1 = sysUserService.selectUserByUserName(dto.getPhone());
        if(Objects.nonNull(sysUser1) && !sysUser1.getUserId().equals(dto.getUserId())){
            return R.fail(dto.getPhone()+"-账号已存在");
        }
        SysUser user = sysUserService.selectUserById(dto.getUserId());
        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);
        // 删除职位薪资
        crmBranchSalaryService.remove(Wrappers.lambdaQuery(TCrmBranchSalary.class).eq(TCrmBranchSalary::getBranchId, dto.getId()));
        // 添加职位薪资
        List<TCrmBranchSalary> branchSalaries = dto.getBranchSalaries();
        branchSalaries.forEach(t -> t.setBranchId(dto.getId()));
        crmBranchSalaryService.saveBatch(branchSalaries);
        if(Objects.nonNull(user)){
            // 修改账号
            user.setPhonenumber(dto.getPhone());
            user.setUserName(dto.getPhone());
            user.setNickName(dto.getUserName());
            user.setPassword(SecurityUtils.encryptPassword(dto.getPassword()));
            sysUserService.updateUser(user);
        }
//        if(Objects.nonNull(user) && user.getUserName().equals(dto.getPhone()) && StringUtils.isNotEmpty(dto.getPassword())) {
//            // 修改密码
//            user.setPassword(SecurityUtils.encryptPassword(dto.getPassword()));
//            sysUserService.updateUser(user);
//        }
        return R.ok();
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmChangePointsServiceImpl.java
New file
@@ -0,0 +1,20 @@
package com.ruoyi.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.mapper.TCrmChangePointsMapper;
import com.ruoyi.system.model.TCrmChangePoints;
import com.ruoyi.system.service.TCrmChangePointsService;
import org.springframework.stereotype.Service;
/**
 * <p>
 * crm修改积分记录 服务实现类
 * </p>
 *
 * @author xiaochen
 * @since 2025-09-02
 */
@Service
public class TCrmChangePointsServiceImpl extends ServiceImpl<TCrmChangePointsMapper, TCrmChangePoints> implements TCrmChangePointsService {
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmSalespersonServiceImpl.java
@@ -1,10 +1,30 @@
package com.ruoyi.system.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.dto.TCrmSalespersonDTO;
import com.ruoyi.system.mapper.TCrmSalespersonMapper;
import com.ruoyi.system.model.TCrmBranch;
import com.ruoyi.system.model.TCrmBranchArea;
import com.ruoyi.system.model.TCrmBranchSalary;
import com.ruoyi.system.model.TCrmSalesperson;
import com.ruoyi.system.query.TCrmSalespersonQuery;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.service.TCrmSalespersonService;
import com.ruoyi.system.vo.TCrmBranchVO;
import com.ruoyi.system.vo.TCrmSalespersonVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
 * <p>
@@ -17,4 +37,69 @@
@Service
public class TCrmSalespersonServiceImpl extends ServiceImpl<TCrmSalespersonMapper, TCrmSalesperson> implements TCrmSalespersonService {
    @Autowired
    private ISysUserService sysUserService;
    @Override
    public PageInfo<TCrmSalespersonVO> pageList(TCrmSalespersonQuery query) {
        PageInfo<TCrmSalespersonVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TCrmSalespersonVO> list = this.baseMapper.pageList(query,pageInfo);
        pageInfo.setRecords(list);
        return pageInfo;
    }
    @Override
    public R<Boolean> addSalesperson(TCrmSalespersonDTO dto) {
        // 判断账号是否已存在
        SysUser sysUser = sysUserService.selectUserByUserName(dto.getPhone());
        if(Objects.nonNull(sysUser)){
            return R.fail(dto.getPhone()+"-账号已存在");
        }
        this.save(dto);
        // 添加账号
        SysUser user = new SysUser();
        user.setUserName(dto.getPhone());
        user.setPhonenumber(dto.getPhone());
        user.setNickName(dto.getSalespersonName());
        user.setPassword(SecurityUtils.encryptPassword(dto.getPassword()));
        user.setStatus("0");
        user.setDelFlag("0");
        user.setRoleType(3);
        user.setRoleId(3L);
        sysUserService.insertUser(user);
        dto.setUserId(user.getUserId());
        this.updateById(dto);
        return R.ok();
    }
    @Override
    public R<Boolean> updateSalesperson(TCrmSalespersonDTO dto) {
        // 判断账号是否已存在
        SysUser sysUser1 = sysUserService.selectUserByUserName(dto.getPhone());
        if(Objects.nonNull(sysUser1) && !sysUser1.getUserId().equals(dto.getUserId())){
            return R.fail(dto.getPhone()+"-账号已存在");
        }
        SysUser user = sysUserService.selectUserById(dto.getUserId());
        this.updateById(dto);
        if(Objects.nonNull(user)){
            // 修改账号
            user.setPhonenumber(dto.getPhone());
            user.setUserName(dto.getPhone());
            user.setNickName(dto.getSalespersonName());
            user.setPassword(SecurityUtils.encryptPassword(dto.getPassword()));
            sysUserService.updateUser(user);
        }
        return R.ok();
    }
    @Override
    public boolean isExit(TCrmSalespersonDTO dto) {
        if(StringUtils.isNotEmpty(dto.getId())){
            // 修改
            return this.count(Wrappers.lambdaQuery(TCrmSalesperson.class).ne(TCrmSalesperson::getId, dto.getId()).eq(TCrmSalesperson::getSalespersonName, dto.getSalespersonName())) > 0;
        }else {
            // 新增
            return this.count(Wrappers.lambdaQuery(TCrmSalesperson.class).eq(TCrmSalesperson::getSalespersonName, dto.getSalespersonName())) > 0;
        }
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/TCrmBranchVO.java
@@ -1,9 +1,13 @@
package com.ruoyi.system.vo;
import com.ruoyi.system.model.TCrmBranch;
import com.ruoyi.system.model.TCrmBranchArea;
import com.ruoyi.system.model.TCrmBranchSalary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(value = "crm分公司管理VO")
@@ -12,4 +16,10 @@
    @ApiModelProperty(value = "省份")
    private String provinceName;
    @ApiModelProperty(value = "省市列表")
    private List<TCrmBranchArea> crmBranchAreas;
    @ApiModelProperty(value = "职位薪资")
    private List<TCrmBranchSalary> crmBranchSalaries;
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/TCrmSalespersonVO.java
New file
@@ -0,0 +1,15 @@
package com.ruoyi.system.vo;
import com.ruoyi.system.model.TCrmSalesperson;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "crm业务员管理TCrmSalespersonVO")
public class TCrmSalespersonVO extends TCrmSalesperson {
    @ApiModelProperty(value = "分公司名称")
    private String branchName;
}
ruoyi-system/src/main/resources/mapper/system/TCrmChangePointsMapper.xml
New file
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.TCrmChangePointsMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.system.model.TCrmChangePoints">
        <id column="id" property="id" />
        <result column="branch_salesperson_id" property="branchSalespersonId" />
        <result column="user_type" property="userType" />
        <result column="change_type" property="changeType" />
        <result column="change_value" property="changeValue" />
        <result column="remarks" property="remarks" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="create_by" property="createBy" />
        <result column="update_by" property="updateBy" />
        <result column="disabled" property="disabled" />
    </resultMap>
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, branch_salesperson_id, user_type, change_type, change_value, remarks, create_time, update_time, create_by, update_by, disabled
    </sql>
</mapper>
ruoyi-system/src/main/resources/mapper/system/TCrmSalespersonMapper.xml
@@ -24,5 +24,28 @@
    <sql id="Base_Column_List">
        id, user_id, salesperson_name, phone, branch_id, money_commission, points_commission, user_points, status, create_time, update_time, create_by, update_by, disabled
    </sql>
    <select id="pageList" resultType="com.ruoyi.system.vo.TCrmSalespersonVO">
        select
            tcs.id, tcs.user_id, tcs.salesperson_name, tcs.phone, tcs.branch_id, tcs.money_commission, tcs.points_commission, tcs.user_points,
            tcs.status, tcs.create_time, tcs.update_time, tcs.create_by, tcs.update_by, tcs.disabled, tcb.branch_name
        from t_crm_salesperson tcs
        left join t_crm_branch tcb on tcs.branch_id = tcb.id
        <where>
            <if test="query.salespersonName != null and query.salespersonName != ''">
                and tcs.salesperson_name like concat('%',#{query.salespersonName},'%')
            </if>
            <if test="query.phone != null and query.phone != ''">
                and tcs.phone like concat('%',#{query.phone},'%')
            </if>
            <if test="query.branchId != null and query.branchId != ''">
                and tcs.branch_id = #{query.branchId}
            </if>
            <if test="query.status != null">
                and tcs.status = #{query.status}
            </if>
            AND tcs.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY tcs.create_time DESC
    </select>
</mapper>