Authored by unknown

断码区区分场景

... ... @@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.yoho.search.service.downgrade.aop.DownGradeAble;
import com.yoho.search.service.service.SearchProductsServiceNew;
import com.yoho.search.service.servicenew.IBreakSizeNewService;
import com.yoho.search.service.servicenew.IDiscountService;
import com.yoho.search.service.servicenew.IProductCountService;
import com.yoho.search.service.servicenew.IRecentService;
... ... @@ -30,8 +29,6 @@ public class SearchNewController {
@Autowired
private IDiscountService discountService;
@Autowired
private IBreakSizeNewService breakSizeNewService;
@Autowired
private SearchProductsServiceNew searchProductsServiceNew;
@Autowired
private IProductCountService productCountService;
... ... @@ -104,28 +101,4 @@ public class SearchNewController {
}
@DownGradeAble(key = "sort_sizes")
@RequestMapping(method = RequestMethod.GET, value = "/sort_sizes")
@ResponseBody
public SearchApiResult sort_sizes(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return breakSizeNewService.sortSizes(paramMap);
}
/**
* 【断码区】按分类和型号获取商品(with storage_sku)
*
* @param request
* @return
*/
@DownGradeAble(key = "sort_size_products")
@RequestMapping(method = RequestMethod.GET, value = "/sort_size_products")
@ResponseBody
public SearchApiResult sort_size_products(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return breakSizeNewService.sort_size_products(paramMap);
}
}
... ...
package com.yoho.search.service.restapi.scene;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yoho.search.service.downgrade.aop.DownGradeAble;
import com.yoho.search.service.servicenew.scene.BreakSizeSceneService;
import com.yoho.search.service.utils.HttpServletRequestUtils;
import com.yoho.search.service.vo.SearchApiResult;
/**
* 断码区场景接口
*
* @author gufei.hu
*
*/
@Controller
public class BreakSizeSceneController {
@Autowired
private BreakSizeSceneService breakSizeSceneService;
/**
* 【断码区】商品列表
*
* @param request
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/break/productList")
@ResponseBody
public SearchApiResult breakProductList(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return breakSizeSceneService.productList(paramMap);
}
/**
* 【断码区】筛选项【无分类和尺码】
*
* @param request
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/break/aggregations")
@ResponseBody
public SearchApiResult breakAggregations(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return breakSizeSceneService.productList(paramMap);
}
/**
* 【断码区】分类和尺码的聚合结果
*
* @param request
* @return
*/
@DownGradeAble(key = "sort_sizes")
@RequestMapping(method = RequestMethod.GET, value = "/sort_sizes")
@ResponseBody
public SearchApiResult sort_sizes(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return breakSizeSceneService.sortSizes(paramMap);
}
/**
* 【断码区】按分类和型号获取商品
*
* @param request
* @return
*/
@DownGradeAble(key = "sort_size_products")
@RequestMapping(method = RequestMethod.GET, value = "/sort_size_products")
@ResponseBody
public SearchApiResult sort_size_products(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return breakSizeSceneService.productList(paramMap);
}
}
... ...
package com.yoho.search.service.servicenew;
import java.util.Map;
import com.yoho.search.service.vo.SearchApiResult;
public interface IBreakSizeNewService {
/**
* 获取断码区的品类和尺码信息
*
* @param sizeSortReqBO
* @return
*/
public SearchApiResult sortSizes(Map<String, String> paramMap);
/**
* 获取断码区的商品列表【支持聚合】[使用本地缓存]
*
* @param paramMap
* @return
*/
public SearchApiResult sort_size_products(Map<String, String> paramMap);
}
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);
}
}
}
... ...
... ... @@ -19,7 +19,7 @@ public abstract class AbstractSceneService {
paramMap.put(SearchRequestParams.PARAM_SEARCH_GLOBAL_FILTER_BRAND, "Y");// 页面屏蔽
paramMap.put(SearchRequestParams.PARAM_SEARCH_STATUS, "1");// 上架
paramMap.put(SearchRequestParams.PARAM_SEARCH_STOCKNUM, "1");// 有库存
paramMap.put(SearchRequestParams.PARAM_SEARCH_SHOWSOLDOUT, "1");// 显示售罄商品
paramMap.put(SearchRequestParams.PARAM_SEARCH_SHOWSOLDOUT, "1");// 显示延期显示的商品
paramMap.put(SearchRequestParams.PARAM_SEARCH_ISOUTLETS, "2");// 非奥莱
paramMap.put(SearchRequestParams.PARAM_SEARCH_ATTRIBUTE_NOT, "2");// 非赠品
paramMap.put("needSmallSort", "1");// 品类聚合时带上小分类
... ...
... ... @@ -119,6 +119,33 @@ public class SceneSelectionsService extends BaseService {
}
/**
* @断码区的聚合选项:
* @比其他的场景少了品类和尺码的筛选项
*/
public List<IAggregation> getBreakSizeAggregations(Map<String, String> paramMap) {
List<IAggregation> aggregations = new ArrayList<>();
// 1)促销
aggregations.add(aggregationFactoryService.getPromotionAggregation(1000));
// 2)全球购
aggregations.add(aggregationFactoryService.getIsGlobalAggregation());
// 3)品牌
aggregations.add(aggregationFactoryService.getBrandAggregation(paramMap));
// 4)人群
aggregations.add(aggregationFactoryService.getAgeLevelAggregation());
// 5)性别
aggregations.add(aggregationFactoryService.getGenderNewAggregation());
// 6)价格
aggregations.add(aggregationFactoryService.getPriceAggregation());
// 7)折扣
aggregations.add(aggregationFactoryService.getDiscountAggregation());
// 8)颜色
aggregations.add(aggregationFactoryService.getColorAggregation(paramMap));
// 9)风格
aggregations.add(aggregationFactoryService.getStyleAggregation(paramMap));
return aggregations;
}
/**
* 店铺、新频到着的筛选项列表
*
* @param paramMap
... ... @@ -199,11 +226,10 @@ public class SceneSelectionsService extends BaseService {
return new JSONObject();
}
}
private JSONObject getFiltersResult(Map<String, String> paramMap, BoolQueryBuilder mustFilter) {
private JSONObject getFiltersResult(Map<String, String> paramMap, List<IAggregation> aggregations, BoolQueryBuilder mustFilter) {
try {
SearchParam searchParam = searchParamHelper.buildWithMustFilter(paramMap, mustFilter);
List<IAggregation> aggregations = this.getCommonAggregations(paramMap);
return this.getFiltersResults(paramMap, searchParam, aggregations);
} catch (Exception e) {
logger.error("[func=fuzzyAggregations][params=" + paramMap + "]", e);
... ... @@ -217,13 +243,23 @@ public class SceneSelectionsService extends BaseService {
}
public SearchApiResult aggregations(Map<String, String> paramMap) throws Exception {
return this.aggregations(paramMap, null);
List<IAggregation> commonAggregations = this.getCommonAggregations(paramMap);
return this.aggregations(paramMap, commonAggregations, null);
}
public SearchApiResult aggregations(Map<String, String> paramMap, List<IAggregation> aggregations) throws Exception {
return this.aggregations(paramMap, aggregations, null);
}
public SearchApiResult aggregations(Map<String, String> paramMap, BoolQueryBuilder mustFilter) throws Exception {
List<IAggregation> commonAggregations = this.getCommonAggregations(paramMap);
return this.aggregations(paramMap, commonAggregations, mustFilter);
}
public SearchApiResult aggregations(Map<String, String> paramMap, List<IAggregation> aggregations, BoolQueryBuilder mustFilter) throws Exception {
// 1、获取通用筛选项
CompletableFuture<JSONObject> commonFiltersFuture = CompletableFuture.supplyAsync(() -> {
return this.getFiltersResult(paramMap, mustFilter);
return this.getFiltersResult(paramMap, aggregations, mustFilter);
}, executorService);
// 2、获取推荐的品牌
CompletableFuture<Object> recommendBrandFuture = CompletableFuture.supplyAsync(() -> {
... ...