|
|
package com.yoho.search.service.index;
|
|
|
|
|
|
import com.yoho.search.base.utils.DateUtil;
|
|
|
import com.yoho.search.base.utils.UfoProductIndexEsField;
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
...
|
...
|
@@ -19,11 +18,10 @@ import java.util.Map; |
|
|
@Service
|
|
|
public class UfoProductIndexBaseService {
|
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
|
// 获取从source中返回的字段定义,用以节省带宽
|
|
|
private List<String> ufoProductIndexIncludeFields = new ArrayList<String>();
|
|
|
private List<String> ufoProductIndexIncludeFieldsPlatform = new ArrayList<String>();
|
|
|
private List<String> ufoSaleCalendarProductListIncludeFields = new ArrayList<String>();
|
|
|
|
|
|
|
|
|
@PostConstruct
|
...
|
...
|
@@ -37,6 +35,12 @@ public class UfoProductIndexBaseService { |
|
|
ufoProductIndexIncludeFieldsPlatform.add(UfoProductIndexEsField.productName);
|
|
|
ufoProductIndexIncludeFieldsPlatform.add(UfoProductIndexEsField.shelveStatus);
|
|
|
ufoProductIndexIncludeFieldsPlatform.add(UfoProductIndexEsField.delStatus);
|
|
|
|
|
|
ufoSaleCalendarProductListIncludeFields.add(UfoProductIndexEsField.id);
|
|
|
ufoSaleCalendarProductListIncludeFields.add(UfoProductIndexEsField.productName);
|
|
|
ufoSaleCalendarProductListIncludeFields.add(UfoProductIndexEsField.defaultImages);
|
|
|
ufoSaleCalendarProductListIncludeFields.add(UfoProductIndexEsField.price);
|
|
|
ufoSaleCalendarProductListIncludeFields.add(UfoProductIndexEsField.saleTime);
|
|
|
}
|
|
|
|
|
|
public List<String> getUfoProductIndexIncludeFields() {
|
...
|
...
|
@@ -51,6 +55,12 @@ public class UfoProductIndexBaseService { |
|
|
return results;
|
|
|
}
|
|
|
|
|
|
public List<String> getUfoSaleCalendarProductListIncludeFields() {
|
|
|
List<String> results = new ArrayList<String>();
|
|
|
results.addAll(ufoSaleCalendarProductListIncludeFields);
|
|
|
return results;
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> buildProductReturnInfoList(List<Map<String, Object>> productEsSourceList) {
|
|
|
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
|
|
|
for (Map<String, Object> productEsSource : productEsSourceList) {
|
...
|
...
|
@@ -67,6 +77,14 @@ public class UfoProductIndexBaseService { |
|
|
return results;
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> buildSaleCalendarProductReturnInfoList(List<Map<String, Object>> productEsSourceList) {
|
|
|
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
|
|
|
for (Map<String, Object> productEsSource : productEsSourceList) {
|
|
|
results.add(this.getProductMapFromEsSourceSaleCalendar(productEsSource));
|
|
|
}
|
|
|
return results;
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getProductMapFromEsSource(Map<String, Object> map) {
|
|
|
Map<String, Object> productMap = new HashMap<String, Object>();
|
|
|
productMap.put("id", MapUtils.getIntValue(map, UfoProductIndexEsField.id, 0));
|
...
|
...
|
@@ -86,5 +104,20 @@ public class UfoProductIndexBaseService { |
|
|
return productMap;
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getProductMapFromEsSourceSaleCalendar(Map<String, Object> map) {
|
|
|
Map<String, Object> productMap = new HashMap<String, Object>();
|
|
|
productMap.put("id", MapUtils.getIntValue(map, UfoProductIndexEsField.id, 0));
|
|
|
productMap.put("product_name", MapUtils.getString(map, UfoProductIndexEsField.productName, ""));
|
|
|
productMap.put("default_images", MapUtils.getString(map, UfoProductIndexEsField.defaultImages, ""));
|
|
|
Double price = MapUtils.getDouble(map, UfoProductIndexEsField.price);
|
|
|
productMap.put("price", price == null || price == -1d ? null : price);
|
|
|
Integer saleTime = MapUtils.getInteger(map, UfoProductIndexEsField.saleTime, 0);
|
|
|
String month = DateUtil.TimeStamp2DateWithFormat(Long.valueOf(saleTime), "MM");
|
|
|
String day = DateUtil.TimeStamp2DateWithFormat(Long.valueOf(saleTime), "dd");
|
|
|
productMap.put("sale_time_month", month);
|
|
|
productMap.put("sale_time_day", day);
|
|
|
return productMap;
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|