...
|
...
|
@@ -193,7 +193,6 @@ public class ShopListServiceImpl implements IShopListService { |
|
|
if (productList == null || productList.isEmpty()) {
|
|
|
return new ArrayList<Map<String, Object>>();
|
|
|
}
|
|
|
productList = this.sortListBySortField(productList);
|
|
|
|
|
|
List<Integer> yohoShopIds = new ArrayList<Integer>();
|
|
|
List<Integer> globalBrandIds = new ArrayList<Integer>();
|
...
|
...
|
@@ -223,6 +222,7 @@ public class ShopListServiceImpl implements IShopListService { |
|
|
if (globalBrand != null && 1==(Integer)globalBrand.get("status")) {
|
|
|
shop_info.put("tbl_brand", globalBrand);
|
|
|
shop_info.put("yoho_shop", null);
|
|
|
shop_info.put("_score", map.getOrDefault("_score", 0));
|
|
|
shops_info.add(shop_info);
|
|
|
continue;
|
|
|
}
|
...
|
...
|
@@ -232,62 +232,34 @@ public class ShopListServiceImpl implements IShopListService { |
|
|
if (yohoShopInfo != null && 1==(Integer)yohoShopInfo.get("status")) {
|
|
|
shop_info.put("tbl_brand", null);
|
|
|
shop_info.put("yoho_shop", yohoShopInfo);
|
|
|
shop_info.put("_score", map.getOrDefault("_score", 0));
|
|
|
shops_info.add(shop_info);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return shops_info;
|
|
|
}
|
|
|
|
|
|
private double getDouble(Object value) {
|
|
|
if (value == null) {
|
|
|
return 0;
|
|
|
}
|
|
|
if (value instanceof Float) {
|
|
|
return ((Float) value).floatValue();
|
|
|
}
|
|
|
if (value instanceof Integer) {
|
|
|
return ((Integer) value);
|
|
|
}
|
|
|
if (value instanceof Long) {
|
|
|
return ((Long) value);
|
|
|
}
|
|
|
if (value instanceof String) {
|
|
|
return Double.valueOf(value.toString());
|
|
|
}
|
|
|
if (value instanceof Double) {
|
|
|
return Double.valueOf(value.toString());
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
private List<Map<String, Object>> sortListBySortField(List<Map<String, Object>> productList) {
|
|
|
if (productList == null || productList.isEmpty()) {
|
|
|
return productList;
|
|
|
}
|
|
|
// 再按照某个字段对商品排序
|
|
|
boolean asc = false;
|
|
|
Collections.sort(productList, new Comparator<Map<String, Object>>() {
|
|
|
Collections.sort(shops_info,new Comparator<Map<String, Object>>() {
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@Override
|
|
|
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
try {
|
|
|
double value1 = getDouble(o1.get("_score"));
|
|
|
double value2 = getDouble(o2.get("_score"));
|
|
|
if (value1 == value2) {
|
|
|
return 0;
|
|
|
}
|
|
|
if (asc) {
|
|
|
return value1 - value2 > 0 ? 1 : -1;
|
|
|
} else {
|
|
|
return value1 - value2 > 0 ? -1 : 1;
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
|
|
float score1 = (float)o1.getOrDefault("_score", 0);
|
|
|
float score2 = (float)o2.getOrDefault("_score", 0);
|
|
|
if(score1>score2){
|
|
|
return -1;
|
|
|
}
|
|
|
if(score1<score2){
|
|
|
return 1;
|
|
|
}
|
|
|
Map<String, Object> yoho_shop1 = (Map<String, Object>)o1.get("yoho_shop");
|
|
|
Map<String, Object> yoho_shop2 = (Map<String, Object>)o2.get("yoho_shop");
|
|
|
if(yoho_shop2==null || yoho_shop2==null){
|
|
|
return 0;
|
|
|
}
|
|
|
int shop_type1 = (Integer)yoho_shop1.getOrDefault("shop_type", Integer.MAX_VALUE);
|
|
|
int shop_type2 = (Integer) yoho_shop2.getOrDefault("shop_type", Integer.MAX_VALUE);
|
|
|
return shop_type1 - shop_type2;
|
|
|
}
|
|
|
});
|
|
|
return productList;
|
|
|
return shops_info;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|