Showing
2 changed files
with
39 additions
and
8 deletions
@@ -48,6 +48,13 @@ public class FuzzySceneService extends AbstractSceneService { | @@ -48,6 +48,13 @@ public class FuzzySceneService extends AbstractSceneService { | ||
48 | return SearchPageIdDefine.PAGE_ID_SEARCH; | 48 | return SearchPageIdDefine.PAGE_ID_SEARCH; |
49 | } | 49 | } |
50 | 50 | ||
51 | + @Override | ||
52 | + public void addParamsToParamMap(Map<String, String> paramMap) { | ||
53 | + super.addDefaultParamsToParamMap(paramMap); | ||
54 | + paramMap.put(SearchRequestParams.PARAM_SEARCH_NEED_SUGGESTION, "Y");// 返回建议词 | ||
55 | + paramMap.put(SearchRequestParams.PARAM_SEARCH_CONTAIN_SECKILL, "Y");// 包含秒杀商品 | ||
56 | + } | ||
57 | + | ||
51 | /** | 58 | /** |
52 | * @1、返回商品列表 | 59 | * @1、返回商品列表 |
53 | * @2、数量太多则返回建议词 | 60 | * @2、数量太多则返回建议词 |
@@ -90,24 +97,28 @@ public class FuzzySceneService extends AbstractSceneService { | @@ -90,24 +97,28 @@ public class FuzzySceneService extends AbstractSceneService { | ||
90 | if (StringUtils.isEmpty(queryWord) || (queryWord.length() > 30 && !searchCommonHelper.isQuerySkn(queryWord))) { | 97 | if (StringUtils.isEmpty(queryWord) || (queryWord.length() > 30 && !searchCommonHelper.isQuerySkn(queryWord))) { |
91 | return; | 98 | return; |
92 | } | 99 | } |
93 | - | ||
94 | - // 1.2 请求制定需要返回term推荐 | 100 | + // 1.2不是第一页直接不返回 |
101 | + int page = this.getPage(paramMap); | ||
102 | + if (page != 1) { | ||
103 | + return; | ||
104 | + } | ||
105 | + // 1.3请求制定需要返回term推荐 | ||
95 | if (!"Y".equalsIgnoreCase(paramMap.get(SearchRequestParams.PARAM_SEARCH_NEED_SUGGESTION))) { | 106 | if (!"Y".equalsIgnoreCase(paramMap.get(SearchRequestParams.PARAM_SEARCH_NEED_SUGGESTION))) { |
96 | return; | 107 | return; |
97 | } | 108 | } |
98 | 109 | ||
99 | - // 1.3 打开智能推荐全局开关 | 110 | + // 1.4打开智能推荐全局开关 |
100 | if (!searchDynamicConfigService.isSearchSuggestionTipsOpen()) { | 111 | if (!searchDynamicConfigService.isSearchSuggestionTipsOpen()) { |
101 | return; | 112 | return; |
102 | } | 113 | } |
103 | 114 | ||
104 | - // 1.4 搜索的数量小于20条 | 115 | + // 1.5 搜索的数量小于20条 |
105 | JSONObject dataMap = ((JSONObject) searchResult.getData()); | 116 | JSONObject dataMap = ((JSONObject) searchResult.getData()); |
106 | if (dataMap.getIntValue("total") >= SMART_SUGGESTION_PRODUCT_LIMIT) { | 117 | if (dataMap.getIntValue("total") >= SMART_SUGGESTION_PRODUCT_LIMIT) { |
107 | return; | 118 | return; |
108 | } | 119 | } |
109 | 120 | ||
110 | - // 1.5加入推荐词 | 121 | + // 1.6加入推荐词 |
111 | dataMap.put("suggestion", searchRecommendService.recommend(searchResult, paramMap)); | 122 | dataMap.put("suggestion", searchRecommendService.recommend(searchResult, paramMap)); |
112 | } | 123 | } |
113 | 124 |
@@ -4,6 +4,8 @@ import java.util.Map; | @@ -4,6 +4,8 @@ import java.util.Map; | ||
4 | import java.util.concurrent.ExecutorService; | 4 | import java.util.concurrent.ExecutorService; |
5 | import java.util.concurrent.Executors; | 5 | import java.util.concurrent.Executors; |
6 | 6 | ||
7 | +import org.apache.commons.lang.StringUtils; | ||
8 | + | ||
7 | import com.yoho.search.service.utils.SearchRequestParams; | 9 | import com.yoho.search.service.utils.SearchRequestParams; |
8 | import com.yoho.search.service.vo.SearchApiResult; | 10 | import com.yoho.search.service.vo.SearchApiResult; |
9 | 11 | ||
@@ -11,12 +13,30 @@ public abstract class AbstractSceneService { | @@ -11,12 +13,30 @@ public abstract class AbstractSceneService { | ||
11 | 13 | ||
12 | protected static ExecutorService executorService = Executors.newFixedThreadPool(500); | 14 | protected static ExecutorService executorService = Executors.newFixedThreadPool(500); |
13 | 15 | ||
14 | - protected void addParamsToParamMap(Map<String, String> paramMap) { | 16 | + /** |
17 | + * 场景化的默认参数 | ||
18 | + * | ||
19 | + * @param paramMap | ||
20 | + */ | ||
21 | + protected void addDefaultParamsToParamMap(Map<String, String> paramMap) { | ||
15 | paramMap.put(SearchRequestParams.PARAM_SEARCH_PAGEID, this.pageId()); | 22 | paramMap.put(SearchRequestParams.PARAM_SEARCH_PAGEID, this.pageId()); |
16 | - paramMap.put(SearchRequestParams.PARAM_SEARCH_GLOBAL_FILTER_BRAND, "Y");// 屏蔽参数 | ||
17 | - paramMap.put("aggWithParamBrand", "Y");// 聚合品牌只取参数中的brand聚合 | 23 | + paramMap.put(SearchRequestParams.PARAM_SEARCH_GLOBAL_FILTER_BRAND, "Y");// 页面屏蔽 |
24 | + paramMap.put(SearchRequestParams.PARAM_SEARCH_STATUS, "1");// 上架 | ||
25 | + paramMap.put(SearchRequestParams.PARAM_SEARCH_STOCKNUM, "1");// 有库存 | ||
26 | + paramMap.put(SearchRequestParams.PARAM_SEARCH_SHOWSOLDOUT, "1");// 显示售罄商品 | ||
27 | + paramMap.put(SearchRequestParams.PARAM_SEARCH_CONTAIN_GLOBAL, "Y");// 包含全球购 | ||
28 | + paramMap.put(SearchRequestParams.PARAM_SEARCH_ISOUTLETS, "2");// 非奥莱 | ||
29 | + paramMap.put("attribute_not", "2");// 非赠品 | ||
30 | + // paramMap.put("sale", "Y");// 没用的参数 | ||
31 | + } | ||
32 | + | ||
33 | + protected int getPage(Map<String, String> paramMap) { | ||
34 | + int page = StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page")); | ||
35 | + return page; | ||
18 | } | 36 | } |
19 | 37 | ||
38 | + public abstract void addParamsToParamMap(Map<String, String> paramMap); | ||
39 | + | ||
20 | public abstract String pageId(); | 40 | public abstract String pageId(); |
21 | 41 | ||
22 | public abstract SearchApiResult productList(Map<String, String> paramMap); | 42 | public abstract SearchApiResult productList(Map<String, String> paramMap); |
-
Please register or login to post a comment