酒店
This commit is contained in:
1 parent
0f2cfe13fd
commit
8dcaae6e3d
1 file changed
+40
-19
+40
-19
@@ -89,7 +89,7 @@ public class SmHotelAppController {
|
||||
private static final String CANDIDATE_CACHE_OVERFLOW = "OVERFLOW";
|
||||
|
||||
/** 列表页结果短缓存(同条件重复进入/下拉) */
|
||||
private static final String PAGE_CACHE_PREFIX = "sm:hotel:app:page:v11:";
|
||||
private static final String PAGE_CACHE_PREFIX = "sm:hotel:app:page:v12:";
|
||||
|
||||
private static final long PAGE_CACHE_SECONDS = 45L;
|
||||
|
||||
@@ -228,14 +228,28 @@ public class SmHotelAppController {
|
||||
return R.ok(cached);
|
||||
}
|
||||
|
||||
boolean hasArea = districtAdcode != null || StrUtil.isNotBlank(city) || StrUtil.isNotBlank(district);
|
||||
var wrapper = applyListColumns(baseOnlineListWrapper(keyword, city, district, districtAdcode, bizArea,
|
||||
starList, minScore, facilityList));
|
||||
applyGuestCapacityFilter(wrapper, needCap);
|
||||
applyMinProductPriceFilter(wrapper, minPrice, maxPrice);
|
||||
starList, minScore, facilityList, true));
|
||||
if (hasArea) {
|
||||
applyGuestCapacityFilter(wrapper, needCap);
|
||||
applyMinProductPriceFilter(wrapper, minPrice, maxPrice);
|
||||
}
|
||||
wrapper.last("ORDER BY star_level DESC, id DESC");
|
||||
Page<SmHotelEntity> raw = pageWithoutCount(page, wrapper);
|
||||
if (raw.getRecords().size() < Math.max(1L, Math.min(page.getSize(), 50L)) && page.getCurrent() <= 1) {
|
||||
String uncodedName = StrUtil.firstNonBlank(city, district, keyword);
|
||||
if (StrUtil.isNotBlank(keyword) && (raw.getRecords() == null || raw.getRecords().isEmpty())) {
|
||||
var infix = applyListColumns(baseOnlineListWrapper(keyword, city, district, districtAdcode, bizArea,
|
||||
starList, minScore, facilityList, false));
|
||||
if (hasArea) {
|
||||
applyGuestCapacityFilter(infix, needCap);
|
||||
applyMinProductPriceFilter(infix, minPrice, maxPrice);
|
||||
}
|
||||
infix.last("ORDER BY star_level DESC, id DESC");
|
||||
raw = pageWithoutCount(page, infix);
|
||||
}
|
||||
int got = raw.getRecords() == null ? 0 : raw.getRecords().size();
|
||||
if (hasArea && got < Math.max(1L, Math.min(page.getSize(), 50L)) && page.getCurrent() <= 1) {
|
||||
String uncodedName = StrUtil.firstNonBlank(city, district);
|
||||
if (StrUtil.isNotBlank(uncodedName)) {
|
||||
fillUncodedHotels(raw, uncodedName, keyword, bizArea, starList, minScore, facilityList, needCap,
|
||||
minPrice, maxPrice);
|
||||
@@ -410,19 +424,23 @@ public class SmHotelAppController {
|
||||
private LambdaQueryWrapper<SmHotelEntity> baseOnlineListWrapper(String keyword, String city, String district,
|
||||
Long districtAdcode, String bizArea, List<Integer> starList, BigDecimal minScore,
|
||||
List<String> facilityList) {
|
||||
return baseOnlineListWrapper(keyword, city, district, districtAdcode, bizArea, starList, minScore,
|
||||
facilityList, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namePrefix true=酒店名走前缀(可用 idx_hotel_name);false=含匹配(仅前缀无结果时)
|
||||
*/
|
||||
private LambdaQueryWrapper<SmHotelEntity> baseOnlineListWrapper(String keyword, String city, String district,
|
||||
Long districtAdcode, String bizArea, List<Integer> starList, BigDecimal minScore,
|
||||
List<String> facilityList, boolean namePrefix) {
|
||||
var wrapper = Wrappers.<SmHotelEntity>lambdaQuery()
|
||||
.and(w -> w.isNull(SmHotelEntity::getUpstreamStatus)
|
||||
.or()
|
||||
.ne(SmHotelEntity::getUpstreamStatus, "OFFLINE"));
|
||||
Long adcode = districtAdcode;
|
||||
String placeName = StrUtil.blankToDefault(district, city);
|
||||
if (adcode == null && StrUtil.isNotBlank(city)) {
|
||||
adcode = resolvePlaceAdcode(city.trim(), true);
|
||||
placeName = city.trim();
|
||||
}
|
||||
if (adcode == null && StrUtil.isBlank(city) && StrUtil.isBlank(district) && StrUtil.isNotBlank(keyword)) {
|
||||
adcode = resolvePlaceAdcode(keyword.trim(), false);
|
||||
placeName = keyword.trim();
|
||||
}
|
||||
if (adcode != null) {
|
||||
long[] range = HotelAreaAdcodeUtil.areaAdcodeRange(adcode);
|
||||
@@ -436,13 +454,16 @@ public class SmHotelAppController {
|
||||
}
|
||||
if (StrUtil.isNotBlank(keyword)) {
|
||||
String kw = keyword.trim();
|
||||
wrapper.and(w -> w.like(SmHotelEntity::getHotelName, kw)
|
||||
.or()
|
||||
.like(SmHotelEntity::getHotelCode, kw)
|
||||
.or()
|
||||
.likeRight(SmHotelEntity::getDistrict, kw)
|
||||
.or()
|
||||
.like(SmHotelEntity::getBizArea, kw));
|
||||
if (namePrefix) {
|
||||
wrapper.and(w -> w.likeRight(SmHotelEntity::getHotelName, kw)
|
||||
.or()
|
||||
.eq(SmHotelEntity::getHotelCode, kw));
|
||||
}
|
||||
else {
|
||||
wrapper.and(w -> w.like(SmHotelEntity::getHotelName, kw)
|
||||
.or()
|
||||
.eq(SmHotelEntity::getHotelCode, kw));
|
||||
}
|
||||
}
|
||||
wrapper.like(StrUtil.isNotBlank(bizArea), SmHotelEntity::getBizArea, StrUtil.trim(bizArea))
|
||||
.in(!starList.isEmpty(), SmHotelEntity::getStarLevel, starList)
|
||||
|
||||
Reference in new issue
Block a user