Skip to content

Commit

Permalink
定时任务添加
Browse files Browse the repository at this point in the history
  • Loading branch information
zhh committed Aug 24, 2018
1 parent 1679413 commit abfb6c1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ JTA事务处理 | ✔
OSS上传功能 | ✔
Elasticsearch搜索功能 | ✔
HTTPS支持 | ✔
SpringSecurity权限管理功能 |
ELK日志收集功能 |
Redis数字型ID生成 |
SpringTask定时任务支持 |
SpringTask定时任务支持 |
RestTemplate服务间调用 |
docker容器化部署 | ✔
配置区分生产和测试环境 | ✔
SpringSecurity权限管理功能 |

### 使用工具

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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编号释放锁定库存");
}
}

0 comments on commit abfb6c1

Please sign in to comment.