|
|
@@ -1387,10 +1387,23 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
|
|
|
Map<Integer, List<StoreOrderDetail>> detailsMap = allDetails.stream()
|
|
|
.collect(Collectors.groupingBy(StoreOrderDetail::getOrderId));
|
|
|
|
|
|
- // 5. 构建返回结果
|
|
|
+ // 5. 批量查询门店名称
|
|
|
+ Set<Integer> storeIds = orders.stream().map(StoreOrder::getStoreId).filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
+ Map<Integer, String> storeNameMap = new HashMap<>();
|
|
|
+ if (!storeIds.isEmpty()) {
|
|
|
+ List<StoreInfo> storeList = storeInfoMapper.selectBatchIds(storeIds);
|
|
|
+ if (storeList != null) {
|
|
|
+ for (StoreInfo s : storeList) {
|
|
|
+ storeNameMap.put(s.getId(), s.getStoreName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 6. 构建返回结果
|
|
|
List<StoreOrderPageVO> voList = orders.stream().map(order -> {
|
|
|
StoreOrderPageVO vo = new StoreOrderPageVO();
|
|
|
vo.setOrder(order);
|
|
|
+ vo.setStoreName(storeNameMap.getOrDefault(order.getStoreId(), ""));
|
|
|
|
|
|
// 获取该订单的菜品列表
|
|
|
List<StoreOrderDetail> orderDetails = detailsMap.getOrDefault(order.getId(), new ArrayList<>());
|
|
|
@@ -1410,7 +1423,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
- // 6. 构建分页结果
|
|
|
+ // 7. 构建分页结果
|
|
|
Page<StoreOrderPageVO> resultPage = new Page<>(page.getCurrent(), page.getSize());
|
|
|
resultPage.setRecords(voList);
|
|
|
resultPage.setTotal(orderPage.getTotal());
|