|
@@ -1,11 +1,17 @@
|
1
|
1
|
package com.community.huiju.controller;
|
2
|
2
|
|
3
|
3
|
import com.community.commom.mode.ResponseBean;
|
|
4
|
+import com.community.commom.redis.RedisTemplate;
|
4
|
5
|
import com.community.huiju.common.wxpay.HfWxConfig;
|
5
|
6
|
import com.community.huiju.common.wxpay.WXPay;
|
|
7
|
+import com.community.huiju.service.TaVistorServiceI;
|
|
8
|
+import com.community.huiju.service.WxPayServiceI;
|
6
|
9
|
import com.google.common.collect.Maps;
|
7
|
10
|
import io.swagger.annotations.Api;
|
8
|
11
|
import io.swagger.annotations.ApiOperation;
|
|
12
|
+import org.slf4j.Logger;
|
|
13
|
+import org.slf4j.LoggerFactory;
|
|
14
|
+import org.springframework.beans.factory.annotation.Autowired;
|
9
|
15
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
10
|
16
|
import org.springframework.web.bind.annotation.PathVariable;
|
11
|
17
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -24,29 +30,55 @@ import java.util.Map;
|
24
|
30
|
@RequestMapping("/")
|
25
|
31
|
@Api(value = "微信支付 API", description = "微信支付 API")
|
26
|
32
|
public class WxPayController {
|
|
33
|
+ private Logger log = LoggerFactory.getLogger(WxPayController.class);
|
|
34
|
+
|
|
35
|
+ @Autowired
|
|
36
|
+ private WxPayServiceI wxPayService;
|
27
|
37
|
|
28
|
38
|
@ApiOperation(value = "统一下单", notes = "统一下单")
|
29
|
39
|
@RequestMapping(value = "/wxUnifiedOrder",method = RequestMethod.GET)
|
30
|
40
|
public ResponseBean wxUnifiedOrder(){
|
31
|
41
|
ResponseBean responseBean = new ResponseBean();
|
32
|
|
- HfWxConfig config = new HfWxConfig();
|
|
42
|
+
|
|
43
|
+ Map<String, String> resp = Maps.newHashMap();
|
|
44
|
+ try {
|
|
45
|
+ resp = wxPayService.wxUnifiedOrder();
|
|
46
|
+ } catch (Exception e) {
|
|
47
|
+ e.printStackTrace();
|
|
48
|
+ responseBean.addError("下单失败");
|
|
49
|
+ return responseBean;
|
|
50
|
+ }
|
|
51
|
+ log.info("下单成功: {}",resp);
|
|
52
|
+ responseBean.addSuccess(resp);
|
|
53
|
+ return responseBean;
|
|
54
|
+ }
|
|
55
|
+
|
|
56
|
+ @ApiOperation(value = "下载对账单", notes = "下载对账单")
|
|
57
|
+ @RequestMapping(value = "/wxDownloadBill",method = RequestMethod.GET)
|
|
58
|
+ public ResponseBean wxDownloadBill(){
|
|
59
|
+ ResponseBean responseBean = new ResponseBean();
|
|
60
|
+
|
|
61
|
+ Map<String, String> resp = Maps.newHashMap();
|
|
62
|
+ try {
|
|
63
|
+ resp = wxPayService.wxDownloadBill();
|
|
64
|
+ } catch (Exception e) {
|
|
65
|
+ e.printStackTrace();
|
|
66
|
+ }
|
|
67
|
+ responseBean.addSuccess(resp);
|
|
68
|
+ return responseBean;
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ @ApiOperation(value = "订单查询", notes = "订单查询")
|
|
72
|
+ @RequestMapping(value = "/wxOrderQuery",method = RequestMethod.GET)
|
|
73
|
+ public ResponseBean wxOrderQuery(){
|
|
74
|
+ ResponseBean responseBean = new ResponseBean();
|
33
|
75
|
Map<String, String> resp = Maps.newHashMap();
|
34
|
76
|
try {
|
35
|
|
- WXPay wxpay = new WXPay(config);
|
36
|
|
-
|
37
|
|
- Map<String, String> data = new HashMap<String, String>();
|
38
|
|
- data.put("body", "支付测试");
|
39
|
|
- data.put("out_trade_no", "2019021910595900000012");
|
40
|
|
- data.put("device_info", "");
|
41
|
|
- data.put("fee_type", "CNY");
|
42
|
|
- data.put("total_fee", "1");
|
43
|
|
- data.put("spbill_create_ip", "123.12.12.123");
|
44
|
|
- data.put("notify_url", "http://www.example.com/wxpay/notify");
|
45
|
|
- // 此处指定为APP支付
|
46
|
|
- data.put("trade_type", "APP");
|
47
|
|
- resp = wxpay.unifiedOrder(data);
|
|
77
|
+ resp = wxPayService.wxOrderQuery();
|
48
|
78
|
} catch (Exception e) {
|
49
|
79
|
e.printStackTrace();
|
|
80
|
+ responseBean.addError("查询失败");
|
|
81
|
+ return responseBean;
|
50
|
82
|
}
|
51
|
83
|
responseBean.addSuccess(resp);
|
52
|
84
|
return responseBean;
|