Authored by wangnan9279

goods

@@ -34,19 +34,25 @@ public class GoodsCoverHelper { @@ -34,19 +34,25 @@ public class GoodsCoverHelper {
34 if (CollectionUtils.isEmpty(goodsList)) { 34 if (CollectionUtils.isEmpty(goodsList)) {
35 return; 35 return;
36 } 36 }
37 - //默认用第一个  
38 - HashMap<String, Object> firstGoods = goodsList.get(0);  
39 - String imagesUrl = MapUtils.getString(firstGoods, "images_url");  
40 - String cover1 = MapUtils.getString(firstGoods, "cover_1");  
41 - String cover2 = MapUtils.getString(firstGoods, "cover_2"); 37 + String imagesUrl = "";
  38 + String cover1 = "";
  39 + String cover2 = "";
  40 + boolean flag = true;
42 for (HashMap<String, Object> goodsMap : goodsList) { 41 for (HashMap<String, Object> goodsMap : goodsList) {
43 - // 如果此skc是默认的,用这个默认的 42 + // 如果此goods是is_default=Y的,用这个goods
44 if ("Y".equals(MapUtils.getString(goodsMap, "is_default"))) { 43 if ("Y".equals(MapUtils.getString(goodsMap, "is_default"))) {
45 imagesUrl = MapUtils.getString(goodsMap, "images_url"); 44 imagesUrl = MapUtils.getString(goodsMap, "images_url");
46 cover1 = MapUtils.getString(goodsMap, "cover_1"); 45 cover1 = MapUtils.getString(goodsMap, "cover_1");
47 cover2 = MapUtils.getString(goodsMap, "cover_2"); 46 cover2 = MapUtils.getString(goodsMap, "cover_2");
48 break; 47 break;
49 } 48 }
  49 + //默认用第一个images_url不是空的goods
  50 + if (flag && StringUtils.isNotBlank(MapUtils.getString(goodsMap, "images_url"))) {
  51 + imagesUrl = MapUtils.getString(goodsMap, "images_url");
  52 + cover1 = MapUtils.getString(goodsMap, "cover_1");
  53 + cover2 = MapUtils.getString(goodsMap, "cover_2");
  54 + flag = false;
  55 + }
50 } 56 }
51 cover1 = StringUtils.isNotBlank(cover1) ? cover1 : imagesUrl; 57 cover1 = StringUtils.isNotBlank(cover1) ? cover1 : imagesUrl;
52 cover2 = StringUtils.isNotBlank(cover2) ? cover2 : imagesUrl; 58 cover2 = StringUtils.isNotBlank(cover2) ? cover2 : imagesUrl;
@@ -59,5 +65,4 @@ public class GoodsCoverHelper { @@ -59,5 +65,4 @@ public class GoodsCoverHelper {
59 } 65 }
60 } 66 }
61 67
62 -  
63 } 68 }