!255 fix: 优化es价格搜索,设置超出限制,则默认搜索最大值

Merge pull request !255 from OceansDeep/feature/pg
This commit is contained in:
OceansDeep 2022-11-29 07:04:32 +00:00 committed by Gitee
commit f3ccabe253
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -5,6 +5,7 @@ import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.lili.cache.Cache;
import cn.lili.cache.CachePrefix;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
@ -480,6 +481,15 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
if (prices.length == 2) {
max = Convert.toDouble(prices[1], Double.MAX_VALUE);
}
if (min > max) {
throw new ServiceException("价格区间错误");
}
if (min > Double.MAX_VALUE) {
min = Double.MAX_VALUE;
}
if (max > Double.MAX_VALUE) {
max = Double.MAX_VALUE;
}
filterBuilder.must(QueryBuilders.rangeQuery("price").from(min).to(max).includeLower(true).includeUpper(true));
}
}