优惠卷
复读
This commit is contained in:
@@ -9,10 +9,10 @@ import com.peanut.modules.common.entity.BuyOrder;
|
||||
import com.peanut.modules.common.entity.BuyOrderProduct;
|
||||
import com.peanut.modules.common.entity.ShopProduct;
|
||||
import com.peanut.modules.book.service.BuyOrderService;
|
||||
import com.peanut.modules.common.service.CouponService;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -29,16 +29,22 @@ public class OrderCancelConsumer {
|
||||
BuyOrderProductDao buyOrderProductDao;
|
||||
@Autowired
|
||||
ShopProductDao shopProductDao;
|
||||
@Autowired
|
||||
CouponService couponService;
|
||||
|
||||
@RabbitListener(queues = DelayQueueConfig.ORDER_CANCEL_DEAD_LETTER_QUEUE)
|
||||
public void orderConsumer(String orderId) {
|
||||
BuyOrder buyOrder = buyOrderService.getById(orderId);
|
||||
if(buyOrder == null){
|
||||
|
||||
return;
|
||||
}
|
||||
if(Constants.ORDER_STATUS_TO_BE_PAID.equals(buyOrder.getOrderStatus())){
|
||||
buyOrder.setOrderStatus(Constants.ORDER_STATUS_OUT_OF_TIME);
|
||||
//回滚优惠卷
|
||||
if (buyOrder.getCouponId()!=null&&buyOrder.getCouponId()!=0){
|
||||
couponService.rollbackCoupon(buyOrder.getCouponId());
|
||||
buyOrder.setCouponId(null);
|
||||
}
|
||||
//回滚库存
|
||||
LambdaQueryWrapper<BuyOrderProduct> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BuyOrderProduct::getOrderId,buyOrder.getOrderId());
|
||||
|
||||
Reference in New Issue
Block a user