...
|
...
|
@@ -3,7 +3,10 @@ package com.yoho.search.service.index.ufo; |
|
|
import com.yoho.search.base.constants.ISearchConstants;
|
|
|
import com.yoho.search.base.constants.UfoProductIndexEsField;
|
|
|
import com.yoho.search.common.SearchCommonService;
|
|
|
import com.yoho.search.common.UfoSearchRequestParams;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -52,15 +55,15 @@ public class UfoProductIndexBaseService { |
|
|
return results;
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> buildProductReturnInfoList(List<Map<String, Object>> productEsSourceList) {
|
|
|
public List<Map<String, Object>> buildProductReturnInfoList(List<Map<String, Object>> productEsSourceList, Map<String, String> paramMap) {
|
|
|
List<Map<String, Object>> results = new ArrayList<>(productEsSourceList.size());
|
|
|
for (Map<String, Object> productEsSource : productEsSourceList) {
|
|
|
results.add(this.getProductMapFromEsSource(productEsSource));
|
|
|
results.add(this.getProductMapFromEsSource(productEsSource, paramMap));
|
|
|
}
|
|
|
return results;
|
|
|
}
|
|
|
|
|
|
private Map<String, Object> getProductMapFromEsSource(Map<String, Object> map) {
|
|
|
private Map<String, Object> getProductMapFromEsSource(Map<String, Object> map, Map<String, String> paramMap) {
|
|
|
Map<String, Object> productMap = new HashMap<>();
|
|
|
productMap.put("id", MapUtils.getIntValue(map, UfoProductIndexEsField.id, 0));
|
|
|
productMap.put("product_name", MapUtils.getString(map, UfoProductIndexEsField.productName, ""));
|
...
|
...
|
@@ -78,16 +81,17 @@ public class UfoProductIndexBaseService { |
|
|
productMap.put("available_now_price", availableNowPrice == null || availableNowPrice == -1d ? null : availableNowPrice);
|
|
|
|
|
|
productMap.put("is_yoho", MapUtils.getString(map, UfoProductIndexEsField.isYoho, "N"));
|
|
|
productMap.put("pool_order_by", getPoolOrderBy(map, paramMap));
|
|
|
productMap.put("pool_ids", MapUtils.getString(map, UfoProductIndexEsField.poolIds, ""));
|
|
|
return productMap;
|
|
|
}
|
|
|
|
|
|
public Map<Integer,Map<String,Object>> queryUfoProductMapByProductIds(final Collection<?> ufoProductIds) {
|
|
|
List<Map<String, Object>> resultList = this.queryListByProductIds(ufoProductIds);
|
|
|
public Map<Integer,Map<String,Object>> queryUfoProductMapByProductIds(final Collection<?> ufoProductIds, Map<String, String> paramMap) {
|
|
|
List<Map<String, Object>> resultList = this.queryListByProductIds(ufoProductIds, paramMap);
|
|
|
return resultList.stream().collect(Collectors.toMap(a->MapUtils.getIntValue(a,"id",0),p->p));
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> queryListByProductIds(final Collection<?> ufoProductIds) {
|
|
|
public List<Map<String, Object>> queryListByProductIds(final Collection<?> ufoProductIds, Map<String, String> paramMap) {
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
try {
|
|
|
if (ufoProductIds == null || ufoProductIds.isEmpty()) {
|
...
|
...
|
@@ -95,7 +99,7 @@ public class UfoProductIndexBaseService { |
|
|
}
|
|
|
List<Map<String, Object>> queryResults = searchCommonService.doMultiGetCommon(ISearchConstants.INDEX_NAME_UFO_PRODUCT_INDEX, ufoProductIds);
|
|
|
for (Map<String, Object> results : queryResults) {
|
|
|
resultList.add(this.getProductMapFromEsSource(results));
|
|
|
resultList.add(this.getProductMapFromEsSource(results, paramMap));
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
...
|
...
|
@@ -103,5 +107,26 @@ public class UfoProductIndexBaseService { |
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
|
|
|
private int getPoolOrderBy(Map<String, Object> map, Map<String, String> paramMap) {
|
|
|
try {
|
|
|
String inputPoolId = MapUtils.getString(paramMap, UfoSearchRequestParams.UFO_PARAM_POOL, "");
|
|
|
if (StringUtils.isBlank(inputPoolId)) {
|
|
|
return 0;
|
|
|
}
|
|
|
List<Map<String, Object>> poolList = (List<Map<String, Object>>) map.get(UfoProductIndexEsField.pools);
|
|
|
if (CollectionUtils.isEmpty(poolList)) {
|
|
|
return 0;
|
|
|
}
|
|
|
for (Map<String, Object> poolMap : poolList) {
|
|
|
Integer poolId = MapUtils.getIntValue(poolMap, "poolId", 0);
|
|
|
if (Integer.valueOf(inputPoolId).equals(poolId)) {
|
|
|
return MapUtils.getIntValue(poolMap, "orderBy", 0);
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|