...
|
...
|
@@ -6,7 +6,6 @@ import com.yoho.search.consumer.service.base.ProductService; |
|
|
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.dal.model.Product;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
...
|
...
|
@@ -28,7 +27,7 @@ public class ProductGoodsBuilder implements ViewBuilder { |
|
|
private ProductService productService;
|
|
|
|
|
|
/**
|
|
|
* 构建ProductGoods
|
|
|
* 构建ProductIndex的ColorIds,ColorNames属性
|
|
|
*/
|
|
|
@Override
|
|
|
public void build(List<ProductIndexBO> productIndexBOs, List<Integer> ids, List<Integer> skns) {
|
...
|
...
|
@@ -39,29 +38,8 @@ public class ProductGoodsBuilder implements ViewBuilder { |
|
|
for (ProductIndexBO productIndexBO : productIndexBOs) {
|
|
|
ProductGoodsBO productGoodsBO = productGoodsesMap.get(productIndexBO.getProductId());
|
|
|
if (productGoodsBO != null) {
|
|
|
this.checkSknStatus(productIndexBO, productGoodsBO);
|
|
|
productIndexBO.setGoodsList(productGoodsBO.getGoodsList());
|
|
|
|
|
|
//如果skn下面所有skc的状态都是0,那skn的状态设为0
|
|
|
JSONArray jsonArray = JSONArray.parseArray(productGoodsBO.getGoodsList());
|
|
|
boolean sknInvalid = true;
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
JSONObject jsonObject = (JSONObject) jsonArray.get(i);
|
|
|
if (jsonObject.get("status") != null) {
|
|
|
String status = jsonObject.get("status").toString();
|
|
|
if (status.equals("1")) {
|
|
|
sknInvalid = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (sknInvalid) {
|
|
|
productIndexBO.setStatus(0);
|
|
|
} else {
|
|
|
Product product = productService.getById(productIndexBO.getProductId());
|
|
|
if (product.getStatus() == 1) {
|
|
|
productIndexBO.setStatus(1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String goodsListJsonArrayStr = productGoodsBO.getGoodsList();
|
|
|
if (goodsListJsonArrayStr == null || goodsListJsonArrayStr.length() < 3) {
|
|
|
productIndexBO.setColorIds("");
|
...
|
...
|
@@ -78,4 +56,27 @@ public class ProductGoodsBuilder implements ViewBuilder { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 如果skn下面所有skc的状态都是0,那skn的状态设为0
|
|
|
* 和增量不同之处:不存在status从0->1,只存在1->0
|
|
|
*/
|
|
|
private void checkSknStatus(ProductIndexBO productIndexBO, ProductGoodsBO productGoodsBO) {
|
|
|
JSONArray jsonArray = JSONArray.parseArray(productGoodsBO.getGoodsList());
|
|
|
if (jsonArray != null) {
|
|
|
boolean sknInvalid = true;
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
JSONObject jsonObject = (JSONObject) jsonArray.get(i);
|
|
|
if (jsonObject!=null&&jsonObject.get("status") != null) {
|
|
|
String status = jsonObject.get("status").toString();
|
|
|
if (status.equals("1")) {
|
|
|
sknInvalid = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (sknInvalid) {
|
|
|
productIndexBO.setStatus(0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|