From 0588d6be74335f41c79a8d8e32dbd1c3d3e47fa3 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期三, 29 五月 2019 17:20:50 +0800
Subject: [PATCH] 精选库商品入库及更新调整 + 9k9类商品查询取消标签查询

---
 fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java |  214 +++++++----------------------------------------------
 1 files changed, 28 insertions(+), 186 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java b/fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java
index 759b35e..33171dc 100644
--- a/fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java
+++ b/fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java
@@ -21,6 +21,7 @@
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
 import com.yeshi.fanli.log.LogHelper;
+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.taobao.TaoBaoGoodsUpdateService;
@@ -52,6 +53,9 @@
 	private QualityFactoryService qualityFactoryService;
 	@Resource
 	private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
+	@Resource
+	private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
+	
 
 	public QualityFactoryJob() {
 		System.out.println("--UpdateQualityFactoryJob 鏋勯�犲嚱鏁�--");
@@ -164,8 +168,7 @@
 	 */
 	private void searchTaoBao(JSONObject jsonData, List<Label> listLabs, BoutiqueAutoRule autoRule) {
 		try {
-			Date time = new Date();
-			String formatDate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(time);
+			String formatDate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date());
 
 			// 椤靛ぇ灏忥紝榛樿100鏉�
 			int pageSize = 100;
@@ -224,13 +227,11 @@
 				autoRule.setStartWeight(startWeight);
 				autoRule.setEndWeight(endWeight);
 
-				/* 绛涢�夊晢鍝佽繘鍏ョ簿閫夊簱涓� */
-				if (!StringUtil.isNullOrEmpty(title) && title.contains(IS_9K9)) {
-					screen9K9(filter, listGoods, jsonData, listLabs, autoRule);
-				} else {
-					screen(listGoods, jsonData, filter, listLabs, autoRule);
-				}
+				// 绛涢�夊叆搴�
+				screen(listGoods, jsonData, filter, listLabs, autoRule);
 
+				
+				
 				/* 閿�鍞噺灏忓�� */
 				int minSales = 0;
 				if (jsonData.get("startSales") != null) {
@@ -280,7 +281,7 @@
 			/* 鏇存柊瀹屾垚鍚庢竻鐞嗕箣鍓嶅垱寤虹殑鏁版嵁 */
 			if (jsonData.get("systemCid") != null && !StringUtil.isNullOrEmpty(jsonData.get("systemCid").toString())) {
 				Long systemCid = Long.parseLong(jsonData.get("systemCid").toString());
-				deleteNotUpdateGoods(systemCid, formatDate, autoRule.getGoodsSource());
+				qualityFactoryService.deleteNotUpdateGoods(systemCid, formatDate, autoRule.getGoodsSource());
 			}
 
 		} catch (Exception e) {
@@ -301,11 +302,11 @@
 	private void searchMaterial(JSONObject jsonData, List<Label> listLabs, BoutiqueAutoRule autoRule) {
 
 		try {
+			String formatDate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date());
+
 			// 榛樿20鏉�
 			int pageSize = 20;
-
 			boolean isCrawl = true;
-
 			// 鏉冮噸璧峰
 			int startWeight = 1000;
 			// 鏉冮噸缁撴潫
@@ -354,12 +355,9 @@
 					return;
 				}
 
-				/* 绛涢�夊晢鍝佽繘鍏ョ簿閫夊簱涓� */
-				if (!StringUtil.isNullOrEmpty(title) && title.contains(IS_9K9)) {
-					screen9K9(filter, listGoods, jsonData, listLabs, autoRule);
-				} else {
-					screen(listGoods, jsonData, filter, listLabs, autoRule);
-				}
+				// 绛涢�夊叆搴�
+				screen(listGoods, jsonData, filter, listLabs, autoRule);
+				
 
 				// 鎬婚〉鏁扮埇鍙栧畬鎴�
 				PageEntity pageEntity = result.getPageEntity();
@@ -374,6 +372,17 @@
 					LogHelper.test("----" + title + "--缁撴潫-------");
 					break;// 缁撴潫鐖彇鏁版嵁
 				}
+			}
+			
+			// 9k9 闄愭椂鎶㈣喘 涓嶆搷浣滃垹闄�
+			if (!StringUtil.isNullOrEmpty(title) && (title.contains(IS_9K9) || title.contains(FLASH_SALE))) {
+				return;
+			}
+
+			/* 鏇存柊瀹屾垚鍚庢竻鐞嗕箣鍓嶅垱寤虹殑鏁版嵁 */
+			if (jsonData.get("systemCid") != null && !StringUtil.isNullOrEmpty(jsonData.get("systemCid").toString())) {
+				Long systemCid = Long.parseLong(jsonData.get("systemCid").toString());
+				qualityFactoryService.deleteNotUpdateGoods(systemCid, formatDate, autoRule.getGoodsSource());
 			}
 
 		} catch (Exception e) {
@@ -484,125 +493,7 @@
 		return filter;
 	}
 
-	/**
-	 * 9.9 19.9 29.9 39.9 鍟嗗搧绛涢��
-	 * 
-	 * @param taoBaoGoodsBriefs
-	 */
-	public void screen9K9(SearchFilter filter, List<TaoBaoGoodsBrief> taoBaoGoodsBriefs, JSONObject jsonData,
-			List<Label> listLabs, BoutiqueAutoRule autoRule) throws Exception {
-
-		/* 9k9 */
-		BigDecimal price9k9 = new BigDecimal(10);
-		List<TaoBaoGoodsBrief> list9k9 = new ArrayList<TaoBaoGoodsBrief>();
-
-		/* 19k9 */
-		BigDecimal price19k9 = new BigDecimal(20);
-		List<TaoBaoGoodsBrief> list19k9 = new ArrayList<TaoBaoGoodsBrief>();
-
-		/* 29.9 */
-		BigDecimal price29K9 = new BigDecimal(30);
-		List<TaoBaoGoodsBrief> list29k9 = new ArrayList<TaoBaoGoodsBrief>();
-
-		/* 49.9 */
-		BigDecimal price49K9 = new BigDecimal(50);
-		List<TaoBaoGoodsBrief> list49k9 = new ArrayList<TaoBaoGoodsBrief>();
-
-		/* 閿�鍞噺灏忓�� */
-		int minSales = 0;
-		if (jsonData.get("startSales") != null) {
-			minSales = (int) jsonData.get("startSales");
-		}
-
-		/* 閿�鍞噺澶у�� */
-		int maxSales = 0;
-		if (jsonData.get("endSales") != null) {
-			maxSales = (int) jsonData.get("endSales");
-		}
-
-		// 楠岃瘉鏄惁绗﹀悎瑕佹眰鍏ュ簱
-		for (TaoBaoGoodsBrief goodsBrief : taoBaoGoodsBriefs) {
-
-			/* 楠岃瘉鍦ㄦ槸鍚︽湁鍒� */
-			if (filter.getQuan() > 0) {
-				String couponInfo = goodsBrief.getCouponInfo();
-				if (StringUtil.isNullOrEmpty(couponInfo)) {
-					continue;
-				}
-			}
-
-			/* 楠岃瘉閿�鍞噺 */
-			int biz30day = goodsBrief.getBiz30day();
-			if (maxSales > 0 && minSales > 0 && (biz30day < minSales || biz30day > maxSales)) {
-				continue;
-			} else if (maxSales > 0 && biz30day > maxSales) {
-				continue;
-			} else if (minSales > 0 && biz30day < minSales) {
-				continue;
-			}
-
-			/* 楠岃瘉姣斾緥 */
-			if (BoutiqueAutoRule.TB_MATERIAL == autoRule.getSource()) {
-				int startTkRate = filter.getStartTkRate();
-				int endTkRate = filter.getEndTkRate();
-				BigDecimal tkRate = goodsBrief.getTkRate();
-				if (startTkRate > 0 && endTkRate > 0 && (tkRate.compareTo(new BigDecimal(startTkRate / 100)) < 0
-						|| tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0)) {
-					continue;
-				} else if (endTkRate > 0 && tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0) {
-					continue;
-				} else if (startTkRate > 0 && tkRate.compareTo(new BigDecimal(startTkRate / 100)) < 0) {
-					continue;
-				}
-			}
-
-			/* 鍒稿悗浠�--璁$畻 */
-			BigDecimal couponPrice = TaoBaoUtil.getAfterUseCouplePrice(goodsBrief);
-			if (couponPrice.compareTo(price9k9) < 0) {
-				list9k9.add(goodsBrief);
-			} else if (couponPrice.compareTo(price19k9) < 0) {
-				list19k9.add(goodsBrief);
-			} else if (couponPrice.compareTo(price29K9) < 0) {
-				list29k9.add(goodsBrief);
-			} else if (couponPrice.compareTo(price49K9) < 0) {
-				list49k9.add(goodsBrief);
-			}
-		}
-		autoRule.setCalss9k9(true);
-		AdminUser admin = autoRule.getAdminUser();
-
-		if (list9k9.size() > 0) {
-			Label label = labelService.getByTitleCache("labKey", "9.9");
-			if (label == null) {
-				label = insertLabel("9.9", admin);
-			}
-			qualityFactoryService.autoInsertOrUpadateStorage(autoRule, list9k9, listLabs, label);
-		}
-
-		if (list19k9.size() > 0) {
-			Label label = labelService.getByTitleCache("labKey", "19.9");
-			if (label == null) {
-				label = insertLabel("9.9", admin);
-			}
-			qualityFactoryService.autoInsertOrUpadateStorage(autoRule, list19k9, listLabs, label);
-		}
-
-		if (list29k9.size() > 0) {
-			Label label = labelService.getByTitleCache("labKey", "29.9");
-			if (label == null) {
-				label = insertLabel("9.9", admin);
-			}
-			qualityFactoryService.autoInsertOrUpadateStorage(autoRule, list29k9, listLabs, label);
-		}
-
-		if (list49k9.size() > 0) {
-			Label label = labelService.getByTitleCache("labKey", "49.9");
-			if (label == null) {
-				label = insertLabel("9.9", admin);
-			}
-			qualityFactoryService.autoInsertOrUpadateStorage(autoRule, list49k9, listLabs, label);
-		}
-	}
+	
 
 	/**
 	 * 绛涢�夌鍚堟潯浠剁殑鍟嗗搧
@@ -616,7 +507,6 @@
 	 */
 	public void screen(List<TaoBaoGoodsBrief> taoBaoGoodsBriefs, JSONObject jsonData, SearchFilter filter,
 			List<Label> listLabs, BoutiqueAutoRule autoRule) throws Exception {
-
 		List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>();
 		for (TaoBaoGoodsBrief goodsBrief : taoBaoGoodsBriefs) {
 			// 楠岃瘉鏄惁绗﹀悎瑕佹眰
@@ -624,11 +514,7 @@
 				listGoods.add(goodsBrief);
 			}
 		}
-
-		if (listGoods.size() > 0) {
-			autoRule.setCalss9k9(false);
-			qualityFactoryService.autoInsertOrUpadateStorage(autoRule, listGoods, listLabs, null);
-		}
+		qualityFactoryService.autoInsertOrUpadateStorage(autoRule, listGoods, listLabs);
 	}
 
 	/**
@@ -736,48 +622,4 @@
 		return label;
 	}
 
-	/**
-	 * 鍒犻櫎鏈洿鏂扮殑鍟嗗搧
-	 * 
-	 * @param systemCid
-	 * @param formatDate
-	 * @param source
-	 */
-	public void deleteNotUpdateGoods(Long systemCid, String formatDate, int source) {
-		List<Long> list = qualityFactoryService.getAuctionIdbyClassId(systemCid, source, formatDate);
-		if (list == null || list.size() == 0) {
-			return;
-		}
-
-		// 灏忎簬100鏉$洿鎺ュ垹闄�
-		if (list.size() <= 100) {
-			qualityFactoryService.deleteBatchByTaoBaoGoodsId(list);
-			return;
-		} 
-		
-		
-		// 澶т簬100闇�瑕佸垎娈靛垹闄�
-		int start = 0;
-		int end = 100;
-		int countRow = 100;
-
-		int count = list.size() / countRow;
-		if (list.size() % countRow > 0) {
-			count += 1;
-		}
-
-		for (int i = 0; i < count; i++) {
-			List<Long> sublist = new ArrayList<Long>();
-			if (i == count - 1) {
-				sublist = list.subList(start, list.size());
-				qualityFactoryService.deleteBatchByTaoBaoGoodsId(sublist);
-				break;
-			}
-			sublist = list.subList(start, end);
-			qualityFactoryService.deleteBatchByTaoBaoGoodsId(sublist);
-			start += countRow;
-			end += countRow;
-		}
-
-	}
 }

--
Gitblit v1.8.0