Commit 955c164a by 崔彦峰

feat(clues): 添加线索最新跟进时间字段支持

- 在 CluesDetailResp、CluesInfo 和 CluesPageResp 中添加 latestFollowTime 字段
- 在 CluesWebPageReq 中添加最新跟进时间范围查询参数
- 更新数据库映射文件中的基础列列表和查询语句
- 修改 updateFollowInfo 方法以包含最新跟进时间更新逻辑
- 添加按最新跟进时间范围过滤的功能
- 在服务层实现最新跟进时间的数据处理和存储逻辑
1 parent 4997e54a
......@@ -31,6 +31,7 @@ public interface CluesInfoMapper extends BaseMapper<CluesInfo> {
int updateFollowInfo(@Param("id") Integer id,
@Param("customerIntentLevel") String customerIntentLevel,
@Param("latestFollowTime") Date latestFollowTime,
@Param("nextFollowTime") Date nextFollowTime,
@Param("cluesStatus") Integer cluesStatus,
@Param("updatedBy") String updatedBy,
......
......@@ -138,8 +138,7 @@ public class CluesInfoService extends ServiceImpl<CluesInfoMapper, CluesInfo> {
Integer originalCluesStatus = cluesInfo.getCluesStatus();
boolean statusChanged = Objects.equals(originalCluesStatus, CluesStatusEnum.PENDING_FOLLOW.getCode());
Integer targetCluesStatus = statusChanged
? CluesStatusEnum.FOLLOWING.getCode() : originalCluesStatus;
Integer targetCluesStatus = statusChanged ? CluesStatusEnum.FOLLOWING.getCode() : originalCluesStatus;
String originalIntentLevel = cluesInfo.getCustomerIntentLevel();
CustomerIntentLevelEnum intentLevel = CustomerIntentLevelEnum.getByCode(req.getCustomerIntentLevelChange());
boolean intentLevelChanged = !Objects.equals(req.getCustomerIntentLevelChange(), originalIntentLevel);
......@@ -179,7 +178,7 @@ public class CluesInfoService extends ServiceImpl<CluesInfoMapper, CluesInfo> {
throw new BusinessException("新增线索跟进记录失败");
}
if (baseMapper.updateFollowInfo(req.getCluesId(), req.getCustomerIntentLevelChange(),
if (baseMapper.updateFollowInfo(req.getCluesId(), req.getCustomerIntentLevelChange(),now,
nextFollowTime, targetCluesStatus, req.getOperatorName(), now) != 1) {
throw new BusinessException("更新线索跟进信息失败");
}
......
......@@ -51,6 +51,12 @@ public class CluesPageQuery {
// 录入结束时间
private Date enterTimeEnd;
// 最新跟进时间开始
private Date latestFollowTimeStart;
// 最新跟进时间结束
private Date latestFollowTimeEnd;
// 录入时间排序 0-升序 1-降序,默认1
private Integer enterTimeOrder;
......
......@@ -10,6 +10,7 @@
<result column="car_owner_name" property="carOwnerName" />
<result column="car_owner_phone" property="carOwnerPhone" />
<result column="enter_time" property="enterTime" />
<result column="latest_follow_time" property="latestFollowTime" />
<result column="next_follow_time" property="nextFollowTime" />
<result column="customer_intent_level" property="customerIntentLevel" />
<result column="car_brand" property="carBrand" />
......@@ -36,7 +37,7 @@
</resultMap>
<sql id="Base_Column_List">
id, clues_no, clues_status, enter_type, car_owner_name, car_owner_phone, enter_time, next_follow_time, customer_intent_level, car_brand, car_childs_brand_id, car_childs_brand_name, car_series_id, car_series_name, car_type_id, car_type_name, seller_user_id, seller_name, seller_merchant_id, seller_merchant_name, conversion_user_id, conversion_name, conversion_merchant_id, conversion_merchant_name, remark, created_by, created_date, updated_by, updated_date, deleted_flag
id, clues_no, clues_status, enter_type, car_owner_name, car_owner_phone, enter_time, latest_follow_time, next_follow_time, customer_intent_level, car_brand, car_childs_brand_id, car_childs_brand_name, car_series_id, car_series_name, car_type_id, car_type_name, seller_user_id, seller_name, seller_merchant_id, seller_merchant_name, conversion_user_id, conversion_name, conversion_merchant_id, conversion_merchant_name, remark, created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<select id="detail" resultType="com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues.CluesDetailResp">
......@@ -47,6 +48,7 @@
c.car_owner_name AS carOwnerName,
c.car_owner_phone AS carOwnerPhone,
c.enter_time AS enterTime,
c.latest_follow_time AS latestFollowTime,
c.next_follow_time AS nextFollowTime,
c.customer_intent_level AS customerIntentLevel,
c.car_brand AS carBrand,
......@@ -107,6 +109,7 @@
<update id="updateFollowInfo">
UPDATE vcp_clues_info
SET customer_intent_level = #{customerIntentLevel},
latest_follow_time = #{latestFollowTime, jdbcType=TIMESTAMP},
next_follow_time = #{nextFollowTime, jdbcType=TIMESTAMP},
clues_status = #{cluesStatus},
updated_by = #{updatedBy},
......@@ -122,7 +125,7 @@
c.seller_name, c.car_owner_name, c.car_owner_phone, c.car_brand,
c.car_childs_brand_name, c.car_series_name, c.car_type_name,
c.customer_intent_level, c.clues_status, c.next_follow_time,
c.conversion_name
c.conversion_name, c.latest_follow_time
FROM vcp_clues_info c
WHERE c.deleted_flag = 'N'
<if test="req.sellerMerchantId != null">
......@@ -205,6 +208,12 @@
<if test="req.enterTimeEnd != null">
AND c.enter_time &lt;= #{req.enterTimeEnd}
</if>
<if test="req.latestFollowTimeStart != null">
AND c.latest_follow_time &gt;= #{req.latestFollowTimeStart}
</if>
<if test="req.latestFollowTimeEnd != null">
AND c.latest_follow_time &lt;= #{req.latestFollowTimeEnd}
</if>
<if test="req.cluesStatus != null">
AND c.clues_status = {req.cluesStatus}
</if>
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议(Top 3)

    1. [功能与健壮性] 上下文存在致命的 MyBatis 语法错误及日期边界隐患

    • 问题描述:
      1. 在 CluesInfoMapper.xml 修改行的紧接下文中,c.clues_status = {req.cluesStatus} 缺少了 # 符号。虽然这不是本次直接修改的代码,但在审查范围内暴露出了严重问题。
      2. 新增的 latestFollowTimeEnd 范围查询使用了 <=,如果前端传入的 Date 仅精确到日期(例如 2023-10-10 00:00:00),将无法查出当天的记录。
    • 影响分析:
      1. 缺少 # 符号会导致 MyBatis 解析异常或底层数据库抛出 SQL 语法错误,使得包含该状态过滤条件的查询完全崩溃。
      2. 日期边界处理不当会导致业务数据查询遗漏,可能引发用户客诉。
    • 优化建议:
      1. 顺手修复上下文中的语法错误,将 {req.cluesStatus} 修正为 #{req.cluesStatus}。
      2. 确保上层传递的 latestFollowTimeEnd 已在代码逻辑中被处理为当天的 23:59:59,或者在 SQL 层进行安全处理。

    2. [最佳实践与可维护性] 方法参数过多且代码格式化不规范

    • 问题描述:CluesInfoMapper.updateFollowInfo 方法在新增 latestFollowTime 参数后,参数数量达到了 7 个。此外,在 CluesInfoService.java 调用该方法时,now 参数前遗漏了空格(req.getCustomerIntentLevelChange(),now,)。
    • 影响分析:根据 Clean Code 原则,方法参数超过 3 个会显著降低代码的可读性,且极易在调用时传错参数位置(尤其是多个同类型的 Date 或 String 参数)。缺少空格则不符合主流的代码格式化规范。
    • 优化建议: 建议将 updateFollowInfo 的参数封装为一个 DTO 类,或直接复用 CluesInfo 实体类。 ```java // 建议封装为参数对象 public class FollowInfoUpdateReq { private Integer id; private String customerIntentLevel; private Date latestFollowTime; // ... 其他属性 } int updateFollowInfo(FollowInfoUpdateReq req);

    // 修复调用时的空格格式 if (baseMapper.updateFollowInfo(req.getCluesId(), req.getCustomerIntentLevelChange(), now, ...

    
    **3. [性能与资源利用] 新增时间范围查询存在潜在的慢 SQL 风险**
    - **问题描述**:在 `CluesPageQuery` 及对应的 XML 动态 SQL 中新增了 `latest_follow_time` 的范围查询条件。
    - **影响分析**:线索表(`vcp_clues_info`)通常数据量较大且增长迅速。如果 `latest_follow_time` 字段上没有合适的索引,基于该字段的范围查询会导致全表扫描,严重影响数据库性能,甚至引发慢 SQL 告警拖垮应用。
    - **优化建议**:请确认数据库表 `vcp_clues_info` 中是否已为 `latest_follow_time` 建立了索引。如果没有,建议根据实际的查询组合场景,增加单列索引或联合索引(如 `idx_latest_follow_time`)。
    
    ---
    
    #### 二、评分明细
    - **功能实现的正确性与健壮性(35 / 40分)**:本次修改的业务逻辑基本正确,但存在时间查询边界的健壮性隐患;同时在审查中发现了上下文代码存在致命的 MyBatis 语法错误,扣 5 分。
    - **安全性与潜在风险(30 / 30分)**:SQL 参数均正确使用了 `#{}` 预编译,有效防止了 SQL 注入;未见越权或敏感信息泄露等安全隐患。满分。
    - **最佳实践与可维护性(16 / 20分)**:Mapper 方法参数过多(7个)未进行对象封装,可维护性较差;代码存在轻微的格式化问题(缺少空格),扣 4 分。
    - **性能与资源利用(3 / 5分)**:新增了时间范围查询,但代码层面未体现对慢 SQL 风险及索引的考量,扣 2 分。
    - **提交信息质量(5 / 5分)**:Commit 信息采用了 `feat(clues):` 规范前缀,且清晰、详尽地列出了修改的点,可追溯性极强。满分。
    
    总分:89分
    
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!