|
|
@@ -2,6 +2,9 @@ package com.ruoyi.schedule;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.ruoyi.shop.constants.ShopConstants;
|
|
|
+import com.ruoyi.shop.order.domain.ShopOrderDetail;
|
|
|
+import com.ruoyi.shop.order.service.IShopOrderDetailService;
|
|
|
+import com.ruoyi.shop.order.service.IShopOrderService;
|
|
|
import com.ruoyi.shop.product.domain.bo.ProductViewUpdate;
|
|
|
import com.ruoyi.shop.product.service.IProductService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
@@ -31,6 +34,10 @@ public class ProjectSchedule {
|
|
|
|
|
|
private final IProductService productService;
|
|
|
|
|
|
+ private final IShopOrderDetailService shopOrderDetailService;
|
|
|
+
|
|
|
+ private final IShopOrderService shopOrderService;
|
|
|
+
|
|
|
@Scheduled(fixedDelay = 30_000) // 每30秒执行一次
|
|
|
public void syncProductViewCountToDb() {
|
|
|
// 获取所有待同步的商品浏览增量
|
|
|
@@ -66,4 +73,19 @@ public class ProjectSchedule {
|
|
|
throw e;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Scheduled(cron = "${task1h}")
|
|
|
+ public void autoEnd() {
|
|
|
+ List<ShopOrderDetail> list = shopOrderDetailService.needAutoEndOrder();
|
|
|
+ list.forEach(v -> {
|
|
|
+ try {
|
|
|
+ log.info(String.format("订单:%s,购买商品【%s】封单开始", v.getOrderNo(),v.getProductTitle()));
|
|
|
+ shopOrderService.autoEnd(v);
|
|
|
+ log.info(String.format("订单:%s,购买商品【%s】封单完成", v.getOrderNo(),v.getProductTitle()));
|
|
|
+ }
|
|
|
+ catch (Exception ex) {
|
|
|
+ log.error(String.format("订单:%s,购买商品【%s】封单完成,出错%s", v.getOrderNo(),v.getProductTitle(), ex.getMessage()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|