Commit 28bcd52d by caiyt

增加微信回调内容打印

parent be82bb8a
...@@ -355,12 +355,13 @@ public class WeixinServiceImpl { ...@@ -355,12 +355,13 @@ public class WeixinServiceImpl {
} }
public String wxNotify(HttpServletRequest request) throws Exception { @Transactional
public synchronized String wxNotify(HttpServletRequest request) throws Exception {
Map<String, String> returnMap = new HashMap<>();//应答对象 Map<String, String> returnMap = new HashMap<>();//应答对象
//处理通知参数 //处理通知参数
String body = this.readData(request); String body = this.readData(request);
log.info("wx notify receive: \n{}", body); log.info("wx notify receive origin: \n{}", body);
//验签 //验签
if (!WXPayUtil.isSignatureValid(body, key)) { if (!WXPayUtil.isSignatureValid(body, key)) {
...@@ -374,6 +375,7 @@ public class WeixinServiceImpl { ...@@ -374,6 +375,7 @@ public class WeixinServiceImpl {
//解析xml数据 //解析xml数据
Map<String, String> notifyMap = WXPayUtil.xmlToMap(body); Map<String, String> notifyMap = WXPayUtil.xmlToMap(body);
log.info("wx notify receive decode: \n{}", JSONObject.toJSONString(notifyMap));
//判断通信和业务是否成功 //判断通信和业务是否成功
if (!"SUCCESS".equals(notifyMap.get("return_code")) || !"SUCCESS".equals(notifyMap.get("result_code"))) { if (!"SUCCESS".equals(notifyMap.get("return_code")) || !"SUCCESS".equals(notifyMap.get("result_code"))) {
log.error("失败"); log.error("失败");
...@@ -397,7 +399,7 @@ public class WeixinServiceImpl { ...@@ -397,7 +399,7 @@ public class WeixinServiceImpl {
// } // }
//处理订单 //处理订单
if (lock.tryLock()) { // if (lock.tryLock()) {
Order order = new Order(); Order order = new Order();
order.setOrderNo(orderNo); order.setOrderNo(orderNo);
List<Order> orders = orderService.selectOrderList(order); List<Order> orders = orderService.selectOrderList(order);
...@@ -407,7 +409,7 @@ public class WeixinServiceImpl { ...@@ -407,7 +409,7 @@ public class WeixinServiceImpl {
return WXPayUtil.mapToXml(returnMap); return WXPayUtil.mapToXml(returnMap);
} }
order = orders.get(0); order = orders.get(0);
try { // try {
//处理重复的通知 //处理重复的通知
//接口调用的幂等性:无论接口被调用多少次,产生的结果是一致的。 //接口调用的幂等性:无论接口被调用多少次,产生的结果是一致的。
String orderStatus = order.getState(); String orderStatus = order.getState();
...@@ -419,11 +421,11 @@ public class WeixinServiceImpl { ...@@ -419,11 +421,11 @@ public class WeixinServiceImpl {
order.setPickCode(generatePickCode(order)); order.setPickCode(generatePickCode(order));
orderService.updateOrder(order); orderService.updateOrder(order);
} }
} finally { /*} finally {
//要主动释放锁 //要主动释放锁
lock.unlock(); lock.unlock();
} }*/
} // }
returnMap.put("return_code", "SUCCESS"); returnMap.put("return_code", "SUCCESS");
returnMap.put("return_msg", "OK"); returnMap.put("return_msg", "OK");
String returnXml = WXPayUtil.mapToXml(returnMap); String returnXml = WXPayUtil.mapToXml(returnMap);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment