From 8cb7ec4a35a38ae91d0eed17cde711e81d2b2bbf Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期二, 14 五月 2019 11:37:49 +0800
Subject: [PATCH] 合并

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java |  120 ++++++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 76 insertions(+), 44 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java
index 05cfc92..c0e0e5c 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java
@@ -3,16 +3,13 @@
 import java.io.PrintWriter;
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import javax.annotation.Resource;
-
-import net.sf.ehcache.Element;
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
 
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Controller;
@@ -26,10 +23,9 @@
 import com.yeshi.fanli.entity.accept.AcceptData;
 import com.yeshi.fanli.entity.bus.lable.QualityFactory;
 import com.yeshi.fanli.entity.bus.recommend.Honest;
-import com.yeshi.fanli.entity.bus.search.HistorySearch;
 import com.yeshi.fanli.entity.bus.search.HotSearch;
 import com.yeshi.fanli.entity.bus.su.search.SuperHotSearch;
-import com.yeshi.fanli.entity.system.System;
+import com.yeshi.fanli.entity.system.BusinessSystem;
 import com.yeshi.fanli.entity.taobao.PidUser;
 import com.yeshi.fanli.entity.taobao.SearchFilter;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -38,27 +34,37 @@
 import com.yeshi.fanli.entity.taobao.TaoBaoSearchNav;
 import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
 import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
+import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
+import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
+import com.yeshi.fanli.service.inter.config.BusinessSystemService;
 import com.yeshi.fanli.service.inter.config.ConfigService;
 import com.yeshi.fanli.service.inter.config.SuperHotSearchService;
-import com.yeshi.fanli.service.inter.config.SystemService;
-import com.yeshi.fanli.service.inter.goods.HonestService;
 import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
 import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
 import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
+import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
 import com.yeshi.fanli.service.inter.user.HistorySearchService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.EhcacheUtil;
 import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.ThreadUtil;
+import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
+import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
 import com.yeshi.fanli.util.taobao.SearchFilterUtil;
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
+import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
+
+import net.sf.ehcache.Element;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
 
 @Controller
 @RequestMapping("api/v1/search")
 public class SearchController {
 
 	@Resource
-	private SystemService systemService;
+	private BusinessSystemService businessSystemService;
 
 	@Resource
 	private ConfigService configService;
@@ -73,9 +79,6 @@
 	private HongBaoManageService manageService;
 
 	@Resource
-	private HonestService honestService;
-
-	@Resource
 	private TaoBaoUnionConfigService taoBaoUnionConfigService;
 
 	@Resource
@@ -84,9 +87,16 @@
 	@Resource
 	private QualityGoodsService qualityGoodsService;
 
+	@Resource
+	private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
+
+	@Resource
+	private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
+
 	@RequestMapping(value = "gethotsearch", method = RequestMethod.POST)
 	public void getHotSearch(AcceptData acceptData, PrintWriter out) {
-		System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -100,7 +110,8 @@
 		List<HotSearch> hotSearchList = new ArrayList<HotSearch>();
 		for (SuperHotSearch superHotSearch : superHotSearchList) {
 			HotSearch hotSearch = superHotSearch.getHotSearch();
-			hotSearchList.add(hotSearch);
+			if (hotSearch != null)
+				hotSearchList.add(hotSearch);
 		}
 
 		JSONObject data = new JSONObject();
@@ -113,7 +124,7 @@
 
 	@RequestMapping("specialSearch")
 	public void specialSearch(AcceptData acceptData, long hid, int page, PrintWriter out) {
-		Honest honest = honestService.getOne(hid);
+		Honest honest = null;
 		if (honest == null) {
 			out.print(JsonUtil.loadFalseResult(""));
 			return;
@@ -164,7 +175,8 @@
 			String endprice, String fastFilter, PrintWriter out) {
 		String bid = getHistorySearchBid(acceptData);
 		historySearchService.addHistorySearch(kw, bid);
-		System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -355,32 +367,6 @@
 		return data;
 	}
 
-	@RequestMapping(value = "gethistorysearch", method = RequestMethod.POST)
-	public void getHistorySearch(AcceptData acceptData, PrintWriter out) {
-		String bid = getHistorySearchBid(acceptData);
-		List<HistorySearch> historySearchList = historySearchService.getHistorySearch(bid);
-		if (historySearchList == null || historySearchList.size() == 0) {
-			out.print(JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
-			return;
-		}
-		JSONObject data = new JSONObject();
-		data.put("count", historySearchList.size());
-		Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
-		data.put("historySearchList", gson.toJson(historySearchList));
-		out.print(JsonUtil.loadTrueResult(data));
-		return;
-	}
-
-	@RequestMapping(value = "clearhistorysearch", method = RequestMethod.POST)
-	public void clearHistorySearch(AcceptData acceptData, PrintWriter out) {
-		String bid = getHistorySearchBid(acceptData);
-		long count = historySearchService.clearHistorySearch(bid);
-		JSONObject data = new JSONObject();
-		data.put("count", count);
-		out.print(JsonUtil.loadTrueResult(data));
-		return;
-	}
-
 	@RequestMapping(value = "suggestsearch", method = RequestMethod.POST)
 	public void getSugguestSearch(AcceptData acceptData, String kw, PrintWriter out) {
 		List<String> list = TaoBaoUtil.getSuguestSearch(kw);
@@ -428,7 +414,8 @@
 
 		historySearchService.addHistorySearch(kw, bid);
 
-		System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -484,7 +471,8 @@
 		}
 
 		Gson gson = new GsonBuilder().create();
-		data.put("words", gson.toJson(listRecommendWords));
+		if (data != null)
+			data.put("words", gson.toJson(listRecommendWords));
 
 		out.print(JsonUtil.loadTrueResult(data));
 	}
@@ -619,9 +607,53 @@
 		}
 
 		TaoBaoSearchResult result = TaoBaoUtil.search(sf);
+		// 澶ф窐瀹㈣繃婊�
+		List<DaTaoKeDetail> detaokeList = daTaoKeGoodsDetailService.listByDtitle(kw);
+		if (detaokeList != null)
+			for (DaTaoKeDetail detail : detaokeList) {
+				for (int i = 0; i < result.getTaoBaoGoodsBriefs().size(); i++) {
+					if (detail.getGoodsId().longValue() == result.getTaoBaoGoodsBriefs().get(i).getAuctionId()) {
+						result.getTaoBaoGoodsBriefs().set(i,
+								DaTaoKeUtil.filterTaoBaoGoods(result.getTaoBaoGoodsBriefs().get(i), detail));
+						break;
+					}					
+				}
+			}
+
+		// result.setTaoBaoGoodsBriefs(daTaoKeGoodsDetailService.filterTaoBaoGoods(result.getTaoBaoGoodsBriefs()));
+
 		if (result == null) {
 			return null;
 		}
+		// 鎼滅储鏄惁鍦ㄨ惀閿�涓诲晢鍝佸簱
+		if (result != null && result.getTaoBaoGoodsBriefs() != null && result.getTaoBaoGoodsBriefs().size() > 0) {
+			String numIds = "";
+			for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) {
+				numIds += goods.getAuctionId() + ",";
+			}
+			if (numIds.endsWith(","))
+				numIds = numIds.substring(0, numIds.length() - 1);
+			try {
+				List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getBatchGoodsInfos(numIds);
+				Map<Long, Integer> map = new HashMap<>();
+				for (TaoBaoGoodsBrief g : goodsList)
+					map.put(g.getAuctionId(), g.getMaterialLibType());
+				for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs())
+					goods.setMaterialLibType(map.get(goods.getAuctionId()));
+
+				ThreadUtil.run(new Runnable() {
+					@Override
+					public void run() {
+						// 鏇存柊鍒扮珐瀛�
+						for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs())
+							taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(goods);
+					}
+				});
+			} catch (TaobaoGoodsDownException e) {
+				e.printStackTrace();
+			}
+
+		}
 
 		List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav();
 		if (result.getNavList() != null)

--
Gitblit v1.8.0