Merge branch 'test' into dev
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.sqx.modules.pay.controller.app;
|
package com.sqx.modules.pay.controller.app;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@@ -183,6 +184,7 @@ public class WuyouController {
|
|||||||
|
|
||||||
@PostMapping("/notify")
|
@PostMapping("/notify")
|
||||||
public String notify(HttpServletRequest request, NotifyDto notifyDto) {
|
public String notify(HttpServletRequest request, NotifyDto notifyDto) {
|
||||||
|
try {
|
||||||
log.info("无忧支付回调, {}", notifyDto);
|
log.info("无忧支付回调, {}", notifyDto);
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("callbacks", notifyDto.getCallbacks());
|
params.put("callbacks", notifyDto.getCallbacks());
|
||||||
@@ -203,7 +205,19 @@ public class WuyouController {
|
|||||||
|
|
||||||
log.info("无忧支付回调成功, 参数: {}", JSONObject.toJSONString(notifyDto));
|
log.info("无忧支付回调成功, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||||
|
|
||||||
PayDetails payDetails = payDetailsDao.selectByTradeNo(notifyDto.getOut_trade_no());
|
DateTime offsetMinute = DateUtil.offsetMinute(new Date(), -30);
|
||||||
|
String format = DateUtil.format(offsetMinute, "yyyy-MM-dd HH:mm:ss");
|
||||||
|
List<PayDetails> details = payDetailsDao.selectList(new LambdaQueryWrapper<PayDetails>()
|
||||||
|
.eq(PayDetails::getTradeNo, notifyDto.getOut_trade_no()).ge(PayDetails::getCreateTime, format));
|
||||||
|
if (details.isEmpty()) {
|
||||||
|
log.error("无忧支付回调订单不存在, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
if (details.size() > 1) {
|
||||||
|
log.error("无忧支付回调订单重复, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
PayDetails payDetails = details.get(0);
|
||||||
if (payDetails == null) {
|
if (payDetails == null) {
|
||||||
log.error("无忧支付回调订单不存在, 参数: {}", JSONObject.toJSONString(notifyDto));
|
log.error("无忧支付回调订单不存在, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||||
return "success";
|
return "success";
|
||||||
@@ -214,7 +228,10 @@ public class WuyouController {
|
|||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
Orders order = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
QueryWrapper<Orders> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("orders_no", payDetails.getOrderId()).eq("user_id", payDetails.getUserId());
|
||||||
|
queryWrapper.last("limit 1");
|
||||||
|
Orders order = ordersService.getOne(queryWrapper);
|
||||||
if (order == null) {
|
if (order == null) {
|
||||||
log.error("无忧支付回调订单不存在, 参数: {}", JSONObject.toJSONString(notifyDto));
|
log.error("无忧支付回调订单不存在, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||||
return "订单不存在";
|
return "订单不存在";
|
||||||
@@ -227,6 +244,9 @@ public class WuyouController {
|
|||||||
|
|
||||||
payDetails.setThirdOrderNo(notifyDto.getOrder_sn());
|
payDetails.setThirdOrderNo(notifyDto.getOrder_sn());
|
||||||
ordersTask.updateOrderStatus(payDetails, order);
|
ordersTask.updateOrderStatus(payDetails, order);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("无忧支付回调异常, 参数: {}", JSONObject.toJSONString(notifyDto), e);
|
||||||
|
}
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user