Authored by 胡古飞

fix breakSizePercent BUG

@@ -6,7 +6,9 @@ import com.yoho.search.consumer.service.base.SizeService; @@ -6,7 +6,9 @@ import com.yoho.search.consumer.service.base.SizeService;
6 import com.yoho.search.consumer.service.base.StorageService; 6 import com.yoho.search.consumer.service.base.StorageService;
7 import com.yoho.search.consumer.service.bo.ProductGoodsBO; 7 import com.yoho.search.consumer.service.bo.ProductGoodsBO;
8 import com.yoho.search.consumer.service.logic.productIndex.ProductGoodsLogicService; 8 import com.yoho.search.consumer.service.logic.productIndex.ProductGoodsLogicService;
  9 +import com.yoho.search.consumer.service.logic.productIndex.ProductSizesLogicService;
9 import com.yoho.search.dal.model.Storage; 10 import com.yoho.search.dal.model.Storage;
  11 +
10 import org.apache.commons.collections.CollectionUtils; 12 import org.apache.commons.collections.CollectionUtils;
11 import org.apache.commons.lang.StringUtils; 13 import org.apache.commons.lang.StringUtils;
12 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
@@ -27,15 +29,14 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractMqListene @@ -27,15 +29,14 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractMqListene
27 29
28 @Autowired 30 @Autowired
29 private StorageService storageService; 31 private StorageService storageService;
30 -  
31 @Autowired 32 @Autowired
32 private SizeService sizeService; 33 private SizeService sizeService;
33 -  
34 @Autowired 34 @Autowired
35 private GoodsService goodsService; 35 private GoodsService goodsService;
36 -  
37 @Autowired 36 @Autowired
38 private ProductGoodsLogicService productGoodsLogicService; 37 private ProductGoodsLogicService productGoodsLogicService;
  38 + @Autowired
  39 + private ProductSizesLogicService productSizesLogicService;
39 40
40 protected void fillStorageNumAndSizeInfo(Integer productId, Map<String, Object> indexData) { 41 protected void fillStorageNumAndSizeInfo(Integer productId, Map<String, Object> indexData) {
41 List<Storage> storageList = storageService.getStoragesByProductId(productId); 42 List<Storage> storageList = storageService.getStoragesByProductId(productId);
@@ -51,7 +52,7 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractMqListene @@ -51,7 +52,7 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractMqListene
51 } 52 }
52 int effectiveSizeCount = storageList.size(); 53 int effectiveSizeCount = storageList.size();
53 54
54 - float breakSizePercent = 100 * (totalSizeCount - effectiveSizeCount)/totalSizeCount; 55 + double breakSizePercent = productSizesLogicService.getBreakSizePercent(totalSizeCount,effectiveSizeCount);
55 56
56 if (CollectionUtils.isEmpty(storageList)) { 57 if (CollectionUtils.isEmpty(storageList)) {
57 indexData.put("storageNum", 0); 58 indexData.put("storageNum", 0);
@@ -59,6 +60,7 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractMqListene @@ -59,6 +60,7 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractMqListene
59 indexData.put("isSoldOut", "Y"); 60 indexData.put("isSoldOut", "Y");
60 indexData.put("soldOut", 0); 61 indexData.put("soldOut", 0);
61 indexData.put("sizeIds", null); 62 indexData.put("sizeIds", null);
  63 + indexData.put("sizeNames", null);
62 indexData.put("breakSizePercent", 100); 64 indexData.put("breakSizePercent", 100);
63 } else { 65 } else {
64 int storageNum = 0; 66 int storageNum = 0;
@@ -129,11 +129,11 @@ public class ProductSizesLogicService { @@ -129,11 +129,11 @@ public class ProductSizesLogicService {
129 return productSizesList; 129 return productSizesList;
130 } 130 }
131 131
132 - private double getBreakSizePercent(int totalSizeCount, int effectiveSizeCount) { 132 + public double getBreakSizePercent(int totalSizeCount, int effectiveSizeCount) {
133 if (totalSizeCount == 0 || effectiveSizeCount == 0) { 133 if (totalSizeCount == 0 || effectiveSizeCount == 0) {
134 return 100d; 134 return 100d;
135 } 135 }
136 - return 100d * (effectiveSizeCount - totalSizeCount) / totalSizeCount; 136 + return 100d * (totalSizeCount - effectiveSizeCount) / totalSizeCount;
137 } 137 }
138 138
139 } 139 }