Commit 79b5b23d by 林永健

fix(peanalysis): 修正轮胎延保生态系数计算及订单流量排名查询

- 注释掉轮胎延保中生态系数计算,避免误计算
- 优化GoodsOrderMapper中findTrafficRank查询语句
- 增加订单关联支付表条件及去重统计
- 添加场景(scene)过滤条件
- 修改起止日期过滤,区分升级订单支付时间和普通订单时间
- 统一表别名规范,避免字段歧义
1 parent 4883dc16
......@@ -1535,8 +1535,8 @@ public class BusinessSceneAnalysisService {
List<Integer> merchantIds = req.getMerchantIds();
Integer sceneType = req.convertToSceneType(queryParams.getBizs());
DateTime startTime = DateUtil.beginOfDay(DateUtil.parse(req.getStartTime()));
DateTime endTime = DateUtil.endOfDay(DateUtil.parse(req.getEndTime()));
Date startTime = DateUtil.beginOfDay(DateUtil.parse(req.getStartTime()));
Date endTime = DateUtil.endOfDay(DateUtil.parse(req.getEndTime())).toJdkDate();
List<TrafficContributionRankResponse> res = goodsOrderMapper.findTrafficRank(merchantIds, staffUuids, startTime, endTime, sceneType);
if (CollectionUtils.isEmpty(res)) {
return Collections.emptyList();
......@@ -1735,7 +1735,7 @@ public class BusinessSceneAnalysisService {
case DataStatsConstants.ITEM_CODE_A093: // 轮胎延保-渗透率
case DataStatsConstants.ITEM_CODE_A0102: // 轮胎延保-渗透率
res.setTireWarrantyPenetrationRate(convertPercentage(data.getItemValue()));
res.computeTireWarrantyEcoCoefficient();
// res.computeTireWarrantyEcoCoefficient(); // 轮胎无需计算生态系数
break;
case DataStatsConstants.ITEM_CODE_A090: // 轮胎延保-转化率
res.setTireWarrantyConversionRate(convertPercentage(data.getItemValue()));
......
......@@ -147,37 +147,54 @@
<select id="findTrafficRank" resultType="cn.com.glsx.dj.peanalysis.dto.res.output.TrafficContributionRankResponse">
select
user_id as employeeId,
employee_name as employeeName,
count(*) as totalTrafficContribution
from dj_car_life_goods_order
o.user_id as employeeId,
o.employee_name as employeeName,
count(distinct o.order_code) as totalTrafficContribution
from dj_car_life_goods_order o
left join dj_car_life_pay_order po on po.order_code=o.order_code and po.deleted_flag='N'
<where>
deleted_flag = 'N'
and user_id is not null
and status in (2, 4, 6)
o.deleted_flag = 'N'
and o.user_id is not null
and o.status in (2, 4, 6)
<if test="merchantIds != null and merchantIds.size() > 0">
and merchant_id in
and o.merchant_id in
<foreach collection="merchantIds" item="uuid" open="(" close=")" separator=",">
#{uuid}
</foreach>
</if>
<if test="staffUuids != null and staffUuids.size() > 0">
and user_id in
and o.user_id in
<foreach collection="staffUuids" item="uuid" open="(" close=")" separator=",">
#{uuid}
</foreach>
</if>
<if test="startDate != null and startDate !=''">
and order_time >= #{startDate}
<if test="scene != null">
and o.scene_type = #{scene}
</if>
<if test="endDate != null and endDate !=''">
and order_time &lt;= #{endDate}
<if test="startDate != null">
<![CDATA[ and (
(
o.upgrade_flag='Y' and po.success_date >= #{startDate}
)
or (
o.upgrade_flag='N' and o.order_time >= #{startDate}
)
)
]]>
</if>
<if test="scene != null">
and scene_type = #{scene}
<if test="endDate != null">
<![CDATA[ and (
(
o.upgrade_flag='Y' and po.success_date <= #{endDate}
)
or (
o.upgrade_flag='N' and o.order_time <= #{endDate}
)
)
]]>
</if>
</where>
group by user_id
group by o.user_id
</select>
</mapper>
\ No newline at end of file
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

    1. 类型不一致的问题

    问题描述: 在 BusinessSceneAnalysisService 类中的 startTime 和 endTime 变量类型从 DateTime 改为了 Date,这可能会导致类型不一致的问题,特别是在后续方法调用中如果仍然期望 DateTime 类型,会导致编译错误或运行时异常。

    优化建议: 建议统一使用 DateTime 类型,或者在所有相关方法中将 Date 类型转换为 DateTime 类型。确保所有方法调用时传入的参数类型一致。

    DateTime startTime = DateUtil.beginOfDay(DateUtil.parse(req.getStartTime()));
    DateTime endTime = DateUtil.endOfDay(DateUtil.parse(req.getEndTime()));
    

    2. 注释的可读性

    问题描述: 虽然注释了 res.computeTireWarrantyEcoCoefficient(); 这一行,但是注释的内容可以更详细一些,以便其他开发者理解为什么需要注释掉这一行代码。

    优化建议: 提供更详细的注释,解释为何轮胎延保不需要计算生态系数。例如:

    // 轮胎延保业务场景下,无需计算生态系数,因此注释掉该方法调用。
    // res.computeTireWarrantyEcoCoefficient();
    

    评分明细

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

      • 问题: 类型不一致可能导致运行时错误。
      • 评分: 35分
    2. 安全性与潜在风险(30分):

      • 问题: 未发现明显安全漏洞。
      • 评分: 30分
    3. 是否符合最佳实践(20分):

      • 问题: 注释不够详细,可以提供更多信息。
      • 评分: 18分
    4. 性能与资源利用效率(5分):

      • 问题: 未发现明显的性能问题。
      • 评分: 5分
    5. Commits信息的清晰性与准确性(5分):

      • 问题: 提交信息较为详细,但可以进一步明确注释掉生态系数计算的具体原因。
      • 评分: 4分

    总分: 92分


    以上是本次代码审查的详细报告,希望对您有所帮助。如果有任何疑问或需要进一步讨论的地方,请随时联系我。

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