/**
* 微信支付微信 回调。java版
*
* @return
* @throws IOException
* @throws QQConnectException
*/
@SuppressWarnings( { "unchecked", "static-access" })
public String wxnotifyurl() throws IOException, QQConnectException {
logger.error("微信 回调 wxnotifyurl() start ============");
String inputLine;
Orderpay orderpay = new Orderpay();// 订单支付信息
Order order = new Order();
Order order2 = new Order();
String notityXml = "";
String resXml = "";
Map<String, String> map = new HashMap();
try {
while ((inputLine = getRequest().getReader().readLine()) != null) {
notityXml += inputLine;
}
getRequest().getReader().close();
logger.error("微信 回调 wxnotifyurl() notityXml ============" + notityXml);
map = XMLUtil.doXMLParse(notityXml);
} catch (JDOMException e) {
logger.error("JDOMException===" + e.getMessage());
throw new NullPointerException("JDOMException参数异常");
} catch (IOException e) {
logger.error("IOException====" + e.getMessage());
throw new NullPointerException("IOException参数异常");
}// 解析微信返回的信息,以Map形式存储便于取值
if (!map.isEmpty()) {
orderpay.setOrderid(map.get("out_trade_no").substring(0, map.get("out_trade_no").length() - 2));
orderpay.setPaystatus(map.get("result_code").equals("SUCCESS") ? "y" : "n");
orderpay.setPayamount(map.get("total_fee").length() > 0 ? Double.parseDouble(map.get("total_fee")) / 100.00 : 0.00);
orderpay.setCreatetime(map.get("time_end"));
orderpay.setConfirmuser(map.get("openid"));
orderpay.setPaymethod(orderpay.orderpay_paymethod_wxpayescow);
// order.setPaystatus(orderpay.getPaystatus());
order.setId(orderpay.getOrderid());
orderid = orderpay.getOrderid();
order2 = orderService.selectOne(order);
/************************************** 支付异常情况处理 *******************************************************/
if (order2 == null) {
if ("n".equals(map.get("result_code").equals("SUCCESS") ? "y" : "n")) {
} else if ("y".equals(map.get("result_code").equals("SUCCESS") ? "y" : "n")) {
// 支付成功
resXml = "<xml>" + "<return_code><![CDATA[SUCCESS]]></return_code>" + "<return_msg><![CDATA[OK]]></return_msg>" + "</xml> ";
logger.error("resXml 支付处理成功 ================" + resXml.toString());
}
}
/************************************** 支付情况处理END *******************************************************/
}
BufferedOutputStream out = new BufferedOutputStream(getResponse().getOutputStream());
out.write(resXml.getBytes());
out.flush();
out.close();
logger.error("微信 回调 wxnotifyurl() end ============");
return null;
}