package com.hzs.third.job; import com.hzs.sale.wares.IWaresServiceApi; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Component; import java.util.Date; @Slf4j @ConditionalOnProperty(name = "xxl-job.start", havingValue = "true") @Component public class WaresJob { @DubboReference IWaresServiceApi iWaresServiceApi; /** * 商品自动上下架 */ @XxlJob("waresAutoLoadingJob") public void waresAutoLoadingJob() { // 修改符合 时间条件商品上架 // 获取当前时间 Date currentTime = new Date(); // 自动上架 iWaresServiceApi.updateByAutoStartAndAutoStart(currentTime); // 定时自动下架 iWaresServiceApi.updateByAutoStartAndAutoEnd(currentTime); } /** * 商品预售状态修改 */ @XxlJob("waresPreSaleJob") public void waresPreSaleJob() { // 修改商品预售状态 iWaresServiceApi.waresPreSale(); } }