Commit 1dd592e6 by 范富荣

fix:修改订单审核通知模板,新增提单时间字段

1 parent 7b0733b9
...@@ -1543,7 +1543,7 @@ public class PayOrderService { ...@@ -1543,7 +1543,7 @@ public class PayOrderService {
sendWorkWechatMessageService.sendOnlineSupervisionWechatMessageNewTemplate(userIdList, sceneName, sendWorkWechatMessageService.sendOnlineSupervisionWechatMessageNewTemplate(userIdList, sceneName,
toBeComeApplyRecordDTO.getOrderCode(), toBeComeApplyRecordDTO.getMerchantName(), toBeComeApplyRecordDTO.getOrderCode(), toBeComeApplyRecordDTO.getMerchantName(),
toBeComeApplyRecordDTO.getSellerName(), toBeComeApplyRecordDTO.getTotalPrice(), toBeComeApplyRecordDTO.getSellerName(), toBeComeApplyRecordDTO.getTotalPrice(),
toBeComeApplyRecordDTO.getFinalPrice()); toBeComeApplyRecordDTO.getFinalPrice(), toBeComeApplyRecordDTO.getApplyDate());
} catch (Exception e) { } catch (Exception e) {
log.error("推送线上运营企微消息异常,异常原因:{}", e.getMessage()); log.error("推送线上运营企微消息异常,异常原因:{}", e.getMessage());
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, e.getMessage()); throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
......
...@@ -1328,7 +1328,7 @@ public class SendWorkWechatMessageService { ...@@ -1328,7 +1328,7 @@ public class SendWorkWechatMessageService {
* 发送线上运营审核企微消息(新模板) * 发送线上运营审核企微消息(新模板)
*/ */
public Boolean sendOnlineSupervisionWechatMessageNewTemplate(List<String> userIdList, String sceneName, String orderCode, public Boolean sendOnlineSupervisionWechatMessageNewTemplate(List<String> userIdList, String sceneName, String orderCode,
String merchantName, String sellerName, BigDecimal totalPrice, BigDecimal finalPrice) { String merchantName, String sellerName, BigDecimal totalPrice, BigDecimal finalPrice, Date applyDate) {
try { try {
if (CollectionUtils.isEmpty(userIdList)) { if (CollectionUtils.isEmpty(userIdList)) {
return false; return false;
...@@ -1344,8 +1344,12 @@ public class SendWorkWechatMessageService { ...@@ -1344,8 +1344,12 @@ public class SendWorkWechatMessageService {
WorkWechatTextCardMessageDTO textCard = new WorkWechatTextCardMessageDTO(); WorkWechatTextCardMessageDTO textCard = new WorkWechatTextCardMessageDTO();
textCard.setTitle(sceneName + "订单折扣审核通知"); textCard.setTitle(sceneName + "订单折扣审核通知");
textCard.setDescription(String.format("订单编号:%s\n下单门店:%s\n提单人:%s\n商品总价/元:%s\n商品实付/元:%s", String strApplyDate = "-";
orderCode, merchantName, sellerName, totalPrice, finalPrice)); if(applyDate != null) {
strApplyDate = DateUtils.formatDate(applyDate, DateUtils.DEFAULT_DATE_FORMAT4);
}
textCard.setDescription(String.format("订单编号:%s\n下单门店:%s\n提单人:%s\n商品总价/元:%s\n商品实付/元:%s\n提单时间:%s",
orderCode, merchantName, sellerName, totalPrice, finalPrice, strApplyDate));
textCard.setBtnTxt("去审核"); textCard.setBtnTxt("去审核");
textCard.setUrl(String.format(env.getProperty("goodsOrder.apply.online.supervision.scene1.url"), orderCode)); textCard.setUrl(String.format(env.getProperty("goodsOrder.apply.online.supervision.scene1.url"), orderCode));
sendWorkWechatMessageRequestDTO.setTextCard(textCard); sendWorkWechatMessageRequestDTO.setTextCard(textCard);
......
  • @wangxw1
    commented
    Master

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

    1. 潜在的 Dubbo 接口兼容性风险(高优先级)

    • 问题描述:在 SendWorkWechatMessageService 中,方法 sendOnlineSupervisionWechatMessageNewTemplate 的签名被直接修改,新增了 Date applyDate 参数。
    • 影响分析:根据审查规则,若该服务类是暴露给外部的 Dubbo Remote 接口实现,直接修改已有请求参数属于危险实现。这会导致未同步更新 API 包的消费端(Consumer)在调用该方法时抛出 NoSuchMethodError 或序列化异常,引发线上故障。
    • 优化建议:
      • 如果该接口是 Dubbo 接口,请不要直接修改原方法。应采用方法重载(Overload)保留原方法,或在原有的请求 DTO 中新增字段。
      • 建议将过长的参数列表封装为一个 DTO 对象(见问题 2),这不仅符合最佳实践,也能彻底解决未来新增参数导致的接口不兼容问题。

    2. 方法参数过多,可维护性较差(代码坏味道)

    • 问题描述:sendOnlineSupervisionWechatMessageNewTemplate 方法的参数数量在本次修改后达到了 8 个。
    • 影响分析:参数列表过长(通常建议不超过 3-4 个)会严重降低代码的可读性,且在调用时极易发生相同类型参数位置传错(例如 merchantName 和 sellerName 都是 String)的低级错误。
    • 优化建议:将这些相关联的参数封装成一个独立的 DTO 类。 java // 示例 public Boolean sendOnlineSupervisionWechatMessageNewTemplate(WechatMessageTemplateDTO templateDTO) { // 内部通过 templateDTO.getApplyDate() 等获取数据 }

    3. 异常日志丢失堆栈信息(最佳实践)

    • 问题描述:在 PayOrderService.java 的 catch 块中,记录异常日志的方式为 log.error("推送线上运营企微消息异常,异常原因:{}", e.getMessage());。
    • 影响分析:e.getMessage() 仅输出简短的异常描述,丢失了最为关键的异常堆栈轨迹(Stack Trace)。当生产环境发生未知异常(如空指针等)时,将无法定位具体的错误代码行,极大增加排查难度。
    • 优化建议:在日志中传入异常对象 e 本身,以便打印完整的堆栈信息。 java // 优化代码示例 log.error("推送线上运营企微消息异常,异常原因:{}", e.getMessage(), e);

    二、评分明细

    • 功能实现的正确性与健壮性(37/40分):

      • 理由:业务逻辑实现正确,对新增的 applyDate 做了 null 值判断和默认值("-")处理,避免了空指针异常,String.format 使用 %s 也能安全处理潜在的 null 值。扣除 3 分是因为若此方法为 Dubbo 接口,直接修改方法签名将破坏系统健壮性。
    • 安全性与潜在风险(30/30分):

      • 理由:本次变更为纯业务逻辑的字符串拼接与日志记录,不涉及 SQL 拼接、外部不可信输入直接执行或越权操作,无明显安全隐患。
    • 最佳实践与可维护性(15/20分):

      • 理由:方法参数列表过长(达到 8 个),违反了 Clean Code 原则;异常处理部分虽然捕获了异常,但日志记录方式不规范,丢失了堆栈信息,降低了系统的可维护性。
    • 性能与资源利用(5/5分):

      • 理由:使用了标准的 String.format 和日期格式化工具,没有引入复杂的循环或消耗资源的计算,性能开销在合理范围内。
    • 提交信息质量(5/5分):

      • 理由:Commit 信息 fix:修改订单审核通知模板,新增提单时间字段 (by fanfr); 格式规范,清晰准确地说明了修改的内容和目的。

    总分:92分

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