Authored by hugufei

添加商品召回的数量限制

@@ -5,6 +5,7 @@ import com.yoho.search.recall.beans.strategy.SortBrandType; @@ -5,6 +5,7 @@ import com.yoho.search.recall.beans.strategy.SortBrandType;
5 import com.yoho.search.recall.beans.strategy.StrategyEnum; 5 import com.yoho.search.recall.beans.strategy.StrategyEnum;
6 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.stereotype.Service; 7 import org.springframework.stereotype.Service;
  8 +import sun.applet.Main;
8 9
9 @Service 10 @Service
10 public class RecallConfigService { 11 public class RecallConfigService {
@@ -13,7 +14,7 @@ public class RecallConfigService { @@ -13,7 +14,7 @@ public class RecallConfigService {
13 @Autowired 14 @Autowired
14 private RecallConfigServiceCommon recallConfigServiceCommon; 15 private RecallConfigServiceCommon recallConfigServiceCommon;
15 16
16 - private int legallValue(int value, int min, int max) { 17 + private static int legallValue(int value, int min, int max) {
17 value = Math.min(value, max); 18 value = Math.min(value, max);
18 value = Math.max(value, min); 19 value = Math.max(value, min);
19 return value; 20 return value;
@@ -106,7 +107,17 @@ public class RecallConfigService { @@ -106,7 +107,17 @@ public class RecallConfigService {
106 */ 107 */
107 public RecallSknCount queryRecallSknCount(int pageId, SortBrandType sortBrandType, SortBrand sortBrand) { 108 public RecallSknCount queryRecallSknCount(int pageId, SortBrandType sortBrandType, SortBrand sortBrand) {
108 String sortBrandTypeKey = this.getStrategyConfiKey(sortBrandType); 109 String sortBrandTypeKey = this.getStrategyConfiKey(sortBrandType);
109 - return recallConfigServiceProduct.queryRecallSknCount(pageId, sortBrandTypeKey, sortBrand); 110 + RecallSknCount recallSknCount = recallConfigServiceProduct.queryRecallSknCount(pageId, sortBrandTypeKey, sortBrand);
  111 + if (recallSknCount == null) {
  112 + return null;
  113 + }
  114 + recallSknCount.setNewShelve(this.legallValue(recallSknCount.getNewShelve(), 0, 20));
  115 + recallSknCount.setPromotion(this.legallValue(recallSknCount.getPromotion(), 0, 20));
  116 + recallSknCount.setCtrValue(this.legallValue(recallSknCount.getCtrValue(), 0, 20));
  117 + recallSknCount.setHeatValue(this.legallValue(recallSknCount.getHeatValue(), 0, 20));
  118 + recallSknCount.setReducePrice(this.legallValue(recallSknCount.getReducePrice(), 0, 20));
  119 + recallSknCount.setRandom(this.legallValue(recallSknCount.getRandom(), 0, 20));
  120 + return recallSknCount;
110 } 121 }
111 122
112 private String getStrategyConfiKey(SortBrandType sortBrandType) { 123 private String getStrategyConfiKey(SortBrandType sortBrandType) {
@@ -122,4 +133,9 @@ public class RecallConfigService { @@ -122,4 +133,9 @@ public class RecallConfigService {
122 return null; 133 return null;
123 } 134 }
124 135
  136 + public static void main(String[] args) {
  137 + System.out.println(legallValue(-1,0,30));
  138 + }
  139 +
  140 +
125 } 141 }