From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/job/UpdateTaoBaoGoodsJob.java | 389 ++++++++++++++++++++++++++++--------------------------- 1 files changed, 198 insertions(+), 191 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/job/UpdateTaoBaoGoodsJob.java b/fanli/src/main/java/com/yeshi/fanli/job/UpdateTaoBaoGoodsJob.java index 1baa55d..fc85d97 100644 --- a/fanli/src/main/java/com/yeshi/fanli/job/UpdateTaoBaoGoodsJob.java +++ b/fanli/src/main/java/com/yeshi/fanli/job/UpdateTaoBaoGoodsJob.java @@ -1,191 +1,198 @@ -package com.yeshi.fanli.job; - -import java.util.List; - -import javax.annotation.Resource; - -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import com.yeshi.fanli.entity.bus.activity.RecommendActivity; -import com.yeshi.fanli.entity.taobao.ShareHotGoods; -import com.yeshi.fanli.exception.ActivityException; -import com.yeshi.fanli.log.LogHelper; -import com.yeshi.fanli.service.inter.activity.ActivityService; -import com.yeshi.fanli.service.inter.brand.BrandClassShopService; -import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; -import com.yeshi.fanli.service.inter.lable.LabelService; -import com.yeshi.fanli.service.inter.lable.QualityFactoryService; -import com.yeshi.fanli.service.inter.lable.QualityFlashSaleService; -import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService; -import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsActivityService; -import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; -import com.yeshi.fanli.util.CMQManager; -import com.yeshi.fanli.util.Constant; -import com.yeshi.fanli.util.TimeUtil; - -/** - * 娣樺疂鍟嗗搧鏇寸粏 - * - * @author Administrator - * - */ - -@Component -public class UpdateTaoBaoGoodsJob { - - @Resource - private TaoBaoGoodsBriefService taoBaoGoodsBriefService; - - @Resource - private ActivityService activityService; - - @Resource - private QualityFactoryService qualityFactoryService; - - @Resource - private LabelService labelService; - - @Resource - private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; - - @Resource - private QualityFlashSaleService qualityFlashSaleService; - - @Resource - private BrandClassShopService brandClassShopService; - - @Resource - private TaoBaoGoodsActivityService taoBaoGoodsActivityService; - - @Resource - private ShareHotGoodsService shareHotGoodsService; - - // 鍔ㄦ�佸晢鍝佹洿鏂� 锛�1涓皬鏃舵洿鏂� - @Scheduled(cron = "0 0 */1 * * ?") - public void updateActivityGoodsJob() { - if (!Constant.IS_TASK) { - return; - } - - Long count = activityService.getRecommendActivityCount(RecommendActivity.TYPE_SHARE_GOODS); - int pageSize = 50; - int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); - // 鏈�澶氭洿鏂�50椤垫暟鎹� - if (totalPage > 50) - totalPage = 50; - for (int i = 1; i <= totalPage; i++) { - List<RecommendActivity> list = activityService.getRecommendActivityList(RecommendActivity.TYPE_SHARE_GOODS, - i, pageSize); - if (list != null) - for (RecommendActivity activity : list) { - try { - activityService.upgradeShareGoodsRecommendActivity(activity.getId()); - } catch (ActivityException e) { - e.printStackTrace(); - } - } - } - - } - - // 璋冩暣瓒呰繃3涓皬鏃舵湭鏇存柊 鐨勫晢鍝佹潈閲嶅�艰涓�10 - @Scheduled(cron = "0 0 0/3 * * ?") - public void updateQualityFactoryWeightJob() { - if (!Constant.IS_TASK) { - return; - } - - try { - qualityFactoryService.updateWeight(1, 4); - } catch (Exception e) { - LogHelper.errorDetailInfo(e); - } - - } - - // 鍒犻櫎杩囨湡鍟嗗搧璧勬簮(30鍒嗛挓) - @Scheduled(cron = "0 0/30 * * * ? ") - public void deleteOutOfDateTaoBaoGoods() { - if (!Constant.IS_TASK) { - return; - } - taoBaoGoodsUpdateService.deleteOutOfDate(); - } - - /** - * 鏇存柊瓒呰繃4涓皬鏃舵湭鏇存柊鐨勫晢鍝� - */ - // 1涓皬鏃舵洿鏂� - @Scheduled(cron = "0 0 1/1 * * ? ") - public void addNeedUpdateTaoBaoGoods() { - if (!Constant.IS_TASK) - return; - - List<Long> list = taoBaoGoodsUpdateService.listNeedUpdateGoodsId(0, 2000, 4); - if (list == null || list.size() == 0) { - return; - } - - for (Long id : list) { - try { - CMQManager.getInstance().addNeedUpdateTaoBaoGoodsId(id); - } catch (Exception e) { - LogHelper.errorDetailInfo(e); - } - } - } - - /** - * 瀹氭椂娓呯悊瓒呰繃6涓皬鏃舵湭鏇存柊鐨勯檺鏃舵姠璐晢鍝� - */ - @Scheduled(cron = "0 15 0/6 * * ? ") - public void removeFlashSaleGoods() { - if (!Constant.IS_TASK) { - return; - } - - try { - while (true) { - List<Long> list = qualityFlashSaleService.queryNeedRemove(0, 200, 6); - if (list == null || list.size() == 0) { - break; - } - qualityFlashSaleService.deleteBatchByPrimaryKey(list); - } - - } catch (Exception e) { - LogHelper.errorDetailInfo(e); - } - } - - // 鏇存柊鍝佺墝鍟嗗搧锛屾瘡澶╂棭涓�6鐐规墽琛屼竴娆� - @Scheduled(cron = "0 0 6 * * ? ") - public void updateBrandGoods() { - if (!Constant.IS_TASK) - return; - brandClassShopService.updateShopGoods(); - } - - /** - * 姣忓ぉ鍑屾櫒杩�5鍒嗛挓楠岃瘉 - */ - @Scheduled(cron = "0 5 0 * * ?") - public void update618() { - 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()); - if (success) { - count++; - } - } - } - -} +package com.yeshi.fanli.job; + +import com.yeshi.fanli.entity.bus.activity.RecommendActivity; +import com.yeshi.fanli.exception.ActivityException; +import com.yeshi.fanli.log.LogHelper; +import com.yeshi.fanli.service.inter.activity.ActivityService; +import com.yeshi.fanli.service.inter.brand.BrandClassShopGoodsService; +import com.yeshi.fanli.service.inter.brand.BrandClassShopService; +import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; +import com.yeshi.fanli.service.inter.lable.LabelService; +import com.yeshi.fanli.service.inter.lable.QualityFactoryService; +import com.yeshi.fanli.service.inter.lable.QualityFlashSaleService; +import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService; +import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService; +import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsActivityService; +import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; +import com.yeshi.fanli.util.Constant; +import com.yeshi.fanli.util.cache.HttpGoodsCacheManager; +import com.yeshi.fanli.util.mq.rabbit.RabbitmqManager; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 娣樺疂鍟嗗搧鏇寸粏 + * + * @author Administrator + * + */ + +@Component +public class UpdateTaoBaoGoodsJob { + + @Resource + private TaoBaoGoodsBriefService taoBaoGoodsBriefService; + + @Resource + private ActivityService activityService; + + @Resource + private QualityFactoryService qualityFactoryService; + + @Resource + private LabelService labelService; + + @Resource + private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; + + @Resource + private QualityFlashSaleService qualityFlashSaleService; + + @Resource + private BrandClassShopService brandClassShopService; + + @Resource + private TaoBaoGoodsActivityService taoBaoGoodsActivityService; + + @Resource + private ShareHotGoodsService shareHotGoodsService; + + @Resource + private TLJBuyGoodsService tljBuyGoodsService; + + @Resource + private BrandClassShopGoodsService brandClassShopGoodsService; + + @Resource + private HttpGoodsCacheManager httpGoodsCacheManager; + + @Resource + private RabbitmqManager rabbitmqManager; + + // 鍔ㄦ�佸晢鍝佹洿鏂� 锛�1涓皬鏃舵洿鏂� + @Scheduled(cron = "0 0 */1 * * ?") + public void updateActivityGoodsJob() { + if (!Constant.IS_TASK) { + return; + } + + Long count = activityService.getRecommendActivityCount(RecommendActivity.TYPE_SHARE_GOODS); + int pageSize = 50; + int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); + // 鏈�澶氭洿鏂�50椤垫暟鎹� + if (totalPage > 50) + totalPage = 50; + for (int i = 1; i <= totalPage; i++) { + List<RecommendActivity> list = activityService.getRecommendActivityList(RecommendActivity.TYPE_SHARE_GOODS, + i, pageSize); + if (list != null) + for (RecommendActivity activity : list) { + try { + activityService.upgradeShareGoodsRecommendActivity(activity.getId()); + } catch (ActivityException e) { + e.printStackTrace(); + } + } + } + + } + + // 璋冩暣瓒呰繃3涓皬鏃舵湭鏇存柊 鐨勫晢鍝佹潈閲嶅�艰涓�10 + @Scheduled(cron = "0 0 0/3 * * ?") + public void updateQualityFactoryWeightJob() { + if (!Constant.IS_TASK) { + return; + } + + try { + qualityFactoryService.updateWeight(1, 4); + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + + } + + // 鍒犻櫎杩囨湡鍟嗗搧璧勬簮(30鍒嗛挓) + @Scheduled(cron = "0 0/30 * * * ? ") + public void deleteOutOfDateTaoBaoGoods() { + if (!Constant.IS_TASK) { + return; + } + taoBaoGoodsUpdateService.deleteOutOfDate(); + } + + /** + * 鏇存柊瓒呰繃4涓皬鏃舵湭鏇存柊鐨勫晢鍝� + */ + // 1涓皬鏃舵洿鏂� + @Scheduled(cron = "0 0 1/1 * * ? ") + public void addNeedUpdateTaoBaoGoods() { + if (!Constant.IS_TASK) + return; + + List<String> list = taoBaoGoodsUpdateService.listNeedUpdateGoodsId(0, 2000, 4); + if (list == null || list.size() == 0) { + return; + } + + for (String id : list) { + try { + rabbitmqManager.addNeedUpdateTaoBaoGoodsId(id); + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + } + } + + /** + * 瀹氭椂娓呯悊瓒呰繃6涓皬鏃舵湭鏇存柊鐨勯檺鏃舵姠璐晢鍝� + */ + @Scheduled(cron = "0 15 0/6 * * ? ") + public void removeFlashSaleGoods() { + if (!Constant.IS_TASK) { + return; + } + + try { + while (true) { + List<Long> list = qualityFlashSaleService.queryNeedRemove(0, 200, 6); + if (list == null || list.size() == 0) { + break; + } + qualityFlashSaleService.deleteBatchByPrimaryKey(list); + } + + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + } + + // 鏇存柊澧炲姞鍝佺墝鍟嗗搧锛屾瘡澶╂棭涓�6鐐规墽琛屼竴娆� + @Scheduled(cron = "0 0 6 * * ? ") + public void updateAddBrandGoods() { + if (!Constant.IS_TASK) + return; + brandClassShopService.updateShopGoods(); + } + + // 鏇存柊鍘熸湁绮惧搧搴撶殑鍝佺墝鍟嗗搧锛屾瘡澶╁噷鏅�3鐐规墽琛屼竴娆� + @Scheduled(cron = "0 0 3 * * ? ") + public void updateBrandGoods() { + if (!Constant.IS_TASK) + return; + brandClassShopGoodsService.startUpdateGoods(); + } + + // 姣忓ぉ鍑屾櫒4鐐规ā鎷熻姹� + @Scheduled(cron = "0 0 4 * * ? ") + public void simulateRequest() { + httpGoodsCacheManager.requestHomeRecommend(); + httpGoodsCacheManager.requestClassGoods(); + httpGoodsCacheManager.requestBrandGoods(); + httpGoodsCacheManager.requestDynamic(); + httpGoodsCacheManager.requestCommonTemplate(); + } +} -- Gitblit v1.8.0