44323
2023-11-27 aa925d851857f50eff0556411366690d9a78a0e5
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
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.util.Map;
 
/**
 * 支付回调控制器
 */
 
 
@RestController
@RequestMapping("/payment/callback")
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 addVipPaymentAliCallback(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();
        }
    }
 
}