提交 3be02d75 authored 作者: luojie's avatar luojie

修复zara

上级 d84f0ccf
......@@ -77,7 +77,7 @@ public class HmSpider implements IItemSpider {
Map<String, Set<ProductProp>> productPropSet = new HashMap<>(16);
Set<ProductProp> propSet = new HashSet<>(16);
Set<ProductProp> sizePropSet = new HashSet<>(16);
productResponse.setStockFlag(true);
productResponse.setStockFlag(false);
// 商品的基本属性
ItemInfo itemInfo = new ItemInfo();
......
......@@ -52,7 +52,7 @@ public class ZaraSpider implements IItemSpider {
* @param dataMap 主要的 json 数据
* @return 格式化后的数据
*/
private ProductResponse formatZaraProductResponse(JSONObject dataMap) {
private ProductResponse formatZaraProductResponse(JSONObject dataMap) throws InterruptedException, ExecutionException, TimeoutException {
// 声明封装类
ProductResponse productResponse = new ProductResponse();
// 含有商品的属性,设置为true
......@@ -68,7 +68,7 @@ public class ZaraSpider implements IItemSpider {
Map<String, Set<ProductProp>> productPropSet = new HashMap<>(16);
Set<ProductProp> propSet = new HashSet<>(16);
Set<ProductProp> sizePropSet = new HashSet<>(16);
productResponse.setStockFlag(true);
productResponse.setStockFlag(false);
// 商品的基本属性
ItemInfo itemInfo = new ItemInfo();
......@@ -81,6 +81,7 @@ public class ZaraSpider implements IItemSpider {
//////////////////////////////////// 获取商品基本信息End(图片下取) ////////////////////////////////////////////
// 取 colors 节点数组
TranslateHelper.translateProductResponse(productObj);
JSONArray colorsArr = productObj.getJSONObject("detail").getJSONArray("colors");
for (int i = 0; i < colorsArr.size(); i++) {
JSONObject colorsObj = colorsArr.getJSONObject(i);
......@@ -106,12 +107,12 @@ public class ZaraSpider implements IItemSpider {
productPropColor.setPropName(color);
productPropColor.setImage(imageUrl);
propSet.add(productPropColor);
if (productPropSet.get("颜色") == null) {
productPropSet.put("颜色", propSet);
if (productPropSet.get("Color") == null) {
productPropSet.put("Color", propSet);
} else {
Set<ProductProp> oldPropSet = productPropSet.get("颜色");
Set<ProductProp> oldPropSet = productPropSet.get("Color");
propSet.addAll(oldPropSet);
productPropSet.put("颜色", propSet);
productPropSet.put("Color", propSet);
}
//////////////////////////////////// 获取商品颜色属性 END ////////////////////////////////////////////
......@@ -130,17 +131,17 @@ public class ZaraSpider implements IItemSpider {
productPropSize.setPropId(size);
productPropSize.setPropName(size);
sizePropSet.add(productPropSize);
if (productPropSet.get("尺码") == null) {
productPropSet.put("尺码", sizePropSet);
if (productPropSet.get("Size") == null) {
productPropSet.put("Size", sizePropSet);
} else {
Set<ProductProp> oldPropSet = productPropSet.get("尺码");
Set<ProductProp> oldPropSet = productPropSet.get("Size");
sizePropSet.addAll(oldPropSet);
productPropSet.put("尺码", sizePropSet);
productPropSet.put("Size", sizePropSet);
}
///////////////////////// 获取商品尺码属性 END////////////////////
// 库存对应的id(Zara 中以颜色id + 尺码id)
String skuStr = ";" + size + ";" + color + ";";
String skuStr = ";" + color + ";" + size + ";";
//////////////////////////////////// 获取库存 ////////////////////////////////////////////
if (productSkuStockList == null) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论