|
|
package com.yoho.search.service.servicenew.impl;
|
|
|
package com.yoho.search.service.servicenew.scene;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
...
|
...
|
@@ -29,6 +29,8 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.search.base.utils.ISearchConstants;
|
|
|
import com.yoho.search.base.utils.SearchPageIdDefine;
|
|
|
import com.yoho.search.core.es.agg.IAggregation;
|
|
|
import com.yoho.search.core.es.model.SearchParam;
|
|
|
import com.yoho.search.core.es.model.SearchResult;
|
|
|
import com.yoho.search.service.cache.SearchCacheFactory;
|
...
|
...
|
@@ -38,8 +40,9 @@ import com.yoho.search.service.service.SearchCommonService; |
|
|
import com.yoho.search.service.service.base.SizeIndexBaseService;
|
|
|
import com.yoho.search.service.service.helper.SearchCommonHelper;
|
|
|
import com.yoho.search.service.service.helper.SearchParamHelper;
|
|
|
import com.yoho.search.service.servicenew.IBreakSizeNewService;
|
|
|
import com.yoho.search.service.servicenew.IProductListService;
|
|
|
import com.yoho.search.service.servicenew.scene.common.AbstractSceneService;
|
|
|
import com.yoho.search.service.servicenew.scene.common.SceneProductListService;
|
|
|
import com.yoho.search.service.servicenew.scene.common.SceneSelectionsService;
|
|
|
import com.yoho.search.service.utils.SearchApiResultUtils;
|
|
|
import com.yoho.search.service.utils.SearchRequestParams;
|
|
|
import com.yoho.search.service.vo.SearchApiResult;
|
...
|
...
|
@@ -47,13 +50,11 @@ import com.yoho.search.service.vo.SizeInfoVO; |
|
|
import com.yoho.search.service.vo.SortWithSizesVO;
|
|
|
|
|
|
@Service
|
|
|
public class BreakSizeNewServiceImpl implements IBreakSizeNewService {
|
|
|
public class BreakSizeSceneService extends AbstractSceneService {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(BreakSizeNewServiceImpl.class);
|
|
|
private static final Logger logger = LoggerFactory.getLogger(BreakSizeSceneService.class);
|
|
|
|
|
|
@Autowired
|
|
|
private IProductListService productListService;
|
|
|
@Autowired
|
|
|
private SearchCommonService searchCommonService;
|
|
|
@Autowired
|
|
|
private SizeIndexBaseService sizeIndexBaseService;
|
...
|
...
|
@@ -65,6 +66,10 @@ public class BreakSizeNewServiceImpl implements IBreakSizeNewService { |
|
|
private SearchCacheFactory searchCacheFactory;
|
|
|
@Autowired
|
|
|
private SearchParamHelper searchParamHelper;
|
|
|
@Autowired
|
|
|
private SceneProductListService sceneProductListService;
|
|
|
@Autowired
|
|
|
private SceneSelectionsService sceneSelectionsService;
|
|
|
|
|
|
private SearchCache aggregationSearchCache;
|
|
|
|
...
|
...
|
@@ -78,18 +83,52 @@ public class BreakSizeNewServiceImpl implements IBreakSizeNewService { |
|
|
*
|
|
|
* @param paramMap
|
|
|
*/
|
|
|
private void dealDefaultBreakParamMap(Map<String, String> paramMap) {
|
|
|
// 获取过滤条件
|
|
|
paramMap.put(SearchRequestParams.PARAM_SEARCH_BREAKING, "1");
|
|
|
paramMap.put(SearchRequestParams.PARAM_SEARCH_STATUS, "1");
|
|
|
paramMap.put(SearchRequestParams.PARAM_SEARCH_STATUS, "1");
|
|
|
paramMap.put(SearchRequestParams.PARAM_SEARCH_STOCKNUM, "1");
|
|
|
paramMap.put("attribute_not", "2");
|
|
|
@Override
|
|
|
public void addParamsToParamMap(Map<String, String> paramMap) {
|
|
|
super.addDefaultParamsToParamMap(paramMap);
|
|
|
paramMap.put(SearchRequestParams.PARAM_SEARCH_BREAKING, "1");// 断码区商品
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String pageId() {
|
|
|
return SearchPageIdDefine.PAGE_ID_BREAKSIZE;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public SearchApiResult productList(Map<String, String> paramMap) {
|
|
|
try {
|
|
|
// 1、添加默认参数
|
|
|
this.addParamsToParamMap(paramMap);
|
|
|
// 2、返回商品列表
|
|
|
return sceneProductListService.productList(paramMap);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("[func=CouponProductList][params=" + paramMap + "]", e);
|
|
|
return SearchApiResultUtils.errorSearchApiResult("CouponProductList", paramMap, e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public SearchApiResult aggregations(Map<String, String> paramMap) {
|
|
|
try {
|
|
|
// 1、添加默认参数
|
|
|
this.addParamsToParamMap(paramMap);
|
|
|
// 2、返回聚合结果
|
|
|
List<IAggregation> aggregation = sceneSelectionsService.getBreakSizeAggregations(paramMap);
|
|
|
return sceneSelectionsService.aggregations(paramMap, aggregation);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("[func=Couponaggregations][params=" + paramMap + "]", e);
|
|
|
return SearchApiResultUtils.errorSearchApiResult("Couponaggregations", paramMap, e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 1、获取断码区的品类和尺码的聚合
|
|
|
*
|
|
|
* @param paramMap
|
|
|
* @return
|
|
|
*/
|
|
|
public SearchApiResult sortSizes(Map<String, String> paramMap) {
|
|
|
this.dealDefaultBreakParamMap(paramMap);
|
|
|
this.addParamsToParamMap(paramMap);
|
|
|
logger.info("[func=sortSizes][param={}][begin={}]", paramMap.toString(), System.currentTimeMillis());
|
|
|
try {
|
|
|
// 获取带filter和query的SearchParam
|
...
|
...
|
@@ -135,7 +174,6 @@ public class BreakSizeNewServiceImpl implements IBreakSizeNewService { |
|
|
|
|
|
private List<SortWithSizesVO> getSortSizesResult(Map<String, Aggregation> aggMaps) {
|
|
|
List<SortWithSizesVO> sortWithSizeList = new ArrayList<SortWithSizesVO>();
|
|
|
|
|
|
// 处理es返回的数据
|
|
|
Collection<Integer> allSizeIds = new HashSet<Integer>();
|
|
|
MultiBucketsAggregation aggreation = (MultiBucketsAggregation) aggMaps.get("sortIdAgg");
|
...
|
...
|
@@ -249,18 +287,4 @@ public class BreakSizeNewServiceImpl implements IBreakSizeNewService { |
|
|
return sizeResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public SearchApiResult sort_size_products(Map<String, String> paramMap) {
|
|
|
this.dealDefaultBreakParamMap(paramMap);
|
|
|
logger.info("[func=sort_size_products][param={}][begin={}]", paramMap.toString(), System.currentTimeMillis());
|
|
|
if (searchCommonHelper.isDebugUser(paramMap)) {
|
|
|
logger.warn("sort_size_products paramMap is : [{}]", paramMap.toString());
|
|
|
}
|
|
|
try {
|
|
|
return productListService.productList(paramMap);
|
|
|
} catch (Exception e) {
|
|
|
return SearchApiResultUtils.errorSearchApiResult("sort_size_products", paramMap, e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|