Showing
1 changed file
with
12 additions
and
10 deletions
@@ -50,8 +50,18 @@ public abstract class AbsOrderListService implements IOrderListService{ | @@ -50,8 +50,18 @@ public abstract class AbsOrderListService implements IOrderListService{ | ||
50 | List<Integer> statusQuery = initOrderListRequest(request); | 50 | List<Integer> statusQuery = initOrderListRequest(request); |
51 | TabType tabType = TabType.getTabType(request.getTabType()); | 51 | TabType tabType = TabType.getTabType(request.getTabType()); |
52 | int total = getTotal(request.getUid(), statusQuery); | 52 | int total = getTotal(request.getUid(), statusQuery); |
53 | - | ||
54 | int limit = request.getLimit(); | 53 | int limit = request.getLimit(); |
54 | + int currentTotal = 0; | ||
55 | + OrderListInfoRsp.OrderListInfoRspBuilder respBuilder = OrderListInfoRsp.builder() | ||
56 | + .currPage(request.getPage()) | ||
57 | + .limit(limit) | ||
58 | + .total(total) | ||
59 | + .currTotal(currentTotal) | ||
60 | + .pageSize((total % limit == 0) ? (total / limit) : (total / limit + 1)); | ||
61 | + if (total == 0){ | ||
62 | + return respBuilder.build(); | ||
63 | + } | ||
64 | + | ||
55 | int offset = (request.getPage() - 1) * limit; | 65 | int offset = (request.getPage() - 1) * limit; |
56 | 66 | ||
57 | List<BuyerOrder> buyerOrderList = getOrderList(request.getUid(), statusQuery, offset, limit); | 67 | List<BuyerOrder> buyerOrderList = getOrderList(request.getUid(), statusQuery, offset, limit); |
@@ -73,18 +83,10 @@ public abstract class AbsOrderListService implements IOrderListService{ | @@ -73,18 +83,10 @@ public abstract class AbsOrderListService implements IOrderListService{ | ||
73 | buyerOrderList.stream().forEach(buyerOrder -> { | 83 | buyerOrderList.stream().forEach(buyerOrder -> { |
74 | OrderListInfo orderListInfo = convertOrderInfo(buyerOrderGoodsMap, sellerOrderGoodsMap, buyerOrder, tabType); | 84 | OrderListInfo orderListInfo = convertOrderInfo(buyerOrderGoodsMap, sellerOrderGoodsMap, buyerOrder, tabType); |
75 | if (orderListInfo == null) return; | 85 | if (orderListInfo == null) return; |
76 | - | ||
77 | data.add(orderListInfo); | 86 | data.add(orderListInfo); |
78 | - | ||
79 | }); | 87 | }); |
80 | 88 | ||
81 | - OrderListInfoRsp orderListInfoRsp = OrderListInfoRsp.builder() | ||
82 | - .data(data) | ||
83 | - .currPage(request.getPage()) | ||
84 | - .limit(limit) | ||
85 | - .total(total) | ||
86 | - .currTotal(data.size()) | ||
87 | - .pageSize((total % limit == 0) ? (total / limit) : (total / limit + 1)).build(); | 89 | + OrderListInfoRsp orderListInfoRsp = respBuilder.data(data).currTotal(data.size()).build(); |
88 | 90 | ||
89 | return orderListInfoRsp; | 91 | return orderListInfoRsp; |
90 | 92 |
-
Please register or login to post a comment