...
|
...
|
@@ -86,8 +86,8 @@ public class ZeroHelpProductPageSceneService extends AbstractPageSceneService { |
|
|
if (CollectionUtils.isEmpty(results)) {
|
|
|
return searchApiResult.setCode(500);
|
|
|
}
|
|
|
Map<Integer, ZeroHelpProduct> zeroHelpProductMap = results.stream().collect(Collectors.toMap(a -> MapUtils.getIntValue(a, "productSkn"), a -> JSON.parseObject(JSON.toJSONString(a), ZeroHelpProduct.class)));
|
|
|
Collection<Integer> productSknList = zeroHelpProductMap.keySet();
|
|
|
Collection<Integer> productSknList = results.stream().map(a -> MapUtils.getIntValue(a, "productSkn")).collect(Collectors.toList());
|
|
|
List<ZeroHelpProduct> zeroHelpProductList = results.stream().map(a -> JSON.parseObject(JSON.toJSONString(a), ZeroHelpProduct.class)).collect(Collectors.toList());
|
|
|
|
|
|
// 查询ProductIndex
|
|
|
SearchResult searchResultProductIndex = this.queryProductInfoMap(productSknList);
|
...
|
...
|
@@ -96,28 +96,34 @@ public class ZeroHelpProductPageSceneService extends AbstractPageSceneService { |
|
|
}
|
|
|
|
|
|
// 构造商品返回顺序
|
|
|
List<Map<String, Object>> productInfoList = searchResultProductIndex.getResultList();
|
|
|
Map<Integer, Map<String, Object>> productInfoMap = productInfoList.stream().collect(Collectors.toMap(a -> MapUtils.getIntValue(a, "productSkn"), a -> a));
|
|
|
List<Map<String, Object>> productList = new ArrayList<>();
|
|
|
for (Map<String, Object> map : searchResultProductIndex.getResultList()) {
|
|
|
Map<String, Object> productMap = new HashMap<>();
|
|
|
Integer productSkn = MapUtils.getIntValue(map, ProductIndexEsField.productSkn, 0);
|
|
|
productMap.put("productSkn", productSkn);
|
|
|
productMap.put("productName", MapUtils.getString(map, ProductIndexEsField.productName, ""));
|
|
|
productMap.put("defaultImages", MapUtils.getString(map, ProductIndexEsField.defaultImages, ""));
|
|
|
productMap.put("sales_price", MapUtils.getString(map, ProductIndexEsField.salesPrice, ""));
|
|
|
ZeroHelpProduct zeroHelpProduct = zeroHelpProductMap.get(productSkn);
|
|
|
for (ZeroHelpProduct zeroHelpProduct : zeroHelpProductList) {
|
|
|
if (zeroHelpProduct == null) {
|
|
|
continue;
|
|
|
}
|
|
|
Map<String, Object> productMap = new HashMap<>();
|
|
|
productMap.put("id", zeroHelpProduct.getId());
|
|
|
productMap.put("begin_time", zeroHelpProduct.getBeginTime());
|
|
|
productMap.put("end_time", zeroHelpProduct.getEndTime());
|
|
|
productMap.put("target_price", zeroHelpProduct.getTargetPrice());
|
|
|
productMap.put("helper_num", zeroHelpProduct.getHelperNum());
|
|
|
Integer productSkn = zeroHelpProduct.getProductSkn();
|
|
|
productMap.put("product_skn", productSkn);
|
|
|
Map<String, Object> productInfo = productInfoMap.get(productSkn);
|
|
|
if (productInfo.isEmpty()) {
|
|
|
continue;
|
|
|
}
|
|
|
productMap.put("product_name", MapUtils.getString(productInfo, ProductIndexEsField.productName, ""));
|
|
|
productMap.put("default_images", MapUtils.getString(productInfo, ProductIndexEsField.defaultImages, ""));
|
|
|
productMap.put("sales_price", MapUtils.getString(productInfo, ProductIndexEsField.salesPrice, ""));
|
|
|
productMap.put("market_price", MapUtils.getString(productInfo, ProductIndexEsField.marketPrice, ""));
|
|
|
productList.add(productMap);
|
|
|
}
|
|
|
|
|
|
//加入变价计划
|
|
|
productPricePlanIndexBaseService.fillProductPricePlanForCutDown(productList);
|
|
|
productPricePlanIndexBaseService.fillProductPricePlan(productList);
|
|
|
JSONObject result = buildReturnDataMap(searchResult.getTotal(), searchResult.getPage(), pageSize, searchResult.getTotalPage(), productList);
|
|
|
return new SearchApiResult().setData(result);
|
|
|
} catch (Exception e) {
|
...
|
...
|
|