From 8830fb9e58e7e345947b06f6862cdd5b2ae6f0bf Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期一, 11 八月 2025 14:05:30 +0800
Subject: [PATCH] 赛事模块
---
cloud-server-account/src/main/java/com/dsh/account/controller/PaymentCallbackController.java | 150 +++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 137 insertions(+), 13 deletions(-)
diff --git a/cloud-server-account/src/main/java/com/dsh/account/controller/PaymentCallbackController.java b/cloud-server-account/src/main/java/com/dsh/account/controller/PaymentCallbackController.java
index be9c41e..1470c33 100644
--- a/cloud-server-account/src/main/java/com/dsh/account/controller/PaymentCallbackController.java
+++ b/cloud-server-account/src/main/java/com/dsh/account/controller/PaymentCallbackController.java
@@ -1,11 +1,14 @@
package com.dsh.account.controller;
+import com.alibaba.fastjson.JSONObject;
import com.dsh.account.service.RechargeRecordsService;
import com.dsh.account.service.TAppUserService;
import com.dsh.account.service.TStudentService;
import com.dsh.account.util.PayMoneyUtil;
import com.dsh.account.util.ResultUtil;
+import com.dsh.account.util.wx.WxV3PayConfig;
+import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -14,7 +17,11 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedReader;
import java.io.PrintWriter;
+import java.nio.charset.StandardCharsets;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.Map;
/**
@@ -23,7 +30,7 @@
@RestController
-@RequestMapping("/payment/callback")
+@RequestMapping("")
public class PaymentCallbackController {
@@ -65,6 +72,44 @@
/**
* 课包续课微信支付回调接口
*/
+ @PostMapping("/base/coursePackage/wechatPaymentCallback1")
+ public void weChatCallback1(HttpServletRequest request, HttpServletResponse response) {
+ try {
+ System.err.println("微信回调");
+ System.err.println("请求" + request);
+ BufferedReader reader = request.getReader();
+ String string1 = reader.toString();
+ System.err.println("请求reader" + string1);
+ StringBuilder requestBody = new StringBuilder();
+ String line;
+ while ((line = reader.readLine()) != null) {
+ requestBody.append(line);
+ }
+ System.err.println("全部请求体" + requestBody);
+ JSONObject jsonObject = JSONObject.parseObject(requestBody.toString());
+ JSONObject resource = jsonObject.getJSONObject("resource");
+
+ AesUtil aesUtil = new AesUtil(WxV3PayConfig.apiV3Key.getBytes(StandardCharsets.UTF_8));
+ String decryptedData = aesUtil.decryptToString(resource.getString("associated_data").getBytes(StandardCharsets.UTF_8), resource.getString("nonce").getBytes(StandardCharsets.UTF_8),
+ resource.getString("ciphertext"));
+ System.err.println("微信解密的字符串信息" + decryptedData);
+ JSONObject jsonInfo = (JSONObject) JSONObject.parse(decryptedData);
+ String out_trade_no = jsonInfo.getString("out_trade_no");
+ String transaction_id = jsonInfo.getString("transaction_id");
+ String trade_state = jsonInfo.getString("trade_state");
+ if (trade_state.equals("SUCCESS")) {
+ ResultUtil resultUtil = tstuService.insertVipPaymentCallback(out_trade_no, transaction_id);
+ if (resultUtil.getCode() == 200) {
+ PrintWriter out = response.getWriter();
+ out.write("SUCCESS");
+ out.flush();
+ out.close();
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
@PostMapping("/base/coursePackage/wechatPaymentCallback")
public void weChatCallback(HttpServletRequest request, HttpServletResponse response) {
try {
@@ -85,7 +130,6 @@
e.printStackTrace();
}
}
-
/**
* 充值玩湃币支付宝支付回调接口
*/
@@ -113,6 +157,47 @@
/**
* 课包续课微信支付回调接口
*/
+ @PostMapping("/base/recharge/wechatRechargeCallback1")
+ public void wechatRechargeCallback1(HttpServletRequest request, HttpServletResponse response) {
+ try {
+ System.err.println("微信回调");
+ System.err.println("请求" + request);
+ BufferedReader reader = request.getReader();
+ String string1 = reader.toString();
+ System.err.println("请求reader" + string1);
+ StringBuilder requestBody = new StringBuilder();
+ String line;
+ while ((line = reader.readLine()) != null) {
+ requestBody.append(line);
+ }
+ System.err.println("全部请求体" + requestBody);
+ JSONObject jsonObject = JSONObject.parseObject(requestBody.toString());
+ JSONObject resource = jsonObject.getJSONObject("resource");
+
+ AesUtil aesUtil = new AesUtil(WxV3PayConfig.apiV3Key.getBytes(StandardCharsets.UTF_8));
+ String decryptedData = aesUtil.decryptToString(resource.getString("associated_data").getBytes(StandardCharsets.UTF_8), resource.getString("nonce").getBytes(StandardCharsets.UTF_8),
+ resource.getString("ciphertext"));
+ System.err.println("微信解密的字符串信息" + decryptedData);
+ JSONObject jsonInfo = (JSONObject) JSONObject.parse(decryptedData);
+ String out_trade_no = jsonInfo.getString("out_trade_no");
+ String transaction_id = jsonInfo.getString("transaction_id");
+ String trade_state = jsonInfo.getString("trade_state");
+ if (trade_state.equals("SUCCESS")) {
+ ResultUtil resultUtil = recordsService.addRechargeCallbackPay(out_trade_no, transaction_id);
+ if (resultUtil.getCode() == 200) {
+ PrintWriter out = response.getWriter();
+ out.write("SUCCESS");
+ out.flush();
+ out.close();
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ /**
+ * 课包续课微信支付回调接口
+ */
@PostMapping("/base/recharge/wechatRechargeCallback")
public void wechatRechargeCallback(HttpServletRequest request, HttpServletResponse response) {
try {
@@ -133,14 +218,6 @@
e.printStackTrace();
}
}
-
-
- /**
- * 兑换商品支付的微信回调
- *
- * @param request
- * @param response
- */
@ResponseBody
@PostMapping("/base/pointMer/exchangeGoodPaymentWeChatCallback")
public void exchangeGoodPaymentWeChatCallback(HttpServletRequest request, HttpServletResponse response) {
@@ -150,10 +227,56 @@
String out_trade_no = map.get("out_trade_no");
String transaction_id = map.get("transaction_id");
String result = map.get("result");
- ResultUtil resultUtil = tappService.exchangeAddPaymentCallback(out_trade_no, transaction_id, 1);
+ ResultUtil resultUtil = tappService.exchangeAddPaymentCallback(out_trade_no, transaction_id);
if (resultUtil.getCode() == 200) {
PrintWriter out = response.getWriter();
out.write(result);
+ out.flush();
+ out.close();
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 兑换商品支付的微信回调V3版本
+ *
+ * @param request
+ * @param response
+ */
+ @ResponseBody
+ @PostMapping("/base/pointMer/exchangeGoodPaymentWeChatCallback1")
+ public void exchangeGoodPaymentWeChatCallback1(HttpServletRequest request, HttpServletResponse response) {
+ try {
+ System.err.println("微信回调");
+ System.err.println("请求" + request);
+ BufferedReader reader = request.getReader();
+ String string1 = reader.toString();
+ System.err.println("请求reader" + string1);
+ StringBuilder requestBody = new StringBuilder();
+ String line;
+ while ((line = reader.readLine()) != null) {
+ requestBody.append(line);
+ }
+ System.err.println("全部请求体" + requestBody);
+ JSONObject jsonObject = JSONObject.parseObject(requestBody.toString());
+ JSONObject resource = jsonObject.getJSONObject("resource");
+
+ AesUtil aesUtil = new AesUtil(WxV3PayConfig.apiV3Key.getBytes(StandardCharsets.UTF_8));
+ String decryptedData = aesUtil.decryptToString(resource.getString("associated_data").getBytes(StandardCharsets.UTF_8), resource.getString("nonce").getBytes(StandardCharsets.UTF_8),
+ resource.getString("ciphertext"));
+ System.err.println("微信解密的字符串信息" + decryptedData);
+ JSONObject jsonInfo = (JSONObject) JSONObject.parse(decryptedData);
+ String out_trade_no = jsonInfo.getString("out_trade_no");
+ String transaction_id = jsonInfo.getString("transaction_id");
+ String trade_state = jsonInfo.getString("trade_state");
+ if (trade_state.equals("SUCCESS")) {
+ ResultUtil resultUtil = tappService.exchangeAddPaymentCallback(out_trade_no, transaction_id);
+ if (resultUtil.getCode() == 200) {
+ PrintWriter out = response.getWriter();
+ out.write("SUCCESS");
out.flush();
out.close();
}
@@ -172,13 +295,14 @@
*/
@ResponseBody
@PostMapping("/base/pointMer/exchangeGoodPaymentAliCallback")
- public void addVipPaymentAliCallback(HttpServletRequest request, HttpServletResponse response) {
+ public void exchangeGoodPaymentAliCallback(HttpServletRequest request, HttpServletResponse response) {
try {
+ System.err.println("积分商品支付宝回调");
Map<String, String> map = payMoneyUtil.alipayCallback(request);
if (null != map) {
String out_trade_no = map.get("out_trade_no");
String trade_no = map.get("trade_no");
- ResultUtil resultUtil = tappService.exchangeAddPaymentCallback(out_trade_no, trade_no, 2);
+ ResultUtil resultUtil = tappService.exchangeAddPaymentCallback(out_trade_no, trade_no);
if (resultUtil.getCode() == 200) {
PrintWriter out = response.getWriter();
out.write("success");
--
Gitblit v1.7.1