处理三方订单回调 异常 bug
This commit is contained in:
parent
7798c1ae10
commit
79bc357bb1
|
|
@ -183,50 +183,54 @@ public class WuyouController {
|
|||
|
||||
@PostMapping("/notify")
|
||||
public String notify(HttpServletRequest request, NotifyDto notifyDto) {
|
||||
log.info("无忧支付回调, {}", notifyDto);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("callbacks", notifyDto.getCallbacks());
|
||||
params.put("total", notifyDto.getTotal());
|
||||
params.put("out_trade_no", notifyDto.getOut_trade_no());
|
||||
params.put("pay_time", notifyDto.getPay_time());
|
||||
try {
|
||||
log.info("无忧支付回调, {}", notifyDto);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("callbacks", notifyDto.getCallbacks());
|
||||
params.put("total", notifyDto.getTotal());
|
||||
params.put("out_trade_no", notifyDto.getOut_trade_no());
|
||||
params.put("pay_time", notifyDto.getPay_time());
|
||||
|
||||
String sign = Encrypt.getParamsSign(params);
|
||||
if (!sign.equals(notifyDto.getSign())) {
|
||||
log.error("无忧支付回调签名错误, 参数: {},签名结果:{}", JSONObject.toJSONString(notifyDto), sign);
|
||||
String sign = Encrypt.getParamsSign(params);
|
||||
if (!sign.equals(notifyDto.getSign())) {
|
||||
log.error("无忧支付回调签名错误, 参数: {},签名结果:{}", JSONObject.toJSONString(notifyDto), sign);
|
||||
// return "签名错误";
|
||||
}
|
||||
|
||||
if (!"CODE_SUCCESS".equals(notifyDto.getCallbacks())) {
|
||||
log.error("无忧支付回调 未支付成功, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
return "success";
|
||||
}
|
||||
|
||||
log.info("无忧支付回调成功, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
|
||||
PayDetails payDetails = payDetailsDao.selectByTradeNo(notifyDto.getOut_trade_no());
|
||||
if (payDetails == null) {
|
||||
log.error("无忧支付回调订单不存在, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
return "success";
|
||||
}
|
||||
|
||||
if (payDetails.getState() == 1) {
|
||||
log.info("重复回调!参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
return "success";
|
||||
}
|
||||
|
||||
Orders order = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
||||
if (order == null) {
|
||||
log.error("无忧支付回调订单不存在, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
return "订单不存在";
|
||||
}
|
||||
|
||||
if (order.getStatus() != 0) {
|
||||
log.error("无忧支付回调订单已支付, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
return "订单已支付";
|
||||
}
|
||||
|
||||
payDetails.setThirdOrderNo(notifyDto.getOrder_sn());
|
||||
ordersTask.updateOrderStatus(payDetails, order);
|
||||
} catch (Exception e) {
|
||||
log.error("无忧支付回调异常, 参数: {}", JSONObject.toJSONString(notifyDto), e);
|
||||
}
|
||||
|
||||
if (!"CODE_SUCCESS".equals(notifyDto.getCallbacks())) {
|
||||
log.error("无忧支付回调 未支付成功, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
return "success";
|
||||
}
|
||||
|
||||
log.info("无忧支付回调成功, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
|
||||
PayDetails payDetails = payDetailsDao.selectByTradeNo(notifyDto.getOut_trade_no());
|
||||
if (payDetails == null) {
|
||||
log.error("无忧支付回调订单不存在, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
return "success";
|
||||
}
|
||||
|
||||
if (payDetails.getState() == 1) {
|
||||
log.info("重复回调!参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
return "success";
|
||||
}
|
||||
|
||||
Orders order = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
||||
if (order == null) {
|
||||
log.error("无忧支付回调订单不存在, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
return "订单不存在";
|
||||
}
|
||||
|
||||
if (order.getStatus() != 0) {
|
||||
log.error("无忧支付回调订单已支付, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||
return "订单已支付";
|
||||
}
|
||||
|
||||
payDetails.setThirdOrderNo(notifyDto.getOrder_sn());
|
||||
ordersTask.updateOrderStatus(payDetails, order);
|
||||
return "success";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue