...
|
...
|
@@ -26,23 +26,42 @@ public class SceneRecommendBrandsService { |
|
|
|
|
|
@Autowired
|
|
|
private UserPersionalFactorComponent userPersionalFactorComponent;
|
|
|
@Autowired
|
|
|
private IAggRecommendService aggRecommendService;
|
|
|
@Autowired
|
|
|
private SearchDynamicConfigService searchDynamicConfigService;
|
|
|
|
|
|
public void getRecommendBrands(Map<String, String> paramMap, SearchApiResult result) {
|
|
|
getRecommendBrands(paramMap, result, null);
|
|
|
}
|
|
|
|
|
|
public void getRecommendBrands(Map<String, String> paramMap, SearchApiResult result, BoolQueryBuilder extFilter) {
|
|
|
if (result != null && result.getData() != null) {
|
|
|
JSONObject data = (JSONObject) result.getData();
|
|
|
JSONObject commonFilters = data.getJSONObject("filter");
|
|
|
if (commonFilters != null) {
|
|
|
getRecommendBrandsNew(commonFilters, paramMap);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void getRecommendBrandsNew(JSONObject commonFilters, Map<String, String> paramMap) {
|
|
|
JSONArray recommendBrands = new JSONArray();
|
|
|
JSONArray brandList = commonFilters.getJSONArray("brand");
|
|
|
if (!CollectionUtils.isEmpty(brandList)) {
|
|
|
recommendBrands = getRecommendBrands(paramMap, brandList);
|
|
|
}
|
|
|
commonFilters.put("recommendBrand", recommendBrands);
|
|
|
}
|
|
|
|
|
|
private JSONArray getRecommendBrands(Map<String, String> paramMap, JSONArray brandList) {
|
|
|
List<JSONObject> brandListTemp = JSON.parseObject(brandList.toJSONString(), new TypeReference<List<JSONObject>>() {});
|
|
|
List<JSONObject> brandListTemp = JSON.parseObject(brandList.toJSONString(), new TypeReference<List<JSONObject>>() {
|
|
|
});
|
|
|
Map<Integer, JSONObject> brandIdMap = brandListTemp.stream().collect(Collectors.toMap(e -> e.getInteger("id"), Function.identity(), (m1, m2) -> m2));
|
|
|
int uid = MapUtils.getIntValue(paramMap, "uid", 0);
|
|
|
String udid = MapUtils.getString(paramMap, "udid", "");
|
|
|
int recommendBrandCount = Integer.parseInt(paramMap.getOrDefault(SearchRequestParams.PARAM_SEARCH_VIEWNUM, "8"));
|
|
|
JSONArray recBrands = new JSONArray(recommendBrandCount);
|
|
|
UserPersonalFactorRspNew userFactor = userPersionalFactorComponent.queryUserPersionalFactor(uid, udid,null);
|
|
|
UserPersonalFactorRspNew userFactor = userPersionalFactorComponent.queryUserPersionalFactor(uid, udid, null);
|
|
|
List<Integer> brandIds = new ArrayList<>();
|
|
|
if (userFactor != null) {
|
|
|
if (userFactor != null && userFactor.getRealTimeSortBrandList()!=null) {
|
|
|
List<SortBrand> sortBrandList = new ArrayList<>(userFactor.getRealTimeSortBrandList());
|
|
|
sortBrandList.addAll(userFactor.getRealTimeSortBrandList());
|
|
|
for (SortBrand sortBrand : sortBrandList) {
|
|
|
if (recBrands.size() >= recommendBrandCount) {
|
|
|
break;
|
...
|
...
|
@@ -71,36 +90,4 @@ public class SceneRecommendBrandsService { |
|
|
return recBrands;
|
|
|
}
|
|
|
|
|
|
public void getRecommendBrands(Map<String, String> paramMap, SearchApiResult result) {
|
|
|
getRecommendBrands(paramMap, result, null);
|
|
|
}
|
|
|
|
|
|
public void getRecommendBrands(Map<String, String> paramMap, SearchApiResult result, BoolQueryBuilder extFilter) {
|
|
|
if (result != null && result.getData() != null) {
|
|
|
JSONObject data = (JSONObject) result.getData();
|
|
|
JSONObject commonFilters = data.getJSONObject("filter");
|
|
|
if (commonFilters != null) {
|
|
|
if (searchDynamicConfigService.isRecommendBrandUserPersonalOpen()) {
|
|
|
getRecommendBrandsNew(commonFilters, paramMap);
|
|
|
} else {
|
|
|
getRecommendBrandsOld(commonFilters, paramMap, extFilter);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void getRecommendBrandsNew(JSONObject commonFilters, Map<String, String> paramMap) {
|
|
|
JSONArray recommendBrands = new JSONArray();
|
|
|
JSONArray brandList = commonFilters.getJSONArray("brand");
|
|
|
if (!CollectionUtils.isEmpty(brandList)) {
|
|
|
recommendBrands = getRecommendBrands(paramMap, brandList);
|
|
|
}
|
|
|
commonFilters.put("recommendBrand", recommendBrands);
|
|
|
}
|
|
|
|
|
|
private void getRecommendBrandsOld(JSONObject commonFilters, Map<String, String> paramMap, BoolQueryBuilder extFilter) {
|
|
|
Map<String, String> newParamMap = new HashMap<>(paramMap);
|
|
|
SearchApiResult searchApiResult = aggRecommendService.aggRecommendBrand(newParamMap, extFilter);
|
|
|
commonFilters.put("recommendBrand", searchApiResult.getData());
|
|
|
}
|
|
|
} |
...
|
...
|
|