Showing
2 changed files
with
47 additions
and
0 deletions
| ... | @@ -40,7 +40,9 @@ import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrdersB | ... | @@ -40,7 +40,9 @@ import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrdersB |
| 40 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrdersByIdsRpcResponse; | 40 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrdersByIdsRpcResponse; |
| 41 | import com.infoloop.tianting.clientcustomerorderservice.GetOrderOperationRecordsByOrderIdRequest; | 41 | import com.infoloop.tianting.clientcustomerorderservice.GetOrderOperationRecordsByOrderIdRequest; |
| 42 | import com.infoloop.tianting.clientcustomerorderservice.GetOrderOperationRecordsByOrderIdResponse; | 42 | import com.infoloop.tianting.clientcustomerorderservice.GetOrderOperationRecordsByOrderIdResponse; |
| 43 | +import com.infoloop.tianting.clientcustomerorderservice.OrderCountByStatus; | ||
| 43 | import com.infoloop.tianting.clientcustomerorderservice.OrderOperationRecord; | 44 | import com.infoloop.tianting.clientcustomerorderservice.OrderOperationRecord; |
| 45 | +import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; | ||
| 44 | import com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByConditionRpcRequest; | 46 | import com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByConditionRpcRequest; |
| 45 | import com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByConditionRpcResponse; | 47 | import com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByConditionRpcResponse; |
| 46 | import com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByPaginationRpcRequest; | 48 | import com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByPaginationRpcRequest; |
| ... | @@ -193,6 +195,42 @@ public class OrderGrpcService extends ClientCustomerOrderServiceRpcGrpc.ClientCu | ... | @@ -193,6 +195,42 @@ public class OrderGrpcService extends ClientCustomerOrderServiceRpcGrpc.ClientCu |
| 193 | queryWrapper.eq(OrderDb::getStatus, request.getStatusValue()); | 195 | queryWrapper.eq(OrderDb::getStatus, request.getStatusValue()); |
| 194 | queryWrapper.orderByDesc(OrderDb::getCreatedAt); | 196 | queryWrapper.orderByDesc(OrderDb::getCreatedAt); |
| 195 | final var result = orderDbService.page(page, queryWrapper); | 197 | final var result = orderDbService.page(page, queryWrapper); |
| 198 | + | ||
| 199 | + // 查询各个状态的订单数量 | ||
| 200 | + int unknownCount = 0; | ||
| 201 | + int toPrepareCount = 0; | ||
| 202 | + int preparingCount = 0; | ||
| 203 | + int allServedCount = 0; | ||
| 204 | + int canceledCount = 0; | ||
| 205 | + for(OrderStatusEnum status: OrderStatusEnum.values()) { | ||
| 206 | + LambdaQueryWrapper<OrderDb> queryCountWrapper = Wrappers.lambdaQuery(); | ||
| 207 | + if (!request.getKeyword().isEmpty()) { | ||
| 208 | + queryCountWrapper.like(OrderDb::getMealTime, request.getKeyword()); | ||
| 209 | + } | ||
| 210 | + queryCountWrapper.eq(OrderDb::getEnterpriseId, request.getEnterpriseId()); | ||
| 211 | + queryCountWrapper.eq(OrderDb::getClientId, request.getClientId()); | ||
| 212 | + queryCountWrapper.eq(OrderDb::getStatus, status.ordinal()); | ||
| 213 | + final var count = orderDbService.count(queryCountWrapper); | ||
| 214 | + if (status.equals(OrderStatusEnum.UNKNOWN_STATUS)) { | ||
| 215 | + unknownCount += count; | ||
| 216 | + } else if (status.equals(OrderStatusEnum.TO_PREPARE)) { | ||
| 217 | + toPrepareCount += count; | ||
| 218 | + } else if (status.equals(OrderStatusEnum.PREPARING)) { | ||
| 219 | + preparingCount += count; | ||
| 220 | + } else if (status.equals(OrderStatusEnum.PARTIAL_SERVED) || status.equals(OrderStatusEnum.ALL_SERVED)) { | ||
| 221 | + allServedCount += count; | ||
| 222 | + } else { | ||
| 223 | + canceledCount += count; | ||
| 224 | + } | ||
| 225 | + } | ||
| 226 | + | ||
| 227 | + builder.setCountByStatus(OrderCountByStatus.newBuilder() | ||
| 228 | + .setUnknownCount(unknownCount) | ||
| 229 | + .setToPrepareCount(toPrepareCount) | ||
| 230 | + .setPreparingCount(preparingCount) | ||
| 231 | + .setAllServedCount(allServedCount) | ||
| 232 | + .setCanceledCount(canceledCount) | ||
| 233 | + .build()); | ||
| 196 | builder.setTotal(result.getTotal()); | 234 | builder.setTotal(result.getTotal()); |
| 197 | builder.setPages(result.getPages()); | 235 | builder.setPages(result.getPages()); |
| 198 | if (!result.getRecords().isEmpty()) { | 236 | if (!result.getRecords().isEmpty()) { | ... | ... |
| ... | @@ -161,10 +161,19 @@ message QueryClientCustomerOrdersByPaginationRpcRequest { | ... | @@ -161,10 +161,19 @@ message QueryClientCustomerOrdersByPaginationRpcRequest { |
| 161 | int32 pageSize = 6; | 161 | int32 pageSize = 6; |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | +message OrderCountByStatus { | ||
| 165 | + int32 unknownCount = 1; | ||
| 166 | + int32 toPrepareCount = 2; | ||
| 167 | + int32 preparingCount = 3; | ||
| 168 | + int32 allServedCount = 4; | ||
| 169 | + int32 canceledCount = 5; | ||
| 170 | +} | ||
| 171 | + | ||
| 164 | message QueryClientCustomerOrdersByPaginationRpcResponse { | 172 | message QueryClientCustomerOrdersByPaginationRpcResponse { |
| 165 | int64 total = 1; | 173 | int64 total = 1; |
| 166 | int64 pages = 2; | 174 | int64 pages = 2; |
| 167 | repeated SingleClientCustomerOrderRpcResponse responses = 3; | 175 | repeated SingleClientCustomerOrderRpcResponse responses = 3; |
| 176 | + OrderCountByStatus countByStatus = 4; | ||
| 168 | } | 177 | } |
| 169 | 178 | ||
| 170 | message QueryClientCustomerOrdersByConditionRpcRequest { | 179 | message QueryClientCustomerOrdersByConditionRpcRequest { | ... | ... |
-
Please register or login to post a comment