From 206f601b1f2a2e3cb0bf4f5dead01bec9077d8e9 Mon Sep 17 00:00:00 2001
From: 彭雪彬 <1724387007@qq.com>
Date: Thu, 04 Sep 2025 15:28:52 +0800
Subject: [PATCH] Merge branch 'xin' into pxb
---
oying-system/src/main/java/com/oying/modules/hwc/service/impl/CallbackServiceImpl.java | 40 +++++++++++++++++++++++++++++-----------
1 files changed, 29 insertions(+), 11 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 404251a..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,23 +1,27 @@
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;
import com.oying.modules.security.config.SwiftPassProperties;
-import com.oying.modules.sh.domain.OrderReturn;
import com.oying.modules.sh.domain.vo.OrderResponse;
+import com.oying.modules.sh.domain.vo.OrderReturnResponse;
import com.oying.modules.sh.service.OrderReturnService;
import com.oying.modules.sh.service.OrderService;
+import com.oying.utils.enums.OrderStatusEnum;
import com.oying.utils.enums.PayStateEnum;
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;
/**
@@ -38,18 +42,19 @@
@Override
@Transactional(rollbackFor = Exception.class)
public void alipayCallback(HttpServletRequest request, HttpServletResponse response) {
+ Map<String, String> map = new HashMap<>();
try {
String resString = XmlUtils.parseRequest(request);
String respString = "error";
if (!resString.isEmpty()) {
- Map<String, String> map = XmlUtils.toMap(resString.getBytes(), "utf-8");
+ map = XmlUtils.toMap(resString.getBytes(), "utf-8");
String sign_type = map.get("sign_type");
String reSign = map.get("sign");
if (map.containsKey("sign")) {
OrderResponse order = orderService.getByOrderNum(map.get("out_trade_no"));
PayTypeEnum status = PayTypeEnum.find(order.getOrder().getPayType());
if (SignUtil.verifySign(reSign, sign_type, map, properties, status)) {
- log.error("验证签名错误!:{}", map.toString());
+ log.error("汇旺财支付验证签名错误!:{}", map.toString());
} else {
if ("0".equals(map.get("status"))) {
if ("0".equals(map.get("result_code"))) {
@@ -61,7 +66,7 @@
PayStateEnum stateEnum = PayStateEnum.NOTPAY;
if ("0".equals(map.get("pay_result"))) {
stateEnum = PayStateEnum.SUCCESS;
- orderService.paySuccess(order);
+ orderService.operationLog(order, OrderStatusEnum.TWO, null);
}
orderService.updatePayStatus(map.get("out_trade_no"), stateEnum, map.get("pay_info"), map.get("time_end"));
// 处理成功
@@ -73,26 +78,33 @@
}
}
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) {
- 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<>();
try {
String resString = XmlUtils.parseRequest(request);
String respString = "error";
if (!resString.isEmpty()) {
- Map<String, String> map = XmlUtils.toMap(resString.getBytes(), "utf-8");
+ map = XmlUtils.toMap(resString.getBytes(), "utf-8");
String sign_type = map.get("sign_type");
String reSign = map.get("sign");
if (map.containsKey("sign")) {
- OrderReturn order = returnService.getByReturnNum(map.get("out_refund_no"));
- PayTypeEnum status = PayTypeEnum.find(order.getPayType());
+ OrderReturnResponse order = returnService.getByReturnNum(map.get("out_refund_no"));
+ PayTypeEnum status = PayTypeEnum.find(order.getOrderReturn().getPayType());
if (SignUtil.verifySign(reSign, sign_type, map, properties, status)) {
- log.error("验证签名错误!:{}", map.toString());
+ log.error("汇旺财退款验证签名错误!:{}", map.toString());
} else {
if ("0".equals(map.get("status"))) {
if ("0".equals(map.get("result_code"))) {
@@ -107,8 +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) {
- System.out.println("操作失败,原因:" + e.getMessage());
+ log.error("汇旺财退款回调失败:{} {}", map.toString(), e.getMessage());
}
}
}
--
Gitblit v1.9.3