浏览代码

chore: /pay/switch 兜底 catch 补异常日志(线上排障埋点)

线上出现 500 通用文案(no.pay.switch.failed),前端确认 payType 已实际
回写——故障点在 createPayment 渠道拉起环节的原始异常,原 catch-all
无日志导致根因不可见。补 logger.error 留痕,非行为修复。
qmj 1 天之前
父节点
当前提交
50f57fc855
共有 1 个文件被更改,包括 7 次插入 和 0 次删除
  1. 7 0
      ruoyi-admin/src/main/java/com/ruoyi/app/pay/PayMethodSwitchController.java

+ 7 - 0
ruoyi-admin/src/main/java/com/ruoyi/app/pay/PayMethodSwitchController.java

@@ -7,6 +7,8 @@ import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.MessageUtils;
 import com.ruoyi.system.utils.Auth;
 import com.ruoyi.system.utils.JwtUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestHeader;
@@ -23,6 +25,8 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/pay")
 public class PayMethodSwitchController {
 
+    private static final Logger logger = LoggerFactory.getLogger(PayMethodSwitchController.class);
+
     private final PayMethodSwitchService switchService;
 
     public PayMethodSwitchController(PayMethodSwitchService switchService) {
@@ -45,6 +49,9 @@ public class PayMethodSwitchController {
             // 业务拒绝(订单不可支付/方式非法/闸门限制)携带国际化文案原样返回
             return AjaxResult.error(exception.getMessage());
         } catch (Exception exception) {
+            // 兜底前必须留痕:真实异常(网关调用/NPE/SQL)只有这里能看到,不打日志等于盲修
+            logger.error("pay switch failed orderId={}",
+                    request == null ? null : request.getOrderId(), exception);
             return AjaxResult.error(MessageUtils.message("no.pay.switch.failed"));
         }
     }