diff --git a/hai-order/src/main/java/com/web/controller/OrderPayNotifyController.java b/hai-order/src/main/java/com/web/controller/OrderPayNotifyController.java index 332aa6c3..bbd7abae 100644 --- a/hai-order/src/main/java/com/web/controller/OrderPayNotifyController.java +++ b/hai-order/src/main/java/com/web/controller/OrderPayNotifyController.java @@ -10,6 +10,7 @@ import com.hai.entity.*; import com.hai.order.service.OrderPaySuccessService; import com.hai.order.service.OrderService; import com.hai.order.type.OrderPayType; +import com.hai.order.type.OrderStatus; import com.hai.service.pay.NotifyService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -65,10 +66,16 @@ public class OrderPayNotifyController { // 处理业务 log.info("开始处理业务"); - paySuccessService.orderPaySuccessHandle(map.get("out_trade_no"), - OrderPayType.PAY_TYPE2, map.get("out_trade_no"), - new BigDecimal(map.get("total_fee")).divide(new BigDecimal("100")), - null); + + // 查询交易订单 + HighOrder order = orderService.getOrderDetailByNo(map.get("out_trade_no")); + if (order != null && order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) { + // 处理订单业务 + paySuccessService.orderPaySuccessHandle(map.get("out_trade_no"), + OrderPayType.PAY_TYPE2, map.get("out_trade_no"), + new BigDecimal(map.get("total_fee")).divide(new BigDecimal("100")), + null); + } log.info("处理业务完成"); BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); @@ -96,16 +103,15 @@ public class OrderPayNotifyController { // 查询订单信息 HighOrder order = orderService.getOrderDetailByNo(body.getString("tradetrace")); - if (order == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); + if (order != null && order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) { + log.info("开始处理业务"); + // 处理订单业务 + paySuccessService.orderPaySuccessHandle(order.getOrderNo(), + OrderPayType.PAY_TYPE5, + body.getString("wtorderid"), + order.getPayPrice(), + null); } - log.info("开始处理业务"); - // 异步处理业务 - paySuccessService.orderPaySuccessHandle(order.getOrderNo(), - OrderPayType.PAY_TYPE5, - body.getString("wtorderid"), - order.getPayPrice(), - null); log.info("处理业务完成"); } BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java index cd132cd0..2e76ea33 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java @@ -96,7 +96,7 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { public HighOrder orderPaySuccessHandle(String orderNo, OrderPayType payType, String paySerialNo, BigDecimal payRealPrice, HighUserCard userCard) { HighOrder order = orderService.getOrderDetailByNo(orderNo); try { - if (order != null && order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) { + if (order != null) { order.setPaySerialNo(paySerialNo); order.setPayRealPrice(payRealPrice); order.setPayTime(new Date()); diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index 97aed713..26f2cff9 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -431,7 +431,7 @@ public class OrderServiceImpl implements OrderService { rocketMQTemplate.syncSend(OrderTopic.ORDER_TOPIC_CANCEL.getTopic(), rocketMsg,1000,14); } else if (orderData.getOrderStatus().equals(OrderStatus.STATUS2.getNumber())) { - // 异步处理业务 + // 处理业务 return paySuccessService.orderPaySuccessHandle(orderData.getOrderNo(), OrderPayType.PAY_TYPE3, null, new BigDecimal("0"), null); } return orderData;