puzhibing
2022-08-22 1421f8e9c308c4741cb396309035009393b5b036
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
package com.stylefeng.guns.modular.api;
 
 
import com.stylefeng.guns.modular.system.service.IUserInfoService;
import com.stylefeng.guns.modular.system.util.PayMoneyUtil;
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("/base")
public class UserCallbackController {
 
    @Autowired
    private IUserInfoService userInfoService;
 
    /*@Autowired
    private ICBCPayUtil icbcPayUtil;*/
 
    @Autowired
    private PayMoneyUtil payMoneyUtil;
 
 
 
    /**
     * 微信余额充值回调函数
     * @param request
     */
    @ResponseBody
    @PostMapping("/wxCancelUserBalance")
    public void wxCancelUserBalance(HttpServletRequest request, HttpServletResponse response){
        try {
            Map<String, String> map = payMoneyUtil.weixinpayCallback(request);
            String id = map.get("out_trade_no");
            String order_id = map.get("out_trade_no");
            String uid = map.get("attach");
            userInfoService.payCancelUserBalance(null, order_id, Integer.valueOf(id), 1);
            //icbcPayUtil.answer(response);
 
            response.getOutputStream().print("success");
        }catch (Exception e){
            e.printStackTrace();
        }
    }
 
 
    /**
     * 支付宝余额充值回调
     * @param request
     */
    @ResponseBody
    @PostMapping("/aliCancelUserBalance")
    public void aliCancelUserBalance(HttpServletRequest request, HttpServletResponse response){
        try {
            Map<String, String> map = payMoneyUtil.alipayCallback(request);
            String id = map.get("out_trade_no");
            String order_id = map.get("out_trade_no");
            //String uid = map.get("attach");
            userInfoService.payCancelUserBalance(null, order_id, Integer.valueOf(id), 2);
            //icbcPayUtil.answer(response);
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out;
            out = response.getWriter();
            out.println("success"); // 请不要修改或删除
        }catch (Exception e){
            e.printStackTrace();
        }
    }
 
 
 
}