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.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Component; import java.util.Date; /** * @BelongsProject: hzs_cloud * @BelongsPackage: com.hzs.third.job * @Author: yh * @CreateTime: 2023-06-01 10:44 * @Description: TODO * @Version: 1.0 */ @Slf4j @ConditionalOnProperty(name = "xxl-job.start", havingValue = "true") @Component public class WaresJob { @DubboReference private IWaresServiceApi waresServiceApi; /** * 商品自动上下架 */ @XxlJob("waresAutoLoadingJob") public void waresAutoLoadingJob() { // 修改符合 时间条件商品上架 /** * 获取当前时间 */ Date currentTime = new Date(); // 自动上架 waresServiceApi.updateByAutoStartAndAutoStart(currentTime); // 定时自动下架 waresServiceApi.updateByAutoStartAndAutoEnd(currentTime); } /** * 商品预售状态修改 */ @XxlJob("waresPreSaleJob") public void waresPreSaleJob() { // 修改商品预售状态 waresServiceApi.waresPreSale(); } }