Authored by hugufei

重命名

package com.yoho.search.recall.scene.beans.builder;
import com.yoho.search.core.personalized.models.SortBrand;
import com.yoho.search.recall.scene.beans.config.SknCountConfig;
import com.yoho.search.recall.scene.beans.config.SknCountConfigService;
import com.yoho.search.recall.scene.beans.config.ProductCountConfig;
import com.yoho.search.recall.scene.beans.config.ProductCountConfigService;
import com.yoho.search.recall.scene.beans.strategy.IStrategy;
import com.yoho.search.recall.scene.beans.strategy.SortBrandType;
import com.yoho.search.recall.scene.beans.strategy.impls.*;
import com.yoho.search.recall.scene.constants.SknCountConstants;
import com.yoho.search.recall.scene.models.common.ParamQueryFilter;
import com.yoho.search.recall.scene.models.req.RecallRequest;
import com.yoho.search.recall.scene.models.req.UserRecallRequest;
import com.yoho.search.service.base.SearchDynamicConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -21,7 +19,7 @@ import java.util.List;
public class SortBrandRecallRequestBuilder {
@Autowired
private SknCountConfigService sknCountConfigService;
private ProductCountConfigService productCountConfigService;
/**
* 构造品牌+品类的召回请求
... ... @@ -42,29 +40,29 @@ public class SortBrandRecallRequestBuilder {
// 3)、参数构造
for (SortBrand sortBrand : sortBrands) {
SknCountConfig sknCountConfig = this.queryRecallSknCount(pageId, sortBrand);
if (sknCountConfig == null) {
ProductCountConfig productCountConfig = this.queryRecallSknCount(pageId, sortBrand);
if (productCountConfig == null) {
continue;
}
// 1) 新品
if (sknCountConfig.getNewShelve() > 0) {
requests.add(this.buildSortBrandNewShelveRequest(paramQueryFilter, sortBrand, sknCountConfig.getNewShelve(), sortBrandType));
if (productCountConfig.getNewShelve() > 0) {
requests.add(this.buildSortBrandNewShelveRequest(paramQueryFilter, sortBrand, productCountConfig.getNewShelve(), sortBrandType));
}
// 2) 人气
if (sknCountConfig.getHeatValue() > 0) {
requests.add(this.buildSortBrandHeatValueRequest(paramQueryFilter, sortBrand, sknCountConfig.getHeatValue(), sortBrandType));
if (productCountConfig.getHeatValue() > 0) {
requests.add(this.buildSortBrandHeatValueRequest(paramQueryFilter, sortBrand, productCountConfig.getHeatValue(), sortBrandType));
}
// 3) 新降价
if (sknCountConfig.getReducePrice() > 0) {
requests.add(this.buildSortBrandReducePriceRequest(paramQueryFilter, sortBrand, sknCountConfig.getReducePrice(), sortBrandType));
if (productCountConfig.getReducePrice() > 0) {
requests.add(this.buildSortBrandReducePriceRequest(paramQueryFilter, sortBrand, productCountConfig.getReducePrice(), sortBrandType));
}
// 4) 新开促销
if (sknCountConfig.getPromotion() > 0) {
requests.add(this.buildSortBrandPromotionRequest(paramQueryFilter, sortBrand, sknCountConfig.getPromotion(), sortBrandType));
if (productCountConfig.getPromotion() > 0) {
requests.add(this.buildSortBrandPromotionRequest(paramQueryFilter, sortBrand, productCountConfig.getPromotion(), sortBrandType));
}
// 5) 转化率
if (sknCountConfig.getCtrValue() > 0) {
requests.add(this.buildSortBrandCtrValueRequest(paramQueryFilter, sortBrand, sknCountConfig.getCtrValue(), sortBrandType));
if (productCountConfig.getCtrValue() > 0) {
requests.add(this.buildSortBrandCtrValueRequest(paramQueryFilter, sortBrand, productCountConfig.getCtrValue(), sortBrandType));
}
}
return requests;
... ... @@ -77,8 +75,8 @@ public class SortBrandRecallRequestBuilder {
* @param sortBrand
* @return
*/
private SknCountConfig queryRecallSknCount(int pageId, SortBrand sortBrand) {
return sknCountConfigService.getSknCountConfig(pageId, sortBrand);
private ProductCountConfig queryRecallSknCount(int pageId, SortBrand sortBrand) {
return productCountConfigService.getProductCountConfig(pageId, sortBrand);
}
/**
... ...
package com.yoho.search.recall.scene.beans.config;
public class SknCountConfig {
public class ProductCountConfig {
private int newShelve;
private int promotion;
... ...
package com.yoho.search.recall.scene.beans.config;
import com.yoho.search.core.personalized.models.SortBrand;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class ProductCountConfigService {
private static int DEFAULT_PAGE_ID = 0;
private static int DEFAULT_NEW_SHELVE = 6;
private static int DEFAULT_PROMOTION = 3;
private static int DEFAULT_REDUCE_PRICE = 6;
private static int DEFAULT_CTR_VALUE = 6;
private static int DEFAULT_HEAT_VALUE = 6;
private Map<Integer, ProductCountConfig> middleSortConfig = new HashMap<>();
private Map<Integer, ProductCountConfig> brandConfig = new HashMap<>();
private Map<Integer, ProductCountConfig> pageConfig = new HashMap<>();
public ProductCountConfig getProductCountConfig(int pageId, SortBrand sortBrand) {
ProductCountConfig middleProductCountConfig = middleSortConfig.get(sortBrand.getMisort());
ProductCountConfig brandCountConfig = brandConfig.get(sortBrand.getBrandId());
if (brandCountConfig != null && middleProductCountConfig != null) {
return genProductCountConfigByCompare(brandCountConfig, middleProductCountConfig);
}
if (brandCountConfig != null) {
return brandCountConfig;
}
if (middleProductCountConfig != null) {
return middleProductCountConfig;
}
ProductCountConfig pageProductCountConfig = pageConfig.get(pageId);
if (pageProductCountConfig != null) {
return pageProductCountConfig;
}
pageProductCountConfig = pageConfig.get(DEFAULT_PAGE_ID);
if (pageProductCountConfig != null) {
return pageProductCountConfig;
}
return genProductCountConfig(DEFAULT_NEW_SHELVE, DEFAULT_PROMOTION, DEFAULT_REDUCE_PRICE, DEFAULT_CTR_VALUE, DEFAULT_HEAT_VALUE);
}
private ProductCountConfig genProductCountConfigByCompare(ProductCountConfig productCountConfig1, ProductCountConfig productCountConfig2) {
int newShelve = Math.min(productCountConfig1.getNewShelve(), productCountConfig2.getNewShelve());
int promotion = Math.min(productCountConfig1.getPromotion(), productCountConfig2.getPromotion());
int reducePrice = Math.min(productCountConfig1.getReducePrice(), productCountConfig2.getReducePrice());
int ctrValue = Math.min(productCountConfig1.getCtrValue(), productCountConfig2.getCtrValue());
int heatValue = Math.min(productCountConfig1.getHeatValue(), productCountConfig2.getHeatValue());
return genProductCountConfig(newShelve, promotion, reducePrice, ctrValue, heatValue);
}
private ProductCountConfig genProductCountConfig(int newShelve, int promotion, int reducePrice, int ctrValue, int heatValue) {
ProductCountConfig productCountConfig = new ProductCountConfig();
productCountConfig.setNewShelve(newShelve);
productCountConfig.setPromotion(promotion);
productCountConfig.setReducePrice(reducePrice);
productCountConfig.setCtrValue(ctrValue);
productCountConfig.setHeatValue(heatValue);
return productCountConfig;
}
}
... ...
package com.yoho.search.recall.scene.beans.config;
import com.yoho.search.core.personalized.models.SortBrand;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class SknCountConfigService {
private static int DEFAULT_PAGE_ID = 0;
private static int DEFAULT_NEW_SHELVE = 6;
private static int DEFAULT_PROMOTION = 3;
private static int DEFAULT_REDUCE_PRICE = 6;
private static int DEFAULT_CTR_VALUE = 6;
private static int DEFAULT_HEAT_VALUE = 6;
private Map<Integer, SknCountConfig> middleSortConfig = new HashMap<>();
private Map<Integer, SknCountConfig> brandConfig = new HashMap<>();
private Map<Integer, SknCountConfig> pageConfig = new HashMap<>();
public SknCountConfig getSknCountConfig(int pageId, SortBrand sortBrand) {
SknCountConfig middleSknCountConfig = middleSortConfig.get(sortBrand.getMisort());
SknCountConfig brandCountConfig = brandConfig.get(sortBrand.getBrandId());
if (brandCountConfig != null && middleSknCountConfig != null) {
return genSknCountConfig(brandCountConfig, middleSknCountConfig);
}
if (brandCountConfig != null) {
return brandCountConfig;
}
if (middleSknCountConfig != null) {
return middleSknCountConfig;
}
SknCountConfig pageSknCountConfig = pageConfig.get(pageId);
if (pageSknCountConfig != null) {
return pageSknCountConfig;
}
pageSknCountConfig = pageConfig.get(DEFAULT_PAGE_ID);
if (pageSknCountConfig != null) {
return pageSknCountConfig;
}
return genSknCountConfig(DEFAULT_NEW_SHELVE, DEFAULT_PROMOTION, DEFAULT_REDUCE_PRICE, DEFAULT_CTR_VALUE, DEFAULT_HEAT_VALUE);
}
private SknCountConfig genSknCountConfig(SknCountConfig sknCountConfig1, SknCountConfig sknCountConfig2) {
int newShelve = Math.min(sknCountConfig1.getNewShelve(), sknCountConfig2.getNewShelve());
int promotion = Math.min(sknCountConfig1.getPromotion(), sknCountConfig2.getPromotion());
int reducePrice = Math.min(sknCountConfig1.getReducePrice(), sknCountConfig2.getReducePrice());
int ctrValue = Math.min(sknCountConfig1.getCtrValue(), sknCountConfig2.getCtrValue());
int heatValue = Math.min(sknCountConfig1.getHeatValue(), sknCountConfig2.getHeatValue());
return genSknCountConfig(newShelve, promotion, reducePrice, ctrValue, heatValue);
}
private SknCountConfig genSknCountConfig(int newShelve, int promotion, int reducePrice, int ctrValue, int heatValue) {
SknCountConfig sknCountConfig = new SknCountConfig();
sknCountConfig.setNewShelve(newShelve);
sknCountConfig.setPromotion(promotion);
sknCountConfig.setReducePrice(reducePrice);
sknCountConfig.setCtrValue(ctrValue);
sknCountConfig.setHeatValue(heatValue);
return sknCountConfig;
}
}