|
|
package com.yoho.search.consumer.service.logic.viewBuilder;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.search.consumer.service.bo.ProductGoodsBO;
|
|
|
import com.yoho.search.consumer.service.bo.ProductIndexBO;
|
|
|
import com.yoho.search.consumer.service.logic.tools.MapGenerator;
|
|
|
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 org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.yoho.search.consumer.service.bo.ProductGoodsBO;
|
|
|
import com.yoho.search.consumer.service.bo.ProductIndexBO;
|
|
|
import com.yoho.search.consumer.service.logic.productIndex.ProductGoodsLogicService;
|
|
|
import com.yoho.search.consumer.service.logic.tools.MapGenerator;
|
|
|
|
|
|
/**
|
|
|
* Created by wangnan on 2017/1/6.
|
...
|
...
|
@@ -23,6 +23,9 @@ public class ProductGoodsBuilder implements ViewBuilder{ |
|
|
@Autowired
|
|
|
private MapGenerator mapGenerator;
|
|
|
|
|
|
@Autowired
|
|
|
private ProductGoodsLogicService productGoodsLogicService;
|
|
|
|
|
|
/**
|
|
|
* 构建ProductGoods
|
|
|
*/
|
...
|
...
|
@@ -41,25 +44,10 @@ public class ProductGoodsBuilder implements ViewBuilder{ |
|
|
productIndexBO.setColorNames("");
|
|
|
continue;
|
|
|
}
|
|
|
JSONArray goodsListJsonArray = JSONArray.parseArray(goodsListJsonArrayStr);
|
|
|
colorIdSet = new HashSet<String>();
|
|
|
colorNameSet = new HashSet<String>();
|
|
|
for (int i = 0; i < goodsListJsonArray.size(); i++) {
|
|
|
JSONObject jsonObject = goodsListJsonArray.getJSONObject(i);
|
|
|
//去除无库存和非正常状态的
|
|
|
if (!jsonObject.containsKey("status")||!jsonObject.get("status").toString().equals("1")) {
|
|
|
continue;
|
|
|
}
|
|
|
if (!jsonObject.containsKey("storage_num")||((Integer)jsonObject.get("storage_num"))<1) {
|
|
|
continue;
|
|
|
}
|
|
|
if (jsonObject.containsKey("color_id")) {
|
|
|
colorIdSet.add(jsonObject.get("color_id").toString());
|
|
|
}
|
|
|
if (jsonObject.containsKey("color_name")) {
|
|
|
colorNameSet.add(jsonObject.get("color_name").toString());
|
|
|
}
|
|
|
}
|
|
|
JSONArray goodsListJsonArray = JSONArray.parseArray(goodsListJsonArrayStr);
|
|
|
productGoodsLogicService.getColorSet(goodsListJsonArray, colorIdSet, colorNameSet);//获取有库存且状态正常的color
|
|
|
productIndexBO.setColorIds(StringUtils.join(colorIdSet, ","));
|
|
|
productIndexBO.setColorNames(StringUtils.join(colorNameSet, ","));
|
|
|
|
...
|
...
|
|