...
|
...
|
@@ -8,17 +8,25 @@ import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.yoho.search.base.utils.SearchPageIdDefine;
|
|
|
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.vo.SearchApiResult;
|
|
|
|
|
|
@Service
|
|
|
public class ProductPoolSceneService {
|
|
|
public class ProductPoolSceneService extends AbstractSceneService {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ProductPoolSceneService.class);
|
|
|
|
|
|
@Autowired
|
|
|
private IProductListService productListService;
|
|
|
@Autowired
|
|
|
private SceneProductListService sceneProductListService;
|
|
|
@Autowired
|
|
|
private SceneSelectionsService sceneSelectionsService;
|
|
|
|
|
|
/**
|
|
|
* 将discount_score:desc 转为 pools.id:asc
|
...
|
...
|
@@ -45,4 +53,56 @@ public class ProductPoolSceneService { |
|
|
return SearchApiResultUtils.errorSearchApiResult("productPool", paramMap, e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 将discount_score:desc 转为 pools.id:asc
|
|
|
*
|
|
|
* @param paramMap
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public void addParamsToParamMap(Map<String, String> paramMap) {
|
|
|
super.addDefaultParamsToParamMap(paramMap);
|
|
|
// 1)排序接口兼容【按商品池导入顺序排序】
|
|
|
String sortFields = paramMap.get("order");
|
|
|
if (!StringUtils.isBlank(sortFields) && sortFields.contains("discount_score")) {
|
|
|
paramMap.put("order", "pools.id:asc");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String pageId() {
|
|
|
return SearchPageIdDefine.PAGE_ID_POOL;
|
|
|
}
|
|
|
|
|
|
public SearchApiResult productList(Map<String, String> paramMap) {
|
|
|
// 1)如果poolId为空返回
|
|
|
if (StringUtils.isBlank(paramMap.get("filter_poolId"))) {
|
|
|
return new SearchApiResult().setCode(400).setMessage("filter_poolId参数为空");
|
|
|
}
|
|
|
// 2)获取商品列表
|
|
|
try {
|
|
|
this.addParamsToParamMap(paramMap);
|
|
|
return sceneProductListService.productList(paramMap);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("[func=PoolProductList][params=" + paramMap + "]", e);
|
|
|
return SearchApiResultUtils.errorSearchApiResult("PoolProductList", paramMap, e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public SearchApiResult aggregations(Map<String, String> paramMap) {
|
|
|
// 1)如果poolId为空返回
|
|
|
if (StringUtils.isBlank(paramMap.get("filter_poolId"))) {
|
|
|
return new SearchApiResult().setCode(400).setMessage("filter_poolId参数为空");
|
|
|
}
|
|
|
// 2)获取商品池筛选项
|
|
|
try {
|
|
|
this.addParamsToParamMap(paramMap);
|
|
|
return sceneSelectionsService.aggregations(paramMap);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("[func=PoolAggregations][params=" + paramMap + "]", e);
|
|
|
return SearchApiResultUtils.errorSearchApiResult("PoolAggregations", paramMap, e);
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|