admin
2019-08-13 37194e2d4b4ab85f7f29c1e900c406afe294579a
fanli/src/main/java/com/yeshi/fanli/job/TaoLiJinJob.java
@@ -13,11 +13,13 @@
import com.yeshi.fanli.entity.taobao.ShareHotGoods;
import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService;
import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinReportService;
import com.yeshi.fanli.util.Constant;
@@ -40,6 +42,9 @@
   
   @Resource
   private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
   @Resource
   private TaoBaoUnionConfigService taoBaoUnionConfigService;
   /**
    * 更新报告
@@ -107,16 +112,19 @@
         return;
      LogHelper.test("验证自购立减商品");
      String day = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd");
      List<TLJBuyGoods> list = tljBuyGoodsService.listByDay(day, 15);
      List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService
            .getConfigByTypeCache(TaoBaoUnionConfig.TYPE_TLJ_BUY);
      for (TaoBaoUnionConfig app : configList) {
         List<TLJBuyGoods> list = tljBuyGoodsService.listByDay(app.getAppKey(), day, 15);// 获取最多15个商品
      int count = 0;
      for (int i = 0; i < list.size(); i++) {
         if (count >= 10)
            break;
         boolean success = shareHotGoodsService.verifyCanCreateTLJ(list.get(i).getGoods().getAuctionId(),
               new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
                     TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
                  new TaoKeAppInfo(app.getAppKey(), app.getAppSecret(), app.getDefaultPid()));
         if (success) {
            count++;
            }
         }
      }
   }
@@ -131,33 +139,16 @@
         }
         if (goods != null && goods.getCouponAmount() != null
               && goods.getCouponAmount().compareTo(new BigDecimal(0)) > 0) {
            if (TaoBaoUtil.getAfterUseCouplePrice(goods).multiply(goods.getTkRate())
                  .compareTo(new BigDecimal("143")) >= 0) {
               goods = daTaoKeGoodsDetailService.filterTaoBaoGoods(goods);
               int totalHongBaoCount = 2000 + (int) (Math.random() * 8000);
               int leftHongBaoCount = 200 + (int) (Math.random() * 2000);
               tljBuyGoodsService.addTLJBuyGoods(
                     new TLJBuyGoods(null, day, new Date(), goods, totalHongBaoCount, leftHongBaoCount),
                     TaoBaoConstant.ownBuyApp);
                     new TLJBuyGoods(null, day, new Date(), goods, totalHongBaoCount, leftHongBaoCount));
            }
         }
      }
   }
   /**
    * 每天晚上11点50添加淘礼金1个商品,用于兼容Android前端没有商品不显示banner的问题
    */
   @Scheduled(cron = "0 50 23 * * ? ")
   public void autoAddTLJBuyGoods() {
      if (!Constant.IS_TASK)
         return;
      String day = TimeUtil.getGernalTime(System.currentTimeMillis() + 1000 * 60 * 60 * 24L, "yyyy-MM-dd");
      List<TaoBaoGoodsBrief> list = tljBuyGoodsService.listPreGoods(1);
      Collections.shuffle(list);
      if (list.size() > 0)
         list = list.subList(0, 1);
      addTLJBuyGoods(list, day);
   }
   /**
@@ -170,8 +161,11 @@
      String day = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd");
      List<TaoBaoGoodsBrief> list = tljBuyGoodsService.listPreGoods(1);
      Collections.shuffle(list);
      if (list.size() > 20)
         list = list.subList(0, 20);
      List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService
            .getConfigByTypeCache(TaoBaoUnionConfig.TYPE_TLJ_BUY);
      if (list.size() > 12 * configList.size())
         list = list.subList(0, 12 * configList.size());
      addTLJBuyGoods(list, day);
   }