Authored by hugufei

fix ActivityService bug

... ... @@ -29,8 +29,8 @@ public class ActivityService{
public SearchApiResult recommendShop(Map<String, String> paramMap) {
//1、查询页面上的所有品牌*店铺
ActivityShopBrandList activityShopBrandList = activityShopBrandListService.queryActivityShopBrandList(paramMap);
if (activityShopBrandList == null || activityShopBrandList.getShopBrandList() == null || activityShopBrandList.getShopBrandList().isEmpty()) {
List<ActivityShopBrandList.ShopBrand> shopBrandList = activityShopBrandListService.queryActivityShopBrandList(paramMap);
if (shopBrandList == null || shopBrandList.isEmpty()) {
return this.buildShopList(200, "success", new ArrayList<>());
}
//2、查询用户的品牌向量
... ... @@ -38,7 +38,7 @@ public class ActivityService{
String udid = MapUtils.getString(paramMap, "udid", "");
UserPersonalFactorRspNew userPersonalFactorRspNew = userComponent.queryUserPersionalFactor(uid, udid, null);
//3、按相关性聚合品牌
List<Integer> shopIds = this.buildShopIds(activityShopBrandList,userPersonalFactorRspNew);
List<Integer> shopIds = this.buildShopIds(shopBrandList,userPersonalFactorRspNew);
//4、查询店铺
List<Map<String, Object>> shopsList = shopsIndexBaseService.getShopListByIdsWithSortAndStatus(shopIds);
//5、数量截取
... ... @@ -48,11 +48,10 @@ public class ActivityService{
return this.buildShopList(200, "success",shopsList);
}
private List<Integer> buildShopIds(ActivityShopBrandList activityShopBrandList, UserPersonalFactorRspNew userPersonalFactorRspNew){
private List<Integer> buildShopIds(List<ActivityShopBrandList.ShopBrand> shopBrandList, UserPersonalFactorRspNew userPersonalFactorRspNew){
//1、计算店铺得分
List<Double> brandVector = userPersonalFactorRspNew.getBrandVector();
List<Double> brandVectorW2v = userPersonalFactorRspNew.getBrandVectorW2v();
List<ActivityShopBrandList.ShopBrand> shopBrandList = activityShopBrandList.getShopBrandList();
if(brandVectorW2v!=null && !brandVectorW2v.isEmpty()){
this.calScore(shopBrandList,brandVector,false);
}else{
... ...
... ... @@ -40,14 +40,17 @@ public class ActivityShopBrandListService extends AbstractPageComponent<Activity
* @param paramMap
* @return
*/
public ActivityShopBrandList queryActivityShopBrandList(Map<String, String> paramMap) {
public List<ActivityShopBrandList.ShopBrand> queryActivityShopBrandList(Map<String, String> paramMap) {
try {
ParamQueryFilter paramQueryFilter = userRecallRequestBuilder.buildParamQueryFilter(paramMap);
Object value = super.queryWithCache(paramQueryFilter, ActivityShopBrandList.class);
return value == null ? null : (ActivityShopBrandList) value;
if(value==null){
return new ArrayList<>();
}
return new ArrayList<>(((ActivityShopBrandList) value).getShopBrandList());
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ActivityShopBrandList();
return new ArrayList<>();
}
}
... ...