Commit cb5b491f by zhoulm

服务商2合同信息及提交oa配置开关控制

1 parent 48fe9cf4
...@@ -314,7 +314,7 @@ public class CreateBusinessApproveMerchantService { ...@@ -314,7 +314,7 @@ public class CreateBusinessApproveMerchantService {
MerchantRopResponse partnerMerchantInfo = partnerMerchantInfoR.getResult(); MerchantRopResponse partnerMerchantInfo = partnerMerchantInfoR.getResult();
ServiceContractAddDTO contractInfo = new ServiceContractAddDTO(); ServiceContractAddDTO contractInfo = new ServiceContractAddDTO();
contractInfo.setServiceMerchantId(merchant.getPartnerMerchantId()); contractInfo.setServiceMerchantId(merchant.getPartnerMerchantId());
contractInfo.setServiceMerchantName(merchant.getParentMerchantName()); contractInfo.setServiceMerchantName(merchant.getPartnerMerchantName());
contractInfo.setServiceProviderLevel(ServiceMerchantLevelEnum.LEVEL_3.getCode()); contractInfo.setServiceProviderLevel(ServiceMerchantLevelEnum.LEVEL_3.getCode());
ServiceMerchantAddDTO partnerMerchant = convertMerchantInfo(partnerMerchantInfo); ServiceMerchantAddDTO partnerMerchant = convertMerchantInfo(partnerMerchantInfo);
partnerMerchant.setContractInfo(contractInfo); partnerMerchant.setContractInfo(contractInfo);
...@@ -329,7 +329,11 @@ public class CreateBusinessApproveMerchantService { ...@@ -329,7 +329,11 @@ public class CreateBusinessApproveMerchantService {
} }
MerchantRopResponse partnerMerchantInfo2 = partnerMerchantInfoR2.getResult(); MerchantRopResponse partnerMerchantInfo2 = partnerMerchantInfoR2.getResult();
ServiceMerchantAddDTO partnerMerchant2 = convertMerchantInfo(partnerMerchantInfo2); ServiceMerchantAddDTO partnerMerchant2 = convertMerchantInfo(partnerMerchantInfo2);
partnerMerchant2.setContractInfo(contractInfo); ServiceContractAddDTO contractInfo2 = new ServiceContractAddDTO();
contractInfo2.setServiceMerchantId(merchant.getPartnerMerchantId2());
contractInfo2.setServiceMerchantName(merchant.getPartnerMerchantName2());
contractInfo2.setServiceProviderLevel(ServiceMerchantLevelEnum.LEVEL_3.getCode());
partnerMerchant2.setContractInfo(contractInfo2);
serviceList.add(partnerMerchant2); serviceList.add(partnerMerchant2);
} }
......
...@@ -3348,8 +3348,8 @@ public class CreateBusinessApproveService { ...@@ -3348,8 +3348,8 @@ public class CreateBusinessApproveService {
@Override @Override
public void afterCommit() { public void afterCommit() {
//createBusinessProductService.updateCreateBusinessProductProfit(dto.getBusinessCode()); //createBusinessProductService.updateCreateBusinessProductProfit(dto.getBusinessCode());
if (!Objects.equals(dto.getSaveDraft(), true)) { if (!Objects.equals(dto.getSaveDraft(), true) && OrePropertyConfigurer.getProperty("create.business.submit.oa.switch", Boolean.class, true)) {
//thiz.submitBusinessOA(dto); thiz.submitBusinessOA(dto);
} }
} }
}); });
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议

    • 问题 1:硬编码逻辑与数据模型扩展性风险(功能健壮性)

      • 问题描述:在 CreateBusinessApproveMerchantService 中,通过 getPartnerMerchantId2 和手动创建 contractInfo2 的方式处理第二个服务商。这种“平铺字段”的设计(Id, Id2...)和重复的 DTO 转换逻辑属于硬编码反模式。
      • 影响分析:如果未来业务需要支持第三个或更多服务商,必须再次修改代码逻辑并增加类字段,违反“开闭原则”,且极易在复制粘贴代码时遗漏属性设置(如代码中多次手动设置 LEVEL_3)。
      • 优化建议:建议将服务商信息封装为集合处理,或至少提取一个私有方法来构建 ServiceContractAddDTO,减少重复代码。 java // 建议提取构建方法 private ServiceContractAddDTO buildContractInfo(String merchantId, String merchantName) { ServiceContractAddDTO contractInfo = new ServiceContractAddDTO(); contractInfo.setServiceMerchantId(merchantId); contractInfo.setServiceMerchantName(merchantName); contractInfo.setServiceProviderLevel(ServiceMerchantLevelEnum.LEVEL_3.getCode()); return contractInfo; }
    • 问题 2:事务后置处理(afterCommit)缺乏异常处理机制(稳定性)

      • 问题描述:在 CreateBusinessApproveService 中,submitBusinessOA 被放在事务提交后的回调中执行,且没有任何 try-catch 保护。
      • 影响分析:虽然 afterCommit 保证了数据库事务已成功,但 OA 提交属于外部 RPC 调用。若 OA 接口超时或宕机,该异常可能向上抛出影响后续逻辑(取决于调用链),且由于事务已提交,系统将处于“本地数据已产生但 OA 未触发”的不一致状态,且无任何错误日志记录。
      • 优化建议:在 afterCommit 内部对外部调用进行 try-catch 包装,并记录关键错误日志,必要时引入补偿机制(如落库异步重试)。
    • 问题 3:配置项获取方式不符合依赖注入最佳实践(可维护性)

      • 问题描述:代码直接通过 OrePropertyConfigurer.getProperty(...) 静态方法在业务逻辑运行期获取配置开关。
      • 影响分析:这种“服务定位器”模式增加了组件与配置框架的强耦合,不利于单元测试(难以 Mock 静态方法),且配置项散落在代码各处,缺乏统一视图。
      • 优化建议:使用 Spring 的 @Value("${create.business.submit.oa.switch:true}") 或 @ConfigurationProperties 将配置注入到类的成员变量中。

    二、评分明细

    • 功能实现的正确性与健壮性(36/40分):修复了原有的名称赋值 Bug,逻辑正确。但采用平铺字段处理多服务商,健壮性稍欠,存在硬编码隐患。
    • 安全性与潜在风险(30/30分):未发现 SQL 注入、越权或敏感信息泄露风险。
    • 最佳实践与可维护性(14/20分):代码存在重复逻辑(DRY原则违背);配置项获取方式不符合 Spring 常用工程实践。
    • 性能与资源利用(5/5分):变更内容不涉及复杂的循环或资源密集型操作,性能影响微乎其微。
    • 提交信息质量(4/5分):提交信息描述了主要变更内容,较为清晰,若能增加任务 ID 或前缀(如 fix: 或 feat:)则更佳。

    总分:89分

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