From 4bb9e8497a255cb4e7b7218e07bbd788978ca846 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Fri, 07 Feb 2025 17:22:46 +0800
Subject: [PATCH] feat(pay): 添加支付成功和失败页面并更新回调逻辑
---
src/main/resources/templates/success.html | 10 ++++++++++
src/main/java/cc/mrbird/febs/pay/controller/FIUUController.java | 17 +++++++++++------
src/main/resources/templates/fail.html | 10 ++++++++++
3 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/pay/controller/FIUUController.java b/src/main/java/cc/mrbird/febs/pay/controller/FIUUController.java
index a4e7930..dba9f02 100644
--- a/src/main/java/cc/mrbird/febs/pay/controller/FIUUController.java
+++ b/src/main/java/cc/mrbird/febs/pay/controller/FIUUController.java
@@ -16,7 +16,12 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections.CollectionUtils;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -25,7 +30,7 @@
import java.util.Map;
@Slf4j
-@RestController
+@Controller
@Api(value = "FIUUController", tags = "FIUU支付")
@RequestMapping(value = "/api/fuPay")
public class FIUUController {
@@ -156,7 +161,7 @@
// Java 通知接口 暂时停止使用
@PostMapping("/callback")
- public FebsResponse handlePaymentCallback(@RequestParam Map<String, String> params) {
+ public String handlePaymentCallback(@RequestParam Map<String, String> params, Model model) {
String secretKey = "59c709fc18978a6a83b87f05d37cecbf";
String tranID = params.get("tranID");
String orderId = params.get("orderid");
@@ -177,7 +182,7 @@
log.info("callback calculatedSkey: {}", calculatedSkey);
log.info("callback payResult: {}", mallOrderInfo.getPayResult());
if("1".equals(mallOrderInfo.getPayResult())){
- return new FebsResponse().success().data("/pages/order/pay/paySuccess?amount="+ amount +"&type=3");
+ return "success";
}
if (!calculatedSkey.equals(skey)) {
@@ -185,9 +190,9 @@
}
if ("00".equals(status)) {
updateOrderStatus(orderId, status, amount, paydate, tranID);
- return new FebsResponse().success().data("/pages/order/pay/paySuccess?amount="+ amount +"&type=3");
+ return "success";
}else{
- return new FebsResponse().fail().message("支付失败");
+ return "fail";
}
}
diff --git a/src/main/resources/templates/fail.html b/src/main/resources/templates/fail.html
new file mode 100644
index 0000000..08662bf
--- /dev/null
+++ b/src/main/resources/templates/fail.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+ <meta charset="UTF-8">
+ <title>支付失败</title>
+</head>
+<body>
+<h1 th:text="支付失败"></h1>
+</body>
+</html>
\ No newline at end of file
diff --git a/src/main/resources/templates/success.html b/src/main/resources/templates/success.html
new file mode 100644
index 0000000..ae2bd18
--- /dev/null
+++ b/src/main/resources/templates/success.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+ <meta charset="UTF-8">
+ <title>支付成功</title>
+</head>
+<body>
+<h1 th:text="支付成功"></h1>
+</body>
+</html>
\ No newline at end of file
--
Gitblit v1.9.1