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;
import springfox.documentation.annotations.ApiIgnore;

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

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

    /**
     * 发货多少天后自动收货
     */
    @GetMapping("/autoReceive")
    public HttpResponseResult autoReceive(){
        Integer count = portalOrderService.autoReceive();
        LOGGER.info("自动收货：{}",count);
        return HttpResponseResult.succeed();
    }


    /**
     * 收货多少天后分润
     */
    @GetMapping("/shareProfit")
    public HttpResponseResult shareProfit(){
        Integer count = portalOrderService.shareProfit();
        LOGGER.info("自动分润：{}",count);
        return HttpResponseResult.succeed();
    }
}
