Authored by wangnan

shops支持搜索全球购店铺 fix

1 package com.yoho.search.service.service.helper; 1 package com.yoho.search.service.service.helper;
2 2
3 -import java.io.UnsupportedEncodingException;  
4 -import java.net.URLDecoder;  
5 -import java.util.ArrayList;  
6 -import java.util.Date;  
7 -import java.util.HashMap;  
8 -import java.util.Iterator;  
9 -import java.util.List;  
10 -import java.util.Map;  
11 -  
12 -import org.apache.commons.collections.CollectionUtils;  
13 -import org.apache.commons.lang.StringUtils;  
14 -import org.elasticsearch.index.query.BoolQueryBuilder;  
15 -import org.elasticsearch.index.query.MatchQueryBuilder;  
16 -import org.elasticsearch.index.query.MultiMatchQueryBuilder;  
17 -import org.elasticsearch.index.query.QueryBuilder;  
18 -import org.elasticsearch.index.query.QueryBuilders;  
19 -import org.slf4j.Logger;  
20 -import org.slf4j.LoggerFactory;  
21 -import org.springframework.beans.factory.annotation.Autowired;  
22 -import org.springframework.stereotype.Service;  
23 -  
24 import com.yoho.search.base.utils.ConvertUtils; 3 import com.yoho.search.base.utils.ConvertUtils;
25 import com.yoho.search.base.utils.DateUtil; 4 import com.yoho.search.base.utils.DateUtil;
26 import com.yoho.search.base.utils.ISearchConstants; 5 import com.yoho.search.base.utils.ISearchConstants;
@@ -32,6 +11,17 @@ import com.yoho.search.service.service.SearchCommonService; @@ -32,6 +11,17 @@ import com.yoho.search.service.service.SearchCommonService;
32 import com.yoho.search.service.service.SearchDynamicConfigService; 11 import com.yoho.search.service.service.SearchDynamicConfigService;
33 import com.yoho.search.service.service.SearchKeyWordService; 12 import com.yoho.search.service.service.SearchKeyWordService;
34 import com.yoho.search.service.utils.SearchRequestParams; 13 import com.yoho.search.service.utils.SearchRequestParams;
  14 +import org.apache.commons.collections.CollectionUtils;
  15 +import org.apache.commons.lang.StringUtils;
  16 +import org.elasticsearch.index.query.*;
  17 +import org.slf4j.Logger;
  18 +import org.slf4j.LoggerFactory;
  19 +import org.springframework.beans.factory.annotation.Autowired;
  20 +import org.springframework.stereotype.Service;
  21 +
  22 +import java.io.UnsupportedEncodingException;
  23 +import java.net.URLDecoder;
  24 +import java.util.*;
35 25
36 @Service 26 @Service
37 public class SearchServiceHelper { 27 public class SearchServiceHelper {
@@ -679,6 +669,9 @@ public class SearchServiceHelper { @@ -679,6 +669,9 @@ public class SearchServiceHelper {
679 productMap.put("sales_num", map.get("salesNum")); 669 productMap.put("sales_num", map.get("salesNum"));
680 productMap.put("status", map.get("status")); 670 productMap.put("status", map.get("status"));
681 productMap.put("is_promotion", map.get("ispromotion")); 671 productMap.put("is_promotion", map.get("ispromotion"));
  672 + productMap.put("is_promotion", map.get("ispromotion"));
  673 + productMap.put("tbl_country_id", map.get("tblCountryId"));
  674 + productMap.put("tbl_country_name", map.get("tblCountryName"));
682 675
683 String yohoodIdFromMap = (String) map.get("yohoodId"); 676 String yohoodIdFromMap = (String) map.get("yohoodId");
684 if (yohoodIdFromMap != null && yohoodIdFromMap.length() > 0) { 677 if (yohoodIdFromMap != null && yohoodIdFromMap.length() > 0) {
@@ -52,6 +52,7 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl @@ -52,6 +52,7 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl
52 52
53 ApplicationEventPublisher publisher; 53 ApplicationEventPublisher publisher;
54 54
  55 +
55 @Autowired 56 @Autowired
56 private SearchCommonService searchCommonService; 57 private SearchCommonService searchCommonService;
57 @Autowired 58 @Autowired
@@ -225,12 +226,14 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl @@ -225,12 +226,14 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl
225 } 226 }
226 } 227 }
227 228
228 - //tbl判断  
229 - SearchApiResult searchApiResult = searchTbl(paramMap,keyword); 229 + SearchApiResult searchApiResult = new SearchApiResult();
230 JSONObject returnMap = new JSONObject(); 230 JSONObject returnMap = new JSONObject();
231 returnMap.put("shop", null); 231 returnMap.put("shop", null);
232 returnMap.put("brand", null); 232 returnMap.put("brand", null);
233 returnMap.put("tblBrand", null); 233 returnMap.put("tblBrand", null);
  234 + //tbl判断
  235 + if (paramMap.containsKey("contain_global") && "Y".equals(paramMap.get("contain_global"))) {
  236 + searchApiResult = searchTbl(paramMap, keyword);
234 if (searchApiResult.getData() != null) { 237 if (searchApiResult.getData() != null) {
235 Map<String, Object> shopInfoMap = (Map<String, Object>) searchApiResult.getData(); 238 Map<String, Object> shopInfoMap = (Map<String, Object>) searchApiResult.getData();
236 JSONObject shopDataMap = new JSONObject(); 239 JSONObject shopDataMap = new JSONObject();
@@ -241,7 +244,7 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl @@ -241,7 +244,7 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl
241 returnMap.put("tblBrand", shopDataMap); 244 returnMap.put("tblBrand", shopDataMap);
242 return searchApiResult.setData(returnMap); 245 return searchApiResult.setData(returnMap);
243 } 246 }
244 - 247 + }
245 248
246 // 2、配置keyword的查询字段以及权重设置 249 // 2、配置keyword的查询字段以及权重设置
247 MultiMatchQueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(keyword); 250 MultiMatchQueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(keyword);
@@ -315,6 +318,7 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl @@ -315,6 +318,7 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl
315 318
316 /** 319 /**
317 * shopsNew中搜索是否有匹配的全球购店铺,如果有直接返回。 320 * shopsNew中搜索是否有匹配的全球购店铺,如果有直接返回。
  321 + *
318 * @param paramMap 322 * @param paramMap
319 * @param keyword 323 * @param keyword
320 * @return 324 * @return
@@ -468,6 +472,9 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl @@ -468,6 +472,9 @@ public class ShopsServiceImpl extends BaseService implements IShopsService, Appl
468 */ 472 */
469 private BoolQueryBuilder constructShopsFilterBuilder(Map<String, String> paramMap) throws Exception { 473 private BoolQueryBuilder constructShopsFilterBuilder(Map<String, String> paramMap) throws Exception {
470 BoolQueryBuilder boolFilter = QueryBuilders.boolQuery(); 474 BoolQueryBuilder boolFilter = QueryBuilders.boolQuery();
  475 + if (!paramMap.containsKey("contain_global") && !"Y".equals(paramMap.get("contain_global"))) {
  476 + boolFilter = boolFilter.must(QueryBuilders.termQuery("contain_global", "N"));
  477 + }
471 boolFilter = BoolQueryTermQuery(paramMap, boolFilter, SearchRequestParams.SHOPS_PARAM_BLKSTATUS); 478 boolFilter = BoolQueryTermQuery(paramMap, boolFilter, SearchRequestParams.SHOPS_PARAM_BLKSTATUS);
472 boolFilter = BoolQueryTermQuery(paramMap, boolFilter, SearchRequestParams.SHOPS_PARAM_CHECKSTATUS); 479 boolFilter = BoolQueryTermQuery(paramMap, boolFilter, SearchRequestParams.SHOPS_PARAM_CHECKSTATUS);
473 boolFilter = BoolQueryTermQuery(paramMap, boolFilter, SearchRequestParams.SHOPS_PARAM_EXAMINESTATUS); 480 boolFilter = BoolQueryTermQuery(paramMap, boolFilter, SearchRequestParams.SHOPS_PARAM_EXAMINESTATUS);
@@ -75,6 +75,7 @@ public class SearchRequestParams { @@ -75,6 +75,7 @@ public class SearchRequestParams {
75 public static final String SHOPS_PARAM_OPERATIONSTATUS = "operationStatus"; 75 public static final String SHOPS_PARAM_OPERATIONSTATUS = "operationStatus";
76 public static final String SHOPS_PARAM_SHOPSTYPE = "shopsType"; 76 public static final String SHOPS_PARAM_SHOPSTYPE = "shopsType";
77 public static final String SHOPS_PARAM_STATUS = "status"; 77 public static final String SHOPS_PARAM_STATUS = "status";
  78 + public static final String SHOPS_PARAM_ISGLOBAL = "isGlobal";
78 79
79 80
80 81