清空购物车同时返还库存及销量
This commit is contained in:
@@ -3,12 +3,14 @@ package cn.ysk.cashier.quartz.task;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import cn.ysk.cashier.repository.order.TbCashierCartRepository;
|
||||
import cn.ysk.cashier.repository.product.TbProductSkuRepository;
|
||||
import cn.ysk.cashier.service.order.TbCashierCartService;
|
||||
import cn.ysk.cashier.service.shop.TbShopStorageService;
|
||||
import cn.ysk.cashier.utils.CacheKey;
|
||||
import cn.ysk.cashier.utils.QueryHelp;
|
||||
import cn.ysk.cashier.utils.RedisUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -36,6 +38,12 @@ public class TestTask {
|
||||
@Autowired
|
||||
private RedisUtils redisUtils;
|
||||
|
||||
private final TbCashierCartService tbCashierCartService;
|
||||
|
||||
public TestTask(TbCashierCartService tbCashierCartService) {
|
||||
this.tbCashierCartService = tbCashierCartService;
|
||||
}
|
||||
|
||||
|
||||
public void run(){
|
||||
log.info("run 执行成功");
|
||||
@@ -70,7 +78,7 @@ public class TestTask {
|
||||
});
|
||||
Set<String> keys = new HashSet<>();
|
||||
for (TbCashierCart cart : all) {
|
||||
skuRepository.updateStockNumber(Integer.valueOf(cart.getSkuId()),cart.getNumber().doubleValue());
|
||||
tbCashierCartService.clearExpireOrder(cart);
|
||||
cart.setStatus("cancelled");
|
||||
cartService.save(cart);
|
||||
keys.add(CacheKey.PRODUCT_SKU + cart.getShopId() + ":" + cart.getSkuId());
|
||||
|
||||
Reference in New Issue
Block a user