Commit 2940e30b by zhouhaibao

[+]获取直营门店逻辑异常

1 parent baa6ca62
......@@ -13,7 +13,7 @@ public class StoreBusinessDetail implements Serializable {
private static final long serialVersionUID = -1;
@ApiModelProperty(notes = "业务类型:1-延保,2-权益,3-轻改,4-二手车", example = "1")
@ApiModelProperty(notes = "业务类型:1-延保,3-权益,2-轻改,4-二手车", example = "1")
private Integer sceneType;
@ApiModelProperty(notes = "该业务产值", example = "5000.00")
......@@ -22,6 +22,8 @@ public class StoreBusinessDetail implements Serializable {
@ApiModelProperty(notes = "该业务占门店总产值的比例(小数形式,如 0.625 表示 62.5%)", example = "0.6250")
private BigDecimal ratio;
private BigDecimal profit;
@ApiModelProperty(notes = "该业务毛利率(小数形式,如 0.3 表示 30%)", example = "0.3000")
private BigDecimal profitMargin;
}
\ No newline at end of file
......@@ -1062,7 +1062,7 @@ public class BusinessAnalysisService {
return rank;
}
}
return 0;
return rank+1;
}
......@@ -1950,9 +1950,9 @@ public class BusinessAnalysisService {
resp.setStoreName(merchantNameResponses.stream()
.filter(dto -> dto.getMerchantId().equals(entry.getKey())).findFirst()
.map(MerchantNameResponse::getMerchantName).orElse(""));
BigDecimal reduce = disConfigByMerchant.get(entry.getKey()) == null ? BigDecimal.ZERO
: disConfigByMerchant.get(entry.getKey());
resp.setGrossProfitMargin(calculatePercent(reduce, entry.getValue()));
/* BigDecimal reduce = disConfigByMerchant.get(entry.getKey()) == null ? BigDecimal.ZERO
: disConfigByMerchant.get(entry.getKey());*/
// 处理每个场景的明细
Map<Integer, BigDecimal> integerBigDecimalMap = disConfigByStoreAndScene.get(
......@@ -2002,6 +2002,8 @@ public class BusinessAnalysisService {
profit = integerBigDecimalMap.get(sceneType) == null ? BigDecimal.ZERO
: integerBigDecimalMap.get(sceneType);
// 毛利率 = 毛利额 / 产值(避免除零)
detail.setProfit(profit); // 如果需要,可暂存 profit 到对象中
detail.setProfitMargin(calculatePercent(profit, sceneOutput));
}
......@@ -2009,7 +2011,15 @@ public class BusinessAnalysisService {
return detail;
})
.collect(Collectors.toList());
BigDecimal reduce = BigDecimal.ZERO;
if (checkSearchType(cycleType)) {
reduce = businessDetails.stream()
.map(StoreBusinessDetail::getProfit) // 假设你加了 getProfit()
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
resp.setGrossProfitMargin(calculatePercent(reduce, storeTotalOutput));
}
resp.setBusinessDetails(businessDetails);
resp.setBussinessSize(businessDetails.size());
}
......
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

    文件: StoreBusinessDetail.java

    1. 问题描述:

      • 在 @ApiModelProperty 注解中,业务类型的描述顺序被错误地修改了。原本的顺序是 1-延保,2-权益,3-轻改,4-二手车,现在变成了 1-延保,3-权益,2-轻改,4-二手车。
      • 新增了一个字段 profit,但没有相应的 getter 和 setter 方法。
    2. 优化建议:

      • 将业务类型的描述顺序恢复到原来的顺序,以确保文档和实际业务逻辑一致。
      • 为新增的 profit 字段添加 getter 和 setter 方法,以保证类的封装性。

    文件: BusinessAnalysisService.java

    1. 问题描述:

      • 在 getRankByOutput 方法中,返回值从 0 改为 rank + 1,这可能会影响业务逻辑的正确性。
      • 在 calculateStoreBusinessDetails 方法中,原有的计算逻辑被注释掉了,但没有提供替代方案。
      • 在 calculateStoreBusinessDetails 方法中,新增了对 profit 的计算和累加,但没有考虑 profit 是否应该在某些情况下被忽略。
    2. 优化建议:

      • 需要确认 getRankByOutput 方法的返回值修改是否符合业务需求,否则应恢复原值。
      • 检查被注释掉的代码,如果不需要,则删除;如果需要,恢复并优化。
      • 在计算 profit 时,应考虑是否需要在某些条件下忽略 null 或特定值的 profit,以避免不正确的结果。

    评分明细

    1. 功能实现的正确性与健壮性(40分):

      • 代码逻辑部分正确,但存在业务类型描述顺序错误和方法返回值修改的问题,扣5分。
      • 计算逻辑被注释掉且未提供替代方案,扣5分。
      • 总计扣10分,得30分。
    2. 安全性与潜在风险(30分):

      • 代码中没有明显的安全漏洞。
      • 总计得30分。
    3. 是否符合最佳实践(20分):

      • 新增字段缺少 getter 和 setter 方法,扣2分。
      • 注释掉的代码没有合理的解释或替代方案,扣2分。
      • 总计扣4分,得16分。
    4. 性能与资源利用效率(5分):

      • 代码中没有明显的性能问题。
      • 总计得5分。
    5. Commits信息的清晰性与准确性(5分):

      • 提交信息不够清晰,没有详细描述具体修改内容和原因。
      • 总计扣2分,得3分。

    总分: 82分


    建议:

    • 请根据上述问题描述和优化建议,尽快修改代码并重新提交。
    • 提交信息应更详细,以便其他开发者理解修改的目的和内容。
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!