|
@@ -6,6 +6,8 @@ import com.community.commom.redis.RedisTemplate;
|
6
|
6
|
import com.community.commom.session.UserElement;
|
7
|
7
|
import com.community.huiju.common.wxpay.HfWxConfig;
|
8
|
8
|
import com.community.huiju.common.wxpay.WXPay;
|
|
9
|
+import com.community.huiju.common.wxpay.WXPayConstants;
|
|
10
|
+import com.community.huiju.common.wxpay.WXPayUtil;
|
9
|
11
|
import com.community.huiju.service.TaVistorServiceI;
|
10
|
12
|
import com.community.huiju.service.WxPayServiceI;
|
11
|
13
|
import com.google.common.collect.Maps;
|
|
@@ -22,7 +24,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
22
|
24
|
import org.springframework.web.bind.annotation.RequestMethod;
|
23
|
25
|
import org.springframework.web.bind.annotation.RestController;
|
24
|
26
|
|
|
27
|
+import javax.servlet.http.HttpServletRequest;
|
|
28
|
+import javax.servlet.http.HttpServletResponse;
|
25
|
29
|
import javax.servlet.http.HttpSession;
|
|
30
|
+import java.io.ByteArrayOutputStream;
|
|
31
|
+import java.io.InputStream;
|
26
|
32
|
import java.util.HashMap;
|
27
|
33
|
import java.util.Map;
|
28
|
34
|
|
|
@@ -61,20 +67,41 @@ public class WxPayController {
|
61
|
67
|
return responseBean;
|
62
|
68
|
}
|
63
|
69
|
|
64
|
|
- @ApiOperation(value = "下载对账单", notes = "下载对账单")
|
65
|
|
- @RequestMapping(value = "/wxDownloadBill",method = RequestMethod.POST)
|
66
|
|
- public ResponseBean wxDownloadBill(){
|
67
|
|
- ResponseBean responseBean = new ResponseBean();
|
68
|
|
-
|
69
|
|
- Map<String, String> resp = Maps.newHashMap();
|
|
70
|
+ @ApiOperation(value = "手机订单支付完成后回调", notes = "手机订单支付完成后回调")
|
|
71
|
+ @RequestMapping(value = "/wxNotify",method = RequestMethod.POST)
|
|
72
|
+ public String wxNotify(HttpServletRequest request, HttpServletResponse response){
|
|
73
|
+ String resXml = "";
|
|
74
|
+ InputStream inStream;
|
70
|
75
|
try {
|
71
|
|
- resp = wxPayService.wxDownloadBill();
|
72
|
|
- log.info("支付成功的回调参数: {}",resp);
|
|
76
|
+
|
|
77
|
+ inStream = request.getInputStream();
|
|
78
|
+ ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
|
|
79
|
+ byte[] buffer = new byte[1024];
|
|
80
|
+ int len = 0;
|
|
81
|
+ while ((len = inStream.read(buffer)) != -1) {
|
|
82
|
+ outSteam.write(buffer, 0, len);
|
|
83
|
+ }
|
|
84
|
+
|
|
85
|
+ // 获取微信调用我们notify_url的返回信息
|
|
86
|
+ String result = new String(outSteam.toByteArray(), "utf-8");
|
|
87
|
+ WXPayUtil.getLogger().info("wxnotify:微信支付----result----=" + result);
|
|
88
|
+
|
|
89
|
+ // 关闭流
|
|
90
|
+ outSteam.close();
|
|
91
|
+ inStream.close();
|
|
92
|
+
|
|
93
|
+ // xml转换为map
|
|
94
|
+ Map<String, String> resultMap = WXPayUtil.xmlToMap(result);
|
|
95
|
+ System.out.println("返回结果是:" + resultMap);
|
|
96
|
+ //处理业务逻辑 修改订单状态等
|
|
97
|
+ String state = wxPayService.wxNotify(resultMap);
|
73
|
98
|
} catch (Exception e) {
|
74
|
|
- e.printStackTrace();
|
|
99
|
+ log.error("手机支付回调通知失败",e);
|
|
100
|
+ String result = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>" + "<return_msg><![CDATA[失败]]></return_msg>" + "</xml> ";
|
|
101
|
+ return result;
|
|
102
|
+
|
75
|
103
|
}
|
76
|
|
- responseBean.addSuccess(resp);
|
77
|
|
- return responseBean;
|
|
104
|
+ return "";
|
78
|
105
|
}
|
79
|
106
|
|
80
|
107
|
@ApiOperation(value = "订单查询", notes = "订单查询")
|