KKSU
2025-02-07 4bb9e8497a255cb4e7b7218e07bbd788978ca846
feat(pay): 添加支付成功和失败页面并更新回调逻辑

- 新增支付成功 (success.html) 和失败 (fail.html) 页面模板
- 修改 FIUUController 中的 handlePaymentCallback 方法返回类型
- 优化回调逻辑,根据支付结果返回不同页面
2 files added
1 files modified
37 ■■■■ changed files
src/main/java/cc/mrbird/febs/pay/controller/FIUUController.java 17 ●●●●● patch | view | raw | blame | history
src/main/resources/templates/fail.html 10 ●●●●● patch | view | raw | blame | history
src/main/resources/templates/success.html 10 ●●●●● patch | view | raw | blame | history
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";
        }
    }
src/main/resources/templates/fail.html
New file
@@ -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>
src/main/resources/templates/success.html
New file
@@ -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>