| | |
| | | import java.util.Collections;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Random;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.scheduling.annotation.Scheduled;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.yeshi.fanli.entity.taobao.ShareHotGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TLJFreeBuyGoods;
|
| | | 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.TLJFreeBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinGiveRecordService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinReportService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
| | | private UserTaoLiJinReportService userTaoLiJinReportService;
|
| | |
|
| | | @Resource
|
| | | private ShareHotGoodsService shareHotGoodsService;
|
| | |
|
| | | @Resource
|
| | | private TLJBuyGoodsService tljBuyGoodsService;
|
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
|
| | | private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
| | | @Resource
|
| | | private UserTaoLiJinOriginService userTaoLiJinOriginService;
|
| | |
|
| | | /**
|
| | | * 每天凌晨过5分钟验证
|
| | | */
|
| | | @Scheduled(cron = "0 2 0 * * ?")
|
| | | public void updateShareTLJGoods() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | LogHelper.test("验证爆款商品库商品");
|
| | | String day = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd");
|
| | | List<ShareHotGoods> list = shareHotGoodsService.listByDay(day, 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));
|
| | | if (success) {
|
| | | count++;
|
| | | }
|
| | | }
|
| | | }
|
| | | @Resource
|
| | | private TLJFreeBuyGoodsService tljFreeBuyGoodsService;
|
| | | |
| | |
|
| | |
|
| | | /**
|
| | | * 每天凌晨5点过10分钟验证
|
| | |
| | | && TaoBaoUtil.getAfterUseCouplePrice(goods).multiply(goods.getTkRate())
|
| | | .compareTo(new BigDecimal("1430")) <= 0
|
| | | && goods.getUserType() == 1) {
|
| | | goods = daTaoKeGoodsDetailService.filterTaoBaoGoods(goods);
|
| | | goods = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods);
|
| | | int totalHongBaoCount = 2000 + (int) (Math.random() * 8000);
|
| | | int leftHongBaoCount = 200 + (int) (Math.random() * 2000);
|
| | | tljBuyGoodsService.addTLJBuyGoods(
|
| | |
| | | */
|
| | | @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");
|
| | | // 重试3次
|
| | |
| | | addTLJBuyGoods(list, day);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 每天凌晨23点过1分开始爬取
|
| | | */
|
| | | @Scheduled(cron = "0 1 23 * * ? ")
|
| | | public void autoAddTLJFreeBuyGoods() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | |
| | | String day = TimeUtil.getGernalTime(System.currentTimeMillis() + 1000 * 60 * 60 * 24L, "yyyy-MM-dd");
|
| | | LogHelper.test("免单商品开始选品" + day);
|
| | | |
| | | // 是否已预选
|
| | | List<TLJFreeBuyGoods> listSelect = tljFreeBuyGoodsService.listByDay(day);
|
| | | if (listSelect != null && listSelect.size() > 0)
|
| | | return;
|
| | | |
| | | int count = 0;
|
| | | int maxCount = 15;
|
| | | for (int page = 1; page <= 10; page ++) {
|
| | | List<TaoBaoGoodsBrief> list = tljFreeBuyGoodsService.listPreGoods("", page);
|
| | | if (list == null || list.size() == 0)
|
| | | break;
|
| | | |
| | | while (list.size() > 0) {
|
| | | if (count >= maxCount)
|
| | | break;
|
| | | |
| | | Random random = new Random();
|
| | | int n = random.nextInt(list.size());
|
| | | TaoBaoGoodsBrief goods = list.get(n);
|
| | | if (goods.getCouponAmount() != null && goods.getCouponAmount().compareTo(new BigDecimal(0)) > 0) {
|
| | | BigDecimal couplePrice = TaoBaoUtil.getAfterUseCouplePrice(goods);
|
| | | if (couplePrice.compareTo(new BigDecimal(1.0)) >= 0 && couplePrice.compareTo(new BigDecimal(2.0)) <= 0) {
|
| | | tljFreeBuyGoodsService.addGoods(new TLJFreeBuyGoods(day, goods));
|
| | | count ++;
|
| | | }
|
| | | }
|
| | | list.remove(n);
|
| | | }
|
| | | |
| | | if (count >= maxCount)
|
| | | break;
|
| | | }
|
| | | |
| | | }
|
| | | }
|