From 53442b3b372373da59b6c936c399874359e2ad67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=85=B4?= Date: Tue, 17 Aug 2021 13:13:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E5=86=99=E6=94=AF=E4=BB=98=E5=AE=9D?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E6=88=90=E5=8A=9F=E5=90=8C=E6=AD=A5=E5=9B=9E?= =?UTF-8?q?=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AlipayCallbackController.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/HMS/src/main/java/com/hqyj/seven/controller/AlipayCallbackController.java b/HMS/src/main/java/com/hqyj/seven/controller/AlipayCallbackController.java index 31aaf34..54d0fe7 100644 --- a/HMS/src/main/java/com/hqyj/seven/controller/AlipayCallbackController.java +++ b/HMS/src/main/java/com/hqyj/seven/controller/AlipayCallbackController.java @@ -2,7 +2,9 @@ package com.hqyj.seven.controller; import com.alipay.api.AlipayApiException; import com.alipay.api.internal.util.AlipaySignature; +import com.hqyj.seven.service.FeeService; import com.hqyj.seven.utils.AlipayConfig; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -25,6 +27,9 @@ import java.util.Map; @Controller public class AlipayCallbackController { + @Autowired + private FeeService feeService; + //异步回调 @RequestMapping("/notifyUrl") public void notifyUrl(HttpServletRequest request, HttpServletResponse response) throws IOException { @@ -144,7 +149,17 @@ public class AlipayCallbackController { //付款金额 String total_amount = new String(request.getParameter("total_amount").getBytes("ISO-8859-1"), "UTF-8"); - out.println("trade_no:" + trade_no + "
out_trade_no:" + out_trade_no + "
total_amount:" + total_amount); + String feeId = new String(request.getParameter("FeeId").getBytes("ISO-8859-1"), "UTF-8"); + String trade_no1 = trade_no.substring(trade_no.length()-9); + int feeid=Integer.parseInt(feeId); + long trade_no2 = Long.parseLong(trade_no1); + Double total_amount1 = Double.parseDouble(total_amount); + if (feeService.payByAliPay(trade_no2,total_amount1,feeid)){ + response.sendRedirect("index"); + }else { + out.println("缴费失败!"); + response.sendRedirect("unpaidList"); + } } else { out.println("验签失败"); } -- GitLab