接收付款结果消息
<h3>创建接收付款消息的WEB方法</h3>
<p>编写ZfbController.java代码</p>
<pre><code class="language-java">@ApiOperation("接收消息通知")
@RequestMapping("/recieveAppMessage")
public void recieveAppMessage(HttpServletRequest request, HttpServletResponse response) throws Exception {
request.setCharacterEncoding("utf-8");
String tradeNo = request.getParameter("trade_no");
String code = request.getParameter("out_trade_no");
String tradeStatus = request.getParameter("trade_status");
Enumeration<String> enumeration=request.getParameterNames();
HashMap<String,String> map=new HashMap<>();
while(enumeration.hasMoreElements()){
String name=enumeration.nextElement();
String value=request.getParameter(name);
map.put(name,value);
}
boolean bool=AlipaySignature.rsaCheckV1(map,app_publicKey,"UTF-8","RSA2");
if(bool){
if ("TRADE_FINISHED".equals(tradeStatus) || "TRADE_SUCCESS".equals(tradeStatus)) {
UpdateWrapper wrapper = new UpdateWrapper();
wrapper.eq("code", code);
wrapper.set("status", 2);
wrapper.set("payment_type", 2);
orderService.update(wrapper);
}
response.setCharacterEncoding("utf-8");
Writer writer = response.getWriter();
writer.write("success");
writer.close();
}
else {
response.sendError(500,"数字签名验证失败");
}
}</code></pre>