定时任务超v过期
课程过期
This commit is contained in:
@@ -40,16 +40,16 @@ public class OrderCancelConsumer {
|
||||
if(Constants.ORDER_STATUS_TO_BE_PAID.equals(buyOrder.getOrderStatus())){
|
||||
buyOrder.setOrderStatus(Constants.ORDER_STATUS_OUT_OF_TIME);
|
||||
//回滚库存
|
||||
// LambdaQueryWrapper<BuyOrderProduct> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.eq(BuyOrderProduct::getOrderId,buyOrder.getOrderId());
|
||||
// List<BuyOrderProduct> buyOrderProducts = buyOrderProductDao.selectList(wrapper);
|
||||
// for (BuyOrderProduct b : buyOrderProducts){
|
||||
// ShopProduct shopProduct = shopProductDao.selectById(b.getProductId());
|
||||
// shopProduct.setProductStock(shopProduct.getProductStock()+b.getQuantity());
|
||||
// shopProductDao.updateById(shopProduct);
|
||||
// }
|
||||
LambdaQueryWrapper<BuyOrderProduct> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BuyOrderProduct::getOrderId,buyOrder.getOrderId());
|
||||
List<BuyOrderProduct> buyOrderProducts = buyOrderProductDao.selectList(wrapper);
|
||||
for (BuyOrderProduct b : buyOrderProducts){
|
||||
ShopProduct shopProduct = shopProductDao.selectById(b.getProductId());
|
||||
shopProduct.setProductStock(shopProduct.getProductStock()+b.getQuantity());
|
||||
shopProductDao.updateById(shopProduct);
|
||||
}
|
||||
buyOrderService.updateById(buyOrder);
|
||||
}
|
||||
buyOrderService.updateById(buyOrder);
|
||||
if(Constants.ORDER_STATUS_OUT_OF_TIME.equals(buyOrder.getOrderStatus())){
|
||||
buyOrderService.removeById(buyOrder);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.peanut.modules.mq.Consumer;
|
||||
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
import com.peanut.modules.common.dao.MyUserDao;
|
||||
import com.peanut.modules.common.dao.UserVipDao;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
import com.peanut.modules.common.entity.UserVip;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
//超v过期死信操作
|
||||
@Component
|
||||
public class UserVipConsumer {
|
||||
|
||||
@Autowired
|
||||
private UserVipDao userVipDao;
|
||||
@Autowired
|
||||
private MyUserDao userDao;
|
||||
|
||||
@RabbitListener(queues = DelayQueueConfig.USERVIP_DEAD_LETTER_QUEUE)
|
||||
public void userVipConsumer(String userVipId) {
|
||||
UserVip userVip = userVipDao.selectById(userVipId);
|
||||
if(userVip == null){
|
||||
return;
|
||||
}else {
|
||||
userVip.setState(1);
|
||||
userVipDao.updateById(userVip);
|
||||
MyUserEntity user = userDao.selectById(userVip.getUserId());
|
||||
user.setVip("0");
|
||||
userDao.updateById(user);
|
||||
System.out.println("vip更新完成");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user