diff --git a/schedule/src/main/java/com/hfkj/consumer/OrderCancelConsumer.java b/schedule/src/main/java/com/hfkj/consumer/OrderCancelConsumer.java index 5091535..87d7272 100644 --- a/schedule/src/main/java/com/hfkj/consumer/OrderCancelConsumer.java +++ b/schedule/src/main/java/com/hfkj/consumer/OrderCancelConsumer.java @@ -1,7 +1,9 @@ package com.hfkj.consumer; +import com.hfkj.entity.BsOrder; import com.hfkj.model.order.OrderModel; import com.hfkj.service.order.BsOrderService; +import com.hfkj.sysenum.order.OrderStatusEnum; import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; import org.apache.rocketmq.spring.core.RocketMQListener; @@ -19,7 +21,11 @@ public class OrderCancelConsumer implements RocketMQListener { @Override public void onMessage(OrderModel order) { - // 取消订单 - orderService.cancel(order.getOrderNo()); + // 查询订单 + BsOrder bsOrder = orderService.getOrder(order.getOrderNo()); + if (bsOrder != null && bsOrder.getOrderStatus().equals(OrderStatusEnum.status1.getCode())) { + // 取消订单 + orderService.cancel(order.getOrderNo()); + } } }