From ca0f290991d7a15748d90d01e57f0f4cd6f26c9c Mon Sep 17 00:00:00 2001
From: xin <1099200748@qq.com>
Date: Wed, 03 Sep 2025 21:38:52 +0800
Subject: [PATCH] 汇旺财支付回调-优化日志

---
 oying-system/src/main/java/com/oying/modules/hwc/service/impl/CallbackServiceImpl.java |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/oying-system/src/main/java/com/oying/modules/hwc/service/impl/CallbackServiceImpl.java b/oying-system/src/main/java/com/oying/modules/hwc/service/impl/CallbackServiceImpl.java
index 3af99bd..c0c879f 100644
--- a/oying-system/src/main/java/com/oying/modules/hwc/service/impl/CallbackServiceImpl.java
+++ b/oying-system/src/main/java/com/oying/modules/hwc/service/impl/CallbackServiceImpl.java
@@ -1,6 +1,5 @@
 package com.oying.modules.hwc.service.impl;
 
-import com.oying.exception.BadRequestException;
 import com.oying.modules.hwc.service.CallbackService;
 import com.oying.modules.hwc.utils.SignUtil;
 import com.oying.modules.hwc.utils.XmlUtils;
@@ -14,11 +13,14 @@
 import com.oying.utils.enums.PayTypeEnum;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.dom4j.DocumentException;
+import org.springframework.dao.DataIntegrityViolationException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -76,16 +78,21 @@
                 }
             }
             response.getWriter().write(respString);
+        } catch (DataIntegrityViolationException e) {
+            log.error("汇旺财退款回调数据异常失败:{} {}", map.toString(), e.getMessage());
+        } catch (DocumentException e) {
+            log.error("汇旺财退款回调XML转码失败:{} {}", map.toString(), e.getMessage());
+        } catch (IOException e) {
+            log.error("汇旺财退款回调写入流失败:{} {}", map.toString(), e.getMessage());
         } catch (Exception e) {
-            log.error("汇旺财支付回调失败:{}", map.toString());
-            throw new BadRequestException("操作失败,原因:" + e.getMessage());
+            log.error("汇旺财退款回调失败:{} {}", map.toString(), e.getMessage());
         }
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void returnNotify(HttpServletRequest request, HttpServletResponse response) {
-        Map<String, String> map =  new HashMap<>();
+        Map<String, String> map = new HashMap<>();
         try {
             String resString = XmlUtils.parseRequest(request);
             String respString = "error";
@@ -112,9 +119,14 @@
                 }
             }
             response.getWriter().write(respString);
+        } catch (DataIntegrityViolationException e) {
+            log.error("汇旺财退款回调数据异常失败:{} {}", map.toString(), e.getMessage());
+        } catch (DocumentException e) {
+            log.error("汇旺财退款回调XML转码失败:{} {}", map.toString(), e.getMessage());
+        } catch (IOException e) {
+            log.error("汇旺财退款回调写入流失败:{} {}", map.toString(), e.getMessage());
         } catch (Exception e) {
-            log.error("汇旺财退款回调失败:{}", map.toString());
-            System.out.println("操作失败,原因:" + e.getMessage());
+            log.error("汇旺财退款回调失败:{} {}", map.toString(), e.getMessage());
         }
     }
 }

--
Gitblit v1.9.3