Authored by hugufei

不缓存的参数全部去掉udid

@@ -38,8 +38,7 @@ public class CommonPageRecallService extends BaseRecallService { @@ -38,8 +38,7 @@ public class CommonPageRecallService extends BaseRecallService {
38 * @param paramMap 38 * @param paramMap
39 * @return 39 * @return
40 */ 40 */
41 - @SearchCacheAble(cacheInMinute = 3, needMd5 = false, cacheName = "COMMON_PAGE_RECALL_BATCH", cacheType = CacheType.EHCACHE, returnClass = CommonRecallResult.class, excludeParams = {  
42 - "uid", "order", "page" }) 41 + @SearchCacheAble(cacheInMinute = 3, needMd5 = false, cacheName = "COMMON_PAGE_RECALL_BATCH", cacheType = CacheType.EHCACHE, returnClass = CommonRecallResult.class, excludeParams = {"uid","udid","order", "page" })
43 public CommonRecallResult doCommonPageRecallBatch(Map<String, String> paramMap) { 42 public CommonRecallResult doCommonPageRecallBatch(Map<String, String> paramMap) {
44 try { 43 try {
45 int viewNum = this.getViewNum(paramMap); 44 int viewNum = this.getViewNum(paramMap);
@@ -21,372 +21,390 @@ import java.util.Map; @@ -21,372 +21,390 @@ import java.util.Map;
21 @Component 21 @Component
22 public class SearchCommonHelper { 22 public class SearchCommonHelper {
23 23
24 - @Autowired  
25 - private SearchDynamicConfigService dynamicConfig;  
26 - @Autowired  
27 - private SearchServiceConfiger searchServiceConfiger;  
28 - @Autowired  
29 - private SearchDynamicConfigService searchDynamicConfigService;  
30 -  
31 - public int getPage(Map<String, String> paramMap) {  
32 - return StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page"));  
33 - }  
34 -  
35 - public int getPageSize(Map<String, String> paramMap) {  
36 - return StringUtils.isBlank(paramMap.get("viewNum")) ? 60 : Integer.parseInt(paramMap.get("viewNum"));  
37 - }  
38 -  
39 - public boolean isPersionalScene(Map<String, String> paramMap) {  
40 - if (!searchDynamicConfigService.openPersonalized()) {  
41 - return false;  
42 - }  
43 - if (this.hasUid(paramMap) && this.isOrderEmpty(paramMap)) {  
44 - return true;  
45 - }  
46 - return false;  
47 - }  
48 -  
49 - public long getTotalPage(long total, int size) {  
50 - return PageUtils.getTotalPage(total,size);  
51 - }  
52 -  
53 - public int getUid(Map<String, String> paramMap) {  
54 - try {  
55 - return MapUtils.getIntValue(paramMap, "uid", 0);  
56 - } catch (Exception e) {  
57 - return 0;  
58 - }  
59 - }  
60 -  
61 - public boolean hasUid(Map<String, String> paramMap) {  
62 - return this.getUid(paramMap) > 0;  
63 - }  
64 -  
65 -  
66 - /**  
67 - * 是否是默认的模糊搜索  
68 - *  
69 - * @param paramMap  
70 - * @return  
71 - */  
72 - public boolean isFuzzySearchPageDefault(Map<String, String> paramMap) {  
73 - String query = paramMap.get(SearchRequestParams.PARAM_SEARCH_QUERY);  
74 - if (StringUtils.isBlank(query)) {  
75 - return false;  
76 - }  
77 - if (!this.isOrderEmpty(paramMap)) {  
78 - return false;  
79 - }  
80 - String pageId = paramMap.get(SearchRequestParams.PARAM_SEARCH_PAGEID);  
81 - if (!SearchPageIdDefine.PAGE_ID_SEARCH.equalsIgnoreCase(pageId)) {  
82 - return false;  
83 - }  
84 - return true;  
85 - }  
86 -  
87 - /**  
88 - * 是否需要开启个性化  
89 - *  
90 - * @param paramMap  
91 - * @return  
92 - */  
93 - public boolean isNeedPersonalSearch(Map<String, String> paramMap) {  
94 - // 从 zk中动态获取是否使用个性化  
95 - boolean openPersonalized = dynamicConfig.openPersonalized();  
96 - if (!openPersonalized) {  
97 - return false;  
98 - }  
99 - if(!this.hasUid(paramMap)){  
100 - return false;  
101 - }  
102 - if (!this.isOrderEmpty(paramMap)) {  
103 - return false;  
104 - }  
105 - return true;  
106 - }  
107 -  
108 - /**  
109 - * 是否需要对某个SKN加分  
110 - *  
111 - * @param paramMap  
112 - * @return  
113 - */  
114 - public boolean isFirstProductSknSearch(Map<String, String> paramMap) {  
115 - String first_productskn = paramMap.get(SearchRequestParams.PARAM_SEARCH_FIRST_PRODUCRSKN);  
116 - if (StringUtils.isBlank(first_productskn)) {  
117 - return false;  
118 - }  
119 - if (!this.isOrderEmpty(paramMap)) {  
120 - return false;  
121 - }  
122 - return true;  
123 - }  
124 -  
125 - /**  
126 - * 是否需要对频道降分  
127 - *  
128 - * @param paramMap  
129 - * @return  
130 - */  
131 - public boolean isNeedDeScoreForChannel(Map<String, String> paramMap) {  
132 - String physicalChannel = paramMap.get(SearchRequestParams.PARAM_SEARCH_PHYSICAL_CHANNEL);  
133 - if (StringUtils.isBlank(physicalChannel)) {  
134 - return false;  
135 - }  
136 - if (!isFuzzySearchPageDefault(paramMap)) {  
137 - return false;  
138 - }  
139 - if (!dynamicConfig.isDeScorePhysicalChannelOpen()) {  
140 - return false;  
141 - }  
142 - return true;  
143 - }  
144 -  
145 - /**  
146 - * 判断搜索是否需要包含全球购  
147 - *  
148 - * @param paramMap  
149 - * @return  
150 - */  
151 - public boolean containGlobal(Map<String, String> paramMap) {  
152 - // 1、如果总开关关了,则肯定不包含全球购商品  
153 - boolean containglobal = dynamicConfig.containglobal();  
154 - if (!containglobal) {  
155 - return false;  
156 - }  
157 - // 2、如果前端传来的参数中不包含contain_global!=Y,则不包含全球购  
158 - if (!paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_CONTAIN_GLOBAL) || !"Y".equals(paramMap.get(SearchRequestParams.PARAM_SEARCH_CONTAIN_GLOBAL))) {  
159 - return false;  
160 - }  
161 - return true;  
162 - }  
163 -  
164 - /**  
165 - * 当前查询的关键字是否是skn  
166 - *  
167 - * @param keyword  
168 - * @return  
169 - */  
170 - public boolean isQuerySknOrSku(String keyword) {  
171 - try {  
172 - String key = "";  
173 - if (keyword.contains(" ")) {  
174 - key = keyword.split(" ")[0];  
175 - } else if (keyword.contains(",")) {  
176 - key = keyword.split(",")[0];  
177 - } else if (keyword.contains("+")) {  
178 - key = keyword.split("\\+")[0];  
179 - }  
180 - if ((CharUtils.isNumeric(keyword) && keyword.length() >= 6) || (CharUtils.isNumeric(key) && key.length() >= 6)) {  
181 - return true;  
182 - }  
183 - return false;  
184 - } catch (Exception e) {  
185 - return false;  
186 - }  
187 - }  
188 -  
189 - /**  
190 - * 从搜索的关键词中提取出skn信息  
191 - *  
192 - * @param keyword  
193 - * @return  
194 - */  
195 - public List<Integer> getQuerySknList(String keyword) {  
196 - List<Integer> sknList = new ArrayList<>();  
197 -  
198 - try {  
199 - String[] keys = null;  
200 - if (keyword.contains(" ")) {  
201 - keys = keyword.split(" ");  
202 - } else if (keyword.contains(",")) {  
203 - keys = keyword.split(",");  
204 - } else if (keyword.contains("+")) {  
205 - keys = keyword.split("\\+");  
206 - }  
207 -  
208 - if (keys != null && keys.length > 0) {  
209 - for (String key : keys) {  
210 - if (CharUtils.isNumeric(key) && key.length() >= 7) {  
211 - sknList.add(Integer.valueOf(key));  
212 - }  
213 - }  
214 - }  
215 -  
216 - return sknList;  
217 - } catch (Exception e) {  
218 - return sknList;  
219 - }  
220 - }  
221 -  
222 - /**  
223 - * 是否是新品到着页  
224 - *  
225 - * @param paramMap  
226 - * @return  
227 - */  
228 - public boolean isNewRecPage(Map<String, String> paramMap) {  
229 - String pageId = paramMap.get(SearchRequestParams.PARAM_SEARCH_PAGEID);  
230 - if (StringUtils.isBlank(pageId) || !pageId.equals(SearchPageIdDefine.PAGE_ID_NEW)) {  
231 - return false;  
232 - }  
233 - return true;  
234 - }  
235 -  
236 - /**  
237 - * 是否是新品到着默认页  
238 - *  
239 - * @param paramMap  
240 - * @return  
241 - */  
242 - public boolean isNewRecPageDefault(Map<String, String> paramMap) {  
243 - if (!isNewRecPage(paramMap)) {  
244 - return false;  
245 - }  
246 - if (!this.isOrderEmpty(paramMap)) {  
247 - return false;  
248 - }  
249 - return true;  
250 - }  
251 -  
252 - /**  
253 - * 是否是新品到着页的人气排序  
254 - *  
255 - * @param paramMap  
256 - * @return  
257 - */  
258 - public boolean isNewRecHeatValueDescSearch(Map<String, String> paramMap) {  
259 - if (!this.isNewRecPage(paramMap)) {  
260 - return false;  
261 - }  
262 - String order = paramMap.get(SearchRequestParams.PARAM_SEARCH_ORDER);  
263 - if (StringUtils.isBlank(order)) {  
264 - return false;  
265 - }  
266 - if (!order.contains("heatValue")) {  
267 - return false;  
268 - }  
269 - return true;  
270 - }  
271 -  
272 - /**  
273 - * 是否未传order  
274 - *  
275 - * @param paramMap  
276 - * @return  
277 - */  
278 - public boolean isOrderEmpty(Map<String, String> paramMap) {  
279 - String order = paramMap.get(SearchRequestParams.PARAM_SEARCH_ORDER);  
280 - if (!StringUtils.isBlank(order)) {  
281 - return false;  
282 - }  
283 - return true;  
284 - }  
285 -  
286 - /**  
287 - * 是否是品类列表的默认页  
288 - *  
289 - * @param paramMap  
290 - * @return  
291 - */  
292 - public boolean isSortPageDefault(Map<String, String> paramMap) {  
293 - String pageId = paramMap.get(SearchRequestParams.PARAM_SEARCH_PAGEID);  
294 - if (StringUtils.isBlank(pageId) || !pageId.equals(SearchPageIdDefine.PAGE_ID_SORT)) {  
295 - return false;  
296 - }  
297 - if (!this.isOrderEmpty(paramMap)) {  
298 - return false;  
299 - }  
300 - return true;  
301 - }  
302 -  
303 - /**  
304 - * 关键字中含性别,则加上性别的过滤条件  
305 - *  
306 - * @param keyword  
307 - * @param paramMap  
308 - */  
309 - public void dealKeywordOfGender(String keyword, Map<String, String> paramMap) {  
310 - // 如果参数中已经包含了性别,则不处理  
311 - String gender = paramMap.get(SearchRequestParams.PARAM_SEARCH_GENDER);  
312 - if (StringUtils.isNotBlank(gender)) {  
313 - return;  
314 - }  
315 - // 对男女关键字做特殊处理  
316 - boolean cotainBoy = keyword.contains("男");  
317 - boolean cotainGirl = keyword.contains("女");  
318 - // 对性别做特殊处理  
319 - if (cotainBoy && !cotainGirl) {  
320 - paramMap.put(SearchRequestParams.PARAM_SEARCH_GENDER, "1,3");  
321 - return;  
322 - }  
323 - if (!cotainBoy && cotainGirl) {  
324 - paramMap.put(SearchRequestParams.PARAM_SEARCH_GENDER, "2,3");  
325 - return;  
326 - }  
327 - if (cotainBoy && cotainGirl) {  
328 - paramMap.put(SearchRequestParams.PARAM_SEARCH_GENDER, "1,2,3");  
329 - return;  
330 - }  
331 - }  
332 -  
333 - // 获取MultiMatchQueryBuilder的类型  
334 - public MultiMatchQueryBuilder.Type getMultiMatchQueryBuilderType() {  
335 - String configMultiMatchQueryType = searchServiceConfiger.getSearchMultiMatchQueryType();  
336 - return SearchFieldUtils.getMultiMatchQueryBuilderType(configMultiMatchQueryType);  
337 - }  
338 -  
339 - /**  
340 - * 构造活动相关的过滤条件  
341 - *  
342 - * @param paramMap  
343 - * @return  
344 - */  
345 - public BoolQueryBuilder getActivitiesTermsBuilder(Map<String, String> paramMap) {  
346 - // 增加活动模板相关的过滤条件  
347 - if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ACT_TEMP) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_TEMP))) {  
348 - BoolQueryBuilder nestedBoolFilter = QueryBuilders.boolQuery();  
349 - nestedBoolFilter.must(QueryBuilders.termQuery("activities.template_id", paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_TEMP)));  
350 - if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ACT_REC) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_REC))) {  
351 - nestedBoolFilter.must(QueryBuilders.termQuery("activities.is_recommend", paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_REC)));  
352 - }  
353 - if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ACT_STATUS) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_STATUS))) {  
354 - nestedBoolFilter.must(QueryBuilders.termQuery("activities.status", paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_STATUS)));  
355 - }  
356 - return nestedBoolFilter;  
357 - }  
358 - return null;  
359 - }  
360 -  
361 - /**  
362 - * 构造商品池相关的过滤条件  
363 - *  
364 - * @param paramMap  
365 - * @return  
366 - */  
367 - public BoolQueryBuilder getPoolIdTermsBuilder(Map<String, String> paramMap) {  
368 - // 增加商品池相关的过滤条件  
369 - if (paramMap.containsKey("filter_poolId") && StringUtils.isNotBlank("filter_poolId")) {  
370 - BoolQueryBuilder nestedBoolFilter = QueryBuilders.boolQuery();  
371 - nestedBoolFilter.must(QueryBuilders.termQuery("pools.pool_id", paramMap.get("filter_poolId")));  
372 - return nestedBoolFilter;  
373 - }  
374 - return null;  
375 - }  
376 -  
377 - /**  
378 - * 自定义标签过滤  
379 - *  
380 - * @param paramMap  
381 - * @return  
382 - */  
383 - public BoolQueryBuilder getCustomizeTagBuilder(Map<String, String> paramMap) {  
384 - if (paramMap.containsKey(SearchRequestParams.SHOPS_PARAM_CUSTOMIZE_TAG) && StringUtils.isNotBlank(SearchRequestParams.SHOPS_PARAM_CUSTOMIZE_TAG)) {  
385 - int[] ids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.SHOPS_PARAM_CUSTOMIZE_TAG), ",");  
386 - BoolQueryBuilder nestedBoolFilter = QueryBuilders.boolQuery();  
387 - nestedBoolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.customizeTagsId, ids));  
388 - return nestedBoolFilter;  
389 - }  
390 - return null;  
391 - } 24 + @Autowired
  25 + private SearchDynamicConfigService dynamicConfig;
  26 + @Autowired
  27 + private SearchServiceConfiger searchServiceConfiger;
  28 + @Autowired
  29 + private SearchDynamicConfigService searchDynamicConfigService;
  30 +
  31 + public int getPage(Map<String, String> paramMap) {
  32 + return StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page"));
  33 + }
  34 +
  35 + public int getPageSize(Map<String, String> paramMap) {
  36 + return StringUtils.isBlank(paramMap.get("viewNum")) ? 60 : Integer.parseInt(paramMap.get("viewNum"));
  37 + }
  38 +
  39 + public boolean isPersionalScene(Map<String, String> paramMap) {
  40 + if (!searchDynamicConfigService.openPersonalized()) {
  41 + return false;
  42 + }
  43 + if (!this.isOrderEmpty(paramMap)) {
  44 + return false;
  45 + }
  46 + if (this.hasUid(paramMap)) {
  47 + return true;
  48 + }
  49 + if (this.hasUdid(paramMap)) {
  50 + return true;
  51 + }
  52 + return false;
  53 + }
  54 +
  55 + public long getTotalPage(long total, int size) {
  56 + return PageUtils.getTotalPage(total, size);
  57 + }
  58 +
  59 + public int getUid(Map<String, String> paramMap) {
  60 + try {
  61 + return MapUtils.getIntValue(paramMap, "uid", 0);
  62 + } catch (Exception e) {
  63 + return 0;
  64 + }
  65 + }
  66 +
  67 + public String getUdid(Map<String, String> paramMap) {
  68 + try {
  69 + return MapUtils.getString(paramMap, "udid", "");
  70 + } catch (Exception e) {
  71 + return "";
  72 + }
  73 + }
  74 +
  75 + public boolean hasUid(Map<String, String> paramMap) {
  76 + return this.getUid(paramMap) > 0;
  77 + }
  78 +
  79 + public boolean hasUdid(Map<String, String> paramMap) {
  80 + return StringUtils.isBlank(this.getUdid(paramMap))?false:true;
  81 + }
  82 +
  83 +
  84 + /**
  85 + * 是否是默认的模糊搜索
  86 + *
  87 + * @param paramMap
  88 + * @return
  89 + */
  90 + public boolean isFuzzySearchPageDefault(Map<String, String> paramMap) {
  91 + String query = paramMap.get(SearchRequestParams.PARAM_SEARCH_QUERY);
  92 + if (StringUtils.isBlank(query)) {
  93 + return false;
  94 + }
  95 + if (!this.isOrderEmpty(paramMap)) {
  96 + return false;
  97 + }
  98 + String pageId = paramMap.get(SearchRequestParams.PARAM_SEARCH_PAGEID);
  99 + if (!SearchPageIdDefine.PAGE_ID_SEARCH.equalsIgnoreCase(pageId)) {
  100 + return false;
  101 + }
  102 + return true;
  103 + }
  104 +
  105 + /**
  106 + * 是否需要开启个性化
  107 + *
  108 + * @param paramMap
  109 + * @return
  110 + */
  111 + public boolean isNeedPersonalSearch(Map<String, String> paramMap) {
  112 + // 从 zk中动态获取是否使用个性化
  113 + boolean openPersonalized = dynamicConfig.openPersonalized();
  114 + if (!openPersonalized) {
  115 + return false;
  116 + }
  117 + if (!this.hasUid(paramMap)) {
  118 + return false;
  119 + }
  120 + if (!this.isOrderEmpty(paramMap)) {
  121 + return false;
  122 + }
  123 + return true;
  124 + }
  125 +
  126 + /**
  127 + * 是否需要对某个SKN加分
  128 + *
  129 + * @param paramMap
  130 + * @return
  131 + */
  132 + public boolean isFirstProductSknSearch(Map<String, String> paramMap) {
  133 + String first_productskn = paramMap.get(SearchRequestParams.PARAM_SEARCH_FIRST_PRODUCRSKN);
  134 + if (StringUtils.isBlank(first_productskn)) {
  135 + return false;
  136 + }
  137 + if (!this.isOrderEmpty(paramMap)) {
  138 + return false;
  139 + }
  140 + return true;
  141 + }
  142 +
  143 + /**
  144 + * 是否需要对频道降分
  145 + *
  146 + * @param paramMap
  147 + * @return
  148 + */
  149 + public boolean isNeedDeScoreForChannel(Map<String, String> paramMap) {
  150 + String physicalChannel = paramMap.get(SearchRequestParams.PARAM_SEARCH_PHYSICAL_CHANNEL);
  151 + if (StringUtils.isBlank(physicalChannel)) {
  152 + return false;
  153 + }
  154 + if (!isFuzzySearchPageDefault(paramMap)) {
  155 + return false;
  156 + }
  157 + if (!dynamicConfig.isDeScorePhysicalChannelOpen()) {
  158 + return false;
  159 + }
  160 + return true;
  161 + }
  162 +
  163 + /**
  164 + * 判断搜索是否需要包含全球购
  165 + *
  166 + * @param paramMap
  167 + * @return
  168 + */
  169 + public boolean containGlobal(Map<String, String> paramMap) {
  170 + // 1、如果总开关关了,则肯定不包含全球购商品
  171 + boolean containglobal = dynamicConfig.containglobal();
  172 + if (!containglobal) {
  173 + return false;
  174 + }
  175 + // 2、如果前端传来的参数中不包含contain_global!=Y,则不包含全球购
  176 + if (!paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_CONTAIN_GLOBAL) || !"Y".equals(paramMap.get(SearchRequestParams.PARAM_SEARCH_CONTAIN_GLOBAL))) {
  177 + return false;
  178 + }
  179 + return true;
  180 + }
  181 +
  182 + /**
  183 + * 当前查询的关键字是否是skn
  184 + *
  185 + * @param keyword
  186 + * @return
  187 + */
  188 + public boolean isQuerySknOrSku(String keyword) {
  189 + try {
  190 + String key = "";
  191 + if (keyword.contains(" ")) {
  192 + key = keyword.split(" ")[0];
  193 + } else if (keyword.contains(",")) {
  194 + key = keyword.split(",")[0];
  195 + } else if (keyword.contains("+")) {
  196 + key = keyword.split("\\+")[0];
  197 + }
  198 + if ((CharUtils.isNumeric(keyword) && keyword.length() >= 6) || (CharUtils.isNumeric(key) && key.length() >= 6)) {
  199 + return true;
  200 + }
  201 + return false;
  202 + } catch (Exception e) {
  203 + return false;
  204 + }
  205 + }
  206 +
  207 + /**
  208 + * 从搜索的关键词中提取出skn信息
  209 + *
  210 + * @param keyword
  211 + * @return
  212 + */
  213 + public List<Integer> getQuerySknList(String keyword) {
  214 + List<Integer> sknList = new ArrayList<>();
  215 +
  216 + try {
  217 + String[] keys = null;
  218 + if (keyword.contains(" ")) {
  219 + keys = keyword.split(" ");
  220 + } else if (keyword.contains(",")) {
  221 + keys = keyword.split(",");
  222 + } else if (keyword.contains("+")) {
  223 + keys = keyword.split("\\+");
  224 + }
  225 +
  226 + if (keys != null && keys.length > 0) {
  227 + for (String key : keys) {
  228 + if (CharUtils.isNumeric(key) && key.length() >= 7) {
  229 + sknList.add(Integer.valueOf(key));
  230 + }
  231 + }
  232 + }
  233 +
  234 + return sknList;
  235 + } catch (Exception e) {
  236 + return sknList;
  237 + }
  238 + }
  239 +
  240 + /**
  241 + * 是否是新品到着页
  242 + *
  243 + * @param paramMap
  244 + * @return
  245 + */
  246 + public boolean isNewRecPage(Map<String, String> paramMap) {
  247 + String pageId = paramMap.get(SearchRequestParams.PARAM_SEARCH_PAGEID);
  248 + if (StringUtils.isBlank(pageId) || !pageId.equals(SearchPageIdDefine.PAGE_ID_NEW)) {
  249 + return false;
  250 + }
  251 + return true;
  252 + }
  253 +
  254 + /**
  255 + * 是否是新品到着默认页
  256 + *
  257 + * @param paramMap
  258 + * @return
  259 + */
  260 + public boolean isNewRecPageDefault(Map<String, String> paramMap) {
  261 + if (!isNewRecPage(paramMap)) {
  262 + return false;
  263 + }
  264 + if (!this.isOrderEmpty(paramMap)) {
  265 + return false;
  266 + }
  267 + return true;
  268 + }
  269 +
  270 + /**
  271 + * 是否是新品到着页的人气排序
  272 + *
  273 + * @param paramMap
  274 + * @return
  275 + */
  276 + public boolean isNewRecHeatValueDescSearch(Map<String, String> paramMap) {
  277 + if (!this.isNewRecPage(paramMap)) {
  278 + return false;
  279 + }
  280 + String order = paramMap.get(SearchRequestParams.PARAM_SEARCH_ORDER);
  281 + if (StringUtils.isBlank(order)) {
  282 + return false;
  283 + }
  284 + if (!order.contains("heatValue")) {
  285 + return false;
  286 + }
  287 + return true;
  288 + }
  289 +
  290 + /**
  291 + * 是否未传order
  292 + *
  293 + * @param paramMap
  294 + * @return
  295 + */
  296 + public boolean isOrderEmpty(Map<String, String> paramMap) {
  297 + String order = paramMap.get(SearchRequestParams.PARAM_SEARCH_ORDER);
  298 + if (!StringUtils.isBlank(order)) {
  299 + return false;
  300 + }
  301 + return true;
  302 + }
  303 +
  304 + /**
  305 + * 是否是品类列表的默认页
  306 + *
  307 + * @param paramMap
  308 + * @return
  309 + */
  310 + public boolean isSortPageDefault(Map<String, String> paramMap) {
  311 + String pageId = paramMap.get(SearchRequestParams.PARAM_SEARCH_PAGEID);
  312 + if (StringUtils.isBlank(pageId) || !pageId.equals(SearchPageIdDefine.PAGE_ID_SORT)) {
  313 + return false;
  314 + }
  315 + if (!this.isOrderEmpty(paramMap)) {
  316 + return false;
  317 + }
  318 + return true;
  319 + }
  320 +
  321 + /**
  322 + * 关键字中含性别,则加上性别的过滤条件
  323 + *
  324 + * @param keyword
  325 + * @param paramMap
  326 + */
  327 + public void dealKeywordOfGender(String keyword, Map<String, String> paramMap) {
  328 + // 如果参数中已经包含了性别,则不处理
  329 + String gender = paramMap.get(SearchRequestParams.PARAM_SEARCH_GENDER);
  330 + if (StringUtils.isNotBlank(gender)) {
  331 + return;
  332 + }
  333 + // 对男女关键字做特殊处理
  334 + boolean cotainBoy = keyword.contains("男");
  335 + boolean cotainGirl = keyword.contains("女");
  336 + // 对性别做特殊处理
  337 + if (cotainBoy && !cotainGirl) {
  338 + paramMap.put(SearchRequestParams.PARAM_SEARCH_GENDER, "1,3");
  339 + return;
  340 + }
  341 + if (!cotainBoy && cotainGirl) {
  342 + paramMap.put(SearchRequestParams.PARAM_SEARCH_GENDER, "2,3");
  343 + return;
  344 + }
  345 + if (cotainBoy && cotainGirl) {
  346 + paramMap.put(SearchRequestParams.PARAM_SEARCH_GENDER, "1,2,3");
  347 + return;
  348 + }
  349 + }
  350 +
  351 + // 获取MultiMatchQueryBuilder的类型
  352 + public MultiMatchQueryBuilder.Type getMultiMatchQueryBuilderType() {
  353 + String configMultiMatchQueryType = searchServiceConfiger.getSearchMultiMatchQueryType();
  354 + return SearchFieldUtils.getMultiMatchQueryBuilderType(configMultiMatchQueryType);
  355 + }
  356 +
  357 + /**
  358 + * 构造活动相关的过滤条件
  359 + *
  360 + * @param paramMap
  361 + * @return
  362 + */
  363 + public BoolQueryBuilder getActivitiesTermsBuilder(Map<String, String> paramMap) {
  364 + // 增加活动模板相关的过滤条件
  365 + if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ACT_TEMP) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_TEMP))) {
  366 + BoolQueryBuilder nestedBoolFilter = QueryBuilders.boolQuery();
  367 + nestedBoolFilter.must(QueryBuilders.termQuery("activities.template_id", paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_TEMP)));
  368 + if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ACT_REC) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_REC))) {
  369 + nestedBoolFilter.must(QueryBuilders.termQuery("activities.is_recommend", paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_REC)));
  370 + }
  371 + if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ACT_STATUS) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_STATUS))) {
  372 + nestedBoolFilter.must(QueryBuilders.termQuery("activities.status", paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_STATUS)));
  373 + }
  374 + return nestedBoolFilter;
  375 + }
  376 + return null;
  377 + }
  378 +
  379 + /**
  380 + * 构造商品池相关的过滤条件
  381 + *
  382 + * @param paramMap
  383 + * @return
  384 + */
  385 + public BoolQueryBuilder getPoolIdTermsBuilder(Map<String, String> paramMap) {
  386 + // 增加商品池相关的过滤条件
  387 + if (paramMap.containsKey("filter_poolId") && StringUtils.isNotBlank("filter_poolId")) {
  388 + BoolQueryBuilder nestedBoolFilter = QueryBuilders.boolQuery();
  389 + nestedBoolFilter.must(QueryBuilders.termQuery("pools.pool_id", paramMap.get("filter_poolId")));
  390 + return nestedBoolFilter;
  391 + }
  392 + return null;
  393 + }
  394 +
  395 + /**
  396 + * 自定义标签过滤
  397 + *
  398 + * @param paramMap
  399 + * @return
  400 + */
  401 + public BoolQueryBuilder getCustomizeTagBuilder(Map<String, String> paramMap) {
  402 + if (paramMap.containsKey(SearchRequestParams.SHOPS_PARAM_CUSTOMIZE_TAG) && StringUtils.isNotBlank(SearchRequestParams.SHOPS_PARAM_CUSTOMIZE_TAG)) {
  403 + int[] ids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.SHOPS_PARAM_CUSTOMIZE_TAG), ",");
  404 + BoolQueryBuilder nestedBoolFilter = QueryBuilders.boolQuery();
  405 + nestedBoolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.customizeTagsId, ids));
  406 + return nestedBoolFilter;
  407 + }
  408 + return null;
  409 + }
392 } 410 }
@@ -42,9 +42,22 @@ public class DefaultProductListService { @@ -42,9 +42,22 @@ public class DefaultProductListService {
42 * @param paramMap 42 * @param paramMap
43 * @return 43 * @return
44 */ 44 */
45 - @SearchCacheAble(cacheName = "PRODUCT_LIST_NOT_PERSIONAL", cacheType = CacheType.SEARCH_REDIS, cacheInMinute = 10, excludeParams = {"uid", "firstProductSkn"}) 45 + @SearchCacheAble(cacheName = "PRODUCT_LIST_NOT_PERSIONAL", cacheType = CacheType.SEARCH_REDIS, cacheInMinute = 10, excludeParams = {"uid", "udid", "firstProductSkn"})
46 public SearchApiResult productListNotPersional(Map<String, String> paramMap) { 46 public SearchApiResult productListNotPersional(Map<String, String> paramMap) {
47 - return this.productList(paramMap); 47 + try {
  48 + // 1) 构建SearchParam
  49 + SearchParam searchParam = productListHelper.buildProductListSearchParam(paramMap, false);
  50 +
  51 + // 2) 执行搜索
  52 + SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
  53 +
  54 + // 3) 构造返回结果,无需做品类品牌平衡
  55 + JSONObject productListResult = productListHelper.buildProductListResult(searchResult, searchParam.getSize(), false);
  56 + return new SearchApiResult().setData(productListResult);
  57 + } catch (Exception e) {
  58 + logger.error(e.getMessage(), e);
  59 + return new SearchApiResult().setData(null).setCode(500);
  60 + }
48 } 61 }
49 62
50 /** 63 /**
@@ -55,10 +68,6 @@ public class DefaultProductListService { @@ -55,10 +68,6 @@ public class DefaultProductListService {
55 */ 68 */
56 @SearchCacheAble(cacheName = "PRODUCT_LIST_DEFAULT_PERSIONAL", cacheType = CacheType.SEARCH_REDIS, cacheInMinute = 10) 69 @SearchCacheAble(cacheName = "PRODUCT_LIST_DEFAULT_PERSIONAL", cacheType = CacheType.SEARCH_REDIS, cacheInMinute = 10)
57 public SearchApiResult productListForDefaultPersional(Map<String, String> paramMap) { 70 public SearchApiResult productListForDefaultPersional(Map<String, String> paramMap) {
58 - return this.productList(paramMap);  
59 - }  
60 -  
61 - private SearchApiResult productList(Map<String, String> paramMap) {  
62 try { 71 try {
63 // 1) 构建SearchParam 72 // 1) 构建SearchParam
64 SearchParam searchParam = productListHelper.buildProductListSearchParam(paramMap, true);//这个必须用buildWithPersional构造,有些特殊的逻辑-如firstSkn在里面 73 SearchParam searchParam = productListHelper.buildProductListSearchParam(paramMap, true);//这个必须用buildWithPersional构造,有些特殊的逻辑-如firstSkn在里面
@@ -66,10 +75,8 @@ public class DefaultProductListService { @@ -66,10 +75,8 @@ public class DefaultProductListService {
66 // 2) 执行搜索 75 // 2) 执行搜索
67 SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam); 76 SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
68 77
69 - // 3) 构造返回结果  
70 - boolean needResort = searchCommonHelper.isOrderEmpty(paramMap);//没传order时,做下品类品牌的平衡  
71 -  
72 - JSONObject productListResult = productListHelper.buildProductListResult(searchResult, searchParam.getSize() , needResort); 78 + // 3) 构造返回结果,需做品类品牌平衡
  79 + JSONObject productListResult = productListHelper.buildProductListResult(searchResult, searchParam.getSize(), true);
73 return new SearchApiResult().setData(productListResult); 80 return new SearchApiResult().setData(productListResult);
74 } catch (Exception e) { 81 } catch (Exception e) {
75 logger.error(e.getMessage(), e); 82 logger.error(e.getMessage(), e);
@@ -101,7 +101,7 @@ public class BreakSizeSceneService extends AbstractSceneService { @@ -101,7 +101,7 @@ public class BreakSizeSceneService extends AbstractSceneService {
101 * @param paramMap 101 * @param paramMap
102 * @return 102 * @return
103 */ 103 */
104 - @SearchCacheAble(cacheName = "SORT_SIZES", cacheInMinute = 10, excludeParams = { "uid", "page", "viewNum", "yh_channel" }) 104 + @SearchCacheAble(cacheName = "SORT_SIZES", cacheInMinute = 10, excludeParams = { "uid","udid","page", "viewNum", "yh_channel" })
105 public SearchApiResult sortSizes(Map<String, String> paramMap) { 105 public SearchApiResult sortSizes(Map<String, String> paramMap) {
106 try { 106 try {
107 this.addParamsToParamMap(paramMap); 107 this.addParamsToParamMap(paramMap);
@@ -59,7 +59,7 @@ public class HotSaleRankSceneService { @@ -59,7 +59,7 @@ public class HotSaleRankSceneService {
59 * @param paramMap 59 * @param paramMap
60 * @return 60 * @return
61 */ 61 */
62 - @SearchCacheAble(cacheInMinute = 60, cacheName = "HOT_SALE_RANK", excludeParams = { "client_type", "yh_channel", "order", "uid" }) 62 + @SearchCacheAble(cacheInMinute = 60, cacheName = "HOT_SALE_RANK", excludeParams = { "client_type", "yh_channel", "order", "uid","udid" })
63 public SearchApiResult hotSaleRankProductList(Map<String, String> paramMap) { 63 public SearchApiResult hotSaleRankProductList(Map<String, String> paramMap) {
64 try { 64 try {
65 // 0) 65 // 0)
@@ -85,7 +85,7 @@ public class NewGoodProductSceneService extends AbstractCacheAbleService { @@ -85,7 +85,7 @@ public class NewGoodProductSceneService extends AbstractCacheAbleService {
85 * @return 85 * @return
86 * @throws Exception 86 * @throws Exception
87 */ 87 */
88 - @SearchCacheAble(cacheInMinute = 10, cacheName = "GOOD_PRODUCT_BY_SKN",excludeParams={ "uid" }) 88 + @SearchCacheAble(cacheInMinute = 10, cacheName = "GOOD_PRODUCT_BY_SKN",excludeParams={ "uid","udid"})
89 public SearchApiResult goodProductListBySkn(Map<String, String> paramMap) throws Exception { 89 public SearchApiResult goodProductListBySkn(Map<String, String> paramMap) throws Exception {
90 try { 90 try {
91 // 1、获取skn参数 91 // 1、获取skn参数
@@ -62,7 +62,7 @@ public class SceneAggregationsHelper { @@ -62,7 +62,7 @@ public class SceneAggregationsHelper {
62 * @param paramMap 62 * @param paramMap
63 * @return 63 * @return
64 */ 64 */
65 - @SearchCacheAble(cacheName = "SCENE_AGG_STANDARD", cacheInMinute = 15, excludeParams = { "uid", "order", "page", "viewNum", "yh_channel" }) 65 + @SearchCacheAble(cacheName = "SCENE_AGG_STANDARD", cacheInMinute = 15, excludeParams = { "uid","udid", "order", "page", "viewNum", "yh_channel" })
66 public SearchApiResult sceneAggStandard(Map<String, String> paramMap) { 66 public SearchApiResult sceneAggStandard(Map<String, String> paramMap) {
67 try { 67 try {
68 IAggregation standardAggregation = aggregationFactoryService.getStandardAggregation(paramMap); 68 IAggregation standardAggregation = aggregationFactoryService.getStandardAggregation(paramMap);
@@ -80,7 +80,7 @@ public class SceneAggregationsHelper { @@ -80,7 +80,7 @@ public class SceneAggregationsHelper {
80 * @param paramMap 80 * @param paramMap
81 * @return 81 * @return
82 */ 82 */
83 - @SearchCacheAble(cacheName = "SCENE_AGG_CUSTOMIZETAG", cacheInMinute = 15, excludeParams = { "uid", "order", "page", "viewNum", "yh_channel" }) 83 + @SearchCacheAble(cacheName = "SCENE_AGG_CUSTOMIZETAG", cacheInMinute = 15, excludeParams = { "uid","udid","order", "page", "viewNum", "yh_channel" })
84 public SearchApiResult sceneAggCustomizeTag(Map<String, String> paramMap) { 84 public SearchApiResult sceneAggCustomizeTag(Map<String, String> paramMap) {
85 try { 85 try {
86 IAggregation customizeAggregation = aggregationFactoryService.getCustomizeTagAggregation(paramMap); 86 IAggregation customizeAggregation = aggregationFactoryService.getCustomizeTagAggregation(paramMap);
@@ -98,7 +98,7 @@ public class SceneAggregationsHelper { @@ -98,7 +98,7 @@ public class SceneAggregationsHelper {
98 * @param paramMap 98 * @param paramMap
99 * @return 99 * @return
100 */ 100 */
101 - @SearchCacheAble(cacheName = "SCENE_AGG_PROMOTION", cacheInMinute = 15, excludeParams = { "uid", "order", "page", "viewNum", "yh_channel" }) 101 + @SearchCacheAble(cacheName = "SCENE_AGG_PROMOTION", cacheInMinute = 15, excludeParams = { "uid","udid", "order", "page", "viewNum", "yh_channel" })
102 public SearchApiResult sceneAggPromotion(Map<String, String> paramMap) { 102 public SearchApiResult sceneAggPromotion(Map<String, String> paramMap) {
103 try { 103 try {
104 // 1、获取aggregation 104 // 1、获取aggregation
@@ -148,7 +148,7 @@ public class SceneAggregationsHelper { @@ -148,7 +148,7 @@ public class SceneAggregationsHelper {
148 * @param paramMap 148 * @param paramMap
149 * @return 149 * @return
150 */ 150 */
151 - @SearchCacheAble(cacheName = "SCENE_AGGREGATIONS", cacheInMinute = 30, excludeParams = { "uid", "order", "page", "viewNum", "yh_channel" }) 151 + @SearchCacheAble(cacheName = "SCENE_AGGREGATIONS", cacheInMinute = 30, excludeParams = { "uid","udid", "order", "page", "viewNum", "yh_channel" })
152 public SearchApiResult sceneAggregations(Map<String, String> paramMap) { 152 public SearchApiResult sceneAggregations(Map<String, String> paramMap) {
153 try { 153 try {
154 // 1、获取筛选项列表 154 // 1、获取筛选项列表
@@ -60,7 +60,7 @@ public class BrandWithShopsServiceImpl implements IBrandWithShopsService, Applic @@ -60,7 +60,7 @@ public class BrandWithShopsServiceImpl implements IBrandWithShopsService, Applic
60 } 60 }
61 61
62 @Override 62 @Override
63 - @SearchCacheAble(cacheInMinute = 30, cacheName = "BRANDS_WITH_SHOPS", excludeParams ={"viewNum","uid"}) 63 + @SearchCacheAble(cacheInMinute = 30, cacheName = "BRANDS_WITH_SHOPS", excludeParams ={"viewNum","uid","udid"})
64 public SearchApiResult brandsWithShops(Map<String, String> paramMap) { 64 public SearchApiResult brandsWithShops(Map<String, String> paramMap) {
65 try { 65 try {
66 logger.info("[func=brandsWithShops][param={}][begin={}]", paramMap.toString(), System.currentTimeMillis()); 66 logger.info("[func=brandsWithShops][param={}][begin={}]", paramMap.toString(), System.currentTimeMillis());