BaseSceneService.java
2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.yoho.search.common;
import com.yoho.search.common.utils.SearchKeyWordUtils;
import org.apache.commons.lang.StringUtils;
import java.util.HashMap;
import java.util.Map;
public class BaseSceneService {
protected Map<String, String> newParamMap(Map<String, String> paramMap) {
Map<String, String> newMap = new HashMap<>();
newMap.putAll(paramMap);
return newMap;
}
/**
* 场景化的默认参数
*
* @param paramMap
*/
protected void addDefaultParamsToParamMap(Map<String, String> paramMap) {
paramMap.put(SearchRequestParams.PARAM_SEARCH_GLOBAL_FILTER_BRAND, "Y");// 页面屏蔽
paramMap.put(SearchRequestParams.PARAM_SEARCH_STATUS, "1");// 上架
paramMap.put(SearchRequestParams.PARAM_SEARCH_STOCKNUM, "1");// 有库存
paramMap.put(SearchRequestParams.PARAM_SEARCH_SHOWSOLDOUT, "1");// 显示延期显示的商品
paramMap.put(SearchRequestParams.PARAM_SEARCH_ISOUTLETS, "2");// 非奥莱
paramMap.put(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE_NOT, "2");// 非赠品
paramMap.put(SearchRequestParams.PARAM_SEARCH_NEEDSMALLSORT, "1");// 品类聚合时带上小分类
paramMap.put(SearchRequestParams.PARAM_SEARCH_AGG_WITH_PARAM_BRAND, "Y");// 聚合时使用参数中自带的参数
// 关键词反转码
String keyword = SearchKeyWordUtils.getParamKeyword(paramMap, SearchRequestParams.PARAM_SEARCH_QUERY);// 转码
if (!StringUtils.isBlank(keyword)) {
paramMap.put(SearchRequestParams.PARAM_SEARCH_QUERY, keyword);
paramMap.put("is_encode", "0");
}
}
/**
* 去除非正常商品的显示
*
* @param paramMap
*/
protected void filterNotNormalToMap(Map<String, String> paramMap) {
paramMap.put(SearchRequestParams.PARAM_SEARCH_ISLIMITED, "N");// 不支持限定
paramMap.put(SearchRequestParams.PARAM_SEARCH_CONTAIN_SECKILL, "N");// 不支持秒杀
paramMap.put(SearchRequestParams.PARAM_SEARCH_CONTAIN_GLOBAL, "N");// 不支持全球购
paramMap.put(SearchRequestParams.PARAM_SEARCH_CONTAIN_UFO, "N");// 不支持UFO
paramMap.put(SearchRequestParams.PARAM_SEARCH_ISADVANCE, "N");// 不支持预售
paramMap.put(SearchRequestParams.PARAM_SEARCH_BUNDLETYPE, "0");// 不支持套餐
paramMap.put(SearchRequestParams.PARAM_SEARCH_ISLIMITEDBUY, "N");// 不支持限购
paramMap.put(SearchRequestParams.PARAM_SEARCH_ISDESPOSITADVANCE, "N");// 不支持定金预售
paramMap.put(SearchRequestParams.PARAM_SEARCH_ISLIMITTIMEADVANCE, "N");// 不支持定金促销
}
protected int getPage(Map<String, String> paramMap) {
int page = StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page"));
return page;
}
}