...
|
...
|
@@ -55,7 +55,7 @@ public class UserRecallResponseBuilder { |
|
|
sknResultList = this.fillBaseInfo(sknResultList);
|
|
|
|
|
|
//4、填充是否满足品类价格带的过滤
|
|
|
sknResultList = this.fillIsLikePriceArea(sknResultList, userPersonalFactor);
|
|
|
sknResultList = this.fillIsLikePriceArea(userRecallRequest.getUid(),sknResultList, userPersonalFactor);
|
|
|
|
|
|
//5、按相关性计算得分
|
|
|
sknResultList = this.doCalScoreAndSort(sknResultList, userRecallRequest.getUid());
|
...
|
...
|
@@ -130,7 +130,7 @@ public class UserRecallResponseBuilder { |
|
|
* @param sknResults
|
|
|
* @return
|
|
|
*/
|
|
|
private List<RecallMergerResult.SknResult> fillIsLikePriceArea(List<RecallMergerResult.SknResult> sknResults, UserPersonalFactor userPersonalFactor) {
|
|
|
private List<RecallMergerResult.SknResult> fillIsLikePriceArea(int uid, List<RecallMergerResult.SknResult> sknResults, UserPersonalFactor userPersonalFactor) {
|
|
|
//1、获取用户价格带偏好
|
|
|
List<SortPriceAreas> userSortPriceAreasList = userPersonalFactor.getSortPriceAreasList();
|
|
|
if (userSortPriceAreasList == null || userSortPriceAreasList.isEmpty()) {
|
...
|
...
|
@@ -144,16 +144,67 @@ public class UserRecallResponseBuilder { |
|
|
//3、填充当前skn是否属于用户偏好的价格带
|
|
|
for (RecallMergerResult.SknResult sknResult : sknResults) {
|
|
|
Integer misortId = sknResult.getMiddleSortId();
|
|
|
List<Integer> priceAreas = userMisort2PriceAreasMap.getOrDefault(misortId, new ArrayList<>());
|
|
|
if (priceAreas.contains(sknResult.getPriceArea())) {
|
|
|
sknResult.setLikePriceArea(true);
|
|
|
} else {
|
|
|
sknResult.setLikePriceArea(false);
|
|
|
}
|
|
|
List<Integer> userPriceAreas = userMisort2PriceAreasMap.getOrDefault(misortId, new ArrayList<>());
|
|
|
boolean isLikePriceArea = this.isLikePriceArea(uid,userPriceAreas,sknResult.getPriceArea());
|
|
|
sknResult.setLikePriceArea(isLikePriceArea);
|
|
|
}
|
|
|
return sknResults;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* AB test
|
|
|
* @param uid
|
|
|
* @param userPriceAreas
|
|
|
* @param sknPriceArea
|
|
|
* @return
|
|
|
*/
|
|
|
private boolean isLikePriceArea(int uid, List<Integer> userPriceAreas,Integer sknPriceArea){
|
|
|
if(userPriceAreas==null || userPriceAreas.isEmpty()){
|
|
|
return false;
|
|
|
}
|
|
|
if(uid%2==1){
|
|
|
if(searchDynamicConfigService.isAStrategyOpen()){
|
|
|
return isLikePriceAreaWithAStrategy(userPriceAreas,sknPriceArea);
|
|
|
}else{
|
|
|
return isLikePriceAreaWithBStrategy(userPriceAreas,sknPriceArea);
|
|
|
}
|
|
|
}else{
|
|
|
if(searchDynamicConfigService.isBStrategyOpen()){
|
|
|
return isLikePriceAreaWithBStrategy(userPriceAreas,sknPriceArea);
|
|
|
}else{
|
|
|
return isLikePriceAreaWithAStrategy(userPriceAreas,sknPriceArea);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private boolean isLikePriceAreaWithAStrategy(List<Integer> userPriceAreas,Integer sknPriceArea){
|
|
|
return userPriceAreas.contains(sknPriceArea);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 价格带左右各扩展一位
|
|
|
* @param userPriceAreas
|
|
|
* @param sknPriceArea
|
|
|
* @return
|
|
|
*/
|
|
|
private boolean isLikePriceAreaWithBStrategy(List<Integer> userPriceAreas,Integer sknPriceArea){
|
|
|
Collections.sort(userPriceAreas);
|
|
|
int min = userPriceAreas.get(0);
|
|
|
int max = userPriceAreas.get(userPriceAreas.size()-1);
|
|
|
int leftCount = min<=1 ? 0 : max>=7 ? 2 : 1;
|
|
|
int rightCount = min<=1 ? 2 : max>=7 ? 0 : 1;
|
|
|
for(int i = 1;i<=leftCount;i++){
|
|
|
if(min-i>=1){
|
|
|
userPriceAreas.add(0,min-i);
|
|
|
}
|
|
|
}
|
|
|
for(int i = 1;i<=rightCount;i++){
|
|
|
if(max+i<=7){
|
|
|
userPriceAreas.add(max+i);
|
|
|
}
|
|
|
}
|
|
|
return userPriceAreas.contains(sknPriceArea);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 粗排-按相关性计算得分,并按得分排序
|
...
|
...
|
@@ -304,24 +355,24 @@ public class UserRecallResponseBuilder { |
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
List<Integer> fromList = new ArrayList<>();
|
|
|
for (int index =1;index <=30;index ++){
|
|
|
fromList.add(index);
|
|
|
List<Integer> userPriceAreas = new ArrayList<>();
|
|
|
userPriceAreas.addAll(Arrays.asList(5,6,7));
|
|
|
Collections.sort(userPriceAreas);
|
|
|
int min = userPriceAreas.get(0);
|
|
|
int max = userPriceAreas.get(userPriceAreas.size()-1);
|
|
|
int leftCount = min<=1 ? 0 : max>=7 ? 2 : 1;
|
|
|
int rightCount = min<=1 ? 2 : max>=7 ? 0 : 1;
|
|
|
for(int i = 1;i<=leftCount;i++){
|
|
|
if(min-i>=1){
|
|
|
userPriceAreas.add(0,min-i);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
List<Integer> toList = new ArrayList<>();
|
|
|
for (int index =0;index <100;index ++){
|
|
|
toList.add(0);
|
|
|
for(int i = 1;i<=rightCount;i++){
|
|
|
if(max+i<=7){
|
|
|
userPriceAreas.add(max+i);
|
|
|
}
|
|
|
}
|
|
|
addByIndexIndex(fromList, toList, 1, 2, (value -> value%2==1),null);
|
|
|
|
|
|
addByIndexIndex(fromList, toList, 2, 3, (value -> value%2==0),null);
|
|
|
|
|
|
System.out.println(toList);
|
|
|
// addByIndexIndex(fromList, toList, 4, 4, (value -> value%2==0));
|
|
|
// System.out.println(toList);
|
|
|
System.out.println(userPriceAreas);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|