mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	CRM-客户: 简化客户公海配置 VO,完善相关操作日志
This commit is contained in:
		| @@ -8,13 +8,12 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfig | ||||
| import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import jakarta.annotation.Resource; | ||||
| import jakarta.validation.Valid; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import jakarta.annotation.Resource; | ||||
| import jakarta.validation.Valid; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
|  | ||||
| @Tag(name = "管理后台 - CRM 客户公海配置") | ||||
| @@ -26,7 +25,6 @@ public class CrmCustomerPoolConfigController { | ||||
|     @Resource | ||||
|     private CrmCustomerPoolConfigService customerPoolConfigService; | ||||
|  | ||||
|     // TODO @puhui999:可以把 vo 改下哈 | ||||
|     @GetMapping("/get") | ||||
|     @Operation(summary = "获取客户公海规则设置") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:customer-pool-config:query')") | ||||
|   | ||||
| @@ -1,31 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
|  | ||||
| import jakarta.validation.constraints.NotNull; | ||||
|  | ||||
| /** | ||||
|  * 客户公海配置 Base VO,提供给添加、修改、详细的子 VO 使用 | ||||
|  * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||||
|  */ | ||||
| @Data | ||||
| public class CrmCustomerPoolConfigBaseVO { | ||||
|  | ||||
|     @Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | ||||
|     @NotNull(message = "是否启用客户公海不能为空") | ||||
|     private Boolean enabled; | ||||
|  | ||||
|     @Schema(description = "未跟进放入公海天数", example = "2") | ||||
|     private Integer contactExpireDays; | ||||
|  | ||||
|     @Schema(description = "未成交放入公海天数", example = "2") | ||||
|     private Integer dealExpireDays; | ||||
|  | ||||
|     @Schema(description = "是否开启提前提醒", example = "true") | ||||
|     private Boolean notifyEnabled; | ||||
|  | ||||
|     @Schema(description = "提前提醒天数", example = "2") | ||||
|     private Integer notifyDays; | ||||
|  | ||||
| } | ||||
| @@ -1,14 +1,27 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import jakarta.validation.constraints.NotNull; | ||||
| import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | ||||
|  | ||||
| @Schema(description = "管理后台 - CRM 客户公海规则 Response VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class CrmCustomerPoolConfigRespVO extends CrmCustomerPoolConfigBaseVO { | ||||
| public class CrmCustomerPoolConfigRespVO { | ||||
|  | ||||
|     @Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | ||||
|     @NotNull(message = "是否启用客户公海不能为空") | ||||
|     private Boolean enabled; | ||||
|  | ||||
|     @Schema(description = "未跟进放入公海天数", example = "2") | ||||
|     private Integer contactExpireDays; | ||||
|  | ||||
|     @Schema(description = "未成交放入公海天数", example = "2") | ||||
|     private Integer dealExpireDays; | ||||
|  | ||||
|     @Schema(description = "是否开启提前提醒", example = "true") | ||||
|     private Boolean notifyEnabled; | ||||
|  | ||||
|     @Schema(description = "提前提醒天数", example = "2") | ||||
|     private Integer notifyDays; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -2,19 +2,38 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; | ||||
|  | ||||
| import cn.hutool.core.util.BooleanUtil; | ||||
| import com.fasterxml.jackson.annotation.JsonIgnore; | ||||
| import com.mzt.logapi.starter.annotation.DiffLogField; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import jakarta.validation.constraints.AssertTrue; | ||||
| import jakarta.validation.constraints.NotNull; | ||||
| import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | ||||
|  | ||||
| import java.util.Objects; | ||||
|  | ||||
| @Schema(description = "管理后台 - CRM 客户公海配置的保存 Request VO") | ||||
| @Schema(description = "管理后台 - CRM 客户公海配置的创建/更新 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class CrmCustomerPoolConfigSaveReqVO extends CrmCustomerPoolConfigBaseVO { | ||||
| public class CrmCustomerPoolConfigSaveReqVO { | ||||
|  | ||||
|     @Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | ||||
|     @DiffLogField(name = "是否启用客户公海") | ||||
|     @NotNull(message = "是否启用客户公海不能为空") | ||||
|     private Boolean enabled; | ||||
|  | ||||
|     @Schema(description = "未跟进放入公海天数", example = "2") | ||||
|     @DiffLogField(name = "未跟进放入公海天数") | ||||
|     private Integer contactExpireDays; | ||||
|  | ||||
|     @Schema(description = "未成交放入公海天数", example = "2") | ||||
|     @DiffLogField(name = "未成交放入公海天数") | ||||
|     private Integer dealExpireDays; | ||||
|  | ||||
|     @Schema(description = "是否开启提前提醒", example = "true") | ||||
|     @DiffLogField(name = "是否开启提前提醒") | ||||
|     private Boolean notifyEnabled; | ||||
|  | ||||
|     @Schema(description = "提前提醒天数", example = "2") | ||||
|     @DiffLogField(name = "提前提醒天数") | ||||
|     private Integer notifyDays; | ||||
|  | ||||
|     @AssertTrue(message = "未成交放入公海天数不能为空") | ||||
|     @JsonIgnore | ||||
|   | ||||
| @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.convert.customer; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; | ||||
| @@ -24,8 +23,6 @@ public interface CrmCustomerLimitConfigConvert { | ||||
|  | ||||
|     CrmCustomerLimitConfigConvert INSTANCE = Mappers.getMapper(CrmCustomerLimitConfigConvert.class); | ||||
|  | ||||
|     CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigCreateReqVO bean); | ||||
|  | ||||
|     CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigSaveReqVO bean); | ||||
|  | ||||
|     CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO bean); | ||||
|   | ||||
| @@ -2,14 +2,19 @@ package cn.iocoder.yudao.module.crm.service.customer; | ||||
|  | ||||
| import cn.hutool.core.lang.Assert; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; | ||||
| import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; | ||||
| import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper; | ||||
| import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum; | ||||
| import cn.iocoder.yudao.module.system.api.dept.DeptApi; | ||||
| import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||||
| import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | ||||
| import com.mzt.logapi.context.LogRecordContext; | ||||
| import com.mzt.logapi.service.impl.DiffParseFunction; | ||||
| import com.mzt.logapi.starter.annotation.LogRecord; | ||||
| import jakarta.annotation.Resource; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| @@ -19,6 +24,7 @@ import java.util.List; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_LIMIT_CONFIG_NOT_EXISTS; | ||||
| import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; | ||||
|  | ||||
| /** | ||||
|  * 客户限制配置 Service 实现类 | ||||
| @@ -38,34 +44,44 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig | ||||
|     private AdminUserApi adminUserApi; | ||||
|  | ||||
|     @Override | ||||
|     // TODO @puhui999:操作日志 | ||||
|     @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE, bizNo = "{{#limitId}}", success = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS) | ||||
|     public Long createCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO createReqVO) { | ||||
|         validateUserAndDept(createReqVO.getUserIds(), createReqVO.getDeptIds()); | ||||
|         // 插入 | ||||
|         CrmCustomerLimitConfigDO customerLimitConfig = CrmCustomerLimitConfigConvert.INSTANCE.convert(createReqVO); | ||||
|         customerLimitConfigMapper.insert(customerLimitConfig); | ||||
|  | ||||
|         // 记录操作日志上下文 | ||||
|         LogRecordContext.putVariable("limitType", CrmCustomerLimitConfigTypeEnum.getNameByType(customerLimitConfig.getType())); | ||||
|         LogRecordContext.putVariable("limitId", customerLimitConfig.getId()); | ||||
|         // 返回 | ||||
|         return customerLimitConfig.getId(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     // TODO @puhui999:操作日志 | ||||
|     @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", success = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS) | ||||
|     public void updateCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|         validateCustomerLimitConfigExists(updateReqVO.getId()); | ||||
|         CrmCustomerLimitConfigDO oldLimitConfig = validateCustomerLimitConfigExists(updateReqVO.getId()); | ||||
|         validateUserAndDept(updateReqVO.getUserIds(), updateReqVO.getDeptIds()); | ||||
|         // 更新 | ||||
|         CrmCustomerLimitConfigDO updateObj = CrmCustomerLimitConfigConvert.INSTANCE.convert(updateReqVO); | ||||
|         customerLimitConfigMapper.updateById(updateObj); | ||||
|  | ||||
|         // 记录操作日志上下文 | ||||
|         LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldLimitConfig, CrmCustomerLimitConfigSaveReqVO.class)); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     // TODO @puhui999:操作日志 | ||||
|     @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE, bizNo = "{{#id}}", success = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS) | ||||
|     public void deleteCustomerLimitConfig(Long id) { | ||||
|         // 校验存在 | ||||
|         validateCustomerLimitConfigExists(id); | ||||
|         CrmCustomerLimitConfigDO limitConfigDO = validateCustomerLimitConfigExists(id); | ||||
|         // 删除 | ||||
|         customerLimitConfigMapper.deleteById(id); | ||||
|  | ||||
|         // 记录操作日志上下文 | ||||
|         LogRecordContext.putVariable("limitType", CrmCustomerLimitConfigTypeEnum.getNameByType(limitConfigDO.getType())); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
| @@ -78,10 +94,12 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig | ||||
|         return customerLimitConfigMapper.selectPage(pageReqVO); | ||||
|     } | ||||
|  | ||||
|     private void validateCustomerLimitConfigExists(Long id) { | ||||
|         if (customerLimitConfigMapper.selectById(id) == null) { | ||||
|     private CrmCustomerLimitConfigDO validateCustomerLimitConfigExists(Long id) { | ||||
|         CrmCustomerLimitConfigDO limitConfigDO = customerLimitConfigMapper.selectById(id); | ||||
|         if (limitConfigDO == null) { | ||||
|             throw exception(CUSTOMER_LIMIT_CONFIG_NOT_EXISTS); | ||||
|         } | ||||
|         return limitConfigDO; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -5,12 +5,16 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCu | ||||
| import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; | ||||
| import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerPoolConfigMapper; | ||||
| import com.mzt.logapi.context.LogRecordContext; | ||||
| import com.mzt.logapi.starter.annotation.LogRecord; | ||||
| import jakarta.annotation.Resource; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
|  | ||||
| import jakarta.annotation.Resource; | ||||
| import java.util.Objects; | ||||
|  | ||||
| import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; | ||||
|  | ||||
| /** | ||||
|  * 客户公海配置 Service 实现类 | ||||
|  * | ||||
| @@ -19,6 +23,7 @@ import java.util.Objects; | ||||
| @Service | ||||
| @Validated | ||||
| public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigService { | ||||
|  | ||||
|     @Resource | ||||
|     private CrmCustomerPoolConfigMapper customerPoolConfigMapper; | ||||
|  | ||||
| @@ -38,16 +43,23 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe | ||||
|      * @param saveReqVO 更新信息 | ||||
|      */ | ||||
|     @Override | ||||
|     // TODO @puhui999:操作日志 | ||||
|     @LogRecord(type = CRM_CUSTOMER_POOL_CONFIG_TYPE, subType = CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE, bizNo = "{{#poolConfigId}}", success = CRM_CUSTOMER_POOL_CONFIG_SUCCESS) | ||||
|     public void saveCustomerPoolConfig(CrmCustomerPoolConfigSaveReqVO saveReqVO) { | ||||
|         // 存在,则进行更新 | ||||
|         CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig(); | ||||
|         CrmCustomerPoolConfigDO poolConfig = CrmCustomerConvert.INSTANCE.convert(saveReqVO); | ||||
|         if (Objects.nonNull(dbConfig)) { | ||||
|             customerPoolConfigMapper.updateById(CrmCustomerConvert.INSTANCE.convert(saveReqVO).setId(dbConfig.getId())); | ||||
|             customerPoolConfigMapper.updateById(poolConfig.setId(dbConfig.getId())); | ||||
|             // 记录操作日志上下文 | ||||
|             LogRecordContext.putVariable("isPoolConfigUpdate", Boolean.TRUE); | ||||
|             LogRecordContext.putVariable("poolConfigId", poolConfig.getId()); | ||||
|             return; | ||||
|         } | ||||
|         // 不存在,则进行插入 | ||||
|         customerPoolConfigMapper.insert(CrmCustomerConvert.INSTANCE.convert(saveReqVO)); | ||||
|         customerPoolConfigMapper.insert(poolConfig); | ||||
|         // 记录操作日志上下文 | ||||
|         LogRecordContext.putVariable("isPoolConfigUpdate", Boolean.FALSE); | ||||
|         LogRecordContext.putVariable("poolConfigId", poolConfig.getId()); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 puhui999
					puhui999