...
|
...
|
@@ -25,7 +25,7 @@ class RecallConfigProductService { |
|
|
@Autowired
|
|
|
private CsRecallConfigProductIndexBaseService csRecallConfigProductIndexBaseService;
|
|
|
|
|
|
private Map<String, Map<Integer, RecallSknCount>> typePageConfigCache = new HashMap<>();
|
|
|
private Map<String, Map<Integer, ConfigSknCount>> typePageConfigCache = new HashMap<>();
|
|
|
|
|
|
private ScheduledExecutorService schedule = Executors.newSingleThreadScheduledExecutor();
|
|
|
|
...
|
...
|
@@ -36,7 +36,7 @@ class RecallConfigProductService { |
|
|
|
|
|
private void loadRecallSknCountConfig() {
|
|
|
try {
|
|
|
Map<String, Map<Integer, RecallSknCount>> tempTypePageConfigCache = new HashMap<>();
|
|
|
Map<String, Map<Integer, ConfigSknCount>> tempTypePageConfigCache = new HashMap<>();
|
|
|
List<CsRecallConfigProduct> configList = csRecallConfigProductIndexBaseService.queryAll();
|
|
|
for (CsRecallConfigProduct productConfig : configList) {
|
|
|
String configType = productConfig.getConfigType();
|
...
|
...
|
@@ -71,14 +71,14 @@ class RecallConfigProductService { |
|
|
return type + "_" + cacheKey;
|
|
|
}
|
|
|
|
|
|
private void addElement(String configKey, int pageId, RecallSknCount recallSknCount, Map<String, Map<Integer, RecallSknCount>> map) {
|
|
|
private void addElement(String configKey, int pageId, ConfigSknCount configSknCount, Map<String, Map<Integer, ConfigSknCount>> map) {
|
|
|
if (!map.containsKey(configKey)) {
|
|
|
map.put(configKey, new HashMap<>());
|
|
|
}
|
|
|
map.get(configKey).put(pageId, recallSknCount);
|
|
|
map.get(configKey).put(pageId, configSknCount);
|
|
|
}
|
|
|
|
|
|
private RecallSknCount genProductCountConfig(CsRecallConfigProduct configProduct) {
|
|
|
private ConfigSknCount genProductCountConfig(CsRecallConfigProduct configProduct) {
|
|
|
int newShelve = configProduct.getNewShelve();
|
|
|
int promotion = configProduct.getPromotion();
|
|
|
int reducePrice = configProduct.getReducePrice();
|
...
|
...
|
@@ -88,24 +88,24 @@ class RecallConfigProductService { |
|
|
return genProductCountConfig(newShelve, promotion, reducePrice, ctrValue, heatValue, random);
|
|
|
}
|
|
|
|
|
|
private RecallSknCount genProductCountConfig(int newShelve, int promotion, int reducePrice, int ctrValue, int heatValue, int random) {
|
|
|
RecallSknCount recallSknCount = new RecallSknCount();
|
|
|
recallSknCount.setNewShelve(newShelve);
|
|
|
recallSknCount.setPromotion(promotion);
|
|
|
recallSknCount.setReducePrice(reducePrice);
|
|
|
recallSknCount.setCtrValue(ctrValue);
|
|
|
recallSknCount.setHeatValue(heatValue);
|
|
|
recallSknCount.setRandom(random);
|
|
|
return recallSknCount;
|
|
|
private ConfigSknCount genProductCountConfig(int newShelve, int promotion, int reducePrice, int ctrValue, int heatValue, int random) {
|
|
|
ConfigSknCount configSknCount = new ConfigSknCount();
|
|
|
configSknCount.setNewShelve(newShelve);
|
|
|
configSknCount.setPromotion(promotion);
|
|
|
configSknCount.setReducePrice(reducePrice);
|
|
|
configSknCount.setCtrValue(ctrValue);
|
|
|
configSknCount.setHeatValue(heatValue);
|
|
|
configSknCount.setRandom(random);
|
|
|
return configSknCount;
|
|
|
}
|
|
|
|
|
|
private RecallSknCount genProductCountConfigByCompare(RecallSknCount recallSknCount1, RecallSknCount recallSknCount2) {
|
|
|
int newShelve = Math.min(recallSknCount1.getNewShelve(), recallSknCount2.getNewShelve());
|
|
|
int promotion = Math.min(recallSknCount1.getPromotion(), recallSknCount2.getPromotion());
|
|
|
int reducePrice = Math.min(recallSknCount1.getReducePrice(), recallSknCount2.getReducePrice());
|
|
|
int ctrValue = Math.min(recallSknCount1.getCtrValue(), recallSknCount2.getCtrValue());
|
|
|
int heatValue = Math.min(recallSknCount1.getHeatValue(), recallSknCount2.getHeatValue());
|
|
|
int random = Math.min(recallSknCount1.getHeatValue(), recallSknCount2.getHeatValue());
|
|
|
private ConfigSknCount genProductCountConfigByCompare(ConfigSknCount configSknCount1, ConfigSknCount configSknCount2) {
|
|
|
int newShelve = Math.min(configSknCount1.getNewShelve(), configSknCount2.getNewShelve());
|
|
|
int promotion = Math.min(configSknCount1.getPromotion(), configSknCount2.getPromotion());
|
|
|
int reducePrice = Math.min(configSknCount1.getReducePrice(), configSknCount2.getReducePrice());
|
|
|
int ctrValue = Math.min(configSknCount1.getCtrValue(), configSknCount2.getCtrValue());
|
|
|
int heatValue = Math.min(configSknCount1.getHeatValue(), configSknCount2.getHeatValue());
|
|
|
int random = Math.min(configSknCount1.getHeatValue(), configSknCount2.getHeatValue());
|
|
|
return genProductCountConfig(newShelve, promotion, reducePrice, ctrValue, heatValue, random);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -116,15 +116,15 @@ class RecallConfigProductService { |
|
|
* @param sortBrand
|
|
|
* @return
|
|
|
*/
|
|
|
public RecallSknCount queryRecallSknCount(int pageId, String sortBrandTypeKey, SortBrand sortBrand) {
|
|
|
public ConfigSknCount queryRecallSknCount(int pageId, String sortBrandTypeKey, SortBrand sortBrand) {
|
|
|
//1、先取【配置的品牌*品类】的配置
|
|
|
RecallSknCount recallSknCount = this.queryConfigBySortBrandWithType(pageId,RecallConfigConstants.SORT_BRAND, sortBrand);
|
|
|
if(recallSknCount!=null){
|
|
|
return recallSknCount;
|
|
|
ConfigSknCount configSknCount = this.queryConfigBySortBrandWithType(pageId,RecallConfigConstants.SORT_BRAND, sortBrand);
|
|
|
if(configSknCount !=null){
|
|
|
return configSknCount;
|
|
|
}
|
|
|
//2、再取【配置的品牌或品类】配置
|
|
|
RecallSknCount sortConfig = this.queryConfigBySort(pageId, sortBrand.getMisort());
|
|
|
RecallSknCount brandConfig = this.queryConfigByBrand(pageId, sortBrand.getBrandId());
|
|
|
ConfigSknCount sortConfig = this.queryConfigBySort(pageId, sortBrand.getMisort());
|
|
|
ConfigSknCount brandConfig = this.queryConfigByBrand(pageId, sortBrand.getBrandId());
|
|
|
if (sortConfig != null && brandConfig != null) {
|
|
|
return genProductCountConfigByCompare(sortConfig, brandConfig);
|
|
|
}
|
...
|
...
|
@@ -135,7 +135,7 @@ class RecallConfigProductService { |
|
|
return brandConfig;
|
|
|
}
|
|
|
//3、再取当前类型的【品牌*品类】配置-没有则取默认的【0_0的数据】
|
|
|
RecallSknCount pageConfig = this.queryConfigBySortBrandWithType(pageId, sortBrandTypeKey, sortBrand);
|
|
|
ConfigSknCount pageConfig = this.queryConfigBySortBrandWithType(pageId, sortBrandTypeKey, sortBrand);
|
|
|
if (pageConfig != null) {
|
|
|
return pageConfig;
|
|
|
}
|
...
|
...
|
@@ -153,7 +153,7 @@ class RecallConfigProductService { |
|
|
* @param sortBrand
|
|
|
* @return
|
|
|
*/
|
|
|
private RecallSknCount queryConfigBySortBrandWithType(int pageId, String sortBrandType, SortBrand sortBrand) {
|
|
|
private ConfigSknCount queryConfigBySortBrandWithType(int pageId, String sortBrandType, SortBrand sortBrand) {
|
|
|
String sortBrandKey = this.buildCacheKey(sortBrandType, sortBrand.key());
|
|
|
return this.getRecallSknCount(sortBrandKey, pageId);
|
|
|
}
|
...
|
...
|
@@ -164,7 +164,7 @@ class RecallConfigProductService { |
|
|
* @param middleSortId
|
|
|
* @return
|
|
|
*/
|
|
|
private RecallSknCount queryConfigBySort(int pageId, int middleSortId) {
|
|
|
private ConfigSknCount queryConfigBySort(int pageId, int middleSortId) {
|
|
|
String sortKey = this.buildCacheKey(RecallConfigConstants.SORT,String.valueOf(middleSortId));
|
|
|
return this.getRecallSknCount(sortKey, pageId);
|
|
|
}
|
...
|
...
|
@@ -175,18 +175,18 @@ class RecallConfigProductService { |
|
|
* @param brandId
|
|
|
* @return
|
|
|
*/
|
|
|
private RecallSknCount queryConfigByBrand(int pageId, int brandId) {
|
|
|
private ConfigSknCount queryConfigByBrand(int pageId, int brandId) {
|
|
|
String brandKey = this.buildCacheKey(RecallConfigConstants.BRAND,String.valueOf(brandId));
|
|
|
return this.getRecallSknCount(brandKey, pageId);
|
|
|
}
|
|
|
|
|
|
|
|
|
private RecallSknCount getRecallSknCount(String key, int pageId) {
|
|
|
Map<Integer, RecallSknCount> pageConfig = typePageConfigCache.get(key);
|
|
|
private ConfigSknCount getRecallSknCount(String key, int pageId) {
|
|
|
Map<Integer, ConfigSknCount> pageConfig = typePageConfigCache.get(key);
|
|
|
if (pageConfig == null) {
|
|
|
return null;
|
|
|
}
|
|
|
RecallSknCount sknCount = pageConfig.get(pageId);
|
|
|
ConfigSknCount sknCount = pageConfig.get(pageId);
|
|
|
if (sknCount == null) {
|
|
|
sknCount = pageConfig.get(RecallConfigConstants.DEFAULT_PAGE_ID);
|
|
|
}
|
...
|
...
|
|