From 403a812d2f47ad124b8ed9e961c1a2f60156e91b Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期一, 29 六月 2020 14:59:59 +0800
Subject: [PATCH] 拉新排行榜

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java |  126 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 104 insertions(+), 22 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
index c8fde66..aca34ea 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
@@ -31,6 +31,8 @@
 import com.yeshi.fanli.dto.vip.VIPSearchResult;
 import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
 import com.yeshi.fanli.entity.accept.AcceptData;
+import com.yeshi.fanli.entity.bus.activity.RecommendActivity;
+import com.yeshi.fanli.entity.bus.help.AppPageNotification;
 import com.yeshi.fanli.entity.goods.CommonGoods;
 import com.yeshi.fanli.entity.jd.JDGoods;
 import com.yeshi.fanli.entity.system.ConfigKeyEnum;
@@ -45,6 +47,7 @@
 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.help.AppPageNotificationService;
 import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
 import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
 import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
@@ -82,8 +85,10 @@
 import com.yeshi.fanli.vo.common.JumpDetailContentVO;
 import com.yeshi.fanli.vo.goods.GoodsDetailVO;
 import com.yeshi.fanli.vo.msg.TokenVO;
+import com.yeshi.fanli.vo.recommend.RecommendJumpInfoVO;
 import com.yeshi.fanli.vo.search.GoodsDocParseResultVO;
 
+import net.sf.json.JSON;
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 
@@ -150,6 +155,9 @@
 
 	@Resource
 	private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
+
+	@Resource
+	private AppPageNotificationService appPageNotificationService;
 
 	/**
 	 * 绮樿创鏉夸俊鎭帹鑽�
@@ -287,6 +295,12 @@
 																orderHongBaoMoneyComputeService.getShowComputeRate(
 																		acceptData.getPlatform(),
 																		acceptData.getVersion()))));
+										// 璺宠浆璇︽儏
+										if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(),
+												acceptData.getVersion())) {
+											buildGoodsClick(data, goods, acceptData, gson);
+										}
+
 										out.print(JsonUtil.loadTrueResult(data));
 										return;
 									}
@@ -301,6 +315,10 @@
 															orderHongBaoMoneyComputeService.getShowComputeRate(
 																	acceptData.getPlatform(),
 																	acceptData.getVersion()))));
+//									if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(),
+//											acceptData.getVersion())) {
+//										buildGoodsClick(data, goods, acceptData, gson);
+//									}
 									out.print(JsonUtil.loadTrueResult(data));
 									return;
 								}
@@ -360,6 +378,47 @@
 						out.print(JsonUtil.loadFalseResult(1001, msg));
 					}
 				});
+	}
+
+	private void buildGoodsClick(JSONObject data, CommonGoods goods, AcceptData acceptData, Gson gson) {
+
+		JSONObject params = new JSONObject();
+		params.put("id", goods.getGoodsId() + "");
+		params.put("from", "鐚滀綘鍠滄");
+		
+		String type="";
+		switch(goods.getGoodsType()){
+		case Constant.SOURCE_TYPE_TAOBAO:
+			type="goodsdetail";
+			break;
+		case Constant.SOURCE_TYPE_JD:
+			type="goodsdetail_jd";
+			break;
+		case Constant.SOURCE_TYPE_PDD:
+			type="goodsdetail_pdd";
+			break;
+		case Constant.SOURCE_TYPE_VIP:
+			type="goodsdetail_vip";
+			break;
+		case Constant.SOURCE_TYPE_SUNING:
+			type="goodsdetail_suning";
+			break;
+		
+		}
+
+		RecommendJumpInfoVO left = new RecommendJumpInfoVO(
+				"鍘荤湅鐪�", jumpDetailV2Service.getByTypeCache(type,
+						Constant.getPlatformCode(acceptData.getPlatform()), Integer.parseInt(acceptData.getVersion())),
+				params);
+		data.put("left", gson.toJson(left));
+		
+		// 鍘荤綉椤�
+		params = new JSONObject();
+		params.put("url", "http://www.baidu.com");
+
+		RecommendJumpInfoVO right = new RecommendJumpInfoVO("鏈夋洿楂樿繑鍒╋紵", jumpDetailV2Service.getByTypeCache("web",
+				Constant.getPlatformCode(acceptData.getPlatform()), Integer.parseInt(acceptData.getVersion())), params);
+		data.put("right", gson.toJson(right));
 	}
 
 	/**
@@ -433,7 +492,7 @@
 	 */
 	@RequestMapping(value = "searchGoods")
 	public void searchGoods(AcceptData acceptData, Integer goodsType, String key, Integer page, String filter,
-			Integer order, Long uid, HttpSession session, PrintWriter out) {
+			Integer order, Long uid, String notifyType, HttpSession session, PrintWriter out) {
 
 		if (goodsType == null || goodsType < 1 || goodsType > 5) {
 			out.print(JsonUtil.loadFalseResult(1, "璇蜂紶閫掓纭钩鍙板弬鏁�"));
@@ -492,33 +551,48 @@
 			out.print(JsonUtil.loadTrueResult(data));
 			return;
 		}
+		AppPageNotification ap = null;
+		if (page == 1) {
+			ap = appPageNotificationService.getValidNotificationByTypeCache(notifyType, acceptData.getPlatform(),
+					Integer.parseInt(acceptData.getVersion()));
+			// 娌℃湁閫氱煡
+			if (ap == null || !ap.getShow()) {
+				ap = null;
+			}
+
+			// else {// 鏈夐�氱煡
+			// Gson gson = new
+			// GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
+			// out.print(JsonUtil.loadTrueResult(gson.toJson(ap)));
+			// }
+		}
 
 		/*--------- 浜笢鍟嗗搧  -------*/
 		if (goodsType.intValue() == Constant.SOURCE_TYPE_JD) {
-			searchJDGoods(acceptData, searchkey, page, filter, order, out);
+			searchJDGoods(acceptData, searchkey, page, filter, order, ap, out);
 			return;
 		}
 
 		/*-------- 鎷煎澶氬晢鍝�  -------*/
 		if (goodsType.intValue() == Constant.SOURCE_TYPE_PDD) {
-			searchPDDGoods(acceptData, searchkey, page, filter, order, out);
+			searchPDDGoods(acceptData, searchkey, page, filter, order, ap, out);
 			return;
 		}
 
 		/*-------- 鍞搧浼氬晢鍝� ------*/
 		if (goodsType.intValue() == Constant.SOURCE_TYPE_VIP) {
-			searchVIPGoods(acceptData, searchkey, page, filter, order, out);
+			searchVIPGoods(acceptData, searchkey, page, filter, order, ap, out);
 			return;
 		}
 
 		/*-------- 鑻忓畞鍟嗗搧 ------*/
 		if (goodsType.intValue() == Constant.SOURCE_TYPE_SUNING) {
-			searchSuningGoods(acceptData, searchkey, page, filter, order, out);
+			searchSuningGoods(acceptData, searchkey, page, filter, order, ap, out);
 			return;
 		}
 
 		/*-------- 娣樺疂鍟嗗搧  -------*/
-		searchTaoBaoGoods(acceptData, searchkey, page, filter, order, out);
+		searchTaoBaoGoods(acceptData, searchkey, page, filter, order, ap, out);
 
 	}
 
@@ -534,7 +608,7 @@
 	 * @return
 	 */
 	private void searchTaoBaoGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order,
-			PrintWriter out) {
+			AppPageNotification ap, PrintWriter out) {
 		SearchFilter sf = new SearchFilter();
 		sf.setKey(SearchFilterUtil.filterSearchContent(key));
 		sf.setPage(page);
@@ -664,7 +738,15 @@
 			}
 		}
 
-		out.print(JsonUtil.loadTrueResult(data));
+		out.print(JsonUtil.loadTrueResult(buildSearchResult(data, ap)));
+	}
+
+	private JSONObject buildSearchResult(JSONObject data, AppPageNotification ap) {
+		if (ap != null && data != null) {
+			Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
+			data.put("notification", gson.toJson(ap));
+		}
+		return data;
 	}
 
 	/**
@@ -679,7 +761,7 @@
 	 * @return
 	 */
 	private void searchJDGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order,
-			PrintWriter out) {
+			AppPageNotification ap, PrintWriter out) {
 
 		JDSearchResult result = null;
 		boolean hasCoupon = false;
@@ -840,7 +922,7 @@
 
 		data.put("result", array);
 		data.put("count", count);
-		out.print(JsonUtil.loadTrueResult(data));
+		out.print(JsonUtil.loadTrueResult(buildSearchResult(data, ap)));
 	}
 
 	/**
@@ -855,7 +937,7 @@
 	 * @return
 	 */
 	private void searchPDDGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order,
-			PrintWriter out) {
+			AppPageNotification ap, PrintWriter out) {
 		PDDSearchFilter pddfilter = new PDDSearchFilter();
 		pddfilter.setKw(SearchFilterUtil.filterSearchContent(key));
 		pddfilter.setPage(page);
@@ -917,7 +999,7 @@
 
 		data.put("result", array);
 		data.put("count", count);
-		out.print(JsonUtil.loadTrueResult(data));
+		out.print(JsonUtil.loadTrueResult(buildSearchResult(data, ap)));
 	}
 
 	/**
@@ -934,7 +1016,7 @@
 	 * @throws
 	 */
 	private void searchVIPGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order,
-			PrintWriter out) {
+			AppPageNotification ap, PrintWriter out) {
 		VIPSearchFilter searchFilter = new VIPSearchFilter();
 		searchFilter.setKeyword(key);
 		searchFilter.setPage(page);
@@ -995,7 +1077,7 @@
 
 		data.put("result", array);
 		data.put("count", count);
-		out.print(JsonUtil.loadTrueResult(data));
+		out.print(JsonUtil.loadTrueResult(buildSearchResult(data, ap)));
 	}
 
 	/**
@@ -1012,7 +1094,7 @@
 	 * @throws
 	 */
 	private void searchSuningGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order,
-			PrintWriter out) {
+			AppPageNotification ap, PrintWriter out) {
 		SuningQueryModel searchFilter = new SuningQueryModel();
 		searchFilter.setKeyword(key);
 		searchFilter.setPageIndex(page);
@@ -1075,15 +1157,15 @@
 		List<SuningGoodsInfo> list = SuningApiUtil.searchGoodsOld(searchFilter);
 		if (list != null && list.size() > 0) {
 			List<String> listId = new ArrayList<>();
-			for (SuningGoodsInfo goodsInfo:  list) {
-				 SuningCommodityInfo info = goodsInfo.getCommodityInfo();
-				 if (info != null) {
-					 listId.add(info.getCommodityCode() + "-" + info.getSupplierCode());
-				 }
+			for (SuningGoodsInfo goodsInfo : list) {
+				SuningCommodityInfo info = goodsInfo.getCommodityInfo();
+				if (info != null) {
+					listId.add(info.getCommodityCode() + "-" + info.getSupplierCode());
+				}
 			}
 			resultList = SuningApiUtil.getGoodsDetailList(listId);
 		}
-		
+
 		if (resultList != null) {
 			Gson gson = JsonUtil.getApiCommonGson();
 			if (resultList != null && resultList.size() > 0) {
@@ -1099,7 +1181,7 @@
 
 		data.put("result", array);
 		data.put("count", 1000);
-		out.print(JsonUtil.loadTrueResult(data));
+		out.print(JsonUtil.loadTrueResult(buildSearchResult(data, ap)));
 	}
 
 }

--
Gitblit v1.8.0