Authored by hugufei

不缓存的参数全部去掉udid

... ... @@ -38,8 +38,7 @@ public class CommonPageRecallService extends BaseRecallService {
* @param paramMap
* @return
*/
@SearchCacheAble(cacheInMinute = 3, needMd5 = false, cacheName = "COMMON_PAGE_RECALL_BATCH", cacheType = CacheType.EHCACHE, returnClass = CommonRecallResult.class, excludeParams = {
"uid", "order", "page" })
@SearchCacheAble(cacheInMinute = 3, needMd5 = false, cacheName = "COMMON_PAGE_RECALL_BATCH", cacheType = CacheType.EHCACHE, returnClass = CommonRecallResult.class, excludeParams = {"uid","udid","order", "page" })
public CommonRecallResult doCommonPageRecallBatch(Map<String, String> paramMap) {
try {
int viewNum = this.getViewNum(paramMap);
... ...
... ... @@ -21,372 +21,390 @@ import java.util.Map;
@Component
public class SearchCommonHelper {
@Autowired
private SearchDynamicConfigService dynamicConfig;
@Autowired
private SearchServiceConfiger searchServiceConfiger;
@Autowired
private SearchDynamicConfigService searchDynamicConfigService;
public int getPage(Map<String, String> paramMap) {
return StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page"));
}
public int getPageSize(Map<String, String> paramMap) {
return StringUtils.isBlank(paramMap.get("viewNum")) ? 60 : Integer.parseInt(paramMap.get("viewNum"));
}
public boolean isPersionalScene(Map<String, String> paramMap) {
if (!searchDynamicConfigService.openPersonalized()) {
return false;
}
if (this.hasUid(paramMap) && this.isOrderEmpty(paramMap)) {
return true;
}
return false;
}
public long getTotalPage(long total, int size) {
return PageUtils.getTotalPage(total,size);
}
public int getUid(Map<String, String> paramMap) {
try {
return MapUtils.getIntValue(paramMap, "uid", 0);
} catch (Exception e) {
return 0;
}
}
public boolean hasUid(Map<String, String> paramMap) {
return this.getUid(paramMap) > 0;
}
/**
* 是否是默认的模糊搜索
*
* @param paramMap
* @return
*/
public boolean isFuzzySearchPageDefault(Map<String, String> paramMap) {
String query = paramMap.get(SearchRequestParams.PARAM_SEARCH_QUERY);
if (StringUtils.isBlank(query)) {
return false;
}
if (!this.isOrderEmpty(paramMap)) {
return false;
}
String pageId = paramMap.get(SearchRequestParams.PARAM_SEARCH_PAGEID);
if (!SearchPageIdDefine.PAGE_ID_SEARCH.equalsIgnoreCase(pageId)) {
return false;
}
return true;
}
/**
* 是否需要开启个性化
*
* @param paramMap
* @return
*/
public boolean isNeedPersonalSearch(Map<String, String> paramMap) {
// 从 zk中动态获取是否使用个性化
boolean openPersonalized = dynamicConfig.openPersonalized();
if (!openPersonalized) {
return false;
}
if(!this.hasUid(paramMap)){
return false;
}
if (!this.isOrderEmpty(paramMap)) {
return false;
}
return true;
}
/**
* 是否需要对某个SKN加分
*
* @param paramMap
* @return
*/
public boolean isFirstProductSknSearch(Map<String, String> paramMap) {
String first_productskn = paramMap.get(SearchRequestParams.PARAM_SEARCH_FIRST_PRODUCRSKN);
if (StringUtils.isBlank(first_productskn)) {
return false;
}
if (!this.isOrderEmpty(paramMap)) {
return false;
}
return true;
}
/**
* 是否需要对频道降分
*
* @param paramMap
* @return
*/
public boolean isNeedDeScoreForChannel(Map<String, String> paramMap) {
String physicalChannel = paramMap.get(SearchRequestParams.PARAM_SEARCH_PHYSICAL_CHANNEL);
if (StringUtils.isBlank(physicalChannel)) {
return false;
}
if (!isFuzzySearchPageDefault(paramMap)) {
return false;
}
if (!dynamicConfig.isDeScorePhysicalChannelOpen()) {
return false;
}
return true;
}
/**
* 判断搜索是否需要包含全球购
*
* @param paramMap
* @return
*/
public boolean containGlobal(Map<String, String> paramMap) {
// 1、如果总开关关了,则肯定不包含全球购商品
boolean containglobal = dynamicConfig.containglobal();
if (!containglobal) {
return false;
}
// 2、如果前端传来的参数中不包含contain_global!=Y,则不包含全球购
if (!paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_CONTAIN_GLOBAL) || !"Y".equals(paramMap.get(SearchRequestParams.PARAM_SEARCH_CONTAIN_GLOBAL))) {
return false;
}
return true;
}
/**
* 当前查询的关键字是否是skn
*
* @param keyword
* @return
*/
public boolean isQuerySknOrSku(String keyword) {
try {
String key = "";
if (keyword.contains(" ")) {
key = keyword.split(" ")[0];
} else if (keyword.contains(",")) {
key = keyword.split(",")[0];
} else if (keyword.contains("+")) {
key = keyword.split("\\+")[0];
}
if ((CharUtils.isNumeric(keyword) && keyword.length() >= 6) || (CharUtils.isNumeric(key) && key.length() >= 6)) {
return true;
}
return false;
} catch (Exception e) {
return false;
}
}
/**
* 从搜索的关键词中提取出skn信息
*
* @param keyword
* @return
*/
public List<Integer> getQuerySknList(String keyword) {
List<Integer> sknList = new ArrayList<>();
try {
String[] keys = null;
if (keyword.contains(" ")) {
keys = keyword.split(" ");
} else if (keyword.contains(",")) {
keys = keyword.split(",");
} else if (keyword.contains("+")) {
keys = keyword.split("\\+");
}
if (keys != null && keys.length > 0) {
for (String key : keys) {
if (CharUtils.isNumeric(key) && key.length() >= 7) {
sknList.add(Integer.valueOf(key));
}
}
}
return sknList;
} catch (Exception e) {
return sknList;
}
}
/**
* 是否是新品到着页
*
* @param paramMap
* @return
*/
public boolean isNewRecPage(Map<String, String> paramMap) {
String pageId = paramMap.get(SearchRequestParams.PARAM_SEARCH_PAGEID);
if (StringUtils.isBlank(pageId) || !pageId.equals(SearchPageIdDefine.PAGE_ID_NEW)) {
return false;
}
return true;
}
/**
* 是否是新品到着默认页
*
* @param paramMap
* @return
*/
public boolean isNewRecPageDefault(Map<String, String> paramMap) {
if (!isNewRecPage(paramMap)) {
return false;
}
if (!this.isOrderEmpty(paramMap)) {
return false;
}
return true;
}
/**
* 是否是新品到着页的人气排序
*
* @param paramMap
* @return
*/
public boolean isNewRecHeatValueDescSearch(Map<String, String> paramMap) {
if (!this.isNewRecPage(paramMap)) {
return false;
}
String order = paramMap.get(SearchRequestParams.PARAM_SEARCH_ORDER);
if (StringUtils.isBlank(order)) {
return false;
}
if (!order.contains("heatValue")) {
return false;
}
return true;
}
/**
* 是否未传order
*
* @param paramMap
* @return
*/
public boolean isOrderEmpty(Map<String, String> paramMap) {
String order = paramMap.get(SearchRequestParams.PARAM_SEARCH_ORDER);
if (!StringUtils.isBlank(order)) {
return false;
}
return true;
}
/**
* 是否是品类列表的默认页
*
* @param paramMap
* @return
*/
public boolean isSortPageDefault(Map<String, String> paramMap) {
String pageId = paramMap.get(SearchRequestParams.PARAM_SEARCH_PAGEID);
if (StringUtils.isBlank(pageId) || !pageId.equals(SearchPageIdDefine.PAGE_ID_SORT)) {
return false;
}
if (!this.isOrderEmpty(paramMap)) {
return false;
}
return true;
}
/**
* 关键字中含性别,则加上性别的过滤条件
*
* @param keyword
* @param paramMap
*/
public void dealKeywordOfGender(String keyword, Map<String, String> paramMap) {
// 如果参数中已经包含了性别,则不处理
String gender = paramMap.get(SearchRequestParams.PARAM_SEARCH_GENDER);
if (StringUtils.isNotBlank(gender)) {
return;
}
// 对男女关键字做特殊处理
boolean cotainBoy = keyword.contains("男");
boolean cotainGirl = keyword.contains("女");
// 对性别做特殊处理
if (cotainBoy && !cotainGirl) {
paramMap.put(SearchRequestParams.PARAM_SEARCH_GENDER, "1,3");
return;
}
if (!cotainBoy && cotainGirl) {
paramMap.put(SearchRequestParams.PARAM_SEARCH_GENDER, "2,3");
return;
}
if (cotainBoy && cotainGirl) {
paramMap.put(SearchRequestParams.PARAM_SEARCH_GENDER, "1,2,3");
return;
}
}
// 获取MultiMatchQueryBuilder的类型
public MultiMatchQueryBuilder.Type getMultiMatchQueryBuilderType() {
String configMultiMatchQueryType = searchServiceConfiger.getSearchMultiMatchQueryType();
return SearchFieldUtils.getMultiMatchQueryBuilderType(configMultiMatchQueryType);
}
/**
* 构造活动相关的过滤条件
*
* @param paramMap
* @return
*/
public BoolQueryBuilder getActivitiesTermsBuilder(Map<String, String> paramMap) {
// 增加活动模板相关的过滤条件
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ACT_TEMP) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_TEMP))) {
BoolQueryBuilder nestedBoolFilter = QueryBuilders.boolQuery();
nestedBoolFilter.must(QueryBuilders.termQuery("activities.template_id", paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_TEMP)));
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ACT_REC) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_REC))) {
nestedBoolFilter.must(QueryBuilders.termQuery("activities.is_recommend", paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_REC)));
}
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ACT_STATUS) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_STATUS))) {
nestedBoolFilter.must(QueryBuilders.termQuery("activities.status", paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_STATUS)));
}
return nestedBoolFilter;
}
return null;
}
/**
* 构造商品池相关的过滤条件
*
* @param paramMap
* @return
*/
public BoolQueryBuilder getPoolIdTermsBuilder(Map<String, String> paramMap) {
// 增加商品池相关的过滤条件
if (paramMap.containsKey("filter_poolId") && StringUtils.isNotBlank("filter_poolId")) {
BoolQueryBuilder nestedBoolFilter = QueryBuilders.boolQuery();
nestedBoolFilter.must(QueryBuilders.termQuery("pools.pool_id", paramMap.get("filter_poolId")));
return nestedBoolFilter;
}
return null;
}
/**
* 自定义标签过滤
*
* @param paramMap
* @return
*/
public BoolQueryBuilder getCustomizeTagBuilder(Map<String, String> paramMap) {
if (paramMap.containsKey(SearchRequestParams.SHOPS_PARAM_CUSTOMIZE_TAG) && StringUtils.isNotBlank(SearchRequestParams.SHOPS_PARAM_CUSTOMIZE_TAG)) {
int[] ids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.SHOPS_PARAM_CUSTOMIZE_TAG), ",");
BoolQueryBuilder nestedBoolFilter = QueryBuilders.boolQuery();
nestedBoolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.customizeTagsId, ids));
return nestedBoolFilter;
}
return null;
}
@Autowired
private SearchDynamicConfigService dynamicConfig;
@Autowired
private SearchServiceConfiger searchServiceConfiger;
@Autowired
private SearchDynamicConfigService searchDynamicConfigService;
public int getPage(Map<String, String> paramMap) {
return StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page"));
}
public int getPageSize(Map<String, String> paramMap) {
return StringUtils.isBlank(paramMap.get("viewNum")) ? 60 : Integer.parseInt(paramMap.get("viewNum"));
}
public boolean isPersionalScene(Map<String, String> paramMap) {
if (!searchDynamicConfigService.openPersonalized()) {
return false;
}
if (!this.isOrderEmpty(paramMap)) {
return false;
}
if (this.hasUid(paramMap)) {
return true;
}
if (this.hasUdid(paramMap)) {
return true;
}
return false;
}
public long getTotalPage(long total, int size) {
return PageUtils.getTotalPage(total, size);
}
public int getUid(Map<String, String> paramMap) {
try {
return MapUtils.getIntValue(paramMap, "uid", 0);
} catch (Exception e) {
return 0;
}
}
public String getUdid(Map<String, String> paramMap) {
try {
return MapUtils.getString(paramMap, "udid", "");
} catch (Exception e) {
return "";
}
}
public boolean hasUid(Map<String, String> paramMap) {
return this.getUid(paramMap) > 0;
}
public boolean hasUdid(Map<String, String> paramMap) {
return StringUtils.isBlank(this.getUdid(paramMap))?false:true;
}
/**
* 是否是默认的模糊搜索
*
* @param paramMap
* @return
*/
public boolean isFuzzySearchPageDefault(Map<String, String> paramMap) {
String query = paramMap.get(SearchRequestParams.PARAM_SEARCH_QUERY);
if (StringUtils.isBlank(query)) {
return false;
}
if (!this.isOrderEmpty(paramMap)) {
return false;
}
String pageId = paramMap.get(SearchRequestParams.PARAM_SEARCH_PAGEID);
if (!SearchPageIdDefine.PAGE_ID_SEARCH.equalsIgnoreCase(pageId)) {
return false;
}
return true;
}
/**
* 是否需要开启个性化
*
* @param paramMap
* @return
*/
public boolean isNeedPersonalSearch(Map<String, String> paramMap) {
// 从 zk中动态获取是否使用个性化
boolean openPersonalized = dynamicConfig.openPersonalized();
if (!openPersonalized) {
return false;
}
if (!this.hasUid(paramMap)) {
return false;
}
if (!this.isOrderEmpty(paramMap)) {
return false;
}
return true;
}
/**
* 是否需要对某个SKN加分
*
* @param paramMap
* @return
*/
public boolean isFirstProductSknSearch(Map<String, String> paramMap) {
String first_productskn = paramMap.get(SearchRequestParams.PARAM_SEARCH_FIRST_PRODUCRSKN);
if (StringUtils.isBlank(first_productskn)) {
return false;
}
if (!this.isOrderEmpty(paramMap)) {
return false;
}
return true;
}
/**
* 是否需要对频道降分
*
* @param paramMap
* @return
*/
public boolean isNeedDeScoreForChannel(Map<String, String> paramMap) {
String physicalChannel = paramMap.get(SearchRequestParams.PARAM_SEARCH_PHYSICAL_CHANNEL);
if (StringUtils.isBlank(physicalChannel)) {
return false;
}
if (!isFuzzySearchPageDefault(paramMap)) {
return false;
}
if (!dynamicConfig.isDeScorePhysicalChannelOpen()) {
return false;
}
return true;
}
/**
* 判断搜索是否需要包含全球购
*
* @param paramMap
* @return
*/
public boolean containGlobal(Map<String, String> paramMap) {
// 1、如果总开关关了,则肯定不包含全球购商品
boolean containglobal = dynamicConfig.containglobal();
if (!containglobal) {
return false;
}
// 2、如果前端传来的参数中不包含contain_global!=Y,则不包含全球购
if (!paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_CONTAIN_GLOBAL) || !"Y".equals(paramMap.get(SearchRequestParams.PARAM_SEARCH_CONTAIN_GLOBAL))) {
return false;
}
return true;
}
/**
* 当前查询的关键字是否是skn
*
* @param keyword
* @return
*/
public boolean isQuerySknOrSku(String keyword) {
try {
String key = "";
if (keyword.contains(" ")) {
key = keyword.split(" ")[0];
} else if (keyword.contains(",")) {
key = keyword.split(",")[0];
} else if (keyword.contains("+")) {
key = keyword.split("\\+")[0];
}
if ((CharUtils.isNumeric(keyword) && keyword.length() >= 6) || (CharUtils.isNumeric(key) && key.length() >= 6)) {
return true;
}
return false;
} catch (Exception e) {
return false;
}
}
/**
* 从搜索的关键词中提取出skn信息
*
* @param keyword
* @return
*/
public List<Integer> getQuerySknList(String keyword) {
List<Integer> sknList = new ArrayList<>();
try {
String[] keys = null;
if (keyword.contains(" ")) {
keys = keyword.split(" ");
} else if (keyword.contains(",")) {
keys = keyword.split(",");
} else if (keyword.contains("+")) {
keys = keyword.split("\\+");
}
if (keys != null && keys.length > 0) {
for (String key : keys) {
if (CharUtils.isNumeric(key) && key.length() >= 7) {
sknList.add(Integer.valueOf(key));
}
}
}
return sknList;
} catch (Exception e) {
return sknList;
}
}
/**
* 是否是新品到着页
*
* @param paramMap
* @return
*/
public boolean isNewRecPage(Map<String, String> paramMap) {
String pageId = paramMap.get(SearchRequestParams.PARAM_SEARCH_PAGEID);
if (StringUtils.isBlank(pageId) || !pageId.equals(SearchPageIdDefine.PAGE_ID_NEW)) {
return false;
}
return true;
}
/**
* 是否是新品到着默认页
*
* @param paramMap
* @return
*/
public boolean isNewRecPageDefault(Map<String, String> paramMap) {
if (!isNewRecPage(paramMap)) {
return false;
}
if (!this.isOrderEmpty(paramMap)) {
return false;
}
return true;
}
/**
* 是否是新品到着页的人气排序
*
* @param paramMap
* @return
*/
public boolean isNewRecHeatValueDescSearch(Map<String, String> paramMap) {
if (!this.isNewRecPage(paramMap)) {
return false;
}
String order = paramMap.get(SearchRequestParams.PARAM_SEARCH_ORDER);
if (StringUtils.isBlank(order)) {
return false;
}
if (!order.contains("heatValue")) {
return false;
}
return true;
}
/**
* 是否未传order
*
* @param paramMap
* @return
*/
public boolean isOrderEmpty(Map<String, String> paramMap) {
String order = paramMap.get(SearchRequestParams.PARAM_SEARCH_ORDER);
if (!StringUtils.isBlank(order)) {
return false;
}
return true;
}
/**
* 是否是品类列表的默认页
*
* @param paramMap
* @return
*/
public boolean isSortPageDefault(Map<String, String> paramMap) {
String pageId = paramMap.get(SearchRequestParams.PARAM_SEARCH_PAGEID);
if (StringUtils.isBlank(pageId) || !pageId.equals(SearchPageIdDefine.PAGE_ID_SORT)) {
return false;
}
if (!this.isOrderEmpty(paramMap)) {
return false;
}
return true;
}
/**
* 关键字中含性别,则加上性别的过滤条件
*
* @param keyword
* @param paramMap
*/
public void dealKeywordOfGender(String keyword, Map<String, String> paramMap) {
// 如果参数中已经包含了性别,则不处理
String gender = paramMap.get(SearchRequestParams.PARAM_SEARCH_GENDER);
if (StringUtils.isNotBlank(gender)) {
return;
}
// 对男女关键字做特殊处理
boolean cotainBoy = keyword.contains("男");
boolean cotainGirl = keyword.contains("女");
// 对性别做特殊处理
if (cotainBoy && !cotainGirl) {
paramMap.put(SearchRequestParams.PARAM_SEARCH_GENDER, "1,3");
return;
}
if (!cotainBoy && cotainGirl) {
paramMap.put(SearchRequestParams.PARAM_SEARCH_GENDER, "2,3");
return;
}
if (cotainBoy && cotainGirl) {
paramMap.put(SearchRequestParams.PARAM_SEARCH_GENDER, "1,2,3");
return;
}
}
// 获取MultiMatchQueryBuilder的类型
public MultiMatchQueryBuilder.Type getMultiMatchQueryBuilderType() {
String configMultiMatchQueryType = searchServiceConfiger.getSearchMultiMatchQueryType();
return SearchFieldUtils.getMultiMatchQueryBuilderType(configMultiMatchQueryType);
}
/**
* 构造活动相关的过滤条件
*
* @param paramMap
* @return
*/
public BoolQueryBuilder getActivitiesTermsBuilder(Map<String, String> paramMap) {
// 增加活动模板相关的过滤条件
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ACT_TEMP) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_TEMP))) {
BoolQueryBuilder nestedBoolFilter = QueryBuilders.boolQuery();
nestedBoolFilter.must(QueryBuilders.termQuery("activities.template_id", paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_TEMP)));
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ACT_REC) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_REC))) {
nestedBoolFilter.must(QueryBuilders.termQuery("activities.is_recommend", paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_REC)));
}
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_ACT_STATUS) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_STATUS))) {
nestedBoolFilter.must(QueryBuilders.termQuery("activities.status", paramMap.get(SearchRequestParams.PARAM_SEARCH_ACT_STATUS)));
}
return nestedBoolFilter;
}
return null;
}
/**
* 构造商品池相关的过滤条件
*
* @param paramMap
* @return
*/
public BoolQueryBuilder getPoolIdTermsBuilder(Map<String, String> paramMap) {
// 增加商品池相关的过滤条件
if (paramMap.containsKey("filter_poolId") && StringUtils.isNotBlank("filter_poolId")) {
BoolQueryBuilder nestedBoolFilter = QueryBuilders.boolQuery();
nestedBoolFilter.must(QueryBuilders.termQuery("pools.pool_id", paramMap.get("filter_poolId")));
return nestedBoolFilter;
}
return null;
}
/**
* 自定义标签过滤
*
* @param paramMap
* @return
*/
public BoolQueryBuilder getCustomizeTagBuilder(Map<String, String> paramMap) {
if (paramMap.containsKey(SearchRequestParams.SHOPS_PARAM_CUSTOMIZE_TAG) && StringUtils.isNotBlank(SearchRequestParams.SHOPS_PARAM_CUSTOMIZE_TAG)) {
int[] ids = ConvertUtils.stringToIntArray(paramMap.get(SearchRequestParams.SHOPS_PARAM_CUSTOMIZE_TAG), ",");
BoolQueryBuilder nestedBoolFilter = QueryBuilders.boolQuery();
nestedBoolFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.customizeTagsId, ids));
return nestedBoolFilter;
}
return null;
}
}
... ...
... ... @@ -42,9 +42,22 @@ public class DefaultProductListService {
* @param paramMap
* @return
*/
@SearchCacheAble(cacheName = "PRODUCT_LIST_NOT_PERSIONAL", cacheType = CacheType.SEARCH_REDIS, cacheInMinute = 10, excludeParams = {"uid", "firstProductSkn"})
@SearchCacheAble(cacheName = "PRODUCT_LIST_NOT_PERSIONAL", cacheType = CacheType.SEARCH_REDIS, cacheInMinute = 10, excludeParams = {"uid", "udid", "firstProductSkn"})
public SearchApiResult productListNotPersional(Map<String, String> paramMap) {
return this.productList(paramMap);
try {
// 1) 构建SearchParam
SearchParam searchParam = productListHelper.buildProductListSearchParam(paramMap, false);
// 2) 执行搜索
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
// 3) 构造返回结果,无需做品类品牌平衡
JSONObject productListResult = productListHelper.buildProductListResult(searchResult, searchParam.getSize(), false);
return new SearchApiResult().setData(productListResult);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new SearchApiResult().setData(null).setCode(500);
}
}
/**
... ... @@ -55,10 +68,6 @@ public class DefaultProductListService {
*/
@SearchCacheAble(cacheName = "PRODUCT_LIST_DEFAULT_PERSIONAL", cacheType = CacheType.SEARCH_REDIS, cacheInMinute = 10)
public SearchApiResult productListForDefaultPersional(Map<String, String> paramMap) {
return this.productList(paramMap);
}
private SearchApiResult productList(Map<String, String> paramMap) {
try {
// 1) 构建SearchParam
SearchParam searchParam = productListHelper.buildProductListSearchParam(paramMap, true);//这个必须用buildWithPersional构造,有些特殊的逻辑-如firstSkn在里面
... ... @@ -66,10 +75,8 @@ public class DefaultProductListService {
// 2) 执行搜索
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
// 3) 构造返回结果
boolean needResort = searchCommonHelper.isOrderEmpty(paramMap);//没传order时,做下品类品牌的平衡
JSONObject productListResult = productListHelper.buildProductListResult(searchResult, searchParam.getSize() , needResort);
// 3) 构造返回结果,需做品类品牌平衡
JSONObject productListResult = productListHelper.buildProductListResult(searchResult, searchParam.getSize(), true);
return new SearchApiResult().setData(productListResult);
} catch (Exception e) {
logger.error(e.getMessage(), e);
... ...
... ... @@ -101,7 +101,7 @@ public class BreakSizeSceneService extends AbstractSceneService {
* @param paramMap
* @return
*/
@SearchCacheAble(cacheName = "SORT_SIZES", cacheInMinute = 10, excludeParams = { "uid", "page", "viewNum", "yh_channel" })
@SearchCacheAble(cacheName = "SORT_SIZES", cacheInMinute = 10, excludeParams = { "uid","udid","page", "viewNum", "yh_channel" })
public SearchApiResult sortSizes(Map<String, String> paramMap) {
try {
this.addParamsToParamMap(paramMap);
... ...
... ... @@ -59,7 +59,7 @@ public class HotSaleRankSceneService {
* @param paramMap
* @return
*/
@SearchCacheAble(cacheInMinute = 60, cacheName = "HOT_SALE_RANK", excludeParams = { "client_type", "yh_channel", "order", "uid" })
@SearchCacheAble(cacheInMinute = 60, cacheName = "HOT_SALE_RANK", excludeParams = { "client_type", "yh_channel", "order", "uid","udid" })
public SearchApiResult hotSaleRankProductList(Map<String, String> paramMap) {
try {
// 0)
... ...
... ... @@ -85,7 +85,7 @@ public class NewGoodProductSceneService extends AbstractCacheAbleService {
* @return
* @throws Exception
*/
@SearchCacheAble(cacheInMinute = 10, cacheName = "GOOD_PRODUCT_BY_SKN",excludeParams={ "uid" })
@SearchCacheAble(cacheInMinute = 10, cacheName = "GOOD_PRODUCT_BY_SKN",excludeParams={ "uid","udid"})
public SearchApiResult goodProductListBySkn(Map<String, String> paramMap) throws Exception {
try {
// 1、获取skn参数
... ...
... ... @@ -62,7 +62,7 @@ public class SceneAggregationsHelper {
* @param paramMap
* @return
*/
@SearchCacheAble(cacheName = "SCENE_AGG_STANDARD", cacheInMinute = 15, excludeParams = { "uid", "order", "page", "viewNum", "yh_channel" })
@SearchCacheAble(cacheName = "SCENE_AGG_STANDARD", cacheInMinute = 15, excludeParams = { "uid","udid", "order", "page", "viewNum", "yh_channel" })
public SearchApiResult sceneAggStandard(Map<String, String> paramMap) {
try {
IAggregation standardAggregation = aggregationFactoryService.getStandardAggregation(paramMap);
... ... @@ -80,7 +80,7 @@ public class SceneAggregationsHelper {
* @param paramMap
* @return
*/
@SearchCacheAble(cacheName = "SCENE_AGG_CUSTOMIZETAG", cacheInMinute = 15, excludeParams = { "uid", "order", "page", "viewNum", "yh_channel" })
@SearchCacheAble(cacheName = "SCENE_AGG_CUSTOMIZETAG", cacheInMinute = 15, excludeParams = { "uid","udid","order", "page", "viewNum", "yh_channel" })
public SearchApiResult sceneAggCustomizeTag(Map<String, String> paramMap) {
try {
IAggregation customizeAggregation = aggregationFactoryService.getCustomizeTagAggregation(paramMap);
... ... @@ -98,7 +98,7 @@ public class SceneAggregationsHelper {
* @param paramMap
* @return
*/
@SearchCacheAble(cacheName = "SCENE_AGG_PROMOTION", cacheInMinute = 15, excludeParams = { "uid", "order", "page", "viewNum", "yh_channel" })
@SearchCacheAble(cacheName = "SCENE_AGG_PROMOTION", cacheInMinute = 15, excludeParams = { "uid","udid", "order", "page", "viewNum", "yh_channel" })
public SearchApiResult sceneAggPromotion(Map<String, String> paramMap) {
try {
// 1、获取aggregation
... ... @@ -148,7 +148,7 @@ public class SceneAggregationsHelper {
* @param paramMap
* @return
*/
@SearchCacheAble(cacheName = "SCENE_AGGREGATIONS", cacheInMinute = 30, excludeParams = { "uid", "order", "page", "viewNum", "yh_channel" })
@SearchCacheAble(cacheName = "SCENE_AGGREGATIONS", cacheInMinute = 30, excludeParams = { "uid","udid", "order", "page", "viewNum", "yh_channel" })
public SearchApiResult sceneAggregations(Map<String, String> paramMap) {
try {
// 1、获取筛选项列表
... ...
... ... @@ -60,7 +60,7 @@ public class BrandWithShopsServiceImpl implements IBrandWithShopsService, Applic
}
@Override
@SearchCacheAble(cacheInMinute = 30, cacheName = "BRANDS_WITH_SHOPS", excludeParams ={"viewNum","uid"})
@SearchCacheAble(cacheInMinute = 30, cacheName = "BRANDS_WITH_SHOPS", excludeParams ={"viewNum","uid","udid"})
public SearchApiResult brandsWithShops(Map<String, String> paramMap) {
try {
logger.info("[func=brandsWithShops][param={}][begin={}]", paramMap.toString(), System.currentTimeMillis());
... ...