|
@@ -60,24 +60,24 @@ public class SearchLikeInShopService { |
|
@@ -60,24 +60,24 @@ public class SearchLikeInShopService { |
60
|
}
|
60
|
}
|
61
|
// 2、检测分页参数【默认30条】
|
61
|
// 2、检测分页参数【默认30条】
|
62
|
int viewNum = 30;
|
62
|
int viewNum = 30;
|
63
|
-
|
|
|
64
|
// 3、获取当前查询的SKN的基本信息
|
63
|
// 3、获取当前查询的SKN的基本信息
|
65
|
JSONObject productInfoInEs = searchLikeHelper.getProductInfoInEs(productSkn);
|
64
|
JSONObject productInfoInEs = searchLikeHelper.getProductInfoInEs(productSkn);
|
66
|
if (productInfoInEs == null) {
|
65
|
if (productInfoInEs == null) {
|
67
|
return new SearchApiResult().setCode(400).setMessage("SKN不存在");
|
66
|
return new SearchApiResult().setCode(400).setMessage("SKN不存在");
|
68
|
}
|
67
|
}
|
69
|
-
|
|
|
70
|
// 4、设置SearchParams
|
68
|
// 4、设置SearchParams
|
71
|
List<SearchParam> searchParams = new ArrayList<SearchParam>();
|
69
|
List<SearchParam> searchParams = new ArrayList<SearchParam>();
|
72
|
searchParams.add(this.builderSearchParam(productInfoInEs, Arrays.asList(productSkn), viewNum));
|
70
|
searchParams.add(this.builderSearchParam(productInfoInEs, Arrays.asList(productSkn), viewNum));
|
73
|
-
|
|
|
74
|
// 5、获取搜索结果[截取条数]
|
71
|
// 5、获取搜索结果[截取条数]
|
75
|
List<Map<String, Object>> tempProductList = searchLikeHelper.queryProductList(searchParams);
|
72
|
List<Map<String, Object>> tempProductList = searchLikeHelper.queryProductList(searchParams);
|
76
|
if (tempProductList.size() > viewNum) {
|
73
|
if (tempProductList.size() > viewNum) {
|
77
|
tempProductList = CollectionUtils.safeSubList(tempProductList,0, viewNum);
|
74
|
tempProductList = CollectionUtils.safeSubList(tempProductList,0, viewNum);
|
78
|
}
|
75
|
}
|
79
|
-
|
|
|
80
|
- // 6、构造真实返回结果
|
76
|
+ //6、保留偶数
|
|
|
77
|
+ if (tempProductList.size() % 2 > 0) {
|
|
|
78
|
+ tempProductList = CollectionUtils.safeSubList(tempProductList, 0, tempProductList.size() - 1);
|
|
|
79
|
+ }
|
|
|
80
|
+ // 7、构造返回结果
|
81
|
List<Map<String, Object>> productListResults = new ArrayList<Map<String, Object>>();
|
81
|
List<Map<String, Object>> productListResults = new ArrayList<Map<String, Object>>();
|
82
|
if (!tempProductList.isEmpty()) {
|
82
|
if (!tempProductList.isEmpty()) {
|
83
|
productListResults = productListHelper.buildReturnInfoByEsSourceList(tempProductList);
|
83
|
productListResults = productListHelper.buildReturnInfoByEsSourceList(tempProductList);
|