|
|
@@ -149,15 +149,29 @@ public class StoreBookingTableServiceImpl extends ServiceImpl<StoreBookingTableM
|
|
|
*/
|
|
|
private static final int UNCATEGORIZED_CATEGORY_GROUP_KEY = Integer.MIN_VALUE;
|
|
|
|
|
|
+ /**
|
|
|
+ * 按桌号(桌子名称)子串模糊过滤;{@code tableName} 为空或仅空白时返回原列表。
|
|
|
+ */
|
|
|
+ private static List<StoreBookingTableVo> filterBookingTablesByNameLike(List<StoreBookingTableVo> vos, String tableName) {
|
|
|
+ if (!StringUtils.hasText(tableName)) {
|
|
|
+ return vos;
|
|
|
+ }
|
|
|
+ String needle = tableName.trim();
|
|
|
+ return vos.stream()
|
|
|
+ .filter(vo -> vo != null && vo.getTableNumber() != null && vo.getTableNumber().contains(needle))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
- public List<StoreBookingTableGroupVo> listTablesGroupedByMerchant(Integer merchantId) {
|
|
|
+ public List<StoreBookingTableGroupVo> listTablesGroupedByMerchant(Integer merchantId, String tableName) {
|
|
|
if (merchantId == null) {
|
|
|
log.warn("listTablesGroupedByMerchant: merchantId 为空(应对应门店 storeId)");
|
|
|
}
|
|
|
- log.info("listTablesGroupedByMerchant 开始 merchantId={}", merchantId);
|
|
|
+ log.info("listTablesGroupedByMerchant 开始 merchantId={} tableName={}", merchantId, tableName);
|
|
|
try {
|
|
|
// merchantId 在本项目中与门店 storeId 语义一致
|
|
|
List<StoreBookingTableVo> all = getTableListWithCategoryName(merchantId, null);
|
|
|
+ all = filterBookingTablesByNameLike(all, tableName);
|
|
|
Map<Integer, List<StoreBookingTableVo>> byCategory = groupTableVosByCategoryPreserveOrder(all);
|
|
|
Map<Integer, String> categoryNameMap = loadCategoryNamesForStoreAndGroupKeys(merchantId, byCategory.keySet());
|
|
|
Map<Integer, List<UserReservationVo>> reservationListByTableId = buildSortedReservationsByTableId(merchantId);
|
|
|
@@ -171,7 +185,7 @@ public class StoreBookingTableServiceImpl extends ServiceImpl<StoreBookingTableM
|
|
|
reservationListByTableId.size(), reservationRowTotal);
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
- log.error("listTablesGroupedByMerchant 失败 merchantId={}", merchantId, e);
|
|
|
+ log.error("listTablesGroupedByMerchant 失败 merchantId={} tableName={}", merchantId, tableName, e);
|
|
|
throw e;
|
|
|
}
|
|
|
}
|