package com.kmall.schedule.quartz;

import com.kmall.schedule.service.QzOrderService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component("orderTask")
public class OrderTask {
    private static Log logger = LogFactory.getLog(OrderTask.class);

    @Autowired
    QzOrderService qzOrderService;

    /**
     * 方法描述：拼团进度通知
     * 每日凌晨2:00
     */
    /*@Scheduled(cron = "0 0 2 * * ?")
    public void groupProgressRemind() {
        logger.info(">>>>>>>>>>>>>>>>>>>>groupProgressRemind is start ");
        qzOrderService.groupProgressRemind();
        logger.info(">>>>>>>>>>>>>>>>>>>>groupProgressRemind is end ");
    }*/

    /**
     * 未评价订单(发送微信模版消息提醒用户)
     * 每日凌晨2:00
     */
    @Scheduled(cron = "0 0 2 * * ?")
    public void orderUnEvaluateRemind() {
        logger.info(">>>>>>>>>>>>>>>>>>>>groupProgressRemind is start ");
        qzOrderService.orderUnEvaluateRemind();
        logger.info(">>>>>>>>>>>>>>>>>>>>groupProgressRemind is end ");
    }
    /**
     * 方法描述：更新过期未支付订单
     * 二分钟更新未付款订单
     */
    @Scheduled(fixedRate = 1000 * 60 * 2)
    public void unpayPastUpdate() {
        logger.info(">>>>>>>>>>>>>>>>>>>>unpayPastUpdate is start ");
        qzOrderService.unpayPastUpdate();
        logger.info(">>>>>>>>>>>>>>>>>>>>unpayPastUpdate is end ");
    }

    /**
     * 方法描述：查询已申请退款订单以及退款中订单，查询微信退款更新订单状态
     * 二分钟更新订单
     */
    @Scheduled(fixedRate = 1000 * 60 * 2)
    public void refundUpdate() {
        logger.info(">>>>>>>>>>>>>>>>>>>>refundUpdate is start ");
        qzOrderService.refundUpdate();
        logger.info(">>>>>>>>>>>>>>>>>>>>refundUpdate is end ");
    }

    /**
     * 方法描述：查询支付中的订单以及小程序更新支付信息异常订单，查询微信订单更新订单状态
     * 二分钟更新订单
     */
    @Scheduled(fixedRate = 1000 * 60 * 2)
    public void orderQueryUpdate() {
        logger.info(">>>>>>>>>>>>>>>>>>>>orderQueryUpdate is start ");
        qzOrderService.orderQueryUpdate();
        logger.info(">>>>>>>>>>>>>>>>>>>>orderQueryUpdate is end ");
    }
}


