Commit 0253846fdfb604043181773798117fc34ce9bc61
Merge branch 'develop' of https://gitee.com/zh8790/ruoyi-vue-pro_develop into develop
# Conflicts: # yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
Showing
11 changed files
with
115 additions
and
14 deletions
README.md
| @@ -92,6 +92,8 @@ | @@ -92,6 +92,8 @@ | ||
| 92 | 92 | ||
| 93 | 如果你想把【完整版】的功能,迁移到【精简版】,可以参考 [《迁移功能到精简版》](https://doc.iocoder.cn/migrate-module/) 文档。 | 93 | 如果你想把【完整版】的功能,迁移到【精简版】,可以参考 [《迁移功能到精简版》](https://doc.iocoder.cn/migrate-module/) 文档。 |
| 94 | 94 | ||
| 95 | +如果你想把【完整版】的功能,迁移到【精简版】,可以参考 [《迁移功能到精简版》](https://doc.iocoder.cn/migrate-module/) 文档。 | ||
| 96 | + | ||
| 95 | ## 😎 开源协议 | 97 | ## 😎 开源协议 |
| 96 | 98 | ||
| 97 | **为什么推荐使用本项目?** | 99 | **为什么推荐使用本项目?** |
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
| @@ -40,6 +40,12 @@ public interface ErrorCodeConstants { | @@ -40,6 +40,12 @@ public interface ErrorCodeConstants { | ||
| 40 | ErrorCode CUSTOMER_LOCKED_PUT_POOL_FAIL = new ErrorCode(1_020_006_005, "客户【{}】放入公海失败,原因:客户已锁定"); | 40 | ErrorCode CUSTOMER_LOCKED_PUT_POOL_FAIL = new ErrorCode(1_020_006_005, "客户【{}】放入公海失败,原因:客户已锁定"); |
| 41 | ErrorCode CUSTOMER_UPDATE_OWNER_USER_FAIL = new ErrorCode(1_020_006_006, "更新客户【{}】负责人失败, 原因:系统异常"); | 41 | ErrorCode CUSTOMER_UPDATE_OWNER_USER_FAIL = new ErrorCode(1_020_006_006, "更新客户【{}】负责人失败, 原因:系统异常"); |
| 42 | 42 | ||
| 43 | + ErrorCode CUSTOMER_UNLOCK_STATUS_NO_REPETITION = new ErrorCode(1_020_006_001, "无需重复操作锁定/解锁状态"); | ||
| 44 | + | ||
| 45 | + ErrorCode CUSTOMER_NO_DEPARTMENT_FOUND = new ErrorCode(1_020_006_002, "操作失败,请先绑定部门再进行操作"); | ||
| 46 | + | ||
| 47 | + ErrorCode CUSTOMER_EXCEED_LOCK_LIMIT = new ErrorCode(1_020_006_003, "操作失败,超出锁定规则上限"); | ||
| 48 | + | ||
| 43 | // ========== 权限管理 1_020_007_000 ========== | 49 | // ========== 权限管理 1_020_007_000 ========== |
| 44 | ErrorCode CRM_PERMISSION_NOT_EXISTS = new ErrorCode(1_020_007_000, "数据权限不存在"); | 50 | ErrorCode CRM_PERMISSION_NOT_EXISTS = new ErrorCode(1_020_007_000, "数据权限不存在"); |
| 45 | ErrorCode CRM_PERMISSION_DENIED = new ErrorCode(1_020_007_001, "{}操作失败,原因:没有权限"); | 51 | ErrorCode CRM_PERMISSION_DENIED = new ErrorCode(1_020_007_001, "{}操作失败,原因:没有权限"); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
| @@ -159,8 +159,8 @@ public class CrmCustomerController { | @@ -159,8 +159,8 @@ public class CrmCustomerController { | ||
| 159 | @Operation(summary = "锁定/解锁客户") | 159 | @Operation(summary = "锁定/解锁客户") |
| 160 | @OperateLog(enable = false) // TODO 关闭原有日志记录 | 160 | @OperateLog(enable = false) // TODO 关闭原有日志记录 |
| 161 | @PreAuthorize("@ss.hasPermission('crm:customer:update')") | 161 | @PreAuthorize("@ss.hasPermission('crm:customer:update')") |
| 162 | - public CommonResult<Boolean> lockCustomer(@Valid @RequestBody CrmCustomerUpdateReqVO updateReqVO) { | ||
| 163 | - customerService.lockCustomer(updateReqVO); | 162 | + public CommonResult<Boolean> lockCustomer(@Valid @RequestBody CrmCustomerLockReqVO lockReqVO) { |
| 163 | + customerService.lockCustomer(lockReqVO); | ||
| 164 | return success(true); | 164 | return success(true); |
| 165 | } | 165 | } |
| 166 | 166 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerLockReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +@Schema(description = "管理后台 - CRM 客户锁定/解锁 Request VO") | ||
| 7 | +@Data | ||
| 8 | +public class CrmCustomerLockReqVO { | ||
| 9 | + | ||
| 10 | + @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") | ||
| 11 | + private Long id; | ||
| 12 | + | ||
| 13 | + @Schema(description = "客户锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||
| 14 | + private Boolean lockStatus; | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigCreateReqVO.java
| @@ -5,10 +5,16 @@ import lombok.Data; | @@ -5,10 +5,16 @@ import lombok.Data; | ||
| 5 | import lombok.EqualsAndHashCode; | 5 | import lombok.EqualsAndHashCode; |
| 6 | import lombok.ToString; | 6 | import lombok.ToString; |
| 7 | 7 | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 8 | @Schema(description = "管理后台 - 客户限制配置创建 Request VO") | 10 | @Schema(description = "管理后台 - 客户限制配置创建 Request VO") |
| 9 | @Data | 11 | @Data |
| 10 | @EqualsAndHashCode(callSuper = true) | 12 | @EqualsAndHashCode(callSuper = true) |
| 11 | @ToString(callSuper = true) | 13 | @ToString(callSuper = true) |
| 12 | public class CrmCustomerLimitConfigCreateReqVO extends CrmCustomerLimitConfigBaseVO { | 14 | public class CrmCustomerLimitConfigCreateReqVO extends CrmCustomerLimitConfigBaseVO { |
| 13 | 15 | ||
| 16 | + | ||
| 17 | + @Schema(description = "规则适用人群") | ||
| 18 | + private Long userId; | ||
| 19 | + | ||
| 14 | } | 20 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java
| @@ -79,4 +79,6 @@ public interface CrmCustomerConvert { | @@ -79,4 +79,6 @@ public interface CrmCustomerConvert { | ||
| 79 | 79 | ||
| 80 | List<CrmCustomerQueryAllRespVO> convertQueryAll(List<CrmCustomerDO> crmCustomerDO); | 80 | List<CrmCustomerQueryAllRespVO> convertQueryAll(List<CrmCustomerDO> crmCustomerDO); |
| 81 | 81 | ||
| 82 | + CrmCustomerDO convert(CrmCustomerLockReqVO lockReqVO); | ||
| 83 | + | ||
| 82 | } | 84 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerLimitConfigMapper.java
| @@ -3,10 +3,14 @@ package cn.iocoder.yudao.module.crm.dal.mysql.customer; | @@ -3,10 +3,14 @@ package cn.iocoder.yudao.module.crm.dal.mysql.customer; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO; | ||
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; | 7 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; |
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; |
| 8 | import org.apache.ibatis.annotations.Mapper; | 9 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 10 | ||
| 11 | +import java.util.Arrays; | ||
| 12 | +import java.util.stream.Collectors; | ||
| 13 | + | ||
| 10 | /** | 14 | /** |
| 11 | * 客户限制配置 Mapper | 15 | * 客户限制配置 Mapper |
| 12 | * | 16 | * |
| @@ -21,4 +25,16 @@ public interface CrmCustomerLimitConfigMapper extends BaseMapperX<CrmCustomerLim | @@ -21,4 +25,16 @@ public interface CrmCustomerLimitConfigMapper extends BaseMapperX<CrmCustomerLim | ||
| 21 | .orderByDesc(CrmCustomerLimitConfigDO::getId)); | 25 | .orderByDesc(CrmCustomerLimitConfigDO::getId)); |
| 22 | } | 26 | } |
| 23 | 27 | ||
| 28 | + default CrmCustomerLimitConfigDO selectByLimitConfig(CrmCustomerLimitConfigCreateReqVO reqVO){ | ||
| 29 | + LambdaQueryWrapperX<CrmCustomerLimitConfigDO> queryWrapper = new LambdaQueryWrapperX<>(); | ||
| 30 | + queryWrapper.apply("FIND_IN_SET({0}, user_ids) > 0", reqVO.getUserId()); | ||
| 31 | + queryWrapper.eq(CrmCustomerLimitConfigDO::getType, reqVO.getType()); | ||
| 32 | + // 将部门ID列表转换成逗号分隔的字符串 | ||
| 33 | + String deptIdsString = reqVO.getDeptIds().stream() | ||
| 34 | + .map(String::valueOf) | ||
| 35 | + .collect(Collectors.joining(",")); | ||
| 36 | + queryWrapper.apply("FIND_IN_SET({0}, dept_ids) > 0", deptIdsString); | ||
| 37 | + return selectOne(queryWrapper); | ||
| 38 | + } | ||
| 39 | + | ||
| 24 | } | 40 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigService.java
| @@ -53,4 +53,9 @@ public interface CrmCustomerLimitConfigService { | @@ -53,4 +53,9 @@ public interface CrmCustomerLimitConfigService { | ||
| 53 | */ | 53 | */ |
| 54 | PageResult<CrmCustomerLimitConfigDO> getCustomerLimitConfigPage(CrmCustomerLimitConfigPageReqVO pageReqVO); | 54 | PageResult<CrmCustomerLimitConfigDO> getCustomerLimitConfigPage(CrmCustomerLimitConfigPageReqVO pageReqVO); |
| 55 | 55 | ||
| 56 | + /** | ||
| 57 | + * 查询当前登录人客户限制配置 | ||
| 58 | + */ | ||
| 59 | + CrmCustomerLimitConfigDO selectByLimitConfig(CrmCustomerLimitConfigCreateReqVO configReqVO); | ||
| 60 | + | ||
| 56 | } | 61 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java
| @@ -90,4 +90,9 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig | @@ -90,4 +90,9 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig | ||
| 90 | adminUserApi.validateUserList(userIds); | 90 | adminUserApi.validateUserList(userIds); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | + @Override | ||
| 94 | + public CrmCustomerLimitConfigDO selectByLimitConfig(CrmCustomerLimitConfigCreateReqVO configReqVO) { | ||
| 95 | + return customerLimitConfigMapper.selectByLimitConfig(configReqVO); | ||
| 96 | + } | ||
| 97 | + | ||
| 93 | } | 98 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java
| 1 | package cn.iocoder.yudao.module.crm.service.customer; | 1 | package cn.iocoder.yudao.module.crm.service.customer; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; | ||
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; | 4 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; |
| 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 9 | import jakarta.validation.Valid; | 6 | import jakarta.validation.Valid; |
| 10 | 7 | ||
| @@ -85,9 +82,9 @@ public interface CrmCustomerService { | @@ -85,9 +82,9 @@ public interface CrmCustomerService { | ||
| 85 | /** | 82 | /** |
| 86 | * 锁定/解锁客户 | 83 | * 锁定/解锁客户 |
| 87 | * | 84 | * |
| 88 | - * @param updateReqVO 更新信息 | 85 | + * @param lockReqVO 更新信息 |
| 89 | */ | 86 | */ |
| 90 | - void lockCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO); | 87 | + void lockCustomer(@Valid CrmCustomerLockReqVO lockReqVO); |
| 91 | 88 | ||
| 92 | // ==================== 公海相关操作 ==================== | 89 | // ==================== 公海相关操作 ==================== |
| 93 | 90 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| @@ -7,8 +7,11 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreat | @@ -7,8 +7,11 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreat | ||
| 7 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; | 7 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; |
| 8 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO; | 8 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO; |
| 9 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; | 9 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; |
| 10 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; | ||
| 11 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO; | ||
| 10 | import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; | 12 | import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; |
| 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | 13 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 14 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; | ||
| 12 | import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; | 15 | import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; |
| 13 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | 16 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 14 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | 17 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| @@ -16,9 +19,11 @@ import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPerm | @@ -16,9 +19,11 @@ import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPerm | ||
| 16 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; | 19 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 17 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; | 20 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 18 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 21 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 22 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | ||
| 19 | import com.mzt.logapi.context.LogRecordContext; | 23 | import com.mzt.logapi.context.LogRecordContext; |
| 20 | import com.mzt.logapi.service.impl.DiffParseFunction; | 24 | import com.mzt.logapi.service.impl.DiffParseFunction; |
| 21 | import com.mzt.logapi.starter.annotation.LogRecord; | 25 | import com.mzt.logapi.starter.annotation.LogRecord; |
| 26 | +import com.mzt.logapi.starter.annotation.LogRecord; | ||
| 22 | import jakarta.annotation.Resource; | 27 | import jakarta.annotation.Resource; |
| 23 | import org.springframework.stereotype.Service; | 28 | import org.springframework.stereotype.Service; |
| 24 | import org.springframework.transaction.annotation.Transactional; | 29 | import org.springframework.transaction.annotation.Transactional; |
| @@ -28,9 +33,13 @@ import java.time.LocalDateTime; | @@ -28,9 +33,13 @@ import java.time.LocalDateTime; | ||
| 28 | import java.util.*; | 33 | import java.util.*; |
| 29 | 34 | ||
| 30 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 35 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 36 | +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||
| 31 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | 37 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; |
| 32 | import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CUSTOMER; | 38 | import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CUSTOMER; |
| 33 | import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.TRANSFER_CUSTOMER_LOG_SUCCESS; | 39 | import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.TRANSFER_CUSTOMER_LOG_SUCCESS; |
| 40 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_EXCEED_LOCK_LIMIT; | ||
| 41 | +import static cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum.CUSTOMER_LOCK_LIMIT; | ||
| 42 | +import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CUSTOMER; | ||
| 34 | import static java.util.Collections.singletonList; | 43 | import static java.util.Collections.singletonList; |
| 35 | 44 | ||
| 36 | /** | 45 | /** |
| @@ -47,6 +56,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -47,6 +56,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 47 | 56 | ||
| 48 | @Resource | 57 | @Resource |
| 49 | private CrmPermissionService crmPermissionService; | 58 | private CrmPermissionService crmPermissionService; |
| 59 | + @Resource | ||
| 60 | + private CrmCustomerLimitConfigService crmCustomerLimitConfigService; | ||
| 50 | 61 | ||
| 51 | @Resource | 62 | @Resource |
| 52 | private AdminUserApi adminUserApi; | 63 | private AdminUserApi adminUserApi; |
| @@ -163,14 +174,47 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -163,14 +174,47 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 163 | 174 | ||
| 164 | @Override | 175 | @Override |
| 165 | @LogRecord(type = CRM_CUSTOMER, subType = "锁定/解锁客户", bizNo = "{{#updateReqVO.id}}", success = "锁定了客户") | 176 | @LogRecord(type = CRM_CUSTOMER, subType = "锁定/解锁客户", bizNo = "{{#updateReqVO.id}}", success = "锁定了客户") |
| 166 | - public void lockCustomer(CrmCustomerUpdateReqVO updateReqVO) { | ||
| 167 | - // 校验存在 | ||
| 168 | - validateCustomerExists(updateReqVO.getId()); | ||
| 169 | - // TODO @Joey:可以校验下,如果已经对应的锁定状态,报个业务异常;原因是:后续这个业务会记录操作日志,会记录多了; | ||
| 170 | - // TODO @芋艿:业务完善,增加锁定上限; | 177 | + public void lockCustomer(CrmCustomerLockReqVO lockReqVO) { |
| 178 | + // 校验当前客户是否存在 | ||
| 179 | + validateCustomerExists(lockReqVO.getId()); | ||
| 180 | + | ||
| 181 | + CrmCustomerDO customerDO = customerMapper.selectById(lockReqVO.getId()); | ||
| 182 | + | ||
| 183 | + // 校验当前是否重复操作锁定/解锁状态 | ||
| 184 | + if (customerDO.getLockStatus().equals(lockReqVO.getLockStatus())) { | ||
| 185 | + throw exception(CUSTOMER_UNLOCK_STATUS_NO_REPETITION); | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + // 获取当前登录信息,开始校验锁定上限 | ||
| 189 | + AdminUserRespDTO userRespDTO = adminUserApi.getUser(getLoginUserId()); | ||
| 190 | + | ||
| 191 | + if (userRespDTO.getDeptId() == null || userRespDTO.getId() == null) { | ||
| 192 | + // 如有入参为空,提示业务异常 | ||
| 193 | + throw exception(CUSTOMER_NO_DEPARTMENT_FOUND); | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + // 开始校验规则限制 | ||
| 197 | + List<Long> userDeptIds = Collections.singletonList(userRespDTO.getDeptId()); | ||
| 198 | + | ||
| 199 | + CrmCustomerLimitConfigCreateReqVO configReqVO = new CrmCustomerLimitConfigCreateReqVO(); | ||
| 200 | + configReqVO.setUserId(userRespDTO.getId()); | ||
| 201 | + configReqVO.setDeptIds(userDeptIds); | ||
| 202 | + configReqVO.setType(CUSTOMER_LOCK_LIMIT.getCode()); | ||
| 203 | + | ||
| 204 | + CrmCustomerLimitConfigDO crmCustomerLimitConfigDO = crmCustomerLimitConfigService.selectByLimitConfig(configReqVO); | ||
| 205 | + | ||
| 206 | + // 统计当前用户已锁定客户数量 | ||
| 207 | + List<CrmCustomerDO> crmCustomerDOS = customerMapper.selectList("owner_user_id", getLoginUserId()); | ||
| 208 | + long customerLockCount = crmCustomerDOS.stream().filter(CrmCustomerDO::getLockStatus).count(); | ||
| 209 | + | ||
| 210 | + // 锁定操作的时候校验当前用户可锁定客户的上限 | ||
| 211 | + if (crmCustomerLimitConfigDO != null && lockReqVO.getLockStatus() && customerLockCount >= crmCustomerLimitConfigDO.getMaxCount()) { | ||
| 212 | + // 超出锁定数量上限,提示业务异常 | ||
| 213 | + throw exception(CUSTOMER_EXCEED_LOCK_LIMIT); | ||
| 214 | + } | ||
| 171 | 215 | ||
| 172 | // 更新 | 216 | // 更新 |
| 173 | - CrmCustomerDO updateObj = CrmCustomerConvert.INSTANCE.convert(updateReqVO); | 217 | + CrmCustomerDO updateObj = CrmCustomerConvert.INSTANCE.convert(lockReqVO); |
| 174 | customerMapper.updateById(updateObj); | 218 | customerMapper.updateById(updateObj); |
| 175 | } | 219 | } |
| 176 | 220 |