package com.dsh.account.controller;
|
|
|
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 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.ResponseBody;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.PrintWriter;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.Map;
|
|
/**
|
* 支付回调控制器
|
*/
|
|
|
@RestController
|
@RequestMapping("")
|
public class PaymentCallbackController {
|
|
|
@Autowired
|
private PayMoneyUtil payMoneyUtil;
|
|
@Autowired
|
private TStudentService tstuService;
|
@Autowired
|
private RechargeRecordsService recordsService;
|
|
@Autowired
|
private TAppUserService tappService;
|
|
/**
|
* 课包续课支付宝支付回调接口
|
*/
|
@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("/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();
|
}
|
}
|
|
|
/**
|
* 兑换商品支付的微信回调
|
*
|
* @param request
|
* @param response
|
*/
|
@ResponseBody
|
@PostMapping("/base/pointMer/exchangeGoodPaymentWeChatCallback")
|
public void exchangeGoodPaymentWeChatCallback(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 = tappService.exchangeAddPaymentCallback(out_trade_no, transaction_id, 1);
|
if (resultUtil.getCode() == 200) {
|
PrintWriter out = response.getWriter();
|
out.write(result);
|
out.flush();
|
out.close();
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
|
/**
|
* 兑换商品支付的支付宝回调
|
*
|
* @param request
|
* @param response
|
*/
|
@ResponseBody
|
@PostMapping("/base/pointMer/exchangeGoodPaymentAliCallback")
|
public void exchangeGoodPaymentAliCallback(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 trade_no = map.get("trade_no");
|
ResultUtil resultUtil = tappService.exchangeAddPaymentCallback(out_trade_no, trade_no, 2);
|
if (resultUtil.getCode() == 200) {
|
PrintWriter out = response.getWriter();
|
out.write("success");
|
out.flush();
|
out.close();
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
}
|