From 28cf328a098334b51a3e9d2d56f983fb8c862211 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期六, 23 五月 2020 09:54:38 +0800 Subject: [PATCH] 足迹、收藏订单兼容新需求 --- fanli/src/main/java/com/yeshi/fanli/job/order/taobao/UpdateTBRelationAndSpecialOrderJob.java | 101 ++++++++++++++++++++++++++------------------------ 1 files changed, 52 insertions(+), 49 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/job/order/taobao/UpdateTBRelationAndSpecialOrderJob.java b/fanli/src/main/java/com/yeshi/fanli/job/order/taobao/UpdateTBRelationAndSpecialOrderJob.java index dc8dc42..d698ad6 100644 --- a/fanli/src/main/java/com/yeshi/fanli/job/order/taobao/UpdateTBRelationAndSpecialOrderJob.java +++ b/fanli/src/main/java/com/yeshi/fanli/job/order/taobao/UpdateTBRelationAndSpecialOrderJob.java @@ -1,23 +1,26 @@ package com.yeshi.fanli.job.order.taobao; +import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.annotation.Resource; -import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; import com.yeshi.fanli.entity.taobao.TaoBaoOrder; import com.yeshi.fanli.log.LogHelper; -import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService; +import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService; import com.yeshi.fanli.util.CMQManager; -import com.yeshi.fanli.util.Constant; +import com.yeshi.fanli.util.RedisKeyEnum; import com.yeshi.fanli.util.RedisManager; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil; +import com.yeshi.fanli.util.taobao.TaoKeApiUtil; import com.yeshi.fanli.util.taobao.TaoKeOrderApiUtil; /** @@ -44,42 +47,49 @@ * 缁撴潫椤电爜锛堟瘡椤�100鏉℃暟鎹級 */ public void updateRelationAndSpecialOrder(long startTime, long endTime) { - List<TaoBaoOrder> list = TaoKeOrderApiUtil.getSpecialOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_ALL); - List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getThirdSpecialOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_ALL); - List<TaoBaoOrder> list2 = TaoKeOrderApiUtil.getRelationOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_ALL); - List<TaoBaoOrder> list3 = TaoKeOrderApiUtil.getThirdRelationOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_ALL); + List<TaoBaoOrder> list = TaoKeOrderApiUtil.getTaoBaoSpecialOrderList(startTime, endTime, 1); + List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getTaoBaoRelationOrderList(startTime, endTime, 1); if (list1 != null && list1.size() > 0) list.addAll(list1); - if (list2 != null && list2.size() > 0) - list.addAll(list2); - if (list3 != null && list3.size() > 0) - list.addAll(list3); // 鐖彇鍒扮殑璁㈠崟鍙� if (list != null) for (TaoBaoOrder order : list) { - LogHelper.orderInfo("鐖彇鍒扮殑璁㈠崟鍙�:" + order.getOrderId()); + LogHelper.orderInfo("浼氬憳/娓犻亾鐖彇鍒扮殑璁㈠崟鍙�:" + order.getOrderId()); } addRelationAndSpecialOrder(list); } - - public void updateRelationAndSpecialSettleOrder(long startTime, long endTime) { - List<TaoBaoOrder> list = TaoKeOrderApiUtil.getSpecialOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_SETTLEMENT); - List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getThirdSpecialOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_SETTLEMENT); - List<TaoBaoOrder> list2 = TaoKeOrderApiUtil.getRelationOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_SETTLEMENT); - List<TaoBaoOrder> list3 = TaoKeOrderApiUtil.getThirdRelationOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_SETTLEMENT); + + /** + * 鎸変粯娆炬椂闂存煡璇� + * + * @param startTime + * @param endTime + */ + public void updateRelationAndSpecialPaidOrder(long startTime, long endTime) { + List<TaoBaoOrder> list = TaoKeOrderApiUtil.getTaoBaoSpecialOrderList(startTime, endTime, 2); + List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getTaoBaoRelationOrderList(startTime, endTime, 2); if (list1 != null && list1.size() > 0) list.addAll(list1); - if (list2 != null && list2.size() > 0) - list.addAll(list2); - if (list3 != null && list3.size() > 0) - list.addAll(list3); // 鐖彇鍒扮殑璁㈠崟鍙� if (list != null) for (TaoBaoOrder order : list) { - LogHelper.orderInfo("鐖彇鍒扮殑璁㈠崟鍙�:" + order.getOrderId()); + LogHelper.orderInfo("浼氬憳/娓犻亾鐖彇鍒扮殑璁㈠崟鍙�:" + order.getOrderId()); } + addRelationAndSpecialOrder(list); + } + + public void updateRelationAndSpecialSettleOrder(long startTime, long endTime) { + List<TaoBaoOrder> list = TaoKeOrderApiUtil.getTaoBaoSpecialOrderList(startTime, endTime, 3); + List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getTaoBaoRelationOrderList(startTime, endTime, 3); + if (list1 != null && list1.size() > 0) + list.addAll(list1); + // 鐖彇鍒扮殑璁㈠崟鍙� + if (list != null) + for (TaoBaoOrder order : list) { + LogHelper.orderInfo("浼氬憳/娓犻亾鐖彇鍒扮殑璁㈠崟鍙�:" + order.getOrderId()); + } addRelationAndSpecialOrder(list); } @@ -97,7 +107,8 @@ while (its.hasNext()) { String key = its.next(); List<TaoBaoOrder> orders = map.get(key); - String redisKey = "addorderqueue-" + TaoBaoOrderUtil.getOrderDataHashCode(orders);; + String redisKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.addOrderQueue, + TaoBaoOrderUtil.getOrderDataHashCode(orders)); // redis鍋氶鐜囬檺鍒� try { if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(redisKey))) { @@ -129,40 +140,32 @@ } } + @XxlJob("updateTBRelationAndSpecialOrderHandler") + public ReturnT<String> updateTBRelationAndSpecialOrder(String param) throws Exception { + if ("1".equalsIgnoreCase(param)) {// 鐖彇杩�20鍒嗛挓鐨勬暟鎹� + doJob1(); + } else if ("1day".equalsIgnoreCase(param)) {// 姣�5鍒嗛挓鏇存柊锛堣繎1澶╂暟鎹級 + doJob2(); + } + return ReturnT.SUCCESS; + } + // 姣�30s鐖彇涓�娆� - @Scheduled(cron = "0/30 * * * * ? ") public void doJob1() { - if (!Constant.IS_TASK) - return; - // 鐖彇杩�20鍒嗛挓鐨勬暟鎹� - LogHelper.orderInfo("鐖崟:30s鐖彇涓�娆″崟"); - long endTime = System.currentTimeMillis(); + LogHelper.job("鐖崟:30s鐖彇涓�娆″崟"); + Date systemDate = TaoKeApiUtil.getTaoBaoSystemTime(); + long endTime = systemDate != null ? systemDate.getTime() : System.currentTimeMillis(); updateRelationAndSpecialOrder(endTime - 1000 * 60 * 20L, endTime); + updateRelationAndSpecialPaidOrder(endTime - 1000 * 60 * 20L, endTime); updateRelationAndSpecialSettleOrder(endTime - 1000 * 60 * 20L, endTime); } // 姣�5鍒嗛挓鏇存柊锛堣繎1澶╂暟鎹級 - @Scheduled(cron = "0 0/5 * * * ? ") public void doJob2() { - if (!Constant.IS_TASK) - return; - long endTime = System.currentTimeMillis(); + LogHelper.job("鐖崟:5min鐖彇涓�娆″崟"); + Date systemDate = TaoKeApiUtil.getTaoBaoSystemTime(); + long endTime = systemDate != null ? systemDate.getTime() : System.currentTimeMillis(); updateRelationAndSpecialOrder(endTime - 1000 * 60 * 60 * 24L, endTime); updateRelationAndSpecialSettleOrder(endTime - 1000 * 60 * 60 * 24L, endTime); } - - // 姣忎釜灏忔椂鏇存柊 - @Scheduled(cron = "0 0 0/1 * * ? ") - public void doJob3() { - if (!Constant.IS_TASK) - return; - // Calendar calendar = Calendar.getInstance(); - // int h = calendar.get(Calendar.HOUR_OF_DAY); - // // 姣忎釜灏忔椂鏇存柊100椤垫暟鎹� - // int fromPage = h * 100; - // if (fromPage <= 0) - // fromPage = 11; - // int toPage = h * 100 + 100; - } - } -- Gitblit v1.8.0