From 39f6fca28e3f78abe48f08e474ec011abb990b36 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期三, 09 九月 2026 10:39:21 +0800
Subject: [PATCH] update

---
 backend/src/main/java/com/tourguide/modules/order/payment/HuifuPaymentRefundGateway.java |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/backend/src/main/java/com/tourguide/modules/order/payment/HuifuPaymentRefundGateway.java b/backend/src/main/java/com/tourguide/modules/order/payment/HuifuPaymentRefundGateway.java
index f9b6d2b..108ba81 100644
--- a/backend/src/main/java/com/tourguide/modules/order/payment/HuifuPaymentRefundGateway.java
+++ b/backend/src/main/java/com/tourguide/modules/order/payment/HuifuPaymentRefundGateway.java
@@ -1,5 +1,6 @@
 package com.tourguide.modules.order.payment;
 
+import com.alibaba.fastjson.JSONObject;
 import com.tourguide.common.huifu.biz.DouGongRefundBiz;
 import com.tourguide.modules.order.entity.TourOrder;
 import com.tourguide.modules.order.entity.TourOrderPaymentAttempt;
@@ -39,9 +40,9 @@
         try {
             Map<String, Object> response = refundBiz.refund(order.getRefundOrderNo(), amount,
                     paymentAttempt.getReqDate(), paymentAttempt.getReqSeqId());
-            String responseCode = stringValue(response.get("resp_code"));
+            String responseCode = responseValue(response, "resp_code", "code");
             if (!SUCCESS_CODE.equals(responseCode)) {
-                String description = stringValue(response.get("resp_desc"));
+                String description = responseValue(response, "resp_desc", "msg");
                 throw new IllegalStateException(StringUtils.hasText(description)
                         ? description : "Huifu refund request failed");
             }
@@ -56,4 +57,28 @@
     private String stringValue(Object value) {
         return value == null ? null : String.valueOf(value);
     }
+
+    private String responseValue(Map<String, Object> response, String... keys) {
+        if (response == null) return null;
+        for (String key : keys) {
+            String value = stringValue(response.get(key));
+            if (StringUtils.hasText(value)) return value;
+        }
+        for (String nestedKey : new String[]{"data", "resp_data"}) {
+            Object nested = response.get(nestedKey);
+            if (nested instanceof Map) {
+                @SuppressWarnings("unchecked")
+                Map<String, Object> nestedMap = (Map<String, Object>) nested;
+                String value = responseValue(nestedMap, keys);
+                if (StringUtils.hasText(value)) return value;
+            } else if (nested instanceof String && StringUtils.hasText((String) nested)) {
+                try {
+                    String value = responseValue(JSONObject.parseObject((String) nested), keys);
+                    if (StringUtils.hasText(value)) return value;
+                } catch (RuntimeException ignored) {
+                }
+            }
+        }
+        return null;
+    }
 }

--
Gitblit v1.7.1