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,33 +399,33 @@ public class WeixinServiceImpl { ...@@ -397,33 +399,33 @@ 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);
if (orders.isEmpty()) { if (orders.isEmpty()) {
returnMap.put("return_code", "FAIL"); returnMap.put("return_code", "FAIL");
returnMap.put("return_msg", "没有该订单"); returnMap.put("return_msg", "没有该订单");
return WXPayUtil.mapToXml(returnMap); return WXPayUtil.mapToXml(returnMap);
}
order = orders.get(0);
try {
//处理重复的通知
//接口调用的幂等性:无论接口被调用多少次,产生的结果是一致的。
String orderStatus = order.getState();
log.info("order current status: {}", orderStatus);
if (OrderStatusConstant.Unpaid.equals(orderStatus)) {
//更新订单状态
order.setPayTime(new Date());
order.setState(OrderStatusConstant.Paid);
order.setPickCode(generatePickCode(order));
orderService.updateOrder(order);
}
} finally {
//要主动释放锁
lock.unlock();
}
} }
order = orders.get(0);
// try {
//处理重复的通知
//接口调用的幂等性:无论接口被调用多少次,产生的结果是一致的。
String orderStatus = order.getState();
log.info("order current status: {}", orderStatus);
if (OrderStatusConstant.Unpaid.equals(orderStatus)) {
//更新订单状态
order.setPayTime(new Date());
order.setState(OrderStatusConstant.Paid);
order.setPickCode(generatePickCode(order));
orderService.updateOrder(order);
}
/*} finally {
//要主动释放锁
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