Authored by 胡古飞

fix breakSizePercent BUG

... ... @@ -6,7 +6,9 @@ import com.yoho.search.consumer.service.base.SizeService;
import com.yoho.search.consumer.service.base.StorageService;
import com.yoho.search.consumer.service.bo.ProductGoodsBO;
import com.yoho.search.consumer.service.logic.productIndex.ProductGoodsLogicService;
import com.yoho.search.consumer.service.logic.productIndex.ProductSizesLogicService;
import com.yoho.search.dal.model.Storage;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -27,15 +29,14 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractMqListene
@Autowired
private StorageService storageService;
@Autowired
private SizeService sizeService;
@Autowired
private GoodsService goodsService;
@Autowired
private ProductGoodsLogicService productGoodsLogicService;
@Autowired
private ProductSizesLogicService productSizesLogicService;
protected void fillStorageNumAndSizeInfo(Integer productId, Map<String, Object> indexData) {
List<Storage> storageList = storageService.getStoragesByProductId(productId);
... ... @@ -51,7 +52,7 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractMqListene
}
int effectiveSizeCount = storageList.size();
float breakSizePercent = 100 * (totalSizeCount - effectiveSizeCount)/totalSizeCount;
double breakSizePercent = productSizesLogicService.getBreakSizePercent(totalSizeCount,effectiveSizeCount);
if (CollectionUtils.isEmpty(storageList)) {
indexData.put("storageNum", 0);
... ... @@ -59,6 +60,7 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractMqListene
indexData.put("isSoldOut", "Y");
indexData.put("soldOut", 0);
indexData.put("sizeIds", null);
indexData.put("sizeNames", null);
indexData.put("breakSizePercent", 100);
} else {
int storageNum = 0;
... ...
... ... @@ -129,11 +129,11 @@ public class ProductSizesLogicService {
return productSizesList;
}
private double getBreakSizePercent(int totalSizeCount, int effectiveSizeCount) {
public double getBreakSizePercent(int totalSizeCount, int effectiveSizeCount) {
if (totalSizeCount == 0 || effectiveSizeCount == 0) {
return 100d;
}
return 100d * (effectiveSizeCount - totalSizeCount) / totalSizeCount;
return 100d * (totalSizeCount - effectiveSizeCount) / totalSizeCount;
}
}
... ...