Authored by wangnan9279

goods

... ... @@ -34,19 +34,25 @@ public class GoodsCoverHelper {
if (CollectionUtils.isEmpty(goodsList)) {
return;
}
//默认用第一个
HashMap<String, Object> firstGoods = goodsList.get(0);
String imagesUrl = MapUtils.getString(firstGoods, "images_url");
String cover1 = MapUtils.getString(firstGoods, "cover_1");
String cover2 = MapUtils.getString(firstGoods, "cover_2");
String imagesUrl = "";
String cover1 = "";
String cover2 = "";
boolean flag = true;
for (HashMap<String, Object> goodsMap : goodsList) {
// 如果此skc是默认的,用这个默认的
// 如果此goods是is_default=Y的,用这个goods
if ("Y".equals(MapUtils.getString(goodsMap, "is_default"))) {
imagesUrl = MapUtils.getString(goodsMap, "images_url");
cover1 = MapUtils.getString(goodsMap, "cover_1");
cover2 = MapUtils.getString(goodsMap, "cover_2");
break;
}
//默认用第一个images_url不是空的goods
if (flag && StringUtils.isNotBlank(MapUtils.getString(goodsMap, "images_url"))) {
imagesUrl = MapUtils.getString(goodsMap, "images_url");
cover1 = MapUtils.getString(goodsMap, "cover_1");
cover2 = MapUtils.getString(goodsMap, "cover_2");
flag = false;
}
}
cover1 = StringUtils.isNotBlank(cover1) ? cover1 : imagesUrl;
cover2 = StringUtils.isNotBlank(cover2) ? cover2 : imagesUrl;
... ... @@ -59,5 +65,4 @@ public class GoodsCoverHelper {
}
}
}
... ...