...
|
...
|
@@ -35,10 +35,8 @@ public class GoodsCoverHelper { |
|
|
return;
|
|
|
}
|
|
|
String imagesUrl = "";
|
|
|
String imagesUrlNotNull = "";
|
|
|
String cover1 = "";
|
|
|
String cover2 = "";
|
|
|
boolean flag = true;
|
|
|
for (HashMap<String, Object> goodsMap : goodsList) {
|
|
|
// 如果此goods是is_default=Y的,用这个goods
|
|
|
if ("Y".equals(MapUtils.getString(goodsMap, "is_default"))) {
|
...
|
...
|
@@ -49,19 +47,17 @@ public class GoodsCoverHelper { |
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
//找一个不为空的imagesUrl
|
|
|
if (flag && StringUtils.isNotBlank(MapUtils.getString(goodsMap, "images_url"))) {
|
|
|
imagesUrlNotNull = MapUtils.getString(goodsMap, "images_url");
|
|
|
flag = false;
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isBlank(imagesUrl)) {
|
|
|
imagesUrl = imagesUrlNotNull;
|
|
|
}
|
|
|
cover1 = StringUtils.isNotBlank(cover1) ? cover1 : imagesUrl;
|
|
|
cover2 = StringUtils.isNotBlank(cover2) ? cover2 : imagesUrl;
|
|
|
productMap.put("cover_1", cover1);
|
|
|
productMap.put("cover_2", cover2);
|
|
|
|
|
|
//default_images灾备
|
|
|
if (StringUtils.isBlank(MapUtils.getString(productMap, "default_images"))) {
|
|
|
String default_images = this.getImageNotNull(goodsList);
|
|
|
productMap.put("default_images", default_images);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
|
|
productMap.put("cover_1", "");
|
...
|
...
|
@@ -69,4 +65,22 @@ public class GoodsCoverHelper { |
|
|
}
|
|
|
}
|
|
|
|
|
|
private String getImageNotNull(List<HashMap<String, Object>> goodsList) {
|
|
|
for (HashMap<String, Object> goodsMap : goodsList) {
|
|
|
String imagesUrl = MapUtils.getString(goodsMap, "images_url");
|
|
|
if (StringUtils.isNotBlank(imagesUrl)) {
|
|
|
return imagesUrl;
|
|
|
}
|
|
|
String cover1 = MapUtils.getString(goodsMap, "cover_1");
|
|
|
if (StringUtils.isNotBlank(cover1)) {
|
|
|
return cover1;
|
|
|
}
|
|
|
String cover2 = MapUtils.getString(goodsMap, "cover_2");
|
|
|
if (StringUtils.isNotBlank(cover2)) {
|
|
|
return cover2;
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|