Browse Source

定时任务移到mall

yubin 2 weeks ago
parent
commit
1a558ab529
1 changed files with 17 additions and 3 deletions
  1. 17 3
      mall-service/src/main/java/com/txz/mall/task/GeneralJob.java

+ 17 - 3
mall-service/src/main/java/com/txz/mall/task/GeneralJob.java

@@ -1,6 +1,7 @@
 package com.txz.mall.task;
 
 import cn.hutool.core.collection.CollUtil;
+import com.txz.mall.service.StoreOrderService;
 import com.xxl.job.core.biz.model.ReturnT;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import org.slf4j.Logger;
@@ -23,15 +24,28 @@ import java.util.List;
  */
 @Component
 public class GeneralJob {
+
     private static Logger logger = LoggerFactory.getLogger(GeneralJob.class);
 
 
+    @Resource
+    private StoreOrderService storeOrderService;
     /**
      * 1、简单任务示例(Bean模式)
      */
-    @XxlJob("generalReportJob")
-    public ReturnT<String> generalReportJob(String param) throws Exception {
-        //do things
+
+
+
+    @XxlJob("newOrderTimeoutAutomaticCancel")
+    public ReturnT<String> newOrderTimeoutAutomaticCancel(String param) throws Exception {
+        try {
+            logger.info("【新的订单支付超时定时关单任务】开始");
+            storeOrderService.orderTimeoutAutomaticCancel();
+            logger.info("【新的订单支付超时定时关单任务】完成");
+        } catch (Exception e) {
+            logger.error("【新的订单支付超时定时关单任务】异常:e{}", e);
+            return ReturnT.FAIL;
+        }
         return ReturnT.SUCCESS;
     }