Commit bce6b27e by 林永健

feat(data-stats): 新增触客转化率统计功能

- 添加了多个业务模块的触客转化率常量定义,包括整车延保、电池、安心包、轮胎、车窗膜、车身膜、精品附件等
- 更新了业务场景分析服务中的转化率计算逻辑,将原有的转化率替换为触客转化率进行统计
- 修改了商品类别汇总响应DTO中的转化率字段注释,明确标注为触客转化率
- 在门店平均值响应中更新了转化率的计算说明,明确为触客转化率总和除以门店数
- 为员工详情汇总响应和门店详情汇总响应添加了触客转化率相关字段
- 更新了预警类型配置,从硬编码改为环境变量配置方式
- 移除了不必要的兜底预警周期判断条件,简化了业务逻辑
1 parent 031365a7
......@@ -84,4 +84,10 @@ public class EmployeeDetailSummaryResponse implements Serializable {
@ApiModelProperty(notes = "转化率环比")
private String conversionRateMom;
@ApiModelProperty(notes = "触客转化率")
private BigDecimal contractConversionRate;
@ApiModelProperty(notes = "触客转化率环比")
private String contractConversionRateMom;
}
......@@ -26,10 +26,10 @@ public class GoodsCategorySummaryResponse implements Serializable {
@ApiModelProperty(notes = "整车延保-渗透率兜底目标")
private BigDecimal vehicleWarrantyPenetrationBottomTarget;
@ApiModelProperty(notes = "整车延保-转化率")
@ApiModelProperty(notes = "整车延保-转化率(触客转化率)")
private BigDecimal vehicleWarrantyConversionRate;
@ApiModelProperty(notes = "整车延保-转化率兜底目标")
@ApiModelProperty(notes = "整车延保-转化率兜底目标(触客转化率)")
private BigDecimal vehicleWarrantyConversionBottomTarget;
@ApiModelProperty(notes = "整车延保-生态系数(依据渗透率计算)")
......@@ -44,10 +44,10 @@ public class GoodsCategorySummaryResponse implements Serializable {
@ApiModelProperty(notes = "安心包-渗透率兜底目标")
private BigDecimal safetyPackagePenetrationBottomTarget;
@ApiModelProperty(notes = "安心包-转化率")
@ApiModelProperty(notes = "安心包-转化率(触客转化率)")
private BigDecimal safetyPackageConversionRate;
@ApiModelProperty(notes = "安心包-转化率兜底目标")
@ApiModelProperty(notes = "安心包-转化率兜底目标(触客转化率)")
private BigDecimal safetyPackageConversionBottomTarget;
@ApiModelProperty(notes = "安心包-生态系数")
......@@ -62,10 +62,10 @@ public class GoodsCategorySummaryResponse implements Serializable {
@ApiModelProperty(notes = "电池延保-渗透率兜底目标")
private BigDecimal batteryWarrantyPenetrationBottomTarget;
@ApiModelProperty(notes = "电池延保-转化率")
@ApiModelProperty(notes = "电池延保-转化率(触客转化率)")
private BigDecimal batteryWarrantyConversionRate;
@ApiModelProperty(notes = "电池延保-转化率兜底目标")
@ApiModelProperty(notes = "电池延保-转化率兜底目标(触客转化率)")
private BigDecimal batteryWarrantyConversionBottomTarget;
@ApiModelProperty(notes = "电池延保-生态系数")
......@@ -80,10 +80,10 @@ public class GoodsCategorySummaryResponse implements Serializable {
@ApiModelProperty(notes = "轮胎延保-渗透率兜底目标")
private BigDecimal tireWarrantyPenetrationBottomTarget;
@ApiModelProperty(notes = "轮胎延保-转化率")
@ApiModelProperty(notes = "轮胎延保-转化率(触客转化率)")
private BigDecimal tireWarrantyConversionRate;
@ApiModelProperty(notes = "轮胎延保-转化率兜底目标")
@ApiModelProperty(notes = "轮胎延保-转化率兜底目标(触客转化率)")
private BigDecimal tireWarrantyConversionBottomTarget;
@ApiModelProperty(notes = "轮胎延保-生态系数")
......@@ -101,10 +101,10 @@ public class GoodsCategorySummaryResponse implements Serializable {
@ApiModelProperty(notes = "车窗膜-渗透率兜底目标")
private BigDecimal windowFilmPenetrationBottomTarget;
@ApiModelProperty(notes = "车窗膜-转化率")
@ApiModelProperty(notes = "车窗膜-转化率(触客转化率)")
private BigDecimal windowFilmConversionRate;
@ApiModelProperty(notes = "车窗膜-转化率兜底目标")
@ApiModelProperty(notes = "车窗膜-转化率兜底目标(触客转化率)")
private BigDecimal windowFilmConversionBottomTarget;
@ApiModelProperty(notes = "车窗膜-生态系数")
......@@ -122,10 +122,10 @@ public class GoodsCategorySummaryResponse implements Serializable {
@ApiModelProperty(notes = "车身膜-渗透率兜底目标")
private BigDecimal carBodyFilmPenetrationBottomTarget;
@ApiModelProperty(notes = "车身膜-转化率")
@ApiModelProperty(notes = "车身膜-转化率(触客转化率)")
private BigDecimal carBodyFilmConversionRate;
@ApiModelProperty(notes = "车身膜-转化率兜底目标")
@ApiModelProperty(notes = "车身膜-转化率兜底目标(触客转化率)")
private BigDecimal carBodyFilmConversionBottomTarget;
@ApiModelProperty(notes = "车身膜-生态系数")
......@@ -143,10 +143,10 @@ public class GoodsCategorySummaryResponse implements Serializable {
@ApiModelProperty(notes = "精品附件-渗透率兜底目标")
private BigDecimal accessoriesPenetrationBottomTarget;
@ApiModelProperty(notes = "精品附件-转化率")
@ApiModelProperty(notes = "精品附件-转化率(触客转化率)")
private BigDecimal accessoriesConversionRate;
@ApiModelProperty(notes = "精品附件-转化率兜底目标")
@ApiModelProperty(notes = "精品附件-转化率兜底目标(触客转化率)")
private BigDecimal accessoriesConversionBottomTarget;
@ApiModelProperty(notes = "精品附件-生态系数")
......
......@@ -32,7 +32,7 @@ public class StoreAvgResponse implements Serializable {
@ApiModelProperty(notes = "平均渗透率环比")
private BigDecimal avgPenetrationRateMom;
@ApiModelProperty(notes = "平均转化率")
@ApiModelProperty(notes = "平均转化率(触客转化率总和/门店数)")
private BigDecimal avgConversionRate;
@ApiModelProperty(notes = "平均转化率环比")
......
......@@ -143,4 +143,10 @@ public class StoreDetailSummaryResponse implements Serializable {
@ApiModelProperty(notes = "渗透率环比")
private String penetrationRateMom;
@ApiModelProperty(notes = "触客转化率")
private BigDecimal contactConversionRate;
@ApiModelProperty(notes = "触客转化率环比")
private String contactConversionRateMom;
}
......@@ -48,7 +48,7 @@ public class StoreEmployeeRankResponse implements Serializable {
@ApiModelProperty(notes = "个人客单价")
private BigDecimal personalCustomerPrice;
@ApiModelProperty(notes = "个人转化率")
@ApiModelProperty(notes = "个人转化率(触客转化率)")
private BigDecimal personalConversionRate;
// @ApiModelProperty(notes = "个人成交客户数")
......
......@@ -40,7 +40,7 @@ public class StoreListResponse implements Serializable {
@ApiModelProperty(notes = "渗透率")
private BigDecimal penetrationRate;
@ApiModelProperty(notes = "转化率")
@ApiModelProperty(notes = "触客转化率")
private BigDecimal conversionRate;
@ApiModelProperty(notes = "升客价")
......
......@@ -19,6 +19,9 @@ public class DataStatsConstants {
/** 转化率 */
public static final String ITEM_CODE_A085 = "A085";
/** 触客转化率 */
public static final String ITEM_CODE_A0130 = "A0130";
/** 渗透率 */
public static final String ITEM_CODE_A077 = "A077";
......@@ -43,6 +46,9 @@ public class DataStatsConstants {
/** 整车延保-转化率 */
public static final String ITEM_CODE_A099 = "A099";
/** 整车延保-触客转化率 */
public static final String ITEM_CODE_A0131 = "A0131";
/** 电池-渗透率(门店) */
public static final String ITEM_CODE_A094 = "A094";
......@@ -55,6 +61,9 @@ public class DataStatsConstants {
/** 电池-转化率 */
public static final String ITEM_CODE_A091 = "A091";
/** 电池-触客转化率 */
public static final String ITEM_CODE_A0132 = "A0132";
/** 安心包-渗透率(门店) */
public static final String ITEM_CODE_A092 = "A092";
......@@ -67,6 +76,9 @@ public class DataStatsConstants {
/** 安心包-转化率 */
public static final String ITEM_CODE_A089 = "A089";
/** 安心包-触客转化率 */
public static final String ITEM_CODE_A0134 = "A0134";
/** 轮胎成交数 */
public static final String ITEM_CODE_A087 = "A087";
......@@ -79,6 +91,9 @@ public class DataStatsConstants {
/** 轮胎转化率 */
public static final String ITEM_CODE_A090 = "A090";
/** 轮胎-触客转化率 */
public static final String ITEM_CODE_A0133 = "A0133";
/** 车窗膜成交数 */
public static final String ITEM_CODE_A0106 = "A0106";
......@@ -91,6 +106,9 @@ public class DataStatsConstants {
/** 车窗膜转化率 */
public static final String ITEM_CODE_A0109 = "A0109";
/** 车窗膜-触客转化率 */
public static final String ITEM_CODE_A0135 = "A0135";
/** 车窗膜渗透率(员工) */
public static final String ITEM_CODE_A0110 = "A0110";
......@@ -106,6 +124,9 @@ public class DataStatsConstants {
/** 车身膜转化率 */
public static final String ITEM_CODE_A0114 = "A0114";
/** 车身膜-触客转化率 */
public static final String ITEM_CODE_A0136 = "A0136";
/** 车身膜渗透率(员工) */
public static final String ITEM_CODE_A0115 = "A0115";
......@@ -121,6 +142,9 @@ public class DataStatsConstants {
/** 精品附件转化率 */
public static final String ITEM_CODE_A0119 = "A0119";
/** 精品附件-触客转化率 */
public static final String ITEM_CODE_A0137 = "A0137";
/** 精品附件渗透率(员工) */
public static final String ITEM_CODE_A0120 = "A0120";
......@@ -179,8 +203,8 @@ public class DataStatsConstants {
public static List<String> getGoodsItemCodes(int bizs, String aggregateType){
List<String> res = null;
if (bizs == 1 || bizs == 3) {
res = Lists.newArrayList(ITEM_CODE_A099, ITEM_CODE_A066, ITEM_CODE_A091, ITEM_CODE_A070, ITEM_CODE_A090,
ITEM_CODE_A087, ITEM_CODE_A089, ITEM_CODE_A086);
res = Lists.newArrayList(ITEM_CODE_A0131, ITEM_CODE_A066, ITEM_CODE_A0132, ITEM_CODE_A070, ITEM_CODE_A0133,
ITEM_CODE_A087, ITEM_CODE_A0134, ITEM_CODE_A086);
if (aggregateType.equals("merchantIds")) {
res.add(ITEM_CODE_A067);
res.add(ITEM_CODE_A093);
......@@ -195,8 +219,8 @@ public class DataStatsConstants {
}
}
if (bizs == 2) {
res = Lists.newArrayList(ITEM_CODE_A0119, ITEM_CODE_A0117, ITEM_CODE_A0116, ITEM_CODE_A0114, ITEM_CODE_A0112,
ITEM_CODE_A0111, ITEM_CODE_A0109, ITEM_CODE_A0107, ITEM_CODE_A0106);
res = Lists.newArrayList(ITEM_CODE_A0137, ITEM_CODE_A0117, ITEM_CODE_A0116, ITEM_CODE_A0136, ITEM_CODE_A0112,
ITEM_CODE_A0111, ITEM_CODE_A0135, ITEM_CODE_A0107, ITEM_CODE_A0106);
if (aggregateType.equals("merchantIds")) {
res.add(ITEM_CODE_A0108);
res.add(ITEM_CODE_A0113);
......@@ -259,7 +283,10 @@ public class DataStatsConstants {
ITEM_CODE_A0108, ITEM_CODE_A0109, ITEM_CODE_A0110,
ITEM_CODE_A0118, ITEM_CODE_A0119, ITEM_CODE_A0120,
ITEM_CODE_A0113, ITEM_CODE_A0114, ITEM_CODE_A0115,
ITEM_CODE_A0104, ITEM_CODE_A0105);
ITEM_CODE_A0104, ITEM_CODE_A0105, ITEM_CODE_A0130,
ITEM_CODE_A0131, ITEM_CODE_A0132, ITEM_CODE_A0133,
ITEM_CODE_A0134, ITEM_CODE_A0135, ITEM_CODE_A0136,
ITEM_CODE_A0137);
public static boolean isRateItemCode(String itemCode){
if (StringUtils.isBlank(itemCode)) {
......
  • @wangxw1
    commented
    Master

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

    1. 字段命名不一致且存在拼写语义错误(可维护性与功能隐患)

    • 问题描述:在新增“触客转化率”字段时,不同 DTO 之间的英文命名不一致且存在拼写/语义错误。在 EmployeeDetailSummaryResponse 中命名为 contractConversionRate(contract 意为“合同”),而在 StoreDetailSummaryResponse 中正确命名为 contactConversionRate(contact 意为“接触/触客”)。
    • 影响分析:前后端对接时,同一业务概念出现不同的字段名,极易导致前端数据绑定错误或漏取数据。同时,contract 的语义错误会给后续维护代码的研发人员带来误导。
    • 优化建议:统一将“触客转化率”相关的字段及 Get/Set 方法命名为 contactConversionRate。 ```java // EmployeeDetailSummaryResponse.java 建议修改为: @ApiModelProperty(notes = "触客转化率") private BigDecimal contactConversionRate;

    @ApiModelProperty(notes = "触客转化率环比") private String contactConversionRateMom;

    
    #### 2. API 响应字段的语义映射混乱(功能正确性风险)
    - **问题描述**:服务层在处理新指标 `A0130`(触客转化率)时,向 DTO 的赋值映射存在严重的不一致。
      - 在 `storeList` 方法中,将 `A0130` 赋值给了原有的 `conversionRate` 字段(覆盖了原有的 A085 语义)。
      - 在 `storeDetailSummary` 和 `employeeDetailSummary` 方法中,将 `A0130` 赋值给了新增的 `contactConversionRate` 字段,同时保留了 `conversionRate` 接收 `A085`。
    - **影响分析**:同一个字段名 `conversionRate` 在不同的接口中代表了不同的底层指标(一个是转化率,一个是触客转化率)。这破坏了 API 契约的一致性,前端或调用方在展示数据时大概率会出现逻辑混乱或数据对不上的情况。
    - **优化建议**:梳理业务需求,统一 API 契约。如果“触客转化率”是作为独立指标新增,所有接口都应使用新增的 `contactConversionRate` 字段接收 `A0130`;如果是要全局替换原有“转化率”,应统一明确字段复用逻辑,并确保所有关联接口同步调整,避免新老概念混用。
    
    #### 3. 环境变量赋值存在冗余代码(代码整洁度)
    - **问题描述**:在 `BusinessSceneAnalysisService.java` 的 `findEcoStores` 方法中,重构硬编码的预警类型为环境变量配置时,遗漏了删除原有的硬编码代码。
    - **影响分析**:虽然对最终运行结果无实质性破坏(后一行覆盖了前一行),但属于明显的冗余代码,降低了代码的整洁度和专业度。
    - **优化建议**:删除多余的硬编码赋值行。
      ```java
      // 修改前
      queryDTO.setWarningType(3);
      queryDTO.setWarningType(env.getProperty("bi.warning.type.eco", Integer.class, 3));
    
      // 修改后
      queryDTO.setWarningType(env.getProperty("bi.warning.type.eco", Integer.class, 3));
    

    二、评分明细

    • 功能实现的正确性与健壮性 (34/40分): 核心的常量替换和指标增加逻辑基本正确,未触发 MyBatis 子查询或 Dubbo 接口参数变更等危险规则。但由于 DTO 字段映射逻辑在不同方法中存在不一致(如问题 2 所述),存在一定的业务逻辑展示风险,故扣除 6 分。

    • 安全性与潜在风险 (30/30分): 本次变动主要集中在 DTO 字段扩展、常量定义及内部服务的数据组装,未引入新的外部输入点,不存在 SQL 注入、XSS 或越权等安全风险。

    • 最佳实践与可维护性 (12/20分): 存在较明显的命名不一致及拼写错误(contract vs contact),且重构时遗留了冗余代码。此外,针对大段的 switch-case 指标解析,未做进一步的策略模式抽象,代码略显臃肿。扣除 8 分。

    • 性能与资源利用 (4/5分): 通过 parallelCallListMap 实现了并发查询,资源利用合理。移除了 isWarningCycle 判断可能会增加部分场景下的计算量,但基于“简化业务逻辑”的提交说明,属于可接受的业务取舍。扣除 1 分。

    • 提交信息质量 (5/5分): Commit 信息结构清晰,采用了列表形式详细说明了各个模块的改动点以及业务意图(如:移除了不必要的兜底预警周期判断条件),具有很好的可追溯性。满分。

    总分:85分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!