📖 CRM:code review 待办事项

This commit is contained in:
YunaiV 2024-01-22 12:23:24 +08:00
parent 422b19caf7
commit 206899bfc0
4 changed files with 25 additions and 24 deletions

View File

@ -87,6 +87,5 @@ public interface ErrorCodeConstants {
ErrorCode FOLLOW_UP_RECORD_DELETE_DENIED = new ErrorCode(1_020_013_001, "删除跟进记录失败,原因:没有权限"); ErrorCode FOLLOW_UP_RECORD_DELETE_DENIED = new ErrorCode(1_020_013_001, "删除跟进记录失败,原因:没有权限");
// ========== 待办消息 1_020_014_000 ========== // ========== 待办消息 1_020_014_000 ==========
ErrorCode BACKLOG_CONTACT_STATUS_INVALID = new ErrorCode(1_020_014_000, "客户联系状态有误");
} }

View File

@ -14,11 +14,19 @@ import lombok.ToString;
@ToString(callSuper = true) @ToString(callSuper = true)
public class CrmTodayCustomerPageReqVO extends PageParam { public class CrmTodayCustomerPageReqVO extends PageParam {
/**
* 联系状态 - 今日需联系
*/
public static final int CONTACT_TODAY = 1; public static final int CONTACT_TODAY = 1;
/**
* 联系状态 - 已逾期
*/
public static final int CONTACT_EXPIRED = 2; public static final int CONTACT_EXPIRED = 2;
/**
* 联系状态 - 已联系
*/
public static final int CONTACT_ALREADY = 3; public static final int CONTACT_ALREADY = 3;
@Schema(description = "联系状态", example = "1") @Schema(description = "联系状态", example = "1")
private Integer contactStatus; private Integer contactStatus;

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.crm.dal.mysql.customer; package cn.iocoder.yudao.module.crm.dal.mysql.customer;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
@ -13,15 +14,10 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BACKLOG_CONTACT_STATUS_INVALID;
/** /**
* 客户 Mapper * 客户 Mapper
* *
@ -85,24 +81,21 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(),
CrmCustomerDO::getId, userId, pageReqVO.getSceneType(), null); CrmCustomerDO::getId, userId, pageReqVO.getSceneType(), null);
query.selectAll(CrmCustomerDO.class);
// 拼接自身的查询条件 // 拼接自身的查询条件
LocalDateTime beginOfToday = LocalDate.now().atTime(LocalTime.MIN); query.selectAll(CrmCustomerDO.class);
LocalDateTime endOfToday = LocalDate.now().atTime(LocalTime.MAX); if (pageReqVO.getContactStatus() != null) {
if (pageReqVO.getContactStatus().equals(CrmTodayCustomerPageReqVO.CONTACT_TODAY)) { LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now());
// 今天需联系 LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now());
if (pageReqVO.getContactStatus().equals(CrmTodayCustomerPageReqVO.CONTACT_TODAY)) { // 今天需联系
query.between(CrmCustomerDO::getContactNextTime, beginOfToday, endOfToday); query.between(CrmCustomerDO::getContactNextTime, beginOfToday, endOfToday);
} else if (pageReqVO.getContactStatus().equals(CrmTodayCustomerPageReqVO.CONTACT_EXPIRED)) { } else if (pageReqVO.getContactStatus().equals(CrmTodayCustomerPageReqVO.CONTACT_EXPIRED)) { // 已逾期
// 已逾期
query.lt(CrmCustomerDO::getContactNextTime, beginOfToday); query.lt(CrmCustomerDO::getContactNextTime, beginOfToday);
} else if (pageReqVO.getContactStatus().equals(CrmTodayCustomerPageReqVO.CONTACT_ALREADY)) { } else if (pageReqVO.getContactStatus().equals(CrmTodayCustomerPageReqVO.CONTACT_ALREADY)) { // 已联系
// 已联系
query.between(CrmCustomerDO::getContactLastTime, beginOfToday, endOfToday); query.between(CrmCustomerDO::getContactLastTime, beginOfToday, endOfToday);
} else { } else {
throw exception(BACKLOG_CONTACT_STATUS_INVALID); throw new IllegalArgumentException("未知联系状态:" + pageReqVO.getContactStatus());
}
} }
return selectJoinPage(pageReqVO, CrmCustomerDO.class, query); return selectJoinPage(pageReqVO, CrmCustomerDO.class, query);
} }

View File

@ -10,8 +10,9 @@ import org.springframework.validation.annotation.Validated;
/** /**
* 待办消息 Service 实现类 * 待办消息 Service 实现类
*
* @author dhb52
*/ */
@Component @Component
@Validated @Validated
public class CrmBacklogServiceImpl implements CrmBacklogService { public class CrmBacklogServiceImpl implements CrmBacklogService {