lubo před 4 týdny
rodič
revize
ab1f1b4591

+ 10 - 4
ruoyi-admin/src/main/java/com/ruoyi/schedule/ProjectSchedule.java

@@ -18,7 +18,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
-import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -38,11 +37,16 @@ public class ProjectSchedule {
 
     private final IShopOrderService shopOrderService;
 
-    @Scheduled(fixedDelay = 30_000) // 每30秒执行一次
+    /**
+     * 每30秒执行一次 商品浏览量同步
+     */
+    @Scheduled(fixedDelay = 30_000) 
     public void syncProductViewCountToDb() {
         // 获取所有待同步的商品浏览增量
         Map<Object, Object> increments = redisTemplate.opsForHash().entries(ShopConstants.PRODUCT_VIEW_KEY);
-        if (increments.isEmpty()) return;
+        if (increments.isEmpty()) {
+            return;
+        };
         // 批量更新数据库(使用 batch update)
         List<ProductViewUpdate> updates = new ArrayList<>();
         try {
@@ -74,7 +78,9 @@ public class ProjectSchedule {
         }
     }
 
-    // 每晚一点钏执行一次 订单封单
+    /**
+     * 每晚一点执行一次 订单封单
+     */
     @Scheduled(cron = "${task1h}")
     public void autoEnd() {
         List<ShopOrderDetail> list = shopOrderDetailService.needAutoEndOrder();