From e9e42b621afdf6ac94f5327ee843b32b10a401b4 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期二, 04 八月 2026 17:45:14 +0800
Subject: [PATCH] update

---
 backend/src/main/java/com/tourguide/common/huifu/biz/DouGongRefundBiz.java |   49 +++++++++++++++++--------------------------------
 1 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/backend/src/main/java/com/tourguide/common/huifu/biz/DouGongRefundBiz.java b/backend/src/main/java/com/tourguide/common/huifu/biz/DouGongRefundBiz.java
index c9853ea..2c58182 100644
--- a/backend/src/main/java/com/tourguide/common/huifu/biz/DouGongRefundBiz.java
+++ b/backend/src/main/java/com/tourguide/common/huifu/biz/DouGongRefundBiz.java
@@ -1,11 +1,7 @@
 package com.tourguide.common.huifu.biz;
 
-import com.alibaba.fastjson.JSONObject;
 import com.huifu.bspay.sdk.opps.core.net.BasePayRequest;
 import com.tourguide.common.huifu.properties.HuiFuProperties;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
@@ -13,44 +9,33 @@
 import java.util.HashMap;
 import java.util.Map;
 
-/**
- * 斗拱退款业务。
- *
- * 备注:该类只发起斗拱退款请求,退款成功后的本地订单退款状态应由退款回调验签后幂等更新。
- */
 @Component
 public class DouGongRefundBiz {
-    private static final Logger log = LoggerFactory.getLogger(DouGongRefundBiz.class);
+    private final HuiFuProperties huiFuProperties;
 
-    @Autowired
-    private HuiFuProperties huiFuProperties;
+    public DouGongRefundBiz(HuiFuProperties huiFuProperties) {
+        this.huiFuProperties = huiFuProperties;
+    }
 
-    /**
-     * 交易退款接口
-     *
-     * @param reqSeqId 请求流水号,同一huifu_id下当天唯一
-     * @param ordAmt 申请退款金额,单位元
-     * @param orgReqDate 原交易请求日期,格式yyyyMMdd
-     * @param orgReqSeqId 原交易请求流水号(三选一)
-     * @param type 类型 1:小件物流;2:跨城出行
-     * @return 请求结果
-     */
-    public Map<String, Object> refund(String reqSeqId, BigDecimal ordAmt, String orgReqDate, String orgReqSeqId, Integer type) throws Exception {
-        log.info("开始调用斗拱退款接口, 退款金额: {}",  ordAmt);
+    public Map<String, Object> refund(String reqSeqId, BigDecimal amount,
+                                      String orgReqDate, String orgReqSeqId) throws Exception {
         DouGongRequestSupport.initBasePay(huiFuProperties);
         Map<String, Object> data = new HashMap<>();
         data.put("req_date", DouGongRequestSupport.todayForHuiFu());
         data.put("req_seq_id", reqSeqId);
-        data.put("huifu_id", huiFuProperties.getSysId());
-        data.put("ord_amt", ordAmt.setScale(2, RoundingMode.HALF_UP).toString());
+        data.put("huifu_id", huiFuProperties.getHuifuId());
+        data.put("ord_amt", amount.setScale(2, RoundingMode.HALF_UP).toString());
         data.put("org_req_date", orgReqDate);
-        // 备注:斗拱原交易定位支持三选一,这里统一使用本系统保存的原请求流水 org_req_seq_id。
         data.put("org_req_seq_id", orgReqSeqId);
-        String notifyUrl = Integer.valueOf(1).equals(type) ? "/base/dougong/refund-logistics" : "/base/dougong/refund-crosscity";
-        data.put("notify_url", huiFuProperties.getCallbackPath() + notifyUrl);
+        data.put("notify_url", callbackBaseUrl() + "/base/dougong/refund-notify");
+        return BasePayRequest.requestBasePay("v4/trade/payment/scanpay/refund", data, null, false);
+    }
 
-        Map<String, Object> response = BasePayRequest.requestBasePay("v4/trade/payment/scanpay/refund", data, null, false);
-        log.info("斗拱退款接口响应内容: {}", JSONObject.toJSONString(response));
-        return response;
+    private String callbackBaseUrl() {
+        String callbackPath = huiFuProperties.getCallbackPath().trim();
+        while (callbackPath.endsWith("/")) {
+            callbackPath = callbackPath.substring(0, callbackPath.length() - 1);
+        }
+        return callbackPath;
     }
 }

--
Gitblit v1.7.1