admin
2020-06-09 afe61a27c4f77db65df66b0ff5dc93cbd3e0014b
fanli/src/main/java/com/yeshi/fanli/job/UpdateDaTaoKeJob.java
@@ -16,7 +16,6 @@
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.TimeUtil;
@@ -34,35 +33,11 @@
   private QualityFactoryService qualityFactoryService;
   @Resource
   private DaTaoKeGoodsDetailService daTaoKeGoodsService;
   @Resource
   private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
   @Resource
   private ShareHotGoodsService shareHotGoodsService;
   @Resource
   private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
   // 1个小时更新一次
   @Scheduled(cron = "0 0 0/1 * * ? ")
   public void doSyncJob() {
      if (!Constant.IS_TASK)
         return;
      try {
         new Thread(new Runnable() {
            @Override
            public void run() {
               daTaoKeGoodsService.startSyncGoods();
            }
         }).start();
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e);
      }
   }
   // 每天早晚同步一次
   @Scheduled(cron = "0 0 6,18 * * ? ")
@@ -151,6 +126,9 @@
   // 自动选品
   @Scheduled(cron = "0 0 23 * * ? ")
   public void setShareHotGoods() {
      if (!Constant.IS_TASK)
         return;
      String day = TimeUtil.getGernalTime(System.currentTimeMillis() + 1000 * 60 * 60 * 24L, "yyyy-MM-dd");
      List<TaoBaoGoodsBrief> goodsList = shareHotGoodsService.listPreGoods(1);
      Collections.shuffle(goodsList);
@@ -167,7 +145,7 @@
               && goods.getCouponAmount().compareTo(new BigDecimal(0)) > 0) {
            if (TaoBaoUtil.canAddToTLJBuyGoods(goods)) {
               count++;
               goods = daTaoKeGoodsDetailService.filterTaoBaoGoods(goods);
               goods = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods).getGoods();
               shareHotGoodsService.addShareHotGoods(new ShareHotGoods(null, day, new Date(), goods));
            }
         }
@@ -176,6 +154,9 @@
   @Scheduled(cron = "0 30 7,11,18,23 * * ? ")
   public void syncGoodsBeiYong() {
      if (!Constant.IS_TASK)
         return;
      long latestUpdateCount = daTaoKeGoodsDetailV2Service
            .countByMinUpdateTime(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24L));
      if (latestUpdateCount < 50000L) {// 若每天没有超过5w数据更新就需要重新更新数据