Authored by hugufei

重命名

1 package com.yoho.search.recall.scene.beans.builder; 1 package com.yoho.search.recall.scene.beans.builder;
2 2
3 import com.yoho.search.core.personalized.models.SortBrand; 3 import com.yoho.search.core.personalized.models.SortBrand;
4 -import com.yoho.search.recall.scene.beans.config.SknCountConfig;  
5 -import com.yoho.search.recall.scene.beans.config.SknCountConfigService; 4 +import com.yoho.search.recall.scene.beans.config.ProductCountConfig;
  5 +import com.yoho.search.recall.scene.beans.config.ProductCountConfigService;
6 import com.yoho.search.recall.scene.beans.strategy.IStrategy; 6 import com.yoho.search.recall.scene.beans.strategy.IStrategy;
7 import com.yoho.search.recall.scene.beans.strategy.SortBrandType; 7 import com.yoho.search.recall.scene.beans.strategy.SortBrandType;
8 import com.yoho.search.recall.scene.beans.strategy.impls.*; 8 import com.yoho.search.recall.scene.beans.strategy.impls.*;
9 -import com.yoho.search.recall.scene.constants.SknCountConstants;  
10 import com.yoho.search.recall.scene.models.common.ParamQueryFilter; 9 import com.yoho.search.recall.scene.models.common.ParamQueryFilter;
11 import com.yoho.search.recall.scene.models.req.RecallRequest; 10 import com.yoho.search.recall.scene.models.req.RecallRequest;
12 import com.yoho.search.recall.scene.models.req.UserRecallRequest; 11 import com.yoho.search.recall.scene.models.req.UserRecallRequest;
13 -import com.yoho.search.service.base.SearchDynamicConfigService;  
14 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.stereotype.Component; 13 import org.springframework.stereotype.Component;
16 14
@@ -21,7 +19,7 @@ import java.util.List; @@ -21,7 +19,7 @@ import java.util.List;
21 public class SortBrandRecallRequestBuilder { 19 public class SortBrandRecallRequestBuilder {
22 20
23 @Autowired 21 @Autowired
24 - private SknCountConfigService sknCountConfigService; 22 + private ProductCountConfigService productCountConfigService;
25 23
26 /** 24 /**
27 * 构造品牌+品类的召回请求 25 * 构造品牌+品类的召回请求
@@ -42,29 +40,29 @@ public class SortBrandRecallRequestBuilder { @@ -42,29 +40,29 @@ public class SortBrandRecallRequestBuilder {
42 40
43 // 3)、参数构造 41 // 3)、参数构造
44 for (SortBrand sortBrand : sortBrands) { 42 for (SortBrand sortBrand : sortBrands) {
45 - SknCountConfig sknCountConfig = this.queryRecallSknCount(pageId, sortBrand);  
46 - if (sknCountConfig == null) { 43 + ProductCountConfig productCountConfig = this.queryRecallSknCount(pageId, sortBrand);
  44 + if (productCountConfig == null) {
47 continue; 45 continue;
48 } 46 }
49 // 1) 新品 47 // 1) 新品
50 - if (sknCountConfig.getNewShelve() > 0) {  
51 - requests.add(this.buildSortBrandNewShelveRequest(paramQueryFilter, sortBrand, sknCountConfig.getNewShelve(), sortBrandType)); 48 + if (productCountConfig.getNewShelve() > 0) {
  49 + requests.add(this.buildSortBrandNewShelveRequest(paramQueryFilter, sortBrand, productCountConfig.getNewShelve(), sortBrandType));
52 } 50 }
53 // 2) 人气 51 // 2) 人气
54 - if (sknCountConfig.getHeatValue() > 0) {  
55 - requests.add(this.buildSortBrandHeatValueRequest(paramQueryFilter, sortBrand, sknCountConfig.getHeatValue(), sortBrandType)); 52 + if (productCountConfig.getHeatValue() > 0) {
  53 + requests.add(this.buildSortBrandHeatValueRequest(paramQueryFilter, sortBrand, productCountConfig.getHeatValue(), sortBrandType));
56 } 54 }
57 // 3) 新降价 55 // 3) 新降价
58 - if (sknCountConfig.getReducePrice() > 0) {  
59 - requests.add(this.buildSortBrandReducePriceRequest(paramQueryFilter, sortBrand, sknCountConfig.getReducePrice(), sortBrandType)); 56 + if (productCountConfig.getReducePrice() > 0) {
  57 + requests.add(this.buildSortBrandReducePriceRequest(paramQueryFilter, sortBrand, productCountConfig.getReducePrice(), sortBrandType));
60 } 58 }
61 // 4) 新开促销 59 // 4) 新开促销
62 - if (sknCountConfig.getPromotion() > 0) {  
63 - requests.add(this.buildSortBrandPromotionRequest(paramQueryFilter, sortBrand, sknCountConfig.getPromotion(), sortBrandType)); 60 + if (productCountConfig.getPromotion() > 0) {
  61 + requests.add(this.buildSortBrandPromotionRequest(paramQueryFilter, sortBrand, productCountConfig.getPromotion(), sortBrandType));
64 } 62 }
65 // 5) 转化率 63 // 5) 转化率
66 - if (sknCountConfig.getCtrValue() > 0) {  
67 - requests.add(this.buildSortBrandCtrValueRequest(paramQueryFilter, sortBrand, sknCountConfig.getCtrValue(), sortBrandType)); 64 + if (productCountConfig.getCtrValue() > 0) {
  65 + requests.add(this.buildSortBrandCtrValueRequest(paramQueryFilter, sortBrand, productCountConfig.getCtrValue(), sortBrandType));
68 } 66 }
69 } 67 }
70 return requests; 68 return requests;
@@ -77,8 +75,8 @@ public class SortBrandRecallRequestBuilder { @@ -77,8 +75,8 @@ public class SortBrandRecallRequestBuilder {
77 * @param sortBrand 75 * @param sortBrand
78 * @return 76 * @return
79 */ 77 */
80 - private SknCountConfig queryRecallSknCount(int pageId, SortBrand sortBrand) {  
81 - return sknCountConfigService.getSknCountConfig(pageId, sortBrand); 78 + private ProductCountConfig queryRecallSknCount(int pageId, SortBrand sortBrand) {
  79 + return productCountConfigService.getProductCountConfig(pageId, sortBrand);
82 } 80 }
83 81
84 /** 82 /**
1 package com.yoho.search.recall.scene.beans.config; 1 package com.yoho.search.recall.scene.beans.config;
2 2
3 -public class SknCountConfig { 3 +public class ProductCountConfig {
4 4
5 private int newShelve; 5 private int newShelve;
6 private int promotion; 6 private int promotion;
  1 +package com.yoho.search.recall.scene.beans.config;
  2 +
  3 +import com.yoho.search.core.personalized.models.SortBrand;
  4 +import org.springframework.stereotype.Component;
  5 +
  6 +import java.util.HashMap;
  7 +import java.util.Map;
  8 +
  9 +@Component
  10 +public class ProductCountConfigService {
  11 +
  12 + private static int DEFAULT_PAGE_ID = 0;
  13 +
  14 + private static int DEFAULT_NEW_SHELVE = 6;
  15 + private static int DEFAULT_PROMOTION = 3;
  16 + private static int DEFAULT_REDUCE_PRICE = 6;
  17 + private static int DEFAULT_CTR_VALUE = 6;
  18 + private static int DEFAULT_HEAT_VALUE = 6;
  19 +
  20 + private Map<Integer, ProductCountConfig> middleSortConfig = new HashMap<>();
  21 + private Map<Integer, ProductCountConfig> brandConfig = new HashMap<>();
  22 + private Map<Integer, ProductCountConfig> pageConfig = new HashMap<>();
  23 +
  24 + public ProductCountConfig getProductCountConfig(int pageId, SortBrand sortBrand) {
  25 + ProductCountConfig middleProductCountConfig = middleSortConfig.get(sortBrand.getMisort());
  26 + ProductCountConfig brandCountConfig = brandConfig.get(sortBrand.getBrandId());
  27 + if (brandCountConfig != null && middleProductCountConfig != null) {
  28 + return genProductCountConfigByCompare(brandCountConfig, middleProductCountConfig);
  29 + }
  30 + if (brandCountConfig != null) {
  31 + return brandCountConfig;
  32 + }
  33 + if (middleProductCountConfig != null) {
  34 + return middleProductCountConfig;
  35 + }
  36 + ProductCountConfig pageProductCountConfig = pageConfig.get(pageId);
  37 + if (pageProductCountConfig != null) {
  38 + return pageProductCountConfig;
  39 + }
  40 + pageProductCountConfig = pageConfig.get(DEFAULT_PAGE_ID);
  41 + if (pageProductCountConfig != null) {
  42 + return pageProductCountConfig;
  43 + }
  44 + return genProductCountConfig(DEFAULT_NEW_SHELVE, DEFAULT_PROMOTION, DEFAULT_REDUCE_PRICE, DEFAULT_CTR_VALUE, DEFAULT_HEAT_VALUE);
  45 + }
  46 +
  47 + private ProductCountConfig genProductCountConfigByCompare(ProductCountConfig productCountConfig1, ProductCountConfig productCountConfig2) {
  48 + int newShelve = Math.min(productCountConfig1.getNewShelve(), productCountConfig2.getNewShelve());
  49 + int promotion = Math.min(productCountConfig1.getPromotion(), productCountConfig2.getPromotion());
  50 + int reducePrice = Math.min(productCountConfig1.getReducePrice(), productCountConfig2.getReducePrice());
  51 + int ctrValue = Math.min(productCountConfig1.getCtrValue(), productCountConfig2.getCtrValue());
  52 + int heatValue = Math.min(productCountConfig1.getHeatValue(), productCountConfig2.getHeatValue());
  53 + return genProductCountConfig(newShelve, promotion, reducePrice, ctrValue, heatValue);
  54 + }
  55 +
  56 + private ProductCountConfig genProductCountConfig(int newShelve, int promotion, int reducePrice, int ctrValue, int heatValue) {
  57 + ProductCountConfig productCountConfig = new ProductCountConfig();
  58 + productCountConfig.setNewShelve(newShelve);
  59 + productCountConfig.setPromotion(promotion);
  60 + productCountConfig.setReducePrice(reducePrice);
  61 + productCountConfig.setCtrValue(ctrValue);
  62 + productCountConfig.setHeatValue(heatValue);
  63 + return productCountConfig;
  64 + }
  65 +}
1 -package com.yoho.search.recall.scene.beans.config;  
2 -  
3 -import com.yoho.search.core.personalized.models.SortBrand;  
4 -import org.springframework.stereotype.Component;  
5 -  
6 -import java.util.HashMap;  
7 -import java.util.Map;  
8 -  
9 -@Component  
10 -public class SknCountConfigService {  
11 -  
12 - private static int DEFAULT_PAGE_ID = 0;  
13 -  
14 - private static int DEFAULT_NEW_SHELVE = 6;  
15 - private static int DEFAULT_PROMOTION = 3;  
16 - private static int DEFAULT_REDUCE_PRICE = 6;  
17 - private static int DEFAULT_CTR_VALUE = 6;  
18 - private static int DEFAULT_HEAT_VALUE = 6;  
19 -  
20 - private Map<Integer, SknCountConfig> middleSortConfig = new HashMap<>();  
21 - private Map<Integer, SknCountConfig> brandConfig = new HashMap<>();  
22 - private Map<Integer, SknCountConfig> pageConfig = new HashMap<>();  
23 -  
24 - public SknCountConfig getSknCountConfig(int pageId, SortBrand sortBrand) {  
25 - SknCountConfig middleSknCountConfig = middleSortConfig.get(sortBrand.getMisort());  
26 - SknCountConfig brandCountConfig = brandConfig.get(sortBrand.getBrandId());  
27 - if (brandCountConfig != null && middleSknCountConfig != null) {  
28 - return genSknCountConfig(brandCountConfig, middleSknCountConfig);  
29 - }  
30 - if (brandCountConfig != null) {  
31 - return brandCountConfig;  
32 - }  
33 - if (middleSknCountConfig != null) {  
34 - return middleSknCountConfig;  
35 - }  
36 - SknCountConfig pageSknCountConfig = pageConfig.get(pageId);  
37 - if (pageSknCountConfig != null) {  
38 - return pageSknCountConfig;  
39 - }  
40 - pageSknCountConfig = pageConfig.get(DEFAULT_PAGE_ID);  
41 - if (pageSknCountConfig != null) {  
42 - return pageSknCountConfig;  
43 - }  
44 - return genSknCountConfig(DEFAULT_NEW_SHELVE, DEFAULT_PROMOTION, DEFAULT_REDUCE_PRICE, DEFAULT_CTR_VALUE, DEFAULT_HEAT_VALUE);  
45 - }  
46 -  
47 - private SknCountConfig genSknCountConfig(SknCountConfig sknCountConfig1, SknCountConfig sknCountConfig2) {  
48 - int newShelve = Math.min(sknCountConfig1.getNewShelve(), sknCountConfig2.getNewShelve());  
49 - int promotion = Math.min(sknCountConfig1.getPromotion(), sknCountConfig2.getPromotion());  
50 - int reducePrice = Math.min(sknCountConfig1.getReducePrice(), sknCountConfig2.getReducePrice());  
51 - int ctrValue = Math.min(sknCountConfig1.getCtrValue(), sknCountConfig2.getCtrValue());  
52 - int heatValue = Math.min(sknCountConfig1.getHeatValue(), sknCountConfig2.getHeatValue());  
53 - return genSknCountConfig(newShelve, promotion, reducePrice, ctrValue, heatValue);  
54 - }  
55 -  
56 - private SknCountConfig genSknCountConfig(int newShelve, int promotion, int reducePrice, int ctrValue, int heatValue) {  
57 - SknCountConfig sknCountConfig = new SknCountConfig();  
58 - sknCountConfig.setNewShelve(newShelve);  
59 - sknCountConfig.setPromotion(promotion);  
60 - sknCountConfig.setReducePrice(reducePrice);  
61 - sknCountConfig.setCtrValue(ctrValue);  
62 - sknCountConfig.setHeatValue(heatValue);  
63 - return sknCountConfig;  
64 - }  
65 -}