
package com.tmerclub.cloud.supplier.task;

import com.tmerclub.cloud.supplier.service.SupplierAllinpayService;
import com.tmerclub.cloud.supplier.service.SupplierDetailService;
import com.tmerclub.cloud.supplier.service.SupplierWalletLogService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 供应商定时任务
 *
 * @Author lth
 * @Date 2021/7/9 13:35
 */
@Component
public class SupplierTask {

    @Autowired
    private SupplierDetailService supplierDetailService;
    @Autowired
    private SupplierWalletLogService supplierWalletLogService;
    @Autowired
    private SupplierAllinpayService supplierAllinpayService;

    /**
     * 根据签约时间改变供应商状态
     */
    @XxlJob("changeSupplierStatus")
    public void changeSupplierStatus() {
        Date now = new Date();
        // 根据签约时间修改供应商状态
        if (supplierAllinpayService.getIsAllinpay()) {
            return;
        }
        supplierDetailService.changeSupplierStatusByContractTime(now);
    }
}
