Authored by hugufei

类重命名

1 -package com.yoho.search.recall.scene;  
2 -  
3 -import com.alibaba.fastjson.JSONObject;  
4 -import com.yoho.search.base.utils.CollectionUtils;  
5 -import com.yoho.search.base.utils.ISearchConstants;  
6 -import com.yoho.search.base.utils.ProductIndexEsField;  
7 -import com.yoho.search.core.es.model.SearchParam;  
8 -import com.yoho.search.core.es.model.SearchResult;  
9 -import com.yoho.search.models.SearchApiResult;  
10 -import com.yoho.search.recall.scene.beans.cache.QueryRecallResultCacheBean;  
11 -import com.yoho.search.recall.scene.beans.cache.QueryProductInfoCacheBean;  
12 -import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper;  
13 -import com.yoho.search.recall.scene.models.*;  
14 -import com.yoho.search.recall.scene.beans.builder.RecallParamsBuilder;  
15 -import com.yoho.search.recall.scene.models.RecallParams;  
16 -import com.yoho.search.service.base.SearchCommonService;  
17 -import com.yoho.search.service.helper.SearchCommonHelper;  
18 -import org.apache.commons.collections.MapUtils;  
19 -import org.elasticsearch.index.query.BoolQueryBuilder;  
20 -import org.elasticsearch.index.query.QueryBuilders;  
21 -import org.elasticsearch.search.sort.SortBuilder;  
22 -import org.slf4j.Logger;  
23 -import org.slf4j.LoggerFactory;  
24 -import org.springframework.beans.factory.annotation.Autowired;  
25 -import org.springframework.stereotype.Component;  
26 -  
27 -import java.util.ArrayList;  
28 -import java.util.Arrays;  
29 -import java.util.List;  
30 -import java.util.Map;  
31 -  
32 -@Component  
33 -public class SceneRecallService {  
34 -  
35 - private static final Logger logger = LoggerFactory.getLogger(SceneRecallService.class);  
36 -  
37 - @Autowired  
38 - private RecallParamsBuilder recallParamsBuilder;  
39 - @Autowired  
40 - private SearchCommonHelper searchCommonHelper;  
41 - @Autowired  
42 - private SearchCommonService searchCommonService;  
43 - @Autowired  
44 - private QueryRecallResultCacheBean queryRecallResultCacheBean;  
45 - @Autowired  
46 - private QueryProductInfoCacheBean queryProductInfoCacheBean;  
47 -  
48 - public SearchApiResult sceneRecall(Map<String, String> paramMap) {  
49 - try {  
50 - //1、分页参数验证  
51 - int page = MapUtils.getIntValue(paramMap, "page", 1);  
52 - int pageSize = MapUtils.getIntValue(paramMap, "viewNum", 20);  
53 - if (page < 1 || pageSize < 0 || page * pageSize > 1000000) {  
54 - return new SearchApiResult().setCode(400).setMessage("分页参数不合法");  
55 - }  
56 - //2、构造召回相关参数  
57 - RecallParams recallParams = recallParamsBuilder.buildRecallParams(paramMap,pageSize);  
58 - //3、执行召回  
59 - RecallResult recallResult = queryRecallResultCacheBean.queryRecallResult(recallParams);  
60 - //4、根据召回结果查询商品信息  
61 - List<Map<String, Object>> productList = this.queryProductList(recallParams, recallResult,page,pageSize);  
62 - //5、构造返回结果  
63 - JSONObject dataMap = new JSONObject();  
64 - dataMap.put("total", recallResult.getTotal());  
65 - dataMap.put("page", page);  
66 - dataMap.put("page_size", recallParams.getPageSize());  
67 - dataMap.put("page_total", searchCommonHelper.getTotalPage(recallResult.getTotal(), recallParams.getPageSize()));  
68 - dataMap.put("product_list", productList);  
69 - return new SearchApiResult().setData(dataMap);  
70 - } catch (Exception e) {  
71 - logger.error(e.getMessage(), e);  
72 - return new SearchApiResult().setData(null).setCode(500).setMessage("Exception");  
73 - }  
74 - }  
75 -  
76 - private List<Map<String, Object>> queryProductList(RecallParams recallParams, RecallResult recallResult, int page, int pageSize) {  
77 - //1、判断当前页码是否在召回的页码里  
78 - int recallTotalPage = recallResult.getRecallTotalPage();  
79 - //2、在召回结果中则直接根据skn去查询  
80 - List<Integer> productSkns = null;  
81 - if(page<=recallTotalPage){  
82 - productSkns = CollectionUtils.safeSubList(recallResult.getSknList(),(page-1)*pageSize,page*pageSize);  
83 - }else{  
84 - //3、过滤召回的skn,修改真实页码,执行查询  
85 - productSkns = this.queryProductSknByFilterSkn(recallParams, recallResult.getSknList(), recallTotalPage-page, pageSize);  
86 - }  
87 - return queryProductInfoCacheBean.queryProductListBySkn(productSkns,productSkns.size());  
88 - }  
89 -  
90 - /**  
91 - * 过滤掉已召回的skn,并按人气排序  
92 - * @param notProductSkns  
93 - * @param realPage  
94 - * @param pageSize  
95 - * @return  
96 - */  
97 - private List<Integer> queryProductSknByFilterSkn(RecallParams recallParams, List<Integer> notProductSkns, int realPage, int pageSize){  
98 - SearchParam searchParam = new SearchParam();  
99 -  
100 - //1、设置query  
101 - searchParam.setQuery(recallParams.getParamQueryFilter().getParamQuery());  
102 -  
103 - //2、设置filter  
104 - BoolQueryBuilder filter = recallParams.getParamQueryFilter().getParamFilter();  
105 - filter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.productSkn,notProductSkns));  
106 - searchParam.setFiter(filter);  
107 -  
108 - //3、设置分页参数  
109 - searchParam.setOffset((realPage-1)*pageSize);  
110 - searchParam.setSize(pageSize);  
111 -  
112 - //4、设置IncludeFields  
113 - searchParam.setIncludeFields(Arrays.asList(ProductIndexEsField.productSkn));  
114 -  
115 - //5、设置排序  
116 - List<SortBuilder<?>> sortBuilders = new ArrayList<>();  
117 - sortBuilders.add(SortBuilderHelper.getSevendayMoneyDescSort());  
118 - sortBuilders.add(SortBuilderHelper.getIdDescSort());  
119 - searchParam.setSortBuilders(sortBuilders);  
120 - SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_PRODUCT_BASE_INDEX,searchParam);  
121 -  
122 - List<Integer> results = new ArrayList<>();  
123 - for (Map<String, Object> product : searchResult.getResultList()) {  
124 - results.add(MapUtils.getIntValue(product,ProductIndexEsField.productSkn,0));  
125 - }  
126 - return results;  
127 - }  
128 -  
129 -}  
1 -package com.yoho.search.service.scene;  
2 -  
3 -import java.util.ArrayList;  
4 -import java.util.List;  
5 -import java.util.Map;  
6 -  
7 -import org.apache.commons.lang.StringUtils;  
8 -import org.elasticsearch.index.query.BoolQueryBuilder;  
9 -import org.elasticsearch.index.query.QueryBuilders;  
10 -import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;  
11 -import org.elasticsearch.search.aggregations.Aggregation;  
12 -import org.slf4j.Logger;  
13 -import org.slf4j.LoggerFactory;  
14 -import org.springframework.beans.factory.annotation.Autowired;  
15 -import org.springframework.stereotype.Service;  
16 -  
17 -import com.alibaba.fastjson.JSONArray;  
18 -import com.alibaba.fastjson.JSONObject;  
19 -import com.yoho.search.base.utils.ConvertUtils;  
20 -import com.yoho.search.base.utils.ISearchConstants;  
21 -import com.yoho.search.base.utils.ProductIndexEsField;  
22 -import com.yoho.search.common.cache.SearchCacheMatchLogger;  
23 -import com.yoho.search.common.cache.model.SearchCache;  
24 -import com.yoho.search.core.es.agg.IAggregation;  
25 -import com.yoho.search.core.es.model.SearchParam;  
26 -import com.yoho.search.core.es.model.SearchResult;  
27 -import com.yoho.search.models.PromotionConditions;  
28 -import com.yoho.search.models.PromotionParam;  
29 -import com.yoho.search.models.SearchApiResult;  
30 -import com.yoho.search.service.aggregations.impls.AggregationFactoryService;  
31 -import com.yoho.search.service.base.SearchCommonService;  
32 -import com.yoho.search.service.base.index.ProductIndexBaseService;  
33 -import com.yoho.search.service.helper.SearchAfterCacheHelper;  
34 -import com.yoho.search.service.helper.SearchParamHelper;  
35 -import com.yoho.search.service.helper.SearchSortHelper;  
36 -import com.yoho.search.service.scene.common.AbstractCacheAbleService;  
37 -import com.yoho.search.service.scene.common.SceneSelectionsService;  
38 -import com.yoho.search.service.service.IBrandService;  
39 -import com.yoho.search.service.service.IDiscountService;  
40 -import com.yoho.search.service.service.ISearchSortGroupService;  
41 -import com.yoho.search.service.service.ISelectionsForApp;  
42 -import com.yoho.search.service.service.ISelectionsForPc;  
43 -  
44 -@Service  
45 -public class PromotionSceneService extends AbstractCacheAbleService {  
46 -  
47 - private static Logger logger = LoggerFactory.getLogger(PromotionSceneService.class);  
48 -  
49 - @Autowired  
50 - private SearchSortHelper searchSortHelper;  
51 - @Autowired  
52 - private SearchCommonService searchCommonService;  
53 - @Autowired  
54 - private AggregationFactoryService aggregationFactoryService;  
55 - @Autowired  
56 - private ISelectionsForApp selectionsWithOutAdvanceService;  
57 - @Autowired  
58 - private SearchAfterCacheHelper searchAfterCacheService;  
59 - @Autowired  
60 - private ISelectionsForPc selectionsForPc;  
61 - @Autowired  
62 - private IBrandService brandService;  
63 - @Autowired  
64 - private ISearchSortGroupService searchSortGroupService;  
65 - @Autowired  
66 - private IDiscountService discountService;  
67 - @Autowired  
68 - private ProductIndexBaseService productIndexBaseService;  
69 - @Autowired  
70 - private SearchParamHelper searchParamHelper;  
71 - @Autowired  
72 - private SceneSelectionsService sceneSelectionsService;  
73 -  
74 - @Override  
75 - public SearchCache getSearchCache() {  
76 - return searchCacheFactory.getPromotionSearchCache();  
77 - }  
78 -  
79 - private BoolQueryBuilder genConditionFilter(PromotionParam param, boolean isAnd) {  
80 - BoolQueryBuilder conditionFilter = QueryBuilders.boolQuery();  
81 - // 判断品牌  
82 - if (StringUtils.isNotBlank(param.getBrand())) {  
83 - int[] brandids = ConvertUtils.stringToIntArray(param.getBrand(), ",");  
84 - BoolQueryBuilder brandFilter = QueryBuilders.boolQuery().must(QueryBuilders.termsQuery(ProductIndexEsField.brandId, brandids));  
85 - if (isAnd) {  
86 - conditionFilter.must(brandFilter);  
87 - } else {  
88 - conditionFilter.should(brandFilter);  
89 - }  
90 - }  
91 - // 判断不包含品牌  
92 - if (StringUtils.isNotBlank(param.getNotBrandId())) {  
93 - int[] notBrandids = ConvertUtils.stringToIntArray(param.getNotBrandId(), ",");  
94 - BoolQueryBuilder notBrandFilter = QueryBuilders.boolQuery();  
95 - notBrandFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.brandId, notBrandids));  
96 - if (isAnd) {  
97 - conditionFilter.must(notBrandFilter);  
98 - } else {  
99 - conditionFilter.should(notBrandFilter);  
100 - }  
101 - }  
102 - // 判断品类  
103 - if (StringUtils.isNotBlank(param.getSort())) {  
104 - int[] sortIds = ConvertUtils.stringToIntArray(param.getSort(), ",");  
105 - BoolQueryBuilder sortFilter = QueryBuilders.boolQuery();  
106 - sortFilter.should(QueryBuilders.termsQuery(ProductIndexEsField.maxSortId, sortIds));  
107 - sortFilter.should(QueryBuilders.termsQuery(ProductIndexEsField.middleSortId, sortIds));  
108 - sortFilter.should(QueryBuilders.termsQuery(ProductIndexEsField.smallSortId, sortIds));  
109 - if (isAnd) {  
110 - conditionFilter.must(QueryBuilders.boolQuery().must(sortFilter));  
111 - } else {  
112 - conditionFilter.should(QueryBuilders.boolQuery().must(sortFilter));  
113 - }  
114 - }  
115 - // 判断非品类  
116 - if (StringUtils.isNotBlank(param.getNotSort())) {  
117 - int[] notSortIds = ConvertUtils.stringToIntArray(param.getNotSort(), ",");  
118 - BoolQueryBuilder notSortFilter = QueryBuilders.boolQuery();  
119 - notSortFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.maxSortId, notSortIds));  
120 - notSortFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.middleSortId, notSortIds));  
121 - notSortFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.smallSortId, notSortIds));  
122 - if (isAnd) {  
123 - conditionFilter.must(notSortFilter);  
124 - } else {  
125 - conditionFilter.should(notSortFilter);  
126 - }  
127 - }  
128 - // 判断promotion  
129 - if (StringUtils.isNotBlank(param.getPromotion())) {  
130 - int[] promotionIds = ConvertUtils.stringToIntArray(param.getPromotion(), ",");  
131 - BoolQueryBuilder promotionFilter = QueryBuilders.boolQuery();  
132 - promotionFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.ispromotion, promotionIds));  
133 - if (isAnd) {  
134 - conditionFilter.must(promotionFilter);  
135 - } else {  
136 - conditionFilter.should(promotionFilter);  
137 - }  
138 - }  
139 - // 判断非promotion  
140 - if (StringUtils.isNotBlank(param.getNotPromotion())) {  
141 - int[] notPromotionIds = ConvertUtils.stringToIntArray(param.getNotPromotion(), ",");  
142 - BoolQueryBuilder notPromotionFilter = QueryBuilders.boolQuery();  
143 - notPromotionFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.ispromotion, notPromotionIds));  
144 - if (isAnd) {  
145 - conditionFilter.must(notPromotionFilter);  
146 - } else {  
147 - conditionFilter.should(notPromotionFilter);  
148 - }  
149 - }  
150 - // 判断skn  
151 - if (StringUtils.isNotBlank(param.getProductSknStr())) {  
152 - BoolQueryBuilder sknFilter = QueryBuilders.boolQuery();  
153 - sknFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.productSkn, param.getProductSknStr().split(",")));  
154 - if (isAnd) {  
155 - conditionFilter.must(sknFilter);  
156 - } else {  
157 - conditionFilter.should(sknFilter);  
158 - }  
159 - }  
160 - // 判断 非skn  
161 - if (StringUtils.isNotBlank(param.getNotProductSkn())) {  
162 - BoolQueryBuilder sknFilter = QueryBuilders.boolQuery();  
163 - sknFilter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.productSkn, param.getNotProductSkn().split(",")));  
164 - if (isAnd) {  
165 - conditionFilter.must(sknFilter);  
166 - } else {  
167 - conditionFilter.should(sknFilter);  
168 - }  
169 - }  
170 - return conditionFilter;  
171 - }  
172 -  
173 - /**  
174 - * 根据促销列表参数生成过滤条件  
175 - *  
176 - * @return  
177 - */  
178 - public BoolQueryBuilder getMustFilterByPromotion(PromotionConditions promotionConditions) {  
179 - if (promotionConditions == null) {  
180 - return null;  
181 - }  
182 - // 生成每种condition的filter列表  
183 - List<BoolQueryBuilder> conditionsFilter = new ArrayList<BoolQueryBuilder>();  
184 - List<PromotionParam> promotionParams = promotionConditions.getPromotionParams();  
185 - for (PromotionParam promotionParam : promotionParams) {  
186 - boolean isAnd = "any".equals(promotionParam.getAggregator()) ? false : true;  
187 - BoolQueryBuilder conditionFilter = this.genConditionFilter(promotionParam, isAnd);  
188 - conditionsFilter.add(conditionFilter);  
189 - }  
190 - // 处理总结果  
191 - String aggregator = promotionConditions.getAggregator();  
192 - boolean isTotalAnd = "any".equals(aggregator) ? false : true;  
193 - BoolQueryBuilder allBuilder = QueryBuilders.boolQuery();  
194 - for (BoolQueryBuilder conditionFilter : conditionsFilter) {  
195 - if (isTotalAnd) {  
196 - allBuilder.must(conditionFilter);  
197 - } else {  
198 - allBuilder.should(conditionFilter);  
199 - }  
200 - }  
201 - return allBuilder;  
202 - }  
203 -  
204 - public SearchApiResult list(PromotionConditions promotionConditions, Map<String, String> paramMap) throws Exception {  
205 - // 1、获取mustFilterByPromotion  
206 - BoolQueryBuilder mustFilterByPromotion = this.getMustFilterByPromotion(promotionConditions);  
207 -  
208 - // 2、构造带filter和Query的SearchParam  
209 - SearchParam searchParam = searchParamHelper.buildWithPersional(paramMap, true, mustFilterByPromotion);  
210 -  
211 - // 3、设置聚合条件  
212 - searchParam.setAggregationBuilders(null);  
213 - // 4、设置分页参数  
214 - int pageSize = StringUtils.isBlank(paramMap.get("viewNum")) ? 10 : Integer.parseInt(paramMap.get("viewNum"));  
215 - int page = StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page"));  
216 - if (page < 1 || pageSize < 0) {  
217 - throw new IllegalArgumentException("分页参数不合法");  
218 - }  
219 - if (pageSize > 100) {  
220 - pageSize = 100;  
221 - }  
222 - searchParam.setOffset((page - 1) * pageSize);  
223 - searchParam.setSize(pageSize);  
224 - // 5)设置排序字段  
225 - searchParam.setSortBuilders(searchSortHelper.buildSortList(paramMap));  
226 -  
227 - // 6)从缓存中获取数据  
228 - final String productIndexName = ISearchConstants.INDEX_NAME_PRODUCT_INDEX;  
229 - JSONObject cacheObject = searchCacheService.getJSONObjectFromCache(this.searchCache, productIndexName, searchParam);  
230 - if (cacheObject != null) {  
231 - SearchCacheMatchLogger.doSearchCacheMatchLog("/promotion/list.json", paramMap);  
232 - return new SearchApiResult().setData(cacheObject);  
233 - }  
234 -  
235 - // 7)查询ES  
236 - SearchResult searchResult = searchCommonService.doSearch(productIndexName, searchParam);  
237 - if (searchResult == null) {  
238 - return new SearchApiResult().setCode(500).setMessage("execption");  
239 - }  
240 - // 8)构造返回结果  
241 - JSONObject dataMap = new JSONObject();  
242 - dataMap.put("total", searchResult.getTotal());  
243 - dataMap.put("page", searchResult.getPage());  
244 - dataMap.put("page_size", searchParam.getSize());  
245 - dataMap.put("page_total", searchResult.getTotalPage());  
246 - dataMap.put("product_list", productIndexBaseService.getProductListWithPricePlan(searchResult.getResultList()));  
247 -  
248 - // 10)将结果存进缓存  
249 - searchCacheService.addJSONObjectToCache(this.searchCache, productIndexName, searchParam, dataMap);  
250 - return new SearchApiResult().setData(dataMap);  
251 - }  
252 -  
253 - public SearchApiResult selectionsForApp(PromotionConditions promotionConditions, Map<String, String> paramMap) throws Exception {  
254 - // 1、获取mustFilterByPromotion  
255 - BoolQueryBuilder mustFilterByPromotion = this.getMustFilterByPromotion(promotionConditions);  
256 - // 2、构造带filter和Query的SearchParam  
257 - SearchParam searchParam = searchParamHelper.buildWithMustFilter(paramMap, mustFilterByPromotion);  
258 - // 3、构造聚合条件【7种】  
259 - List<AbstractAggregationBuilder<?>> aggregationBuilders = new ArrayList<AbstractAggregationBuilder<?>>();  
260 - searchParam.setAggregationBuilders(aggregationBuilders);  
261 - // 3.1获取通用的聚合场景  
262 - aggregationBuilders.addAll(selectionsWithOutAdvanceService.getAllAggregationBuilders(paramMap));  
263 - // 3.2加上折扣聚合场景  
264 - IAggregation discountAggregation = aggregationFactoryService.getDiscountAggregation();  
265 - aggregationBuilders.add(discountAggregation.getBuilder());  
266 - // 3.3加上品类聚合场景  
267 - IAggregation sortGroupAggregation = aggregationFactoryService.getSortGroupAggregation(paramMap);  
268 - aggregationBuilders.add(sortGroupAggregation.getBuilder());  
269 -  
270 - // 4、设置分页参数  
271 - searchParam.setOffset(0);  
272 - searchParam.setSize(0);  
273 -  
274 - final String productIndexName = ISearchConstants.INDEX_NAME_PRODUCT_INDEX;  
275 -  
276 - // 5、从缓存中取  
277 - JSONObject cacheObject = searchCacheService.getJSONObjectFromCache(this.searchCache, productIndexName, searchParam);  
278 - if (cacheObject != null) {  
279 - Object newCacheObject = searchAfterCacheService.dealFilterCacheObject(cacheObject);  
280 - newCacheObject = searchAfterCacheService.dealDiscountCacheObject((JSONObject) newCacheObject);  
281 - SearchCacheMatchLogger.doSearchCacheMatchLog("/promotion/selections.json", paramMap);  
282 - return new SearchApiResult().setData(newCacheObject);  
283 - }  
284 -  
285 - // 6)查询ES  
286 - SearchResult searchResult = searchCommonService.doSearch(productIndexName, searchParam);  
287 - if (searchResult == null) {  
288 - return new SearchApiResult().setCode(500).setMessage("execption");  
289 - }  
290 - // 7)构造并返回聚合结果  
291 - Map<String, Aggregation> aggMaps = searchResult.getAggMaps();  
292 - if (aggMaps == null) {  
293 - return null;  
294 - }  
295 - // 8)先拿通用的聚合结果  
296 - Map<String, Object> commonAggResult = selectionsWithOutAdvanceService.getAggResultMap(paramMap, aggMaps);  
297 - // 9)获取折扣的聚合结果  
298 - Object discountAggResult = discountAggregation.getAggregationResponseMap(aggMaps);  
299 - // 10)获取品类的聚合结果  
300 - Object sortGroupAggResult = sortGroupAggregation.getAggregationResponseMap(aggMaps);  
301 -  
302 - // 11)构造返回对象  
303 - JSONObject result = new JSONObject();  
304 - result.put("filter", commonAggResult);  
305 - result.put("discount", discountAggResult);  
306 - result.put("sort", sortGroupAggResult);  
307 -  
308 - // 12)将结果加入缓存  
309 - searchCacheService.addJSONObjectToCache(this.searchCache, productIndexName, searchParam, result);  
310 - return new SearchApiResult().setData(result);  
311 - }  
312 -  
313 - public SearchApiResult selectionsForPc(PromotionConditions promotionConditions, Map<String, String> paramMap) throws Exception {  
314 - // 1、获取默认的mustFilterByPromotion  
315 - BoolQueryBuilder mustFilterByPromotion = this.getMustFilterByPromotion(promotionConditions);  
316 -  
317 - // 2、调通用的PC聚合逻辑  
318 - SearchApiResult apiResult = selectionsForPc.getSelectionsForPc(paramMap, mustFilterByPromotion);  
319 - if (apiResult == null || apiResult.getData() == null) {  
320 - return apiResult;  
321 - }  
322 - JSONObject result = (JSONObject) apiResult.getData();  
323 - // 3、加入品类聚合结果  
324 - JSONArray jsonArray = searchSortGroupService.sortGroup(paramMap, mustFilterByPromotion);  
325 - result.put("sort", jsonArray);  
326 - // 4、加入折扣聚合结果  
327 - JSONObject discount = discountService.discount(paramMap, mustFilterByPromotion);  
328 - result.put("dicount", discount);  
329 - return new SearchApiResult().setData(result);  
330 - }  
331 -  
332 - public SearchApiResult aggPromotionBrands(PromotionConditions promotionConditions, Map<String, String> paramMap) throws Exception {  
333 - logger.info("[func=aggPromotionBrands][param={}][begin={}]", paramMap.toString(), System.currentTimeMillis());  
334 - // 1、设置必须满足的过滤条件  
335 - BoolQueryBuilder mustFilterByPromotion = this.getMustFilterByPromotion(promotionConditions);  
336 - // 2、调聚合品牌的方法  
337 - SearchApiResult searchApiResult = brandService.aggBrand(paramMap, mustFilterByPromotion);  
338 - return searchApiResult;  
339 - }  
340 -  
341 - /**  
342 - * 促销列表新版筛选项  
343 - *  
344 - * @param promotionConditions  
345 - * @param paramMap  
346 - * @return  
347 - */  
348 - public SearchApiResult aggregations(PromotionConditions promotionConditions, Map<String, String> paramMap) {  
349 - try {  
350 - // 0、解析promotion的限制条件  
351 - BoolQueryBuilder mustFilter = this.getMustFilterByPromotion(promotionConditions);  
352 - return sceneSelectionsService.aggregations(paramMap, mustFilter);  
353 - } catch (Exception e) {  
354 - logger.error(e.getMessage(), e);  
355 - return new SearchApiResult().setData(null).setMessage("PromotionAggregations Exception").setCode(500);  
356 - }  
357 - }  
358 -  
359 -}