From cdcbed9af813b2a02cdc01eefa24db8bec6b51a9 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期三, 27 三月 2019 12:17:33 +0800
Subject: [PATCH] 主分类 + 子分类 DAO改造

---
 fanli/src/main/java/com/yeshi/fanli/job/UpdateOrderJob.java |  172 ++++++++++++++-------------------------------------------
 1 files changed, 43 insertions(+), 129 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/job/UpdateOrderJob.java b/fanli/src/main/java/com/yeshi/fanli/job/UpdateOrderJob.java
index 5b0d224..9798bbb 100644
--- a/fanli/src/main/java/com/yeshi/fanli/job/UpdateOrderJob.java
+++ b/fanli/src/main/java/com/yeshi/fanli/job/UpdateOrderJob.java
@@ -11,22 +11,16 @@
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
-import com.taobao.api.TaobaoObject;
 import com.yeshi.fanli.entity.bus.user.Order;
 import com.yeshi.fanli.entity.taobao.PidUser;
 import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
 import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
 import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
-import com.yeshi.fanli.exception.TaoBaoOrderException;
 import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.common.DataMonitorService;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
-import com.yeshi.fanli.service.inter.hongbao.ThreeSaleGiftService;
 import com.yeshi.fanli.service.inter.order.LostOrderService;
-import com.yeshi.fanli.service.inter.order.OrderItemServcie;
 import com.yeshi.fanli.service.inter.order.OrderProcessService;
 import com.yeshi.fanli.service.inter.order.OrderService;
-import com.yeshi.fanli.service.inter.order.PidOrderService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoWeiQuanOrderService;
@@ -35,7 +29,6 @@
 import com.yeshi.fanli.util.RedisManager;
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.TimeUtil;
-import com.yeshi.fanli.util.taobao.TaoBao110Util;
 import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
 import com.yeshi.fanli.util.taobao.TaoKeOrderApiUtil;
 
@@ -46,18 +39,6 @@
 	public UpdateOrderJob() {
 		System.out.println("鍒濆鍖�:UpdateOrderJob");
 	}
-
-	@Resource
-	private OrderItemServcie orderItemServcie;
-
-	@Resource
-	private ThreeSaleGiftService threeSaleGiftService;
-
-	@Resource
-	private HongBaoService hongBaoService;
-
-	@Resource
-	private PidOrderService pidOrderService;
 
 	@Resource
 	private OrderProcessService orderProcessService;
@@ -107,9 +88,10 @@
 		}
 		return orderList;
 	}
-	
+
 	/**
 	 * 鑾峰彇绗笁鏂规櫘閫氳鍗�
+	 * 
 	 * @param startTime
 	 * @param span
 	 * @return
@@ -131,13 +113,14 @@
 
 	/**
 	 * 鑾峰彇鏌愪釜鍖洪棿娈电殑璁㈠崟
+	 * 
 	 * @param startTime
 	 * @param endTime
 	 * @return
 	 */
 	public static List<TaoBaoOrder> getCommonOrder(long startTime, long endTime) {
 		List<TaoBaoOrder> orderList = new ArrayList<>();
-		long span =(endTime - startTime)%1000==0? (endTime - startTime)/1000:(endTime - startTime)/1000+1;
+		long span = (endTime - startTime) % 1000 == 0 ? (endTime - startTime) / 1000 : (endTime - startTime) / 1000 + 1;
 		int count = (int) (span / 1200);
 		if (span % 1200 != 0)
 			count++;
@@ -155,17 +138,17 @@
 		}
 		return orderList;
 	}
-	
-	
+
 	/**
 	 * 鐖彇涓夋柟璁㈠崟
+	 * 
 	 * @param startTime
 	 * @param endTime
 	 * @return
 	 */
 	public static List<TaoBaoOrder> getThirdCommonOrder(long startTime, long endTime) {
 		List<TaoBaoOrder> orderList = new ArrayList<>();
-		long span =(endTime - startTime)%1000==0? (endTime - startTime)/1000:(endTime - startTime)/1000+1;
+		long span = (endTime - startTime) % 1000 == 0 ? (endTime - startTime) / 1000 : (endTime - startTime) / 1000 + 1;
 		int count = (int) (span / 1200);
 		if (span % 1200 != 0)
 			count++;
@@ -202,29 +185,38 @@
 	}
 
 	public void updateOrder(long startTime, long endTime) {
-		List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
-		List<TaoBaoOrder> orderList = new ArrayList<>();
-		try {
-			orderList = TaoBaoOrderUtil.getOrderList(startTime, endTime, configList.get(0));
-		} catch (TaoBaoOrderException e2) {
-			try {
-				LogHelper.errorDetailInfo(e2);
-			} catch (Exception e) {
-				e.printStackTrace();
-			}
-		}
-		List<TaoBaoOrder> thirdOrderList = new ArrayList<>();
-		try {
-			thirdOrderList = TaoBaoOrderUtil.getThirdServiceOrderList(startTime, endTime, configList.get(0));
-		} catch (TaoBaoOrderException e2) {
-			try {
-				LogHelper.errorDetailInfo(e2);
-			} catch (Exception e) {
-				e.printStackTrace();
-			}
-		}
-		if (thirdOrderList != null && thirdOrderList.size() > 0)
-			orderList.addAll(thirdOrderList);
+		// 鑰佺増鏈鐞嗘柟寮�
+		// List<TaoBaoUnionConfig> configList =
+		// taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
+		// List<TaoBaoOrder> orderList = new ArrayList<>();
+		// try {
+		// orderList = TaoBaoOrderUtil.getOrderList(startTime, endTime,
+		// configList.get(0));
+		// } catch (TaoBaoOrderException e2) {
+		// try {
+		// LogHelper.errorDetailInfo(e2);
+		// } catch (Exception e) {
+		// e.printStackTrace();
+		// }
+		// }
+		// List<TaoBaoOrder> thirdOrderList = new ArrayList<>();
+		// try {
+		// thirdOrderList = TaoBaoOrderUtil.getThirdServiceOrderList(startTime,
+		// endTime, configList.get(0));
+		// } catch (TaoBaoOrderException e2) {
+		// try {
+		// LogHelper.errorDetailInfo(e2);
+		// } catch (Exception e) {
+		// e.printStackTrace();
+		// }
+		// }
+		// if (thirdOrderList != null && thirdOrderList.size() > 0)
+		// orderList.addAll(thirdOrderList);
+		// 鏂扮増鏈鐞嗘柟寮�
+		List<TaoBaoOrder> orderList = getCommonOrder(startTime, endTime);
+		List<TaoBaoOrder> tempOrderList2 = getThirdCommonOrder(startTime, endTime);
+		if (tempOrderList2 != null && tempOrderList2.size() > 0)
+			orderList.addAll(tempOrderList2);
 
 		LogHelper.orderInfo("姝e湪鎵ц璁㈠崟鐖彇缁撴潫锛屽叡鏈夎鍗�:" + orderList.size());
 		addOrder(orderList);
@@ -269,54 +261,6 @@
 		}
 
 		return orderList;
-	}
-
-	private void addRelationAndSpecialOrder(List<TaoBaoOrder> orderList) {
-		try {
-			taoBaoOrderService.addTaoBaoOrderList(orderList);
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
-
-		try {
-			Map<String, List<TaoBaoOrder>> map = TaoBaoOrderUtil.classifyTaoBaoOrderByOrderId(orderList);
-			if (map != null) {
-				Iterator<String> its = map.keySet().iterator();
-				while (its.hasNext()) {
-					String key = its.next();
-					List<TaoBaoOrder> orders = map.get(key);
-					String redisKey = "addorderqueue-" + key;
-					// redis鍋氶鐜囬檺鍒�
-					try {
-						if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(redisKey))) {
-							continue;
-						}
-
-					} catch (Exception e) {
-
-					}
-
-					CMQManager.getInstance().addTaoBaoOrderMsg(key, orders);
-
-					try {
-						// 6灏忔椂鍐呬笉鍐嶅鐞�
-						redisManager.cacheCommonString(redisKey, "1", 60 * 60 * 6);
-					} catch (Exception e) {
-
-					}
-				}
-			}
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
 	}
 
 	private void addOrder(List<TaoBaoOrder> orderList) {
@@ -395,7 +339,7 @@
 	public void doJob1() {
 		if (!Constant.IS_TASK)
 			return;
-		long currentTime = System.currentTimeMillis();
+		long currentTime = System.currentTimeMillis() - 1000 * 60;
 		String h = TimeUtil.getGernalTime(currentTime, "HH");
 		String m = TimeUtil.getGernalTime(currentTime, "mm");
 		int mm = Integer.parseInt(h) * 60 + Integer.parseInt(m);
@@ -414,39 +358,9 @@
 	public void doJob6() {
 		if (!Constant.IS_TASK)
 			return;
-		List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
-		LogHelper.orderInfo("姝e湪鎵ц璁㈠崟鐖彇...");
-		// 鐖彇1鍒嗛挓浠ュ墠鐨�
-		long endTime = System.currentTimeMillis() - 1000 * 60 * 1L;
-		List<TaoBaoOrder> orderList = new ArrayList<TaoBaoOrder>();
-		try {
-			orderList = TaoBaoOrderUtil.getOrderList(endTime - 1000 * 60 * 60 * 24 * 2L, endTime, configList.get(0));
-			TaoBao110Util.rightTaoBaoOrderWarning();
-		} catch (TaoBaoOrderException e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-				TaoBao110Util.reportTaoBaoOrderWarning(e.getCode(), e.getMessage());
-			} catch (Exception e2) {
-				e2.printStackTrace();
-			}
-		}
-		List<TaoBaoOrder> thirdOrderList = new ArrayList<>();
-		try {
-			thirdOrderList = TaoBaoOrderUtil.getThirdServiceOrderList(endTime - 1000 * 60 * 60 * 24 * 2L, endTime,
-					configList.get(0));
-		} catch (TaoBaoOrderException e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e2) {
-				e2.printStackTrace();
-			}
-		}
-		if (thirdOrderList != null && thirdOrderList.size() > 0)
-			orderList.addAll(thirdOrderList);
-		if (orderList != null && orderList.size() > 0)
-			dataMonitorService.parseTaoBaoOrderSuccess();
-		LogHelper.orderInfo("姝e湪鎵ц璁㈠崟鐖彇缁撴潫锛屽叡鏈夎鍗�:" + orderList.size());
-		addOrder(orderList);
+		long endTime = System.currentTimeMillis() - 1000 * 60;
+		;
+		updateOrder(endTime - 1000 * 60 * 20L, endTime);
 	}
 
 	// 杩斿埄

--
Gitblit v1.8.0