Showing
8 changed files
with
47 additions
and
23 deletions
@@ -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); |
@@ -40,14 +40,20 @@ public class SearchCommonHelper { | @@ -40,14 +40,20 @@ public class SearchCommonHelper { | ||
40 | if (!searchDynamicConfigService.openPersonalized()) { | 40 | if (!searchDynamicConfigService.openPersonalized()) { |
41 | return false; | 41 | return false; |
42 | } | 42 | } |
43 | - if (this.hasUid(paramMap) && this.isOrderEmpty(paramMap)) { | 43 | + if (!this.isOrderEmpty(paramMap)) { |
44 | + return false; | ||
45 | + } | ||
46 | + if (this.hasUid(paramMap)) { | ||
47 | + return true; | ||
48 | + } | ||
49 | + if (this.hasUdid(paramMap)) { | ||
44 | return true; | 50 | return true; |
45 | } | 51 | } |
46 | return false; | 52 | return false; |
47 | } | 53 | } |
48 | 54 | ||
49 | public long getTotalPage(long total, int size) { | 55 | public long getTotalPage(long total, int size) { |
50 | - return PageUtils.getTotalPage(total,size); | 56 | + return PageUtils.getTotalPage(total, size); |
51 | } | 57 | } |
52 | 58 | ||
53 | public int getUid(Map<String, String> paramMap) { | 59 | public int getUid(Map<String, String> paramMap) { |
@@ -58,10 +64,22 @@ public class SearchCommonHelper { | @@ -58,10 +64,22 @@ public class SearchCommonHelper { | ||
58 | } | 64 | } |
59 | } | 65 | } |
60 | 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 | + | ||
61 | public boolean hasUid(Map<String, String> paramMap) { | 75 | public boolean hasUid(Map<String, String> paramMap) { |
62 | return this.getUid(paramMap) > 0; | 76 | return this.getUid(paramMap) > 0; |
63 | } | 77 | } |
64 | 78 | ||
79 | + public boolean hasUdid(Map<String, String> paramMap) { | ||
80 | + return StringUtils.isBlank(this.getUdid(paramMap))?false:true; | ||
81 | + } | ||
82 | + | ||
65 | 83 | ||
66 | /** | 84 | /** |
67 | * 是否是默认的模糊搜索 | 85 | * 是否是默认的模糊搜索 |
@@ -96,7 +114,7 @@ public class SearchCommonHelper { | @@ -96,7 +114,7 @@ public class SearchCommonHelper { | ||
96 | if (!openPersonalized) { | 114 | if (!openPersonalized) { |
97 | return false; | 115 | return false; |
98 | } | 116 | } |
99 | - if(!this.hasUid(paramMap)){ | 117 | + if (!this.hasUid(paramMap)) { |
100 | return false; | 118 | return false; |
101 | } | 119 | } |
102 | if (!this.isOrderEmpty(paramMap)) { | 120 | if (!this.isOrderEmpty(paramMap)) { |
@@ -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()); |
-
Please register or login to post a comment