查询订单支付状态
This commit is contained in:
@@ -113,6 +113,36 @@ public class WuyouController {
|
|||||||
return Result.success().put("data", baseResp.getData());
|
return Result.success().put("data", baseResp.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("查询订单支付结果")
|
||||||
|
@GetMapping("/queryOrder/{orderId}")
|
||||||
|
public Result queryOrder(HttpServletRequest request, @PathVariable("orderId") Long orderId) {
|
||||||
|
Orders order = ordersService.getById(orderId);
|
||||||
|
if (order == null) {
|
||||||
|
return Result.error("订单不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
PayDetails payDetails = payDetailsDao.selectByOrderId(order.getOrdersNo());
|
||||||
|
if (payDetails == null) {
|
||||||
|
return Result.error("订单支付信息不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payDetails.getState() == 1) {
|
||||||
|
return Result.success().put("data", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseResp baseResp = WuyouPay.queryOrder(payDetails.getTradeNo(), order.getPayMoney().toString(), request.getHeader("User-Agent"));
|
||||||
|
if (baseResp.getCode() == null || baseResp.getData() == null) {
|
||||||
|
return Result.success().put("data", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("SUCCESS".equals(baseResp.getPayStatus())) {
|
||||||
|
updateOrderStatus(payDetails, order);
|
||||||
|
return Result.success().put("data", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.success().put("data", 0);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/extractNotify")
|
@PostMapping("/extractNotify")
|
||||||
public String extractNotify(HttpServletRequest request, NotifyDto notifyDto) {
|
public String extractNotify(HttpServletRequest request, NotifyDto notifyDto) {
|
||||||
log.info("无忧支付提现回调, {}", notifyDto);
|
log.info("无忧支付提现回调, {}", notifyDto);
|
||||||
@@ -166,12 +196,18 @@ public class WuyouController {
|
|||||||
// return "签名错误";
|
// return "签名错误";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!"CODE_SUCCESS".equals(notifyDto.getStatus())) {
|
||||||
|
log.error("无忧支付回调 未支付成功, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
|
||||||
log.info("无忧支付回调成功, 参数: {}", JSONObject.toJSONString(notifyDto));
|
log.info("无忧支付回调成功, 参数: {}", JSONObject.toJSONString(notifyDto));
|
||||||
|
|
||||||
PayDetails payDetails = payDetailsDao.selectByTradeNo(notifyDto.getOut_trade_no());
|
PayDetails payDetails = payDetailsDao.selectByTradeNo(notifyDto.getOut_trade_no());
|
||||||
|
|
||||||
if (payDetails.getState() != 0) {
|
if (payDetails.getState() == 1) {
|
||||||
log.info("订单表信息丢失!");
|
log.info("订单表信息丢失!");
|
||||||
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
Orders order = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
Orders order = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
||||||
@@ -185,36 +221,8 @@ public class WuyouController {
|
|||||||
return "订单已支付";
|
return "订单已支付";
|
||||||
}
|
}
|
||||||
|
|
||||||
String format = sdf.format(new Date());
|
updateOrderStatus(payDetails, order);
|
||||||
payDetailsDao.updateState(payDetails.getId(), 1, format, notifyDto.getOut_trade_no());
|
|
||||||
|
|
||||||
order.setPayWay(9);
|
|
||||||
order.setStatus(1);
|
|
||||||
order.setPayTime(DateUtils.format(new Date()));
|
|
||||||
|
|
||||||
UserEntity user = userService.selectUserById(order.getUserId());
|
|
||||||
UserEntity byUser = userService.queryByInvitationCode(user.getInviterCode());
|
|
||||||
Map<String, Object> map = inviteService.updateInvite(byUser, format, user.getUserId(), order.getPayMoney());
|
|
||||||
Object oneUserId = map.get("oneUserId");
|
|
||||||
if (oneUserId != null) {
|
|
||||||
order.setOneUserId(Long.parseLong(String.valueOf(oneUserId)));
|
|
||||||
order.setOneMoney(new BigDecimal(String.valueOf(map.get("oneMoney"))));
|
|
||||||
}
|
|
||||||
Object twoUserId = map.get("twoUserId");
|
|
||||||
if (twoUserId != null) {
|
|
||||||
order.setTwoUserId(Long.parseLong(String.valueOf(twoUserId)));
|
|
||||||
order.setTwoMoney(new BigDecimal(String.valueOf(map.get("twoMoney"))));
|
|
||||||
}
|
|
||||||
Object sysUserId = map.get("sysUserId");
|
|
||||||
if (sysUserId != null) {
|
|
||||||
order.setSysUserId(Long.parseLong(String.valueOf(sysUserId)));
|
|
||||||
order.setQdMoney(new BigDecimal(String.valueOf(map.get("qdMoney"))));
|
|
||||||
}
|
|
||||||
ordersService.updateById(order);
|
|
||||||
ordersService.insertOrders(order);
|
|
||||||
CompletableFuture.runAsync(() -> {
|
|
||||||
activities(user, byUser);
|
|
||||||
});
|
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,4 +264,41 @@ public class WuyouController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateOrderStatus(PayDetails payDetails, Orders order) {
|
||||||
|
if (payDetails.getState() == 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String format = sdf.format(new Date());
|
||||||
|
payDetailsDao.updateState(payDetails.getId(), 1, format, payDetails.getTradeNo());
|
||||||
|
|
||||||
|
order.setPayWay(9);
|
||||||
|
order.setStatus(1);
|
||||||
|
order.setPayTime(DateUtils.format(new Date()));
|
||||||
|
|
||||||
|
UserEntity user = userService.selectUserById(order.getUserId());
|
||||||
|
UserEntity byUser = userService.queryByInvitationCode(user.getInviterCode());
|
||||||
|
Map<String, Object> map = inviteService.updateInvite(byUser, format, user.getUserId(), order.getPayMoney());
|
||||||
|
Object oneUserId = map.get("oneUserId");
|
||||||
|
if (oneUserId != null) {
|
||||||
|
order.setOneUserId(Long.parseLong(String.valueOf(oneUserId)));
|
||||||
|
order.setOneMoney(new BigDecimal(String.valueOf(map.get("oneMoney"))));
|
||||||
|
}
|
||||||
|
Object twoUserId = map.get("twoUserId");
|
||||||
|
if (twoUserId != null) {
|
||||||
|
order.setTwoUserId(Long.parseLong(String.valueOf(twoUserId)));
|
||||||
|
order.setTwoMoney(new BigDecimal(String.valueOf(map.get("twoMoney"))));
|
||||||
|
}
|
||||||
|
Object sysUserId = map.get("sysUserId");
|
||||||
|
if (sysUserId != null) {
|
||||||
|
order.setSysUserId(Long.parseLong(String.valueOf(sysUserId)));
|
||||||
|
order.setQdMoney(new BigDecimal(String.valueOf(map.get("qdMoney"))));
|
||||||
|
}
|
||||||
|
ordersService.updateById(order);
|
||||||
|
ordersService.insertOrders(order);
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
activities(user, byUser);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user