定时任务添加

This commit is contained in:
zhh
2018-08-24 16:36:33 +08:00
parent 16794132b2
commit abfb6c13e6
3 changed files with 28 additions and 2 deletions

View File

@@ -3,9 +3,11 @@ package com.macro.mall.portal;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@MapperScan({"com.macro.mall.mapper","com.macro.mall.portal.dao"})
@EnableScheduling
public class MallPortalApplication {
public static void main(String[] args) {

View File

@@ -0,0 +1,24 @@
package com.macro.mall.portal.component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* Created by macro on 2018/8/24.
* 订单超时取消并解锁库存的定时器
*/
@Component
public class OrderTimeOutCancelTask {
private Logger LOGGER =LoggerFactory.getLogger(OrderTimeOutCancelTask.class);
/**
* cron表达式Seconds Minutes Hours DayofMonth Month DayofWeek [Year]
* 每10分钟扫描一次扫描超时时间*2时间内所下订单如果没支付则取消该订单
*/
@Scheduled(cron = "0 0/10 * ? * ?")
private void cancelTimeOutOrder(){
LOGGER.info("取消订单并根据sku编号释放锁定库存");
}
}