Authored by wangnan9279

拼团购 fix

... ... @@ -77,9 +77,8 @@ public class CollageService extends BaseService {
List<Integer> productSknList = new ArrayList<>(searchResult.getResultList().size());
List<Map<String, Object>> collageIndexResultList = getIndexMap(searchResult.getResultList(), productSknList);
List<Map<String, Object>> sknInfoList = sknReturnInfoCacheBean.queryProductListBySkn(productSknList, productSknList.size());
if (CollectionUtils.isEmpty(sknInfoList)) {
return searchApiResult.setCode(500);
}
List<Map<String, Object>> finalList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(sknInfoList)) {
Map<Integer, Map<String, Object>> sknInfoMap = new LinkedHashMap<>(sknInfoList.size());
sknInfoList.forEach(p -> sknInfoMap.put(MapUtils.getInteger(p, "product_skn"), p));
collageIndexResultList.forEach(p -> {
... ... @@ -94,13 +93,13 @@ public class CollageService extends BaseService {
Map<Map<String, Object>, Integer> salesNumSknInfoMap = collageIndexResultList.stream().collect(Collectors.toMap(p -> p, p -> MapUtils.getInteger(p, "sales_num")));
Map<Map<String, Object>, Integer> finalMap = new LinkedHashMap<>(salesNumSknInfoMap.size());
salesNumSknInfoMap.entrySet().stream().sorted(Map.Entry.comparingByValue()).forEachOrdered(e -> finalMap.put(e.getKey(), e.getValue()));
List<Map<String, Object>> finalList = new ArrayList<>(finalMap.size());
Iterator iterator = finalMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
finalList.add((Map<String, Object>) entry.getKey());
}
Collections.reverse(finalList);
}
// 4.构造返回结果并加入缓存
JSONObject dataMap = new JSONObject();
dataMap.put("total", searchResult.getTotal());
... ...