package com.yonge.cooleshow.portal.task;

import com.yonge.cooleshow.common.entity.HttpResponseResult;
import com.yonge.cooleshow.portal.service.OmsPortalOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 取消超时订单并解锁库存的定时器
 * Created by macro on 2018/8/24.
 */
@RestController
@RequestMapping("/task")
public class OrderTimeOutCancelTask {
    private Logger LOGGER =LoggerFactory.getLogger(OrderTimeOutCancelTask.class);
    @Autowired
    private OmsPortalOrderService portalOrderService;

    /**
     * 订单轮询
     */
    @GetMapping("/pollingOrder")
    public HttpResponseResult cancelTimeOutOrder(){
        Integer count = portalOrderService.cancelTimeOutOrder();
        LOGGER.info("取消订单，并根据sku编号释放锁定库存，取消订单数量：{}",count);
        return HttpResponseResult.succeed();
    }
}
