From 8ff46dbb23daa0d72f0d234ba1797fa75b99e16a Mon Sep 17 00:00:00 2001 From: HuyDiCode Date: Thu, 24 Oct 2024 18:05:39 +0700 Subject: [PATCH 1/4] [PBS-84][HuyNBQ] refactor: add more field into getOrderDetailAndAmenity api --- .../controller/OrderDetailAmenityController.java | 9 +++------ .../OrderDetail/OrderDetailAmenityListResponse.java | 2 ++ .../swp/PodBookingSystem/service/OrderDetailService.java | 7 +++++++ .../com/swp/PodBookingSystem/service/RoomService.java | 3 +-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/swp/PodBookingSystem/controller/OrderDetailAmenityController.java b/src/main/java/com/swp/PodBookingSystem/controller/OrderDetailAmenityController.java index c695b08a..c6bd1bf3 100644 --- a/src/main/java/com/swp/PodBookingSystem/controller/OrderDetailAmenityController.java +++ b/src/main/java/com/swp/PodBookingSystem/controller/OrderDetailAmenityController.java @@ -31,20 +31,17 @@ public class OrderDetailAmenityController { private final OrderService orderService; @GetMapping("/page") - public ApiResponse>> getOrderDetailAndAmenity( + public PaginationResponse> getOrderDetailAndAmenity( @RequestHeader("Authorization") String token, @RequestParam String startDate, @RequestParam String endDate, @RequestParam(defaultValue = "0") int page, - @RequestParam(defaultValue = "10") int size) { + @RequestParam(defaultValue = "10") int take) { String accountId = accountService.extractAccountIdFromToken(token); Account user = accountService.getAccountById(accountId); LocalDateTime startDateTime = orderService.parseDateTime(startDate); LocalDateTime endDateTime = orderService.parseDateTime(endDate); - return ApiResponse.>>builder() - .data(orderDetailService.getPagedOrderDetails(user, startDateTime, endDateTime, page, size)) - .message("get paging order detail successfully") - .build(); + return orderDetailService.getPagedOrderDetails(user, startDateTime, endDateTime, page, take); } @PostMapping diff --git a/src/main/java/com/swp/PodBookingSystem/dto/respone/OrderDetail/OrderDetailAmenityListResponse.java b/src/main/java/com/swp/PodBookingSystem/dto/respone/OrderDetail/OrderDetailAmenityListResponse.java index 1729507b..99796fe0 100644 --- a/src/main/java/com/swp/PodBookingSystem/dto/respone/OrderDetail/OrderDetailAmenityListResponse.java +++ b/src/main/java/com/swp/PodBookingSystem/dto/respone/OrderDetail/OrderDetailAmenityListResponse.java @@ -15,7 +15,9 @@ public class OrderDetailAmenityListResponse { String id; String customerId; + String customerName; int buildingId; + String buildingAddress; int roomId; String roomName; String orderId; diff --git a/src/main/java/com/swp/PodBookingSystem/service/OrderDetailService.java b/src/main/java/com/swp/PodBookingSystem/service/OrderDetailService.java index f3c8bb22..7d44c601 100644 --- a/src/main/java/com/swp/PodBookingSystem/service/OrderDetailService.java +++ b/src/main/java/com/swp/PodBookingSystem/service/OrderDetailService.java @@ -138,7 +138,14 @@ public PaginationResponse> getPagedOrderDet .customerId(Optional.ofNullable(orderDetail.getCustomer()) .map(Account::getId) .orElse(null)) + .customerName(Optional.ofNullable(orderDetail.getCustomer()) + .map(Account::getName) + .orElse(null)) + .orderHandledId(Optional.ofNullable(orderDetail.getOrderHandler()) + .map(Account::getId) + .orElse(null)) .buildingId(orderDetail.getBuilding().getId()) + .buildingAddress(orderDetail.getBuilding().getAddress()) .roomId(orderDetail.getRoom().getId()) .roomName(orderDetail.getRoom().getName()) .orderId(orderDetail.getOrder().getId()) diff --git a/src/main/java/com/swp/PodBookingSystem/service/RoomService.java b/src/main/java/com/swp/PodBookingSystem/service/RoomService.java index 535a4c5b..edfa8313 100644 --- a/src/main/java/com/swp/PodBookingSystem/service/RoomService.java +++ b/src/main/java/com/swp/PodBookingSystem/service/RoomService.java @@ -206,7 +206,6 @@ public List getUnavailableRooms(LocalDateTime startTime, Lo public List getBookedRooms(String customerId) { LocalDateTime currentTime = LocalDateTime.now(); - List bookedRoomDtos = roomRepository.findBookedRooms(currentTime, customerId); - return bookedRoomDtos; + return roomRepository.findBookedRooms(currentTime, customerId); } } From c3926ed076a934d2efe5728166e0e4ea147c7ef1 Mon Sep 17 00:00:00 2001 From: HuyDiCode Date: Fri, 25 Oct 2024 02:00:35 +0700 Subject: [PATCH 2/4] [PBS-84][HuyNBQ] feat: add get list booked rooms by account id and change order amenity status --- .../swp/PodBookingSystem/controller/RoomController.java | 8 ++++++++ .../PodBookingSystem/enums/OrderDetailAmenityStatus.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/swp/PodBookingSystem/controller/RoomController.java b/src/main/java/com/swp/PodBookingSystem/controller/RoomController.java index e0a53050..6e3fc1d5 100644 --- a/src/main/java/com/swp/PodBookingSystem/controller/RoomController.java +++ b/src/main/java/com/swp/PodBookingSystem/controller/RoomController.java @@ -148,4 +148,12 @@ ApiResponse> getBookedRooms(@RequestHeader("Authorization") .data(roomService.getBookedRooms(accountIdFromToken)) .build(); } + + @GetMapping("/booked-rooms/account") + ApiResponse> getBookedRoomsByAccountId(@RequestParam("accountId") String accountId) { + return ApiResponse.>builder() + .message("Các phòng đã đặt") + .data(roomService.getBookedRooms(accountId)) + .build(); + } } diff --git a/src/main/java/com/swp/PodBookingSystem/enums/OrderDetailAmenityStatus.java b/src/main/java/com/swp/PodBookingSystem/enums/OrderDetailAmenityStatus.java index 2a95098a..f3e8cc52 100644 --- a/src/main/java/com/swp/PodBookingSystem/enums/OrderDetailAmenityStatus.java +++ b/src/main/java/com/swp/PodBookingSystem/enums/OrderDetailAmenityStatus.java @@ -5,7 +5,7 @@ public enum OrderDetailAmenityStatus { Booked("Đã đặt"), Delivered("Đã giao"), - Canceled("Đã xóa"); + Canceled("Đã hủy"); private final String description; From 926ccfa4a1668b19d4143f3a848bcfaddc7ad9df Mon Sep 17 00:00:00 2001 From: HuyDiCode Date: Fri, 25 Oct 2024 13:50:26 +0700 Subject: [PATCH 3/4] [PBS-84][HuyNBQ] refactor: add Paid status to OrderDetailAmenityStatus --- .../com/swp/PodBookingSystem/enums/OrderDetailAmenityStatus.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/swp/PodBookingSystem/enums/OrderDetailAmenityStatus.java b/src/main/java/com/swp/PodBookingSystem/enums/OrderDetailAmenityStatus.java index f3e8cc52..54aca3ce 100644 --- a/src/main/java/com/swp/PodBookingSystem/enums/OrderDetailAmenityStatus.java +++ b/src/main/java/com/swp/PodBookingSystem/enums/OrderDetailAmenityStatus.java @@ -4,6 +4,7 @@ @Getter public enum OrderDetailAmenityStatus { Booked("Đã đặt"), + Paid("Đã thanh toán"), Delivered("Đã giao"), Canceled("Đã hủy"); From 1b82af912a1c74e9b9ca1e67cc8b6c5c33b0e00a Mon Sep 17 00:00:00 2001 From: HuyDiCode Date: Sat, 26 Oct 2024 18:04:45 +0700 Subject: [PATCH 4/4] [PBS-84][HuyNBQ] refactor: change status when create amenity order --- .../swp/PodBookingSystem/service/OrderDetailAmenityService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/swp/PodBookingSystem/service/OrderDetailAmenityService.java b/src/main/java/com/swp/PodBookingSystem/service/OrderDetailAmenityService.java index 48e3c0e5..effcfb4b 100644 --- a/src/main/java/com/swp/PodBookingSystem/service/OrderDetailAmenityService.java +++ b/src/main/java/com/swp/PodBookingSystem/service/OrderDetailAmenityService.java @@ -59,7 +59,7 @@ public void createOrderDetailAmenity(OrderDetailAmenityRequest request) { throw new RuntimeException("Order detail or amenity not found"); } OrderDetailAmenity orderDetailAmenity = new OrderDetailAmenity(); - orderDetailAmenity.setStatus(OrderDetailAmenityStatus.Booked); + orderDetailAmenity.setStatus(OrderDetailAmenityStatus.Paid); orderDetailAmenity.setCreatedAt(LocalDateTime.now()); orderDetailAmenity.setUpdatedAt(LocalDateTime.now()); orderDetailAmenity.setId(UUID.randomUUID().toString());