Commit 744cc9fb authored by wangpeng's avatar wangpeng

Merge branch 'dev' into 'test'

预热定时任务 See merge request !36
parents d0a27a16 8c28cfd2
...@@ -22,7 +22,8 @@ public enum SpuStatusEnum { ...@@ -22,7 +22,8 @@ public enum SpuStatusEnum {
CHECK_FAIL(6),//审核未通过 CHECK_FAIL(6),//审核未通过
CHECK_PASS(7),//审核通过 CHECK_PASS(7),//审核通过
CANCEL(8),//取消发布 CANCEL(8),//取消发布
DRAFT(9);//草稿 DRAFT(9),//草稿
PREHEAT(10);//预热
private Integer status; private Integer status;
......
...@@ -161,4 +161,6 @@ public interface ISpuService extends IService<Spu> { ...@@ -161,4 +161,6 @@ public interface ISpuService extends IService<Spu> {
*/ */
List<GoodsListVO> getSpuByVague(String goodsInfo, String merchantId); List<GoodsListVO> getSpuByVague(String goodsInfo, String merchantId);
List<Spu> listForPreheat();
} }
...@@ -545,4 +545,12 @@ public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements ISpuS ...@@ -545,4 +545,12 @@ public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements ISpuS
externalTokenService.updateById(externalToken); externalTokenService.updateById(externalToken);
} }
} }
@Override
public List<Spu> listForPreheat() {
LambdaQueryWrapper<Spu> qw = new LambdaQueryWrapper<>();
qw.eq(Spu::getStatus, SpuStatusEnum.PREHEAT.getStatus());
return list(qw);
}
} }
package com.fzm.mall.server.admin.task.goods;
import com.fzm.mall.server.admin.goods_center.enums.status.SpuStatusEnum;
import com.fzm.mall.server.admin.goods_center.model.Spu;
import com.fzm.mall.server.admin.goods_center.service.ISpuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @author wangp
* @date 2021/6/18 10:43
* @description 订单定时任务
* @since JDK 1.8
*/
@Component
@Slf4j
@Transactional
public class GoodsTask {
@Autowired
private ISpuService spuService;
//预热商品上架
@Scheduled(cron = "10 * * * * ?")
public void yrsj() {
List<Spu> spuList = spuService.listForPreheat();
spuList.forEach(v -> {
if (v.getPreheatEndTime() < System.currentTimeMillis()) {
//修改状态为上架
spuService.updateStatus(v.getGoodsId(), SpuStatusEnum.ON.getStatus(), "");
}
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment