This commit is contained in:
YAS\29473
2026-01-04 08:40:56 +08:00
parent 2347445e74
commit ccd2f96466
3 changed files with 76 additions and 46 deletions

View File

@@ -6302,25 +6302,23 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
.orderStatus(dto.getOrderStatus())
.build();
// 分页参数处理
// 1. 分页参数处理
int pageNum = dto.getPageNum() == null || dto.getPageNum() <= 0 ? 1 : dto.getPageNum();
int pageSize = dto.getPageSize() == null || dto.getPageSize() <= 0 ? 10 : dto.getPageSize();
// 使用聚合 SQL 统计订单数量和总金额
OrderStatisticsVO statistics = orderBasicInfoMapper.countBusinessOrderStatistics(queryOrderDTO);
// 订单数量和总金额的为空判断
long orderCount = statistics != null && statistics.getOrderCount() != null
? statistics.getOrderCount() : 0L;
BigDecimal totalOrderAmount = statistics != null && statistics.getOrderAmount() != null
? statistics.getOrderAmount() : BigDecimal.ZERO;
// 分页查询订单列表
// 2. 分页查询订单列表
PageHelper.startPage(pageNum, pageSize);
List<OrderListVO> orderListVOS = selectOrderBasicInfoList(queryOrderDTO);
PageInfo<OrderListVO> pageInfo = new PageInfo<>(orderListVOS);
// 转换为BusinessOrderListVO
long orderCount = pageInfo.getTotal();
// 3. 统计总金额(使用聚合 SQL避免查询所有数据到内存
OrderStatisticsVO statistics = orderBasicInfoMapper.countBusinessOrderStatistics(queryOrderDTO);
BigDecimal totalOrderAmount = statistics != null && statistics.getOrderAmount() != null
? statistics.getOrderAmount() : BigDecimal.ZERO;
//4. 转换为 BusinessOrderListVO
List<BusinessOrderListVO> businessOrderList = orderListVOS.stream()
.map(order -> BusinessOrderListVO.builder()
.createTime(order.getCreateTime())
@@ -6334,8 +6332,8 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
.build())
.collect(Collectors.toList());
// 构建分页响应
com.jsowell.common.core.page.PageResponse pageResponse = com.jsowell.common.core.page.PageResponse.builder()
// 5. 构建分页响应
PageResponse pageResponse = PageResponse.builder()
.pageNum(pageNum)
.pageSize(pageSize)
.total(pageInfo.getTotal())
@@ -6343,12 +6341,11 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
.list(businessOrderList)
.build();
// 构建返回结果
// 6. 构建返回结果
return BusinessOrderQueryResultVO.builder()
.orderCount(orderCount)
.orderAmount(totalOrderAmount)
.pageResponse(pageResponse)
.orderList(businessOrderList)
.build();
}

View File

@@ -35,9 +35,5 @@ public class BusinessOrderQueryResultVO {
*/
private PageResponse pageResponse;
/**
* 订单列表
*/
private List<BusinessOrderListVO> orderList;
}