优惠卷

复读
This commit is contained in:
wuchunlei
2024-10-25 10:43:11 +08:00
parent 54901e7133
commit cce2106e04
17 changed files with 602 additions and 100 deletions

View File

@@ -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());