|
|
package com.yoho.search.consumer.index.increment;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.yoho.search.base.utils.ProductIndexEsField;
|
|
|
import com.yoho.search.consumer.service.bo.ProductGoodsBO;
|
|
|
import com.yoho.search.consumer.service.bo.ProductSizesBO;
|
|
|
import com.yoho.search.consumer.service.logicService.ProductGoodsLogicService;
|
|
|
import com.yoho.search.consumer.service.logicService.ProductSizesLogicService;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by ginozhang on 2017/2/8. 将库存相关的增量更新代码抽象到父类,被Storage和Goods的MqListener共用。
|
...
|
...
|
@@ -28,23 +24,23 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractIndexMqLi |
|
|
protected void fillStorageNumAndSizeInfo(Integer productId, Map<String, Object> indexData) {
|
|
|
List<ProductSizesBO> productSizesBOList = productSizesLogicService.getProductSizeBOList(Arrays.asList(productId));
|
|
|
if (productSizesBOList == null || productSizesBOList.isEmpty()) {
|
|
|
indexData.put("storageNum", 0);
|
|
|
indexData.put("isSoonSoldOut", "Y");
|
|
|
indexData.put("sizeIds", "");
|
|
|
indexData.put("sizeNames", "");
|
|
|
indexData.put("breakSizePercent", 100);
|
|
|
indexData.put("heatValue", 0);
|
|
|
indexData.put("skuIds", "");
|
|
|
indexData.put(ProductIndexEsField.storageNum, 0);
|
|
|
indexData.put(ProductIndexEsField.isSoonSoldOut, "Y");
|
|
|
indexData.put(ProductIndexEsField.sizeIds, "");
|
|
|
indexData.put(ProductIndexEsField.sizeNames, "");
|
|
|
indexData.put(ProductIndexEsField.breakSizePercent, 100);
|
|
|
indexData.put(ProductIndexEsField.heatValue, 0);
|
|
|
indexData.put(ProductIndexEsField.skuIds, "");
|
|
|
return;
|
|
|
}
|
|
|
ProductSizesBO productSizesBO = productSizesBOList.get(0);
|
|
|
indexData.put("storageNum", productSizesBO.getStorageNum());
|
|
|
indexData.put("isSoonSoldOut", productSizesBO.getIsSoonSoldOut());
|
|
|
indexData.put("sizeIds", productSizesBO.getSizeIds());
|
|
|
indexData.put("sizeNames", productSizesBO.getSizeNames());
|
|
|
indexData.put("breakSizePercent", productSizesBO.getBreakSizePercent());
|
|
|
indexData.put("heatValue", productSizesBO.getHeatValue());
|
|
|
indexData.put("skuIds", productSizesBO.getSkuIds());
|
|
|
indexData.put(ProductIndexEsField.storageNum, productSizesBO.getStorageNum());
|
|
|
indexData.put(ProductIndexEsField.isSoonSoldOut, productSizesBO.getIsSoonSoldOut());
|
|
|
indexData.put(ProductIndexEsField.sizeIds, productSizesBO.getSizeIds());
|
|
|
indexData.put(ProductIndexEsField.sizeNames, productSizesBO.getSizeNames());
|
|
|
indexData.put(ProductIndexEsField.breakSizePercent, productSizesBO.getBreakSizePercent());
|
|
|
indexData.put(ProductIndexEsField.heatValue, productSizesBO.getHeatValue());
|
|
|
indexData.put(ProductIndexEsField.skuIds, productSizesBO.getSkuIds());
|
|
|
}
|
|
|
|
|
|
protected void fillColor(Map<String, Object> indexData, Integer productId) {
|
...
|
...
|
@@ -58,13 +54,13 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractIndexMqLi |
|
|
JSONArray goodsListJsonArray = productGoodsBO.getGoodsList();
|
|
|
// 获取有库存且状态正常的color
|
|
|
productGoodsLogicService.getColorSet(goodsListJsonArray, colorIdSet, colorNameSet);
|
|
|
indexData.put("goodsList", goodsListJsonArray);
|
|
|
indexData.put("colorIds", StringUtils.join(colorIdSet, ","));
|
|
|
indexData.put("colorNames", StringUtils.join(colorNameSet, ","));
|
|
|
indexData.put(ProductIndexEsField.goodsList, goodsListJsonArray);
|
|
|
indexData.put(ProductIndexEsField.colorIds, StringUtils.join(colorIdSet, ","));
|
|
|
indexData.put(ProductIndexEsField.colorNames, StringUtils.join(colorNameSet, ","));
|
|
|
} else {
|
|
|
indexData.put("goodsList", new JSONArray());
|
|
|
indexData.put("colorIds", "");
|
|
|
indexData.put("colorNames", "");
|
|
|
indexData.put(ProductIndexEsField.goodsList, new JSONArray());
|
|
|
indexData.put(ProductIndexEsField.colorIds, "");
|
|
|
indexData.put(ProductIndexEsField.colorNames, "");
|
|
|
}
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|