Commit 6a7e728b by 崔彦峰

修改复制没有生效记录的规则。

1 parent 9e81339b
...@@ -503,7 +503,7 @@ public class GoodsListingSettleRuleService { ...@@ -503,7 +503,7 @@ public class GoodsListingSettleRuleService {
merchantDistributionRule.setTargetMerchantLevel(oldRule.getTargetMerchantLevel()); merchantDistributionRule.setTargetMerchantLevel(oldRule.getTargetMerchantLevel());
merchantDistributionRule.setMerchantId(oldRule.getMerchantId()); merchantDistributionRule.setMerchantId(oldRule.getMerchantId());
merchantDistributionRule.setMerchantName(oldRule.getMerchantName()); merchantDistributionRule.setMerchantName(oldRule.getMerchantName());
if (Objects.equals(baseRule.getShopMerchantDivideTarget(), MerchantDistributionRuleTargetMerchantTypeEnum.SHOP4S.getValue())) { if (Objects.equals(oldRule.getTargetMerchantType(), MerchantDistributionRuleTargetMerchantTypeEnum.SHOP4S.getValue())) {
merchantDistributionRule.setTargetMerchantLevel(baseRule.getRealityShopLevel()); merchantDistributionRule.setTargetMerchantLevel(baseRule.getRealityShopLevel());
if (Objects.equals(TargetMerchantLevelEnum.SUPERIOR.getValue(),baseRule.getRealityShopLevel())) { if (Objects.equals(TargetMerchantLevelEnum.SUPERIOR.getValue(),baseRule.getRealityShopLevel())) {
merchantDistributionRule.setMerchantId(merchantRef.getParentMerchantId()); merchantDistributionRule.setMerchantId(merchantRef.getParentMerchantId());
...@@ -515,7 +515,7 @@ public class GoodsListingSettleRuleService { ...@@ -515,7 +515,7 @@ public class GoodsListingSettleRuleService {
} }
} }
if (Objects.equals(baseRule.getShopMerchantDivideTarget(), MerchantDistributionRuleTargetMerchantTypeEnum.PLATFORM.getValue())) { if (Objects.equals(oldRule.getTargetMerchantType(), MerchantDistributionRuleTargetMerchantTypeEnum.PLATFORM.getValue())) {
merchantDistributionRule.setMerchantId(merchantRef.getContractingMerchantId()); merchantDistributionRule.setMerchantId(merchantRef.getContractingMerchantId());
merchantDistributionRule.setMerchantName(merchantRef.getContractingMerchantName()); merchantDistributionRule.setMerchantName(merchantRef.getContractingMerchantName());
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议,如果必要,给出代码示例(仅限 Top 3)

    1. 最佳实践:互斥的条件判断建议使用 else if(重要性:中)

    • 问题描述:代码中对 oldRule.getTargetMerchantType() 进行了两次独立的 if 判断,分别校验其是否为 SHOP4S 和 PLATFORM。
    • 影响分析:由于目标商户类型是枚举值,在同一时刻只能是其中一种情况(互斥条件)。使用两个独立的 if 语句,即使第一个条件命中,程序仍会强制计算并判断第二个条件,这在逻辑表达上不够严谨,也存在极其微小的性能损耗。
    • 优化建议:将第二个 if 替换为 else if,或者在条件较多时使用 switch 语句。 java if (Objects.equals(oldRule.getTargetMerchantType(), MerchantDistributionRuleTargetMerchantTypeEnum.SHOP4S.getValue())) { // ... 逻辑处理 } else if (Objects.equals(oldRule.getTargetMerchantType(), MerchantDistributionRuleTargetMerchantTypeEnum.PLATFORM.getValue())) { // ... 逻辑处理 }

    2. 提交信息质量:Commit Message 缺乏技术上下文与追溯性(重要性:低)

    • 问题描述:提交信息为“修改复制没有生效记录的规则。 (by cuiyf)”,仅描述了业务动作,缺乏技术维度的解释和任务追踪关联。
    • 影响分析:未来进行代码回溯(Code Review 或排查线上问题)时,其他开发者无法通过 Commit 信息得知为什么要把 baseRule.getShopMerchantDivideTarget() 改为 oldRule.getTargetMerchantType()。
    • 优化建议:建议在 Commit Message 中补充缺陷关联 ID(如 Jira/Tapd ID)以及简要的技术原因。例如:fix(rule): 修复复制未生效记录时商户类型取值错误的问题 (BugID: xxx) - 将 baseRule 替换为正确的 oldRule 取值。

    二、评分明细

    • 功能实现的正确性与健壮性(40/40分): 本次修改修复了取值对象的错误(从 baseRule 修正为 oldRule),属于核心逻辑的 Bug 修复。未发现空指针风险(oldRule 在上文已使用,若为空已提前抛出异常),未涉及 MyBatis 子查询和 Dubbo 接口变更。
    • 安全性与潜在风险(30/30分): 本次变更仅为普通的条件判断字段修正,不涉及外部输入直接处理、SQL 拼接或权限校验,无安全隐患。
    • 最佳实践与可维护性(17/20分): 扣除 3 分。互斥条件使用了连续的独立 if 判断,未采用 else if,在代码结构的严谨性和可读性上可进一步提升。
    • 性能与资源利用(4/5分): 扣除 1 分。连续的独立 if 判断会导致不必要的条件计算,虽然对整体性能影响微乎其微,但从极致的工程习惯来看属于无效的 CPU 周期消耗。
    • 提交信息质量(2/5分): 扣除 3 分。提交信息仅有一句业务描述,缺乏技术原因解释和 Issue/Bug 追踪 ID,不利于后续的代码维护和回溯。

    总分:93分

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