From 134d13688e4b6677133ba2d362d2978d8bda2b87 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期三, 12 七月 2023 11:46:30 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- cloud-server-account/src/main/java/com/dsh/account/controller/PaymentCallbackController.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 105 insertions(+), 9 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 fad5bff..84d79ba 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,9 +1,19 @@ package com.dsh.account.controller; +import com.dsh.account.service.RechargeRecordsService; +import com.dsh.account.service.TStudentService; +import com.dsh.account.util.PayMoneyUtil; +import com.dsh.account.util.ResultUtil; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; +import java.util.Map; /** * 支付回调控制器 @@ -15,22 +25,108 @@ public class PaymentCallbackController { - /** - * 支付宝支付回调接口 - */ - @PostMapping("/v1") - public void alipayCallback(){ + @Autowired + private PayMoneyUtil payMoneyUtil; + @Autowired + private TStudentService tstuService; + @Autowired + private RechargeRecordsService recordsService; + + /** + * 课包续课支付宝支付回调接口 + */ + @PostMapping("/base/coursePackage/alipayPaymentCallback") + public void alipayCallback(HttpServletRequest request, HttpServletResponse response){ + try { + Map<String, String> map = payMoneyUtil.alipayCallback(request); + if(null != map){ + String out_trade_no = map.get("out_trade_no"); + String transaction_id = map.get("transaction_id"); + 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("/v2") - public void weChatCallback(){ - + @PostMapping("/base/coursePackage/wechatPaymentCallback") + public void weChatCallback(HttpServletRequest request, HttpServletResponse response){ + try { + Map<String, String> map = payMoneyUtil.weixinpayCallback(request); + if(null != map){ + String out_trade_no = map.get("out_trade_no"); + String transaction_id = map.get("transaction_id"); + String result = map.get("result"); + ResultUtil resultUtil = tstuService.insertVipPaymentCallback(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(); + } } + /** + * 充值玩湃币支付宝支付回调接口 + */ + @PostMapping("/base/recharge/alipayRechargeCallback") + public void alipayRechargeCallback(HttpServletRequest request, HttpServletResponse response){ + try { + Map<String, String> map = payMoneyUtil.alipayCallback(request); + if(null != map){ + String out_trade_no = map.get("out_trade_no"); + String transaction_id = map.get("transaction_id"); + 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 { + Map<String, String> map = payMoneyUtil.weixinpayCallback(request); + if(null != map){ + String out_trade_no = map.get("out_trade_no"); + String transaction_id = map.get("transaction_id"); + String result = map.get("result"); + ResultUtil resultUtil = recordsService.addRechargeCallbackPay(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(); + } + } } -- Gitblit v1.7.1