Authored by sailing-PC\sailing

optimized

... ... @@ -50,8 +50,18 @@ public abstract class AbsOrderListService implements IOrderListService{
List<Integer> statusQuery = initOrderListRequest(request);
TabType tabType = TabType.getTabType(request.getTabType());
int total = getTotal(request.getUid(), statusQuery);
int limit = request.getLimit();
int currentTotal = 0;
OrderListInfoRsp.OrderListInfoRspBuilder respBuilder = OrderListInfoRsp.builder()
.currPage(request.getPage())
.limit(limit)
.total(total)
.currTotal(currentTotal)
.pageSize((total % limit == 0) ? (total / limit) : (total / limit + 1));
if (total == 0){
return respBuilder.build();
}
int offset = (request.getPage() - 1) * limit;
List<BuyerOrder> buyerOrderList = getOrderList(request.getUid(), statusQuery, offset, limit);
... ... @@ -73,18 +83,10 @@ public abstract class AbsOrderListService implements IOrderListService{
buyerOrderList.stream().forEach(buyerOrder -> {
OrderListInfo orderListInfo = convertOrderInfo(buyerOrderGoodsMap, sellerOrderGoodsMap, buyerOrder, tabType);
if (orderListInfo == null) return;
data.add(orderListInfo);
});
OrderListInfoRsp orderListInfoRsp = OrderListInfoRsp.builder()
.data(data)
.currPage(request.getPage())
.limit(limit)
.total(total)
.currTotal(data.size())
.pageSize((total % limit == 0) ? (total / limit) : (total / limit + 1)).build();
OrderListInfoRsp orderListInfoRsp = respBuilder.data(data).currTotal(data.size()).build();
return orderListInfoRsp;
... ...