|
@@ -4,19 +4,11 @@ import com.alipay.api.AlipayApiException;
|
4
|
4
|
import com.yunzhi.niucai.alipay.AlipayFactory;
|
5
|
5
|
import com.yunzhi.niucai.alipay.AliPayService;
|
6
|
6
|
import com.yunzhi.niucai.common.BaseController;
|
7
|
|
-import com.yunzhi.niucai.common.ResponseBean;
|
8
|
|
-import com.yunzhi.niucai.entity.TaOrder;
|
9
|
|
-import com.yunzhi.niucai.service.ITaShopAppService;
|
10
|
7
|
import io.swagger.annotations.Api;
|
11
|
|
-import io.swagger.annotations.ApiOperation;
|
12
|
|
-import io.swagger.annotations.ApiParam;
|
13
|
8
|
import org.slf4j.Logger;
|
14
|
9
|
import org.slf4j.LoggerFactory;
|
15
|
10
|
import org.springframework.beans.factory.annotation.Autowired;
|
16
|
11
|
import org.springframework.web.bind.annotation.*;
|
17
|
|
-import com.yunzhi.niucai.service.ITaAlipayService;
|
18
|
|
-
|
19
|
|
-import javax.servlet.http.HttpServletRequest;
|
20
|
12
|
|
21
|
13
|
/**
|
22
|
14
|
* <p>
|
|
@@ -29,58 +21,14 @@ import javax.servlet.http.HttpServletRequest;
|
29
|
21
|
|
30
|
22
|
@Api(tags = "")
|
31
|
23
|
@RestController
|
32
|
|
-@RequestMapping("/aliPay")
|
|
24
|
+@RequestMapping("/")
|
33
|
25
|
public class TaAlipayController extends BaseController {
|
34
|
26
|
|
35
|
27
|
private final Logger logger = LoggerFactory.getLogger(TaAlipayController.class);
|
36
|
28
|
|
37
|
|
-
|
38
|
|
- @Autowired
|
39
|
|
- public ITaShopAppService iTaShopAppService;
|
40
|
|
-
|
41
|
29
|
@Autowired
|
42
|
30
|
private AlipayFactory alipayFactory;
|
43
|
31
|
|
44
|
|
- @Autowired
|
45
|
|
- private ITaAlipayService aliPayService;
|
46
|
|
-
|
47
|
|
- /**
|
48
|
|
- * 手机app获取唤醒支付宝的参数
|
49
|
|
- * @param request
|
50
|
|
- * @param taOrder
|
51
|
|
- * @return
|
52
|
|
- * @throws Exception
|
53
|
|
- */
|
54
|
|
- @PostMapping("/app/alipay/order")
|
55
|
|
- @ApiOperation(value = "创建订单", notes = "创建订单", httpMethod = "POST", response = ResponseBean.class)
|
56
|
|
- public ResponseBean create(HttpServletRequest request,@ApiParam("下单记录") @RequestBody TaOrder taOrder) throws Exception {
|
57
|
|
- boolean res = aliPayService.orderPaying(taOrder);
|
58
|
|
- if (res) {
|
59
|
|
- return ResponseBean.success("success");
|
60
|
|
- } else {
|
61
|
|
- return ResponseBean.error("error", ResponseBean.ERROR_UNAVAILABLE);
|
62
|
|
- }
|
63
|
|
- }
|
64
|
|
-
|
65
|
|
- @GetMapping("/app/alipay/result")
|
66
|
|
- @ApiOperation(value = "查询支付状态", notes = "查询支付状态", httpMethod = "GET", response = ResponseBean.class)
|
67
|
|
- public ResponseBean getPayResult(@ApiParam("订单号") @RequestParam String orderId) {
|
68
|
|
- return ResponseBean.success("");
|
69
|
|
- }
|
70
|
|
-
|
71
|
|
- /**
|
72
|
|
- * 支付成功回调
|
73
|
|
- * @param request
|
74
|
|
- */
|
75
|
|
- @GetMapping("/app/callback/alipay/pay")
|
76
|
|
- public void callback(HttpServletRequest request){
|
77
|
|
- String tradeNo = request.getParameter("trade_no");
|
78
|
|
- String appId = request.getParameter("app_id");
|
79
|
|
- String outTradeNo = request.getParameter("out_trade_no");
|
80
|
|
- String tradeStatus = request.getParameter("trade_status");
|
81
|
|
- aliPayService.payCallback(tradeNo,outTradeNo,tradeStatus);
|
82
|
|
- }
|
83
|
|
-
|
84
|
32
|
/**
|
85
|
33
|
* 应用授权成功回调
|
86
|
34
|
* @param appId
|
|
@@ -88,7 +36,8 @@ public class TaAlipayController extends BaseController {
|
88
|
36
|
* @throws AlipayApiException
|
89
|
37
|
*/
|
90
|
38
|
@GetMapping("/app/callback/alipay/auth")
|
91
|
|
- public void aliPayAuthNotice(@RequestParam("app_id") String appId,@RequestParam("app_auth_code") String appAuthCode) throws AlipayApiException {
|
|
39
|
+ public void aliPayAuthNotice(@RequestParam("app_id") String appId,
|
|
40
|
+ @RequestParam("app_auth_code") String appAuthCode) throws AlipayApiException {
|
92
|
41
|
// 虚拟一个服务, 主要是为了调用其中方法
|
93
|
42
|
AliPayService payService = alipayFactory.getService(-1);
|
94
|
43
|
payService.persistToken(appAuthCode);
|