admin
2019-11-23 51a4ff5d777028d52a19c314a99f796334cb7b51
fanli/src/main/java/com/yeshi/fanli/job/TaoLiJinJob.java
@@ -10,7 +10,6 @@
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinGiveRecord;
import com.yeshi.fanli.entity.taobao.ShareHotGoods;
import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -18,7 +17,6 @@
import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.log.TLJLogHelper;
import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService;
import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
@@ -55,40 +53,6 @@
   @Resource
   private UserTaoLiJinOriginService userTaoLiJinOriginService;
   /**
    * 更新报告
    */
   @Scheduled(cron = "0 0 1,10 * * ?")
   public void insetDynamicInfo() {
      if (!Constant.IS_TASK) {
         return;
      }
      try {
         userTaoLiJinReportService.needUpdateReport();
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e);
      }
   }
   /**
    * 退回超过3天无领取的淘礼金
    */
   @Scheduled(cron = "0 0 1 * * ?")
   public void refundNotWin() {
      if (!Constant.IS_TASK) {
         return;
      }
      try {
         userTaoLiJinReportService.refundNotWin();
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e);
      }
   }
   /**
    * 每天凌晨过5分钟验证
@@ -152,8 +116,13 @@
         }
         if (goods != null && goods.getCouponAmount() != null
               && goods.getCouponAmount().compareTo(new BigDecimal(0)) > 0) {
            // 淘礼金的金额位于1-10块之间 必须是天猫
            if (TaoBaoUtil.getAfterUseCouplePrice(goods).multiply(goods.getTkRate())
                  .compareTo(new BigDecimal("143")) >= 0) {
                  .compareTo(new BigDecimal("143")) >= 0
                  && TaoBaoUtil.getAfterUseCouplePrice(goods).multiply(goods.getTkRate())
                        .compareTo(new BigDecimal("1430")) <= 0
                  && goods.getUserType() == 1) {
               goods = daTaoKeGoodsDetailService.filterTaoBaoGoods(goods);
               int totalHongBaoCount = 2000 + (int) (Math.random() * 8000);
               int leftHongBaoCount = 200 + (int) (Math.random() * 2000);
@@ -169,10 +138,27 @@
    */
   @Scheduled(cron = "0 1 5 * * ? ")
   public void autoAddTLJBuyGoods2() {
      if (!Constant.IS_TASK)
         return;
      // if (!Constant.IS_TASK)
      // return;
      LogHelper.test("自购立减开始选品");
      String day = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd");
      List<TaoBaoGoodsBrief> list = tljBuyGoodsService.listPreGoods(1);
      // 重试3次
      List<TaoBaoGoodsBrief> list = null;
      try {
         list = tljBuyGoodsService.listPreGoods(1);
      } catch (Exception e) {
      }
      if (list == null || list.size() == 0)
         try {
            list = tljBuyGoodsService.listPreGoods(1);
         } catch (Exception e) {
         }
      if (list == null || list.size() == 0)
         try {
            list = tljBuyGoodsService.listPreGoods(1);
         } catch (Exception e) {
         }
      LogHelper.test("自购立减备选商品数量:" + list.size());
      Collections.shuffle(list);
      List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService
@@ -183,32 +169,4 @@
      addTLJBuyGoods(list, day);
   }
   /**
    * 每2个小时 赠送退回已过期淘礼金
    */
   @Scheduled(cron = "0 0 0/2 * * ? ")
   public void giveSendBack() {
      if (!Constant.IS_TASK)
         return;
      for (int i = 0; i < 100; i++) {
         List<UserTaoLiJinGiveRecord> overdueList = userTaoLiJinGiveRecordService.overdueList(500);
         if (overdueList == null || overdueList.size() == 0) {
            break;
         }
         for (UserTaoLiJinGiveRecord record : overdueList) {
            try {
               userTaoLiJinOriginService.giveSendBack(record.getGiveUid(), record);
               // 更新记录
               UserTaoLiJinGiveRecord updateRecord = new UserTaoLiJinGiveRecord();
               updateRecord.setId(record.getId());
               updateRecord.setState(UserTaoLiJinGiveRecord.STATE_OVERDUE);
               userTaoLiJinGiveRecordService.updateByPrimaryKeySelective(updateRecord);
            } catch (Exception e) {
               e.printStackTrace();
            }
         }
      }
   }
}