| | |
| | | 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.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;
|
| | |
| | | @Resource
|
| | | private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
|
| | |
|
| | | /**
|
| | | * 更新报告
|
| | | */
|
| | | @Scheduled(cron = "0 0 1,10 * * ?")
|
| | | public void insetDynamicInfo() {
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
|
| | | if (!Constant.IS_TASK) {
|
| | | return;
|
| | | }
|
| | | @Resource
|
| | | private UserTaoLiJinGiveRecordService userTaoLiJinGiveRecordService;
|
| | |
|
| | | 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);
|
| | | }
|
| | | }
|
| | | @Resource
|
| | | private UserTaoLiJinOriginService userTaoLiJinOriginService;
|
| | |
|
| | | /**
|
| | | * 每天凌晨过5分钟验证
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 每天凌晨过3分钟验证
|
| | | * 每天凌晨5点过10分钟验证
|
| | | */
|
| | | @Scheduled(cron = "0 3 0 * * ?")
|
| | | @Scheduled(cron = "0 10 5 * * ? ")
|
| | | public void updateBuyTLJGoods() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | LogHelper.test("验证自购立减商品");
|
| | | String day = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd");
|
| | | List<TLJBuyGoods> list = tljBuyGoodsService.listByDay(day, 15);
|
| | | int count = 0;
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (count >= 10)
|
| | | break;
|
| | | boolean success = tljBuyGoodsService.verifyCanCreateTLJ(list.get(i).getGoods().getAuctionId());
|
| | | if (success) {
|
| | | count++;
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService
|
| | | .getConfigByTypeCache(TaoBaoUnionConfig.TYPE_TLJ_BUY);
|
| | | int totalCount = 0;
|
| | | 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 = tljBuyGoodsService.verifyCanCreateTLJ(list.get(i).getGoods().getAuctionId(),
|
| | | new TaoKeAppInfo(app.getAppKey(), app.getAppSecret(), app.getDefaultPid()));
|
| | | if (success) {
|
| | | count++;
|
| | | }
|
| | | }
|
| | | totalCount += count;
|
| | | }
|
| | | LogHelper.test("自购立减商品验证通过的数量:" + totalCount);
|
| | | }
|
| | |
|
| | | private void addTLJBuyGoods(List<TaoBaoGoodsBrief> list, String day) {
|
| | |
| | | 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);
|
| | | 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() > 20)
|
| | | list = list.subList(0, 1);
|
| | | addTLJBuyGoods(list, day);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | @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);
|
| | | if (list.size() > 20)
|
| | | list = list.subList(0, 1);
|
| | | 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);
|
| | | }
|
| | |
|