lisy
2023-07-11 643d431548ddb65a904a45d024fe04ea3ec49276
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.dsh.account.controller;
 
 
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;
 
/**
 * 支付回调控制器
 */
 
 
@RestController
@RequestMapping("/payment/callback")
public class PaymentCallbackController {
 
 
    @Autowired
    private PayMoneyUtil payMoneyUtil;
 
    @Autowired
    private TStudentService tstuService;
 
    /**
     * 支付宝支付回调接口
     */
    @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();
        }
    }
 
 
}