diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java index 48f0a0c32..bcffd2a45 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java @@ -18,17 +18,17 @@ public interface LogRecordConstants { String CRM_CUSTOMER_CREATE_SUB_TYPE = "创建客户"; String CRM_CUSTOMER_CREATE_SUCCESS = "创建了客户{{#customer.name}}"; String CRM_CUSTOMER_UPDATE_SUB_TYPE = "更新客户"; - String CRM_CUSTOMER_UPDATE_SUCCESS = "更新了客户【{{#customerName}}】{_DIFF{#updateReqVO}}"; + String CRM_CUSTOMER_UPDATE_SUCCESS = "更新了客户【{{#customerName}}】: {_DIFF{#updateReqVO}}"; String CRM_CUSTOMER_DELETE_SUB_TYPE = "删除客户"; String CRM_CUSTOMER_DELETE_SUCCESS = "删除了客户【{{#customerName}}】"; String CRM_CUSTOMER_TRANSFER_SUB_TYPE = "转移客户"; String CRM_CUSTOMER_TRANSFER_SUCCESS = "将客户【{{#crmCustomer.name}}】的负责人从【{getAdminUserById{#crmCustomer.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; String CRM_CUSTOMER_LOCK_SUB_TYPE = "{{#crmCustomer.lockStatus ? '锁定客户' : '解锁客户'}}"; - String CRM_CUSTOMER_LOCK_SUCCESS = "{{#crmCustomer.lockStatus ? '将客户【#crmCustomer.name】锁定' : '将客户【#crmCustomer.name】解锁'}}"; + String CRM_CUSTOMER_LOCK_SUCCESS = "{{#crmCustomer.lockStatus ? '将客户【' + #crmCustomer.name + '】锁定' : '将客户【' + #crmCustomer.name + '】解锁'}}"; String CRM_CUSTOMER_POOL_SUB_TYPE = "客户放入公海"; String CRM_CUSTOMER_POOL_SUCCESS = "将客户【{{#customerName}}】放入了公海"; String CRM_CUSTOMER_RECEIVE_SUB_TYPE = "{{#ownerUserName != null ? '分配客户' : '领取客户'}}"; - String CRM_CUSTOMER_RECEIVE_SUCCESS = "{{#ownerUserName != null ? '将客户【#customer.name】分配给【#ownerUserName】' : '领取客户【#customer.name】'}}"; + String CRM_CUSTOMER_RECEIVE_SUCCESS = "{{#ownerUserName != null ? '将客户【' + #customer.name + '】分配给【' + #ownerUserName + '】' : '领取客户【' + #customer.name + '】'}}"; // ======================= CRM_CONTACT 联系人 ======================= diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java index 93b6557a4..c8a18723b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java @@ -1,13 +1,13 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.ObjectUtil; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.AssertTrue; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import jakarta.validation.constraints.AssertTrue; import java.util.Objects; @Schema(description = "管理后台 - CRM 客户公海配置的保存 Request VO") @@ -16,19 +16,27 @@ import java.util.Objects; @ToString(callSuper = true) public class CrmCustomerPoolConfigSaveReqVO extends CrmCustomerPoolConfigBaseVO { - // TODO @puhui999:AssertTrue 必须 is 开头哈;注意需要 json 忽略下,避免被序列化; - @AssertTrue(message = "客户公海规则设置不正确") - // TODO @puhui999:这个方法,是不是拆成 2 个,一个校验 contactExpireDays、一个校验 dealExpireDays; - public boolean poolEnableValid() { + @AssertTrue(message = "未成交放入公海天数不能为空") + @JsonIgnore + public boolean isDealExpireDaysValid() { if (!BooleanUtil.isTrue(getEnabled())) { return true; } - return ObjectUtil.isAllNotEmpty(getContactExpireDays(), getDealExpireDays()); + return Objects.nonNull(getDealExpireDays()); } - @AssertTrue(message = "客户公海规则设置不正确") - // TODO @puhui999:这个方法,是不是改成 isNotifyDaysValid() 更好点?本质校验的是 notifyDays 是否为空 - public boolean notifyEnableValid() { + @AssertTrue(message = "未跟进放入公海天数不能为空") + @JsonIgnore + public boolean isContactExpireDaysValid() { + if (!BooleanUtil.isTrue(getEnabled())) { + return true; + } + return Objects.nonNull(getContactExpireDays()); + } + + @AssertTrue(message = "提前提醒天数不能为空") + @JsonIgnore + public boolean isNotifyDaysValid() { if (!BooleanUtil.isTrue(getNotifyEnabled())) { return true; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java index 898a966a4..16ab801bf 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.service.customer; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.Assert; +import cn.hutool.extra.spring.SpringUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; @@ -247,13 +248,15 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { user = adminUserApi.getUser(ownerUserId); } for (CrmCustomerDO customer : customers) { - receiveCustomerLog(customer, user == null ? null : user.getNickname()); + getSelf().receiveCustomerLog(customer, user == null ? null : user.getNickname()); } } @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}", success = CRM_CUSTOMER_RECEIVE_SUCCESS) public void receiveCustomerLog(CrmCustomerDO customer, String ownerUserName) { - + // 记录操作日志上下文 + LogRecordContext.putVariable("customer", customer); + LogRecordContext.putVariable("ownerUserName", ownerUserName); } //======================= 查询相关 ======================= @@ -364,4 +367,14 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { } } + + /** + * 获得自身的代理对象,解决 AOP 生效问题 + * + * @return 自己 + */ + private CrmCustomerServiceImpl getSelf() { + return SpringUtil.getBean(getClass()); + } + } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogV2RespDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogV2RespDTO.java index 6345965a3..e217baada 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogV2RespDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogV2RespDTO.java @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.system.api.logger.dto; import lombok.Data; +import java.time.LocalDateTime; + /** * 系统操作日志 Resp DTO * @@ -64,4 +66,9 @@ public class OperateLogV2RespDTO { */ private String userAgent; + /** + * 创建时间 + */ + private LocalDateTime createTime; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/logger/OperateLogConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/logger/OperateLogConvert.java index 93fc1c638..ffbf8d6f4 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/logger/OperateLogConvert.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/logger/OperateLogConvert.java @@ -35,10 +35,12 @@ public interface OperateLogConvert { return BeanUtils.toBean(operateLogPage, OperateLogV2RespDTO.class).setList(setUserInfo(operateLogPage.getList(), userList)); } - private static List setUserInfo(List logList, List userList) { + OperateLogV2RespDTO convert(OperateLogV2DO operateLogV2DO); + + private List setUserInfo(List logList, List userList) { Map userMap = convertMap(userList, AdminUserDO::getId); return CollectionUtils.convertList(logList, item -> { - OperateLogV2RespDTO respDTO = BeanUtils.toBean(item, OperateLogV2RespDTO.class); + OperateLogV2RespDTO respDTO = convert(item); findAndThen(userMap, item.getUserId(), user -> respDTO.setUserName(user.getNickname())); return respDTO; });