Authored by hugufei

fix buildGoodsCover

... ... @@ -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;
}
}
... ...
... ... @@ -143,9 +143,9 @@ public class ProductIndexBaseService {
productMap.put("is_student_rebate", MapUtils.getString(map, ProductIndexEsField.isstudentrebate, "N"));
// 把gateway逻辑抽过来,抽取cover1,cover2
goodsCoverHelper.buildGoodsCover(map, productMap);
productMap.put("default_images", MapUtils.getString(map, ProductIndexEsField.defaultImages, ""));
productMap.put("skn_default_img", MapUtils.getString(map, ProductIndexEsField.sknDefaultImg, ""));
productMap.put("default_images", MapUtils.getString(map, ProductIndexEsField.defaultImages, ""));
goodsCoverHelper.buildGoodsCover(map, productMap);
productMap.put("edit_time", MapUtils.getIntValue(map, ProductIndexEsField.editTime));
productMap.put("shelve_time", MapUtils.getIntValue(map, ProductIndexEsField.shelveTime));
... ...
... ... @@ -104,9 +104,9 @@ public class WebProductIndexBaseService {
productMap.put("vip_discount_type", MapUtils.getIntValue(map, ProductIndexEsField.vipDiscountType, 1));
// 把gateway逻辑抽过来,抽取cover1,cover2
goodsCoverHelper.buildGoodsCover(map, productMap);
productMap.put("default_images", MapUtils.getString(map, ProductIndexEsField.defaultImages, ""));
productMap.put("first_shelve_time", MapUtils.getIntValue(map, ProductIndexEsField.firstShelveTime));
productMap.put("default_images", MapUtils.getString(map, ProductIndexEsField.defaultImages, ""));
goodsCoverHelper.buildGoodsCover(map, productMap);
productMap.put("gender", MapUtils.getString(map, ProductIndexEsField.gender, ""));
productMap.put("status", MapUtils.getIntValue(map, ProductIndexEsField.status, 0));
... ...