Showing
1 changed file
with
21 additions
and
14 deletions
@@ -9,6 +9,8 @@ import com.yoho.search.common.SearchDynamicConfigService; | @@ -9,6 +9,8 @@ import com.yoho.search.common.SearchDynamicConfigService; | ||
9 | import com.yoho.search.common.SearchRequestParams; | 9 | import com.yoho.search.common.SearchRequestParams; |
10 | import org.apache.commons.collections.MapUtils; | 10 | import org.apache.commons.collections.MapUtils; |
11 | import org.apache.commons.lang.StringUtils; | 11 | import org.apache.commons.lang.StringUtils; |
12 | +import org.slf4j.Logger; | ||
13 | +import org.slf4j.LoggerFactory; | ||
12 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
13 | import org.springframework.stereotype.Component; | 15 | import org.springframework.stereotype.Component; |
14 | 16 | ||
@@ -25,27 +27,32 @@ public class GoodsCoverHelper { | @@ -25,27 +27,32 @@ public class GoodsCoverHelper { | ||
25 | @Autowired | 27 | @Autowired |
26 | private SearchDynamicConfigService searchDynamicConfigService; | 28 | private SearchDynamicConfigService searchDynamicConfigService; |
27 | 29 | ||
30 | + private static final Logger logger = LoggerFactory.getLogger(GoodsCoverHelper.class); | ||
31 | + | ||
28 | public void pickImgOnColor(List<Map<String, Object>> productReturnInfoList, Map paramMap){ | 32 | public void pickImgOnColor(List<Map<String, Object>> productReturnInfoList, Map paramMap){ |
29 | List<String> values = ConvertUtils.stringToStringList(MapUtils.getString(paramMap, SearchRequestParams.PARAM_SEARCH_COLOR), ","); | 33 | List<String> values = ConvertUtils.stringToStringList(MapUtils.getString(paramMap, SearchRequestParams.PARAM_SEARCH_COLOR), ","); |
30 | if(values==null || values.isEmpty()){ | 34 | if(values==null || values.isEmpty()){ |
31 | return; | 35 | return; |
32 | } | 36 | } |
33 | for (Map<String, Object> productInfo : productReturnInfoList) { | 37 | for (Map<String, Object> productInfo : productReturnInfoList) { |
34 | - List<JSONObject> goodsList = JSON.parseObject(JSON.toJSONString(productInfo.get("goods_list")), new TypeReference<List<JSONObject>>() {}); | ||
35 | - for (JSONObject good : goodsList) { | ||
36 | - String colorId = good.getString("color_id"); | ||
37 | - String imagesUrl = good.getString("images_url"); | ||
38 | - if (StringUtils.isNotBlank(colorId) && StringUtils.isNotBlank(imagesUrl) && values.contains(colorId)) { | ||
39 | - productInfo.put("default_images", imagesUrl); | ||
40 | - productInfo.put("cover_1", ""); | ||
41 | - productInfo.put("cover_2", ""); | ||
42 | - break; | 38 | + try { |
39 | + List<JSONObject> goodsList = JSON.parseObject(JSON.toJSONString(productInfo.get("goods_list")), new TypeReference<List<JSONObject>>() {}); | ||
40 | + for (JSONObject good : goodsList) { | ||
41 | + String colorId = good.getString("color_id"); | ||
42 | + String imagesUrl = good.getString("images_url"); | ||
43 | + if (StringUtils.isNotBlank(colorId) && StringUtils.isNotBlank(imagesUrl) && values.contains(colorId)) { | ||
44 | + productInfo.put("default_images", imagesUrl); | ||
45 | + productInfo.put("cover_1", ""); | ||
46 | + productInfo.put("cover_2", ""); | ||
47 | + break; | ||
48 | + } | ||
43 | } | 49 | } |
44 | - } | ||
45 | - | ||
46 | - //测试环境zk配置改为false以不返回goods,刚上线默认还是要返回,等6.7上线后彻底删除 | ||
47 | - if (!searchDynamicConfigService.productListReturnGoods()) { | ||
48 | - productInfo.put("goods_list", new JSONArray()); | 50 | + //测试环境zk配置改为false以不返回goods,刚上线默认还是要返回,等6.7上线后彻底删除 |
51 | + if (!searchDynamicConfigService.productListReturnGoods()) { | ||
52 | + productInfo.put("goods_list", new JSONArray()); | ||
53 | + } | ||
54 | + }catch (Exception e){ | ||
55 | + logger.error(e.getMessage(),e); | ||
49 | } | 56 | } |
50 | } | 57 | } |
51 | } | 58 | } |
-
Please register or login to post a comment