Browse Source

Reason master restriction and amount configuration changed

master
KaNi-04 4 months ago
parent
commit
dd132f0fa8
  1. 308
      src/main/java/com/gcc/communityHall/controller/AdminAPIController.java
  2. 158
      src/main/java/com/gcc/communityHall/controller/OfficerAPIController.java
  3. 207
      src/main/java/com/gcc/communityHall/entity/HallRequestDetails.java
  4. 19
      src/main/java/com/gcc/communityHall/entity/ReasonMaster.java
  5. 1
      src/main/java/com/gcc/communityHall/exception/PaymentRefundSlotOccupiedException.java
  6. 668
      src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java
  7. 56
      src/main/java/com/gcc/communityHall/paymentService/repository/TransactionResponseRepository.java
  8. 39
      src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java
  9. 39
      src/main/java/com/gcc/communityHall/repository/HallRequestDetailsRepository.java
  10. 5
      src/main/java/com/gcc/communityHall/repository/PaymentsRepository.java
  11. 3
      src/main/java/com/gcc/communityHall/repository/ReasonMasterRepository.java
  12. 92
      src/main/java/com/gcc/communityHall/service/BookingService.java
  13. 348
      src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java
  14. 7
      src/main/java/com/gcc/communityHall/service/Impl/ReasonMasterImpl.java
  15. 6
      src/main/java/com/gcc/communityHall/service/ReasonMasterService.java
  16. 2
      src/main/resources/templates/user/hallbookingform.html

308
src/main/java/com/gcc/communityHall/controller/AdminAPIController.java

@ -97,10 +97,7 @@ import lombok.AllArgsConstructor;
//@RestController //@RestController
//@RequestMapping("/admin/api") //@RequestMapping("/admin/api")
@Tag(
name = "CRUD REST APIs for Admin in CommunityHall",
description = "CRUD REST APIs in CommunityHall to CREATE, UPDATE, FETCH AND DELETE Booking details"
)
@Tag(name = "CRUD REST APIs for Admin in CommunityHall", description = "CRUD REST APIs in CommunityHall to CREATE, UPDATE, FETCH AND DELETE Booking details")
@RestController @RestController
@RequestMapping("/victoriahallbooking/admin/api") @RequestMapping("/victoriahallbooking/admin/api")
@AllArgsConstructor @AllArgsConstructor
@ -168,32 +165,10 @@ public class AdminAPIController {
@Autowired @Autowired
private ApplicationLogsRepository applicationLogsRepository; private ApplicationLogsRepository applicationLogsRepository;
@Operation(
summary = "Update HallDetails REST API",
description = "REST API to update the Hall Details"
)
@Operation(summary = "Update HallDetails REST API", description = "REST API to update the Hall Details")
@ApiResponses({ @ApiResponses({
@ApiResponse(
responseCode = "200",
description = "HTTP Status UPDATED",
content = @Content(
mediaType = "text/plain",
schema = @Schema(implementation = HallDetails.class),
examples = @ExampleObject(value = "Hall details updated successfully")
)
),
@ApiResponse(
responseCode = "500",
description = "HTTP Status Internal Server Error",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponseDto.class),
examples = @ExampleObject(
name = "Internal Server Error Example",
value = "{ \"path\": \"/updateHallDetails\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }"
)
)
)
@ApiResponse(responseCode = "200", description = "HTTP Status UPDATED", content = @Content(mediaType = "text/plain", schema = @Schema(implementation = HallDetails.class), examples = @ExampleObject(value = "Hall details updated successfully"))),
@ApiResponse(responseCode = "500", description = "HTTP Status Internal Server Error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponseDto.class), examples = @ExampleObject(name = "Internal Server Error Example", value = "{ \"path\": \"/updateHallDetails\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }")))
}) })
@PostMapping("/updateHallDetails") @PostMapping("/updateHallDetails")
public ResponseEntity<String> updateHallInfo( public ResponseEntity<String> updateHallInfo(
@ -270,43 +245,18 @@ public class AdminAPIController {
return ResponseEntity.ok("Success"); return ResponseEntity.ok("Success");
} }
@Operation(
summary = "Update Settlement Status REST API",
description = "REST API to update the Settlement Status to INITIATED"
)
@Operation(summary = "Update Settlement Status REST API", description = "REST API to update the Settlement Status to INITIATED")
@ApiResponses({ @ApiResponses({
@ApiResponse(
responseCode = "200",
description = "HTTP Status UPDATED",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = Settlement.class),
examples = @ExampleObject(
name = "Settlement Example",
value = "{\"settlementId\": Id, \"Refundstatus\": \"INITIATED\", \"comments\": \"Settlement initiated successfully\"}"
)
)
),
@ApiResponse(
responseCode = "500",
description = "HTTP Status Internal Server Error",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponseDto.class),
examples = @ExampleObject(
name = "Internal Server Error Example",
value = "{ \"path\": \"/updateInitiatedSettlementStatus/{settlementId}\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }"
)
)
)
@ApiResponse(responseCode = "200", description = "HTTP Status UPDATED", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Settlement.class), examples = @ExampleObject(name = "Settlement Example", value = "{\"settlementId\": Id, \"Refundstatus\": \"INITIATED\", \"comments\": \"Settlement initiated successfully\"}"))),
@ApiResponse(responseCode = "500", description = "HTTP Status Internal Server Error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponseDto.class), examples = @ExampleObject(name = "Internal Server Error Example", value = "{ \"path\": \"/updateInitiatedSettlementStatus/{settlementId}\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }")))
}) })
@PostMapping("/updateInitiatedSettlementStatus/{settlementId}") @PostMapping("/updateInitiatedSettlementStatus/{settlementId}")
public ResponseEntity<Settlement> updateInitiatedSettlementStatus( public ResponseEntity<Settlement> updateInitiatedSettlementStatus(
@PathVariable("settlementId") int settlementId, @PathVariable("settlementId") int settlementId,
@RequestParam("status") BookingDetails.RefundStatus status, @RequestParam("status") BookingDetails.RefundStatus status,
@RequestParam("comments") String comments) { @RequestParam("comments") String comments) {
Settlement updateInitialiseSettlement = settlementService.updateSettlementStatus(settlementId, status, comments);
Settlement updateInitialiseSettlement = settlementService.updateSettlementStatus(settlementId, status,
comments);
String adminname = (String) session.getAttribute("usertype"); String adminname = (String) session.getAttribute("usertype");
Integer loginid = (Integer) session.getAttribute("id"); Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs = new ApplicationLogs(); ApplicationLogs logs = new ApplicationLogs();
@ -330,27 +280,11 @@ public class AdminAPIController {
} }
} }
@Operation(
summary = "HallDetails by HallId REST API",
description = "REST API to Retrieving the Hall Details by hallId"
)
@Operation(summary = "HallDetails by HallId REST API", description = "REST API to Retrieving the Hall Details by hallId")
@ApiResponses({ @ApiResponses({
@ApiResponse(
responseCode = "200",
description = "HTTP Status OK",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = HallDetails.class)
)
),
@ApiResponse(
responseCode = "400",
description = "Bad Request"
),
@ApiResponse(
responseCode = "404",
description = "Not Found"
)
@ApiResponse(responseCode = "200", description = "HTTP Status OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = HallDetails.class))),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "404", description = "Not Found")
}) })
@GetMapping("/getHallDetails/{hallId}") @GetMapping("/getHallDetails/{hallId}")
public ResponseEntity<HallDetails> getHallDetails(@PathVariable String hallId) { public ResponseEntity<HallDetails> getHallDetails(@PathVariable String hallId) {
@ -370,10 +304,7 @@ public class AdminAPIController {
} }
} }
@Operation(
summary = "Saving the DiscountRange REST API",
description = "REST API to Saving the Discount Range for usertypes"
)
@Operation(summary = "Saving the DiscountRange REST API", description = "REST API to Saving the Discount Range for usertypes")
@PostMapping("/savediscountrange") @PostMapping("/savediscountrange")
public String saveDiscountrange( public String saveDiscountrange(
@RequestParam String userType, @RequestParam String userType,
@ -427,12 +358,10 @@ public class AdminAPIController {
return "success"; return "success";
} }
@Operation(
summary = " Update the DiscountRange REST API",
description = "REST API to Updating the Discount Range for usertypes"
)
@Operation(summary = " Update the DiscountRange REST API", description = "REST API to Updating the Discount Range for usertypes")
@PutMapping("/updateById/{id}") @PutMapping("/updateById/{id}")
public String updateDiscountRangeById(@PathVariable int id, @RequestParam float discountRange, HttpSession session) {
public String updateDiscountRangeById(@PathVariable int id, @RequestParam float discountRange,
HttpSession session) {
String adminname = (String) session.getAttribute("usertype"); String adminname = (String) session.getAttribute("usertype");
Optional<DiscountRange> existingDiscount = discountRangeRepo.findById(id); Optional<DiscountRange> existingDiscount = discountRangeRepo.findById(id);
if (existingDiscount.isPresent()) { if (existingDiscount.isPresent()) {
@ -462,11 +391,7 @@ public class AdminAPIController {
} }
} }
@Operation(
summary = " Delete the DiscountRange REST API",
description = "REST API to Deleting the Discount for usertypes"
)
@Operation(summary = " Delete the DiscountRange REST API", description = "REST API to Deleting the Discount for usertypes")
@DeleteMapping("/deleteById/{id}") @DeleteMapping("/deleteById/{id}")
public ResponseEntity<String> deleteDiscountRangeById(@PathVariable int id) { public ResponseEntity<String> deleteDiscountRangeById(@PathVariable int id) {
if (discountRangeRepo.existsById(id)) { if (discountRangeRepo.existsById(id)) {
@ -523,10 +448,7 @@ public class AdminAPIController {
} }
@Operation(
summary = "Retrieving the Discount Details REST API",
description = "REST API to Retrieve the Discount Details for usertypes"
)
@Operation(summary = "Retrieving the Discount Details REST API", description = "REST API to Retrieve the Discount Details for usertypes")
// Retrieving the Discount Details // Retrieving the Discount Details
@GetMapping("/getDiscountDetails") @GetMapping("/getDiscountDetails")
public Optional<DiscountRange> getDIscountDetails(@RequestParam("id") int id) { public Optional<DiscountRange> getDIscountDetails(@RequestParam("id") int id) {
@ -534,54 +456,48 @@ public class AdminAPIController {
return discountdetails; return discountdetails;
} }
@Operation(
summary = "Save Reasons REST API",
description = "REST API to save the reasons"
)
@Operation(summary = "Save Reasons REST API", description = "REST API to save the reasons")
// saving the Reason // saving the Reason
@PostMapping("/saveReason") @PostMapping("/saveReason")
public ResponseEntity<?> saveReason(@RequestBody ReasonMaster reasaon) { public ResponseEntity<?> saveReason(@RequestBody ReasonMaster reasaon) {
return ResponseEntity.ok(reasonMasterService.saveTheReason(reasaon)); return ResponseEntity.ok(reasonMasterService.saveTheReason(reasaon));
} }
@Operation(
summary = "All Reasons REST API",
description = "REST API to retrie the allreasons"
)
@Operation(summary = "All Reasons REST API", description = "REST API to retrie the allreasons")
// retrieving the allreasons // retrieving the allreasons
@GetMapping("/getReasons") @GetMapping("/getReasons")
@ResponseBody @ResponseBody
public List<ReasonMaster> getAllReasons() { public List<ReasonMaster> getAllReasons() {
return reasonMasterService.getAllReasons();
// return reasonMasterService.getAllReasons();
return reasonMasterService.getAllReasonsWithStatus();
} }
@Operation(
summary = "Reason Documents by reasonId REST API",
description = "REST API to Get the ReasonDocuments By reasonId"
)
@Operation(summary = "Reason Documents by reasonId REST API", description = "REST API to Get the ReasonDocuments By reasonId")
// Getting ReasonDocuments By reasonId // Getting ReasonDocuments By reasonId
@GetMapping("/getReasonDocumentDetails") @GetMapping("/getReasonDocumentDetails")
public List<ReasonDocumentMaster> getReasonDocumentDetails(@RequestParam int reasonId) { public List<ReasonDocumentMaster> getReasonDocumentDetails(@RequestParam int reasonId) {
return reasonMasterService.getReasonDocumentDetailsByReasonId(reasonId); return reasonMasterService.getReasonDocumentDetailsByReasonId(reasonId);
} }
@Operation(
summary = "Booking Details by Fromdate,toDate and HallId REST API",
description = "REST API to get the Booking Details by Fromdate,toDate and HallId for GccBlokcing"
)
@Operation(summary = "Booking Details by Fromdate,toDate and HallId REST API", description = "REST API to get the Booking Details by Fromdate,toDate and HallId for GccBlokcing")
// @GetMapping("/filter") // @GetMapping("/filter")
// public ResponseEntity<List<BookingResponseDTO>> getFilteredBookings( // public ResponseEntity<List<BookingResponseDTO>> getFilteredBookings(
// @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate,
// @RequestParam("toDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate toDate,
// @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate
// fromDate,
// @RequestParam("toDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate
// toDate,
// @RequestParam("hallIds") List<Long> hallIds) { // @RequestParam("hallIds") List<Long> hallIds) {
// //
// List<BookingDetails> bookings = bookingService.getFilteredBookings(fromDate, toDate, hallIds);
// List<BookingDetails> bookings = bookingService.getFilteredBookings(fromDate,
// toDate, hallIds);
// //
// List<BookingResponseDTO> responses = new ArrayList<>(); // List<BookingResponseDTO> responses = new ArrayList<>();
// for (BookingDetails bookingDetails : bookings) { // for (BookingDetails bookingDetails : bookings) {
// // Fetch GccBlockingDate records for each bookingId // // Fetch GccBlockingDate records for each bookingId
// List<GccBlockingDate> gccBlockedList = blockingDateRepository.getByBookingId(bookingDetails.getBookingId());
// Integer blockingId = gccBlockedList.isEmpty() ? null : gccBlockedList.get(0).getBlockingId();
// List<GccBlockingDate> gccBlockedList =
// blockingDateRepository.getByBookingId(bookingDetails.getBookingId());
// Integer blockingId = gccBlockedList.isEmpty() ? null :
// gccBlockedList.get(0).getBlockingId();
// responses.add(new BookingResponseDTO(bookingDetails, blockingId)); // responses.add(new BookingResponseDTO(bookingDetails, blockingId));
// } // }
// //
@ -594,7 +510,8 @@ public class AdminAPIController {
@RequestParam("hallIds") List<Long> hallIds) { @RequestParam("hallIds") List<Long> hallIds) {
List<BookingDetails> bookings = bookingService.getFilteredBookings(fromDate, toDate, hallIds); List<BookingDetails> bookings = bookingService.getFilteredBookings(fromDate, toDate, hallIds);
List<GccBlockingDate> gccBlockedList = blockingDateRepository.findByFromDateAndToDateBetweenAndHallIdIn(fromDate, toDate, hallIds);
List<GccBlockingDate> gccBlockedList = blockingDateRepository
.findByFromDateAndToDateBetweenAndHallIdIn(fromDate, toDate, hallIds);
Map<String, Object> response = new HashMap<>(); Map<String, Object> response = new HashMap<>();
response.put("bookings", bookings); response.put("bookings", bookings);
@ -603,22 +520,19 @@ public class AdminAPIController {
return ResponseEntity.ok(response); return ResponseEntity.ok(response);
} }
@Operation(
summary = " GCC Blocked Booking Details REST API",
description = "REST API to get the GCC Blocked BookingDetails"
)
@Operation(summary = " GCC Blocked Booking Details REST API", description = "REST API to get the GCC Blocked BookingDetails")
// retrieving the GCC Blocked BookingDetails // retrieving the GCC Blocked BookingDetails
@GetMapping("/blockedevents") @GetMapping("/blockedevents")
public ResponseEntity<List<GccBlockingDate>> getBlockedEvents( public ResponseEntity<List<GccBlockingDate>> getBlockedEvents(
@RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate, @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate,
@RequestParam("toDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate toDate, @RequestParam("toDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate toDate,
@RequestParam("hallIds") List<Long> hallIds
) {
//System.out.println("Blocked Events Request - fromDate: " + fromDate + ", toDate: " + toDate + ", hallIds: " + hallIds );
@RequestParam("hallIds") List<Long> hallIds) {
// System.out.println("Blocked Events Request - fromDate: " + fromDate + ",
// toDate: " + toDate + ", hallIds: " + hallIds );
List<GccBlockingDate> blockedBookings = bookingService.getBlockedEvents(fromDate, toDate, hallIds); List<GccBlockingDate> blockedBookings = bookingService.getBlockedEvents(fromDate, toDate, hallIds);
// List<BookingDetails> bookingDetails = bookingService.getByBookingId(fromDate,toDate,hallIds,blockingId,bookingId);
// List<BookingDetails> bookingDetails =
// bookingService.getByBookingId(fromDate,toDate,hallIds,blockingId,bookingId);
if (blockedBookings.isEmpty()) { if (blockedBookings.isEmpty()) {
// System.out.println("No blocked bookings found."); // System.out.println("No blocked bookings found.");
@ -632,11 +546,7 @@ public class AdminAPIController {
return ResponseEntity.ok(blockedBookings); return ResponseEntity.ok(blockedBookings);
} }
@Operation(
summary = "UNBLOCK the gcc Blocked Event REST API",
description = "REST API to unblocking the Gcc blocked Events for blocking"
)
@Operation(summary = "UNBLOCK the gcc Blocked Event REST API", description = "REST API to unblocking the Gcc blocked Events for blocking")
@GetMapping("/cancelByid") @GetMapping("/cancelByid")
public ResponseEntity<String> cancellationById(@RequestParam int blockingId, public ResponseEntity<String> cancellationById(@RequestParam int blockingId,
@RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate, @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate,
@ -668,7 +578,8 @@ public class AdminAPIController {
List<BookingCalendar> bookingCalendars = bookingService.getBookedslots(fromDate, endDate, hallIdList); List<BookingCalendar> bookingCalendars = bookingService.getBookedslots(fromDate, endDate, hallIdList);
if (bookingCalendars.isEmpty()) { if (bookingCalendars.isEmpty()) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("No booking slots found for the given date range and hall IDs.");
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body("No booking slots found for the given date range and hall IDs.");
} }
// Iterate over bookingCalendars and update them as needed // Iterate over bookingCalendars and update them as needed
@ -716,8 +627,10 @@ public class AdminAPIController {
// public ResponseEntity<String> cancellationById( // public ResponseEntity<String> cancellationById(
// @RequestParam int blockingId, // @RequestParam int blockingId,
// @RequestParam int bookingId, // @RequestParam int bookingId,
// @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate,
// @RequestParam("endDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate,
// @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate
// fromDate,
// @RequestParam("endDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate
// endDate,
// @RequestParam(value = "hallId", required = false) List<Long> hallId) { // @RequestParam(value = "hallId", required = false) List<Long> hallId) {
// //
// System.out.println("Received blockingId: " + blockingId); // System.out.println("Received blockingId: " + blockingId);
@ -726,19 +639,23 @@ public class AdminAPIController {
// System.out.println("Received hallId: " + hallId); // System.out.println("Received hallId: " + hallId);
// //
// // Retrieve blocking date // // Retrieve blocking date
// GccBlockingDate blockingDate = blockingDateRepository.findById(blockingId).orElse(null);
// GccBlockingDate blockingDate =
// blockingDateRepository.findById(blockingId).orElse(null);
// //
// if (blockingDate == null) { // if (blockingDate == null) {
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Blocking ID not found.");
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Blocking ID not
// found.");
// } // }
// //
// if (hallId != null && bookingId > 0) { // if (hallId != null && bookingId > 0) {
// // Specific bookingId and hallId selected // // Specific bookingId and hallId selected
// //
// // Retrieve and update booking calendar // // Retrieve and update booking calendar
// List<BookingCalendar> bookingCalendar = bookingService.getBookedslots(fromDate, endDate, hallId);
// List<BookingCalendar> bookingCalendar =
// bookingService.getBookedslots(fromDate, endDate, hallId);
// if (bookingCalendar.isEmpty()) { // if (bookingCalendar.isEmpty()) {
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("No booking slots found for the given date and hall ID.");
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("No booking slots
// found for the given date and hall ID.");
// } // }
// //
// BookingCalendar bookingSlots = bookingCalendar.get(0); // BookingCalendar bookingSlots = bookingCalendar.get(0);
@ -752,7 +669,8 @@ public class AdminAPIController {
// hallIdList.remove(hallId.toString()); // hallIdList.remove(hallId.toString());
// String updatedHallIds = String.join(",", hallIdList); // String updatedHallIds = String.join(",", hallIdList);
// //
// List<String> bookingIdList = Arrays.asList(blockingDate.getBookingIds().split(","));
// List<String> bookingIdList =
// Arrays.asList(blockingDate.getBookingIds().split(","));
// bookingIdList.remove(Integer.toString(bookingId)); // bookingIdList.remove(Integer.toString(bookingId));
// String updatedBookingIds = String.join(",", bookingIdList); // String updatedBookingIds = String.join(",", bookingIdList);
// //
@ -782,7 +700,8 @@ public class AdminAPIController {
// } else { // } else {
// // All halls and bookings selected // // All halls and bookings selected
// // Retrieve and clear all bookings for the date range // // Retrieve and clear all bookings for the date range
// List<BookingCalendar> bookingCalendars = bookingService.getBookedslots(fromDate,endDate,hallId);
// List<BookingCalendar> bookingCalendars =
// bookingService.getBookedslots(fromDate,endDate,hallId);
// for (BookingCalendar bookingCalendar : bookingCalendars) { // for (BookingCalendar bookingCalendar : bookingCalendars) {
// bookingCalendar.setBookingId_1(null); // bookingCalendar.setBookingId_1(null);
// bookingCalendar.setBookingId_2(null); // bookingCalendar.setBookingId_2(null);
@ -809,20 +728,14 @@ public class AdminAPIController {
// return ResponseEntity.ok("Success"); // return ResponseEntity.ok("Success");
// } // }
@Operation(
summary = "HAll IMAGES by HallId REST API",
description = "REST API to get the hall Images by Hall Id"
)
@Operation(summary = "HAll IMAGES by HallId REST API", description = "REST API to get the hall Images by Hall Id")
// retrieving Hall Images by Hallid // retrieving Hall Images by Hallid
@GetMapping("/getImageById") @GetMapping("/getImageById")
public List<HallImages> getImageDetails(@RequestParam int hallId) { public List<HallImages> getImageDetails(@RequestParam int hallId) {
return hallService.getHallImages(hallId); return hallService.getHallImages(hallId);
} }
@Operation(
summary = "GCC Blocking REST API",
description = "REST API to Block the Halls by Admin"
)
@Operation(summary = "GCC Blocking REST API", description = "REST API to Block the Halls by Admin")
// GccBlocking Api // GccBlocking Api
@PostMapping("/cancelAll") @PostMapping("/cancelAll")
public ResponseEntity<String> cancelAllBookings( public ResponseEntity<String> cancelAllBookings(
@ -844,7 +757,8 @@ public class AdminAPIController {
.collect(Collectors.toList()); .collect(Collectors.toList());
// Call the service with descriptions and documents // Call the service with descriptions and documents
bookingService.cancelAllBookings(fromDate, toDate, hallIdsList, reasonforblocking, selectedBookings, updatedBy, descriptions, documents);
bookingService.cancelAllBookings(fromDate, toDate, hallIdsList, reasonforblocking, selectedBookings, updatedBy,
descriptions, documents);
String adminname = (String) session.getAttribute("usertype"); String adminname = (String) session.getAttribute("usertype");
Integer loginid = (Integer) session.getAttribute("id"); Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs = new ApplicationLogs(); ApplicationLogs logs = new ApplicationLogs();
@ -867,12 +781,15 @@ public class AdminAPIController {
// @PostMapping("/blockhall") // @PostMapping("/blockhall")
// public ResponseEntity<String> blockHall( // public ResponseEntity<String> blockHall(
// @RequestParam("blockingId") Integer blockingId, // @RequestParam("blockingId") Integer blockingId,
// @RequestParam("hallID") String hallID, // Ensure this matches the parameter name used in AJAX
// @RequestParam(value = "selectedBookings", required = false) List<String> selectedBookings,
// @RequestParam("hallID") String hallID, // Ensure this matches the parameter
// name used in AJAX
// @RequestParam(value = "selectedBookings", required = false) List<String>
// selectedBookings,
// HttpSession session) { // HttpSession session) {
// //
// String updatedBy = (String) session.getAttribute("employeeId"); // String updatedBy = (String) session.getAttribute("employeeId");
// Optional<GccBlockingDate> gccblocking = blockingDateRepository.findById(blockingId);
// Optional<GccBlockingDate> gccblocking =
// blockingDateRepository.findById(blockingId);
// GccBlockingDate gccblockingdata = gccblocking.get(); // GccBlockingDate gccblockingdata = gccblocking.get();
// //
// // Convert startDate and endDate to String // // Convert startDate and endDate to String
@ -888,12 +805,13 @@ public class AdminAPIController {
// System.out.println("selected BookingIds: " + selectedBookings); // System.out.println("selected BookingIds: " + selectedBookings);
// //
// // Pass the formatted date strings // // Pass the formatted date strings
// bookingService.cancelAllBookings(startDateString, endDateString, hallIdsList, gccblockingdata.getDepartment(), gccblockingdata.getBlockingReason(), selectedBookings, updatedBy);
// bookingService.cancelAllBookings(startDateString, endDateString, hallIdsList,
// gccblockingdata.getDepartment(), gccblockingdata.getBlockingReason(),
// selectedBookings, updatedBy);
// //
// return ResponseEntity.ok("Success"); // return ResponseEntity.ok("Success");
// } // }
@GetMapping("/bookingdetailsByuserId") @GetMapping("/bookingdetailsByuserId")
public List<BookingDetails> getuserDetails(@RequestParam Integer userId) { public List<BookingDetails> getuserDetails(@RequestParam Integer userId) {
return bookingService.getAllBookingsByUserId(userId); return bookingService.getAllBookingsByUserId(userId);
@ -901,11 +819,14 @@ public class AdminAPIController {
@GetMapping("/settlement-approved") @GetMapping("/settlement-approved")
public ResponseEntity<List<Settlement>> getApprovedSettlements(HttpSession session) { public ResponseEntity<List<Settlement>> getApprovedSettlements(HttpSession session) {
List<Settlement> approvedSettlements = settlementRepository.findByBookingDetailsRefundStatus(RefundStatus.APPROVED);
List<Settlement> approvedSettlements = settlementRepository
.findByBookingDetailsRefundStatus(RefundStatus.APPROVED);
return ResponseEntity.ok(approvedSettlements); return ResponseEntity.ok(approvedSettlements);
} }
// @PostMapping("/complete-refund") // @PostMapping("/complete-refund")
// public ResponseEntity<String> completeRefund(@RequestBody List<String> bookingIds, HttpSession session, HttpServletResponse response) throws IOException {
// public ResponseEntity<String> completeRefund(@RequestBody List<String>
// bookingIds, HttpSession session, HttpServletResponse response) throws
// IOException {
// String token = (String) session.getAttribute("jwtToken"); // String token = (String) session.getAttribute("jwtToken");
// //System.out.println("tokensssssssss" + token); // //System.out.println("tokensssssssss" + token);
// //
@ -919,28 +840,34 @@ public class AdminAPIController {
// //
// if (!bookids.isEmpty()) { // if (!bookids.isEmpty()) {
// // Prepare and return error response if there are errors // // Prepare and return error response if there are errors
// StringBuilder errorResponse = new StringBuilder("Errors processing refund for IDs: ");
// StringBuilder errorResponse = new StringBuilder("Errors processing refund for
// IDs: ");
// for (String bookId : bookids) { // for (String bookId : bookids) {
// errorResponse.append(bookId).append(", "); // errorResponse.append(bookId).append(", ");
// } // }
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse.toString());
// return
// ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse.toString());
// } // }
// //
// return ResponseEntity.ok("Refund completed successfully"); // return ResponseEntity.ok("Refund completed successfully");
// } catch (Exception e) { // } catch (Exception e) {
// e.printStackTrace(); // e.printStackTrace();
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error processing refund: " + e.getMessage());
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error
// processing refund: " + e.getMessage());
// } // }
// } else { // } else {
// // Token is invalid or not present, redirect to login // // Token is invalid or not present, redirect to login
// session.invalidate(); // Invalidate the session to clear all session attributes
// session.invalidate(); // Invalidate the session to clear all session
// attributes
// response.sendRedirect("/login"); // Redirect to the login page // response.sendRedirect("/login"); // Redirect to the login page
// return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); // Return HTTP 401 Unauthorized
// return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); // Return HTTP
// 401 Unauthorized
// } // }
// } // }
// @GetMapping("/Gccblocking") // @GetMapping("/Gccblocking")
// public ResponseEntity<List<Object>> getGccBlockingEvents(@RequestParam("hallId") int hallId) {
// public ResponseEntity<List<Object>>
// getGccBlockingEvents(@RequestParam("hallId") int hallId) {
// System.out.println("Received hallId: " + hallId); // System.out.println("Received hallId: " + hallId);
// //
// List<Object> results = bookingService.getGccBlockingEvents(hallId); // List<Object> results = bookingService.getGccBlockingEvents(hallId);
@ -992,8 +919,10 @@ public class AdminAPIController {
if (hallDetailsOpt.isPresent()) { if (hallDetailsOpt.isPresent()) {
HallDetails hallDetails = hallDetailsOpt.get(); HallDetails hallDetails = hallDetailsOpt.get();
List<Integer> bookingIds = bookingDetailsRepository.findBookingIdsByHallIdAndBookingDateBetween(hallId, startDate, endDate);
// System.out.println("Booking IDs for hallId " + hallId + ": " + bookingIds); // Add this line
List<Integer> bookingIds = bookingDetailsRepository.findBookingIdsByHallIdAndBookingDateBetween(hallId,
startDate, endDate);
// System.out.println("Booking IDs for hallId " + hallId + ": " + bookingIds);
// // Add this line
Map<String, Object> hallInfo = new HashMap<>(); Map<String, Object> hallInfo = new HashMap<>();
hallInfo.put("hallName", hallDetails.getHallName()); hallInfo.put("hallName", hallDetails.getHallName());
@ -1023,7 +952,6 @@ public class AdminAPIController {
} }
} }
@GetMapping("/blockedHallsByHallIdAndReason") @GetMapping("/blockedHallsByHallIdAndReason")
@ResponseBody @ResponseBody
public Map<String, Object> viewBlockedHallsByHallIdAndReason( public Map<String, Object> viewBlockedHallsByHallIdAndReason(
@ -1032,11 +960,13 @@ public class AdminAPIController {
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date startDate, @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date startDate,
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date endDate) { @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date endDate) {
List<GccBlockingDate> blockedHalls = blockingDateRepository.findByBlockingReasonAndDateRange(blockingReason, startDate, endDate);
List<GccBlockingDate> blockedHalls = blockingDateRepository.findByBlockingReasonAndDateRange(blockingReason,
startDate, endDate);
// Ensure distinct by hallId and other keys // Ensure distinct by hallId and other keys
List<GccBlockingDate> uniqueGccBlockingDates = blockedHalls.stream() List<GccBlockingDate> uniqueGccBlockingDates = blockedHalls.stream()
.filter(distinctByKey(g -> Arrays.asList(g.getHallId(), g.getBlockingReason(), g.getStartDate(), g.getEndDate())))
.filter(distinctByKey(
g -> Arrays.asList(g.getHallId(), g.getBlockingReason(), g.getStartDate(), g.getEndDate())))
.collect(Collectors.toList()); .collect(Collectors.toList());
// Prepare response data // Prepare response data
@ -1083,7 +1013,6 @@ public class AdminAPIController {
return response; return response;
} }
// Utility method to ensure distinct by a key // Utility method to ensure distinct by a key
private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) { private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Set<Object> seen = new HashSet<>(); Set<Object> seen = new HashSet<>();
@ -1092,7 +1021,8 @@ public class AdminAPIController {
// Method to calculate number of bookings // Method to calculate number of bookings
private int calculateBookings(HallDetails hall, GccBlockingDate blockedHall) { private int calculateBookings(HallDetails hall, GccBlockingDate blockedHall) {
return blockingDateRepository.countBlockedBookings(hall.getHallId(), blockedHall.getStartDate(), blockedHall.getEndDate());
return blockingDateRepository.countBlockedBookings(hall.getHallId(), blockedHall.getStartDate(),
blockedHall.getEndDate());
} }
private double calculateRefund(HallDetails hall, GccBlockingDate blockedHall) { private double calculateRefund(HallDetails hall, GccBlockingDate blockedHall) {
@ -1111,7 +1041,8 @@ public class AdminAPIController {
@RequestParam(required = false, defaultValue = "ALL") String userType) { @RequestParam(required = false, defaultValue = "ALL") String userType) {
try { try {
Map<String, Map<String, Integer>> statistics = bookingService.getBookingStatistics(fromDate, toDate, zone, division, hallid, userType);
Map<String, Map<String, Integer>> statistics = bookingService.getBookingStatistics(fromDate, toDate, zone,
division, hallid, userType);
return ResponseEntity.ok(statistics); return ResponseEntity.ok(statistics);
} catch (Exception e) { } catch (Exception e) {
// Log the exception and return an appropriate error response // Log the exception and return an appropriate error response
@ -1161,7 +1092,8 @@ public class AdminAPIController {
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(Collections.singletonMap("error", e.getMessage())); return ResponseEntity.status(HttpStatus.NOT_FOUND).body(Collections.singletonMap("error", e.getMessage()));
} catch (IOException e) { } catch (IOException e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(Collections.singletonMap("error", "Failed to update image"));
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(Collections.singletonMap("error", "Failed to update image"));
} }
} }
@ -1239,7 +1171,6 @@ public class AdminAPIController {
return ResponseEntity.ok(response); return ResponseEntity.ok(response);
} }
@GetMapping("/viewsettlement-complete") @GetMapping("/viewsettlement-complete")
public ResponseEntity<Map<String, Object>> viewSettlementcompleteMaster(HttpSession session) { public ResponseEntity<Map<String, Object>> viewSettlementcompleteMaster(HttpSession session) {
@ -1342,10 +1273,16 @@ public class AdminAPIController {
List<Users> userList = handleUserRequest(request, fromDate, toDate, userstatus, usertype); List<Users> userList = handleUserRequest(request, fromDate, toDate, userstatus, usertype);
List<Object[]> bookingList = handleBookingRequest(request, fromDate, toDate, bookingStatus, bookingId); List<Object[]> bookingList = handleBookingRequest(request, fromDate, toDate, bookingStatus, bookingId);
List<BookingDetails> bookingSettlementList = handleBookingSettlementRequest(request, fromDate, toDate, refundStatus);
List<Object[]> paymentList = request.equals("3") ? bookingService.getAllPaymentsDetails(fromDate, toDate) : new ArrayList<>();
List<Object[]> userbookingList = request.equals("4") ? bookingService.getBookingUserDetailsReport(fromDate, toDate) : new ArrayList<>();
List<Object[]> hallbookingList = request.equals("5") ? bookingService.getBookingHallDetailsReport(fromDate, toDate) : new ArrayList<>();
List<BookingDetails> bookingSettlementList = handleBookingSettlementRequest(request, fromDate, toDate,
refundStatus);
List<Object[]> paymentList = request.equals("3") ? bookingService.getAllPaymentsDetails(fromDate, toDate)
: new ArrayList<>();
List<Object[]> userbookingList = request.equals("4")
? bookingService.getBookingUserDetailsReport(fromDate, toDate)
: new ArrayList<>();
List<Object[]> hallbookingList = request.equals("5")
? bookingService.getBookingHallDetailsReport(fromDate, toDate)
: new ArrayList<>();
response.put("users", userList); response.put("users", userList);
response.put("bookings", bookingList); response.put("bookings", bookingList);
@ -1365,7 +1302,8 @@ public class AdminAPIController {
return new ResponseEntity<>(response, HttpStatus.OK); return new ResponseEntity<>(response, HttpStatus.OK);
} }
private List<Users> handleUserRequest(String request, String fromDate, String toDate, String userstatus, String usertype) {
private List<Users> handleUserRequest(String request, String fromDate, String toDate, String userstatus,
String usertype) {
if (!request.equals("1")) { if (!request.equals("1")) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -1381,7 +1319,8 @@ public class AdminAPIController {
return userService.getAllUsers(fromDate, toDate); return userService.getAllUsers(fromDate, toDate);
} }
private List<Object[]> handleBookingRequest(String request, String fromDate, String toDate, String bookingStatus, Long bookingId) {
private List<Object[]> handleBookingRequest(String request, String fromDate, String toDate, String bookingStatus,
Long bookingId) {
if (!request.equals("2")) { if (!request.equals("2")) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -1394,7 +1333,8 @@ public class AdminAPIController {
} }
} }
private List<BookingDetails> handleBookingSettlementRequest(String request, String fromDate, String toDate, String refundStatus) {
private List<BookingDetails> handleBookingSettlementRequest(String request, String fromDate, String toDate,
String refundStatus) {
if (!request.equals("6")) { if (!request.equals("6")) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -1410,7 +1350,6 @@ public class AdminAPIController {
return ResponseEntity.ok(halldetails); return ResponseEntity.ok(halldetails);
} }
@GetMapping("/listgccblocking") @GetMapping("/listgccblocking")
public ResponseEntity<Map<String, Object>> getGccBlocking() { public ResponseEntity<Map<String, Object>> getGccBlocking() {
@ -1504,7 +1443,8 @@ public class AdminAPIController {
return ResponseEntity.ok("File uploaded and saved successfully"); return ResponseEntity.ok("File uploaded and saved successfully");
} catch (Exception e) { } catch (Exception e) {
System.err.println("Error during file upload: " + e.getMessage()); System.err.println("Error during file upload: " + e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("File upload failed: " + e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body("File upload failed: " + e.getMessage());
} }
} }
} }

158
src/main/java/com/gcc/communityHall/controller/OfficerAPIController.java

@ -65,11 +65,7 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSession;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@Tag(
name = "CRUD REST APIs for Officer in CommunityHall",
description = "CRUD REST APIs in CommunityHall to CREATE, UPDATE, FETCH AND DELETE Booking details"
)
@Tag(name = "CRUD REST APIs for Officer in CommunityHall", description = "CRUD REST APIs in CommunityHall to CREATE, UPDATE, FETCH AND DELETE Booking details")
@RestController @RestController
@RequestMapping("/victoriahallbooking/api/officer") @RequestMapping("/victoriahallbooking/api/officer")
@AllArgsConstructor @AllArgsConstructor
@ -128,10 +124,7 @@ public class OfficerAPIController {
@Autowired @Autowired
private ApplicationLogsRepository applicationLogsRepository; private ApplicationLogsRepository applicationLogsRepository;
@Operation(
summary = "Retriving the User Details by userId REST API",
description = "REST API for Retriving the User Details by UserId"
)
@Operation(summary = "Retriving the User Details by userId REST API", description = "REST API for Retriving the User Details by UserId")
// Getting User Details by User Id // Getting User Details by User Id
@GetMapping("/getUserDetails") @GetMapping("/getUserDetails")
public ResponseEntity<?> getUsersByID(HttpServletRequest request, @RequestParam String usersid) { public ResponseEntity<?> getUsersByID(HttpServletRequest request, @RequestParam String usersid) {
@ -139,39 +132,32 @@ public class OfficerAPIController {
return ResponseEntity.ok(user); return ResponseEntity.ok(user);
} }
@Operation(
summary = "Settlement List where the Refund Status is WAITING REST API",
description = "REST API for Retriving the Settlement List where the Refund Status is WAITING"
)
@Operation(summary = "Settlement List where the Refund Status is WAITING REST API", description = "REST API for Retriving the Settlement List where the Refund Status is WAITING")
// retrieving the Settlement List by Refund Status is WAITING // retrieving the Settlement List by Refund Status is WAITING
@GetMapping("/waiting-refund") @GetMapping("/waiting-refund")
public List<Settlement> getSettlementsWithWaitingRefund() { public List<Settlement> getSettlementsWithWaitingRefund() {
return settlementService.getSettlementListWithWaitingRefund(); return settlementService.getSettlementListWithWaitingRefund();
} }
@Operation(
summary = "Settlement List by Settlement Id REST API",
description = "REST API for Retriving the Settlement List by Settlement Id"
)
@Operation(summary = "Settlement List by Settlement Id REST API", description = "REST API for Retriving the Settlement List by Settlement Id")
// retrieving the Settlement List by Settlement Id // retrieving the Settlement List by Settlement Id
@GetMapping("/getSettlementList") @GetMapping("/getSettlementList")
public ResponseEntity<BookingDetails> getBookingDetailsWithSettlement(HttpServletRequest request, @RequestParam String settlementsid) {
BookingDetails bookingDetails = bookingServiceImpl.getBookingDetailsWithSettlement(Integer.parseInt(settlementsid));
public ResponseEntity<BookingDetails> getBookingDetailsWithSettlement(HttpServletRequest request,
@RequestParam String settlementsid) {
BookingDetails bookingDetails = bookingServiceImpl
.getBookingDetailsWithSettlement(Integer.parseInt(settlementsid));
System.out.println("bookingDetails:12 " + bookingDetails); System.out.println("bookingDetails:12 " + bookingDetails);
return ResponseEntity.ok(bookingDetails); return ResponseEntity.ok(bookingDetails);
} }
@GetMapping("/getsettlementListbyid") @GetMapping("/getsettlementListbyid")
public ResponseEntity<Optional<Settlement>> getsettlementlist(HttpServletRequest request, @RequestParam int settlementsid) {
public ResponseEntity<Optional<Settlement>> getsettlementlist(HttpServletRequest request,
@RequestParam int settlementsid) {
Optional<Settlement> settlementlist = settlementRepository.findById(settlementsid); Optional<Settlement> settlementlist = settlementRepository.findById(settlementsid);
return ResponseEntity.ok(settlementlist); return ResponseEntity.ok(settlementlist);
} }
@Operation(
summary = "Booking Details by Booking Id REST API",
description = "REST API for Retriving the Booking Details by Booking Id"
)
@Operation(summary = "Booking Details by Booking Id REST API", description = "REST API for Retriving the Booking Details by Booking Id")
// retrieving the Booking Details by Booking Id // retrieving the Booking Details by Booking Id
@GetMapping("/getBookingDetails") @GetMapping("/getBookingDetails")
public ResponseEntity<?> getBookingsById(HttpServletRequest request, @RequestParam String bookingsId) { public ResponseEntity<?> getBookingsById(HttpServletRequest request, @RequestParam String bookingsId) {
@ -179,11 +165,9 @@ public class OfficerAPIController {
return ResponseEntity.ok(book); return ResponseEntity.ok(book);
} }
@Operation(
summary = "Settlement APPROVED REST API",
description = "REST API for Updating the Refund Status to Approved by Settlement Id If the settlement is Approved"
)
//Updating the Refund Status to Approved by Settlement Id If the settlement is Approved
@Operation(summary = "Settlement APPROVED REST API", description = "REST API for Updating the Refund Status to Approved by Settlement Id If the settlement is Approved")
// Updating the Refund Status to Approved by Settlement Id If the settlement is
// Approved
@PostMapping("/updateApprovedSettlementStatus/{settlementId}") // need to check this API for settlement approval @PostMapping("/updateApprovedSettlementStatus/{settlementId}") // need to check this API for settlement approval
public ResponseEntity<Object> updateApprovedSettlementStatus( public ResponseEntity<Object> updateApprovedSettlementStatus(
@PathVariable("settlementId") int settlementId, @PathVariable("settlementId") int settlementId,
@ -191,7 +175,6 @@ public class OfficerAPIController {
@RequestParam("comments") String comments) { @RequestParam("comments") String comments) {
Map<String, Object> response = new HashMap<>(); Map<String, Object> response = new HashMap<>();
try { try {
System.out.println("settlementId1: " + settlementId); System.out.println("settlementId1: " + settlementId);
System.out.println("status" + status); System.out.println("status" + status);
@ -231,7 +214,8 @@ public class OfficerAPIController {
applicationLogsRepository.save(logs); applicationLogsRepository.save(logs);
// Process refund request // Process refund request
String refundResponse = bookingServiceImpl.processRefundRequest(updateSettlement.getBookingDetails().getBookingId());
String refundResponse = bookingServiceImpl
.processRefundRequest(updateSettlement.getBookingDetails().getBookingId());
// ak // ak
// Prepare response map // Prepare response map
@ -246,14 +230,16 @@ public class OfficerAPIController {
} else { } else {
// Refund failure, update refund status to FAILURE // Refund failure, update refund status to FAILURE
bookingService.updateRefundStatus(updateSettlement.getBookingDetails().getBookingId(), BookingDetails.RefundStatus.FAILURE);
bookingService.updateRefundStatus(updateSettlement.getBookingDetails().getBookingId(),
BookingDetails.RefundStatus.FAILURE);
Map<String, Object> responses = new HashMap<>(); Map<String, Object> responses = new HashMap<>();
responses.put("approvedFlag", 1); responses.put("approvedFlag", 1);
responses.put("message", "Refund processing failed: " + refundResponse); responses.put("message", "Refund processing failed: " + refundResponse);
responses.put("status", "FAILURE"); responses.put("status", "FAILURE");
return new ResponseEntity<>(responses, HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(responses, HttpStatus.INTERNAL_SERVER_ERROR);
//return new ResponseEntity<>("Refund processing failed: " + refundResponse, HttpStatus.INTERNAL_SERVER_ERROR);
// return new ResponseEntity<>("Refund processing failed: " + refundResponse,
// HttpStatus.INTERNAL_SERVER_ERROR);
} }
} catch (Exception e) { } catch (Exception e) {
@ -261,15 +247,15 @@ public class OfficerAPIController {
response.put("message", "Exception while approving settlement: " + e.getMessage()); response.put("message", "Exception while approving settlement: " + e.getMessage());
return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR);
//return new ResponseEntity<>("An error occurred while processing the settlement for Settlement ID: " + settlementId, HttpStatus.INTERNAL_SERVER_ERROR);
// return new ResponseEntity<>("An error occurred while processing the
// settlement for Settlement ID: " + settlementId,
// HttpStatus.INTERNAL_SERVER_ERROR);
} }
} }
@Operation(
summary = "Settlement APPROVED REST API",
description = "REST API for Updating the Refund Status to Approved by Settlement Id If the settlement is Approved"
)
//Updating the Refund Status to Rejected by Settlement Id If the settlement is Rejected
@Operation(summary = "Settlement APPROVED REST API", description = "REST API for Updating the Refund Status to Approved by Settlement Id If the settlement is Approved")
// Updating the Refund Status to Rejected by Settlement Id If the settlement is
// Rejected
@PostMapping("/updateRejectSettlementStatus/{settlementId}") @PostMapping("/updateRejectSettlementStatus/{settlementId}")
public ResponseEntity<Settlement> updateRejectSettlementStatus( public ResponseEntity<Settlement> updateRejectSettlementStatus(
@PathVariable("settlementId") int settlementId, @PathVariable("settlementId") int settlementId,
@ -300,10 +286,7 @@ public class OfficerAPIController {
} }
} }
@Operation(
summary = "USER STATUS APPROVED REST API",
description = "REST API for Updating the user Status Approved"
)
@Operation(summary = "USER STATUS APPROVED REST API", description = "REST API for Updating the user Status Approved")
// Updating the user Status Approved // Updating the user Status Approved
@PostMapping("/updateApprovedStatus/{userId}") @PostMapping("/updateApprovedStatus/{userId}")
public ResponseEntity<Users> updateApprovedStatus( public ResponseEntity<Users> updateApprovedStatus(
@ -319,10 +302,7 @@ public class OfficerAPIController {
} }
} }
@Operation(
summary = "USER STATUS REJECTED REST API",
description = "REST API for Updating the user Status Rejected"
)
@Operation(summary = "USER STATUS REJECTED REST API", description = "REST API for Updating the user Status Rejected")
// Updating the user Status Rejected // Updating the user Status Rejected
@PostMapping("/updateRejectStatus/{userId}") @PostMapping("/updateRejectStatus/{userId}")
public ResponseEntity<Users> updateRejectStatus( public ResponseEntity<Users> updateRejectStatus(
@ -339,10 +319,7 @@ public class OfficerAPIController {
} }
} }
@Operation(
summary = "BOOKING STATUS APPROVED REST API",
description = "REST API for Updating the Booking Status Approved by Booking Id"
)
@Operation(summary = "BOOKING STATUS APPROVED REST API", description = "REST API for Updating the Booking Status Approved by Booking Id")
// Updating the Booking Status Approved by Booking Id // Updating the Booking Status Approved by Booking Id
@PostMapping("/updateBookingApproved/{bookingId}") @PostMapping("/updateBookingApproved/{bookingId}")
public ResponseEntity<BookingDetails> updateBookingApproved( public ResponseEntity<BookingDetails> updateBookingApproved(
@ -377,13 +354,12 @@ public class OfficerAPIController {
} }
// ak // ak
@PostMapping("/toggleStatus") @PostMapping("/toggleStatus")
public ResponseEntity<String> toggleUserStatus( public ResponseEntity<String> toggleUserStatus(
@RequestParam Integer userId, @RequestParam Integer userId,
@RequestParam boolean active
) {
//System.out.println("userID: " + userId + ", active or deactivate: " + active);
@RequestParam boolean active) {
// System.out.println("userID: " + userId + ", active or deactivate: " +
// active);
try { try {
userService.toggleUserStatus(userId, active); userService.toggleUserStatus(userId, active);
return ResponseEntity.ok("User status updated successfully"); return ResponseEntity.ok("User status updated successfully");
@ -392,11 +368,7 @@ public class OfficerAPIController {
} }
} }
@Operation(
summary = "BOOKING STATUS REJECTED REST API",
description = "REST API for Updating the Booking Status Rejected by Booking Id"
)
@Operation(summary = "BOOKING STATUS REJECTED REST API", description = "REST API for Updating the Booking Status Rejected by Booking Id")
// Updating the Booking Status Rejected by Booking Id // Updating the Booking Status Rejected by Booking Id
@PostMapping("/updateBookingReject/{bookingId}") @PostMapping("/updateBookingReject/{bookingId}")
public ResponseEntity<?> updateBookingReject( public ResponseEntity<?> updateBookingReject(
@ -410,7 +382,8 @@ public class OfficerAPIController {
BookingDetails result = book.get(); BookingDetails result = book.get();
result.setBookingStatus(BookingStatus.REJECTED); result.setBookingStatus(BookingStatus.REJECTED);
result.setRefundStatus(RefundStatus.NA); result.setRefundStatus(RefundStatus.NA);
List<BookingCalendar> bookingCalendarList = bookingCalendarRepository.getCancellingdata1(String.valueOf(result.getBookingId()));
List<BookingCalendar> bookingCalendarList = bookingCalendarRepository
.getCancellingdata1(String.valueOf(result.getBookingId()));
for (BookingCalendar calendar : bookingCalendarList) { for (BookingCalendar calendar : bookingCalendarList) {
boolean isUpdated = false; boolean isUpdated = false;
@ -458,10 +431,17 @@ public class OfficerAPIController {
BookingDetails rejectBooking = bookingService.updateCancelledBookingStatus(bookingId, status, comments); BookingDetails rejectBooking = bookingService.updateCancelledBookingStatus(bookingId, status, comments);
Optional<BookingDetails> book = bookingDetailsRepository.findById(bookingId); Optional<BookingDetails> book = bookingDetailsRepository.findById(bookingId);
BookingDetails bookingDetails = book.get(); BookingDetails bookingDetails = book.get();
String rejectionsms="Your booking ID "+bookingDetails.getBookingId()+" on "+bookingDetails.getStartDate()+" has been rejected by GCC due to insufficient details.";
String rejectedurlString ="https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to="+bookingDetails.getUsers().getMobileNo()+"&from=GCCCRP&body="+rejectionsms+"&entityid=1401572690000011081&templateid=1407172346485956648";
//String rejectedwhatsupmsg="https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="+bookingDetails.getUsers().getMobileNo()+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+booking+with+ID+"+bookingId+"+on+"+bookingDetails.getStartDate()+"+has+been+rejected+by+GCC+due+to+insufficient+details.+%0AThanks+for+using+GCC+Community+Hall+Booking+System.";
String rejectedwhatsupmsg="https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="+bookingDetails.getUsers().getMobileNo()+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+booking+with+ID+"+bookingId+"+on+"+bookingDetails.getStartDate()+"+has+been+rejected+by+GCC+due+to+insufficient+details.";
String rejectionsms = "Your booking ID " + bookingDetails.getBookingId() + " on "
+ bookingDetails.getStartDate() + " has been rejected by GCC due to insufficient details.";
String rejectedurlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to="
+ bookingDetails.getUsers().getMobileNo() + "&from=GCCCRP&body=" + rejectionsms
+ "&entityid=1401572690000011081&templateid=1407172346485956648";
// String
// rejectedwhatsupmsg="https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="+bookingDetails.getUsers().getMobileNo()+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+booking+with+ID+"+bookingId+"+on+"+bookingDetails.getStartDate()+"+has+been+rejected+by+GCC+due+to+insufficient+details.+%0AThanks+for+using+GCC+Community+Hall+Booking+System.";
String rejectedwhatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="
+ bookingDetails.getUsers().getMobileNo()
+ "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+booking+with+ID+" + bookingId
+ "+on+" + bookingDetails.getStartDate() + "+has+been+rejected+by+GCC+due+to+insufficient+details.";
whatsappMsgServiceImpl.sendMsg(rejectedwhatsupmsg); whatsappMsgServiceImpl.sendMsg(rejectedwhatsupmsg);
whatsappMsgServiceImpl.sendSMS(rejectedurlString); whatsappMsgServiceImpl.sendSMS(rejectedurlString);
String adminname = (String) session.getAttribute("usertype"); String adminname = (String) session.getAttribute("usertype");
@ -487,10 +467,7 @@ public class OfficerAPIController {
} }
} }
@Operation(
summary = "Retrieving BOOKING STATUS APPROVED REST API",
description = "REST API for retrieving the Booking Status Approved"
)
@Operation(summary = "Retrieving BOOKING STATUS APPROVED REST API", description = "REST API for retrieving the Booking Status Approved")
// retrieving the Booking Status Approved // retrieving the Booking Status Approved
@GetMapping("/user-Approved") @GetMapping("/user-Approved")
public ResponseEntity<List<Users>> getUserApprovedList() { public ResponseEntity<List<Users>> getUserApprovedList() {
@ -498,10 +475,7 @@ public class OfficerAPIController {
return new ResponseEntity<>(userApproved, HttpStatus.OK); return new ResponseEntity<>(userApproved, HttpStatus.OK);
} }
@Operation(
summary = "Retrieving BOOKING STATUS REJECTED REST API",
description = "REST API for retrieving the Booking Status Rejected"
)
@Operation(summary = "Retrieving BOOKING STATUS REJECTED REST API", description = "REST API for retrieving the Booking Status Rejected")
// retrieving the Booking Status Rejected // retrieving the Booking Status Rejected
@GetMapping("/user-Reject") @GetMapping("/user-Reject")
public ResponseEntity<List<Users>> getUserRejectedList() { public ResponseEntity<List<Users>> getUserRejectedList() {
@ -509,11 +483,7 @@ public class OfficerAPIController {
return new ResponseEntity<>(userReject, HttpStatus.OK); return new ResponseEntity<>(userReject, HttpStatus.OK);
} }
@Operation(
summary = "Counter Refund Approval by Officer REST API",
description = "REST API to approve the Counter Refund by Officer"
)
@Operation(summary = "Counter Refund Approval by Officer REST API", description = "REST API to approve the Counter Refund by Officer")
// RefundApproval by Officer // RefundApproval by Officer
@PostMapping("/approveRefund/{id}") @PostMapping("/approveRefund/{id}")
public ResponseEntity<String> approveRefund(@PathVariable int id) { public ResponseEntity<String> approveRefund(@PathVariable int id) {
@ -529,10 +499,7 @@ public class OfficerAPIController {
} }
} }
@Operation(
summary = "Counter Refund Reject by Officer REST API",
description = "REST API to Reject the Counter Refund by Officer"
)
@Operation(summary = "Counter Refund Reject by Officer REST API", description = "REST API to Reject the Counter Refund by Officer")
// RefundReject by Officer // RefundReject by Officer
@PostMapping("/rejectRefund/{id}") @PostMapping("/rejectRefund/{id}")
public ResponseEntity<String> rejectRefund(@PathVariable int id) { public ResponseEntity<String> rejectRefund(@PathVariable int id) {
@ -548,10 +515,7 @@ public class OfficerAPIController {
} }
} }
@Operation(
summary = "Reason By reasonName REST API",
description = "REST API to get the Reason Details with the reason"
)
@Operation(summary = "Reason By reasonName REST API", description = "REST API to get the Reason Details with the reason")
// retrieving the Reason Details with the reason // retrieving the Reason Details with the reason
@GetMapping("/getReasonByName") @GetMapping("/getReasonByName")
public ResponseEntity<?> getReasonByName(@RequestParam String reasonName) { public ResponseEntity<?> getReasonByName(@RequestParam String reasonName) {
@ -591,9 +555,11 @@ public class OfficerAPIController {
@RequestParam("status") BookingDetails.RefundStatus status) { @RequestParam("status") BookingDetails.RefundStatus status) {
try { try {
// Update refund status preliminarily // Update refund status preliminarily
// //BookingDetails updatedBooking = bookingService.updateRefundStatus(bookingId, status);
// //BookingDetails updatedBooking =
// bookingService.updateRefundStatus(bookingId, status);
// if (updatedBooking == null) { // if (updatedBooking == null) {
// return new ResponseEntity<>("Booking not found for ID: " + bookingId, HttpStatus.NOT_FOUND);
// return new ResponseEntity<>("Booking not found for ID: " + bookingId,
// HttpStatus.NOT_FOUND);
// } // }
// Log the action // Log the action
@ -629,11 +595,11 @@ public class OfficerAPIController {
} }
} catch (Exception e) { } catch (Exception e) {
return new ResponseEntity<>("An error occurred while processing the refund for Booking ID: " + bookingId, HttpStatus.INTERNAL_SERVER_ERROR);
return new ResponseEntity<>("An error occurred while processing the refund for Booking ID: " + bookingId,
HttpStatus.INTERNAL_SERVER_ERROR);
} }
} }
@GetMapping("/bookingstatistics") @GetMapping("/bookingstatistics")
public ResponseEntity<Map<String, Map<String, Integer>>> getBookingStatistics( public ResponseEntity<Map<String, Map<String, Integer>>> getBookingStatistics(
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate, @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate,
@ -643,18 +609,15 @@ public class OfficerAPIController {
@RequestParam(required = false, defaultValue = "1000") Integer hallid, @RequestParam(required = false, defaultValue = "1000") Integer hallid,
@RequestParam(required = false) String userType) { @RequestParam(required = false) String userType) {
String zone = (String) session.getAttribute("zone"); String zone = (String) session.getAttribute("zone");
Map<String, Map<String, Integer>> statistics = bookingService.getOfficerDashboard(fromDate, toDate, zone, division, hallid, userType);
Map<String, Map<String, Integer>> statistics = bookingService.getOfficerDashboard(fromDate, toDate, zone,
division, hallid, userType);
return ResponseEntity.ok(statistics); return ResponseEntity.ok(statistics);
} }
@GetMapping("/getHallsDetailsByZone") @GetMapping("/getHallsDetailsByZone")
public ResponseEntity<Map<String, Object>> getHallsDetailsByZone(@RequestParam String zone)
{
public ResponseEntity<Map<String, Object>> getHallsDetailsByZone(@RequestParam String zone) {
Map<String, Object> hallzones = hallDetailService.getHallsDetailsForOfficer(zone); Map<String, Object> hallzones = hallDetailService.getHallsDetailsForOfficer(zone);
return ResponseEntity.ok(hallzones); return ResponseEntity.ok(hallzones);
@ -676,6 +639,7 @@ public class OfficerAPIController {
public List<BookingDetails> getRejectedBookingDetails() { public List<BookingDetails> getRejectedBookingDetails() {
return bookingService.getRejectedBookingDetails(); return bookingService.getRejectedBookingDetails();
} }
@GetMapping("/getwaitingforNOCapproval") @GetMapping("/getwaitingforNOCapproval")
public List<BookingDetails> getWaitingforNOCapproval() { public List<BookingDetails> getWaitingforNOCapproval() {
return bookingService.getWaitingforNOCapproval(); return bookingService.getWaitingforNOCapproval();

207
src/main/java/com/gcc/communityHall/entity/HallRequestDetails.java

@ -0,0 +1,207 @@
package com.gcc.communityHall.entity;
import jakarta.persistence.*;
import java.time.LocalDateTime;
@Entity
@Table(name = "hall_request_details")
public class HallRequestDetails {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "req_id")
private Integer reqId;
@Column(name = "booking_id")
private Integer bookingId;
@Column(name = "start_date")
private String startDate;
@Column(name = "end_date")
private String endDate;
@Column(name = "starting_slot")
private Integer startingSlot;
@Column(name = "ending_slot")
private Integer endingSlot;
@Column(name = "reason")
private String reason;
@Column(name = "booking_status")
private String bookingStatus;
@Column(name = "hall_id")
private Integer hallId;
@Column(name = "user_id")
private Integer userId;
@Column(name = "org_type", length = 15)
private String orgType;
@Column(name = "event_description")
private String eventDescription;
@Column(name = "office_details")
private String officeDetails;
@Column(name = "bonafide_path")
private String bonafidePath;
@Column(name = "cdate", insertable = false, updatable = false)
private LocalDateTime cdate;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private BookingDetails bookingDetails;
// @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
// private Users users;
// @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
// private HallDetails hallDetails;
// Getters and Setters
public Integer getReqId() {
return reqId;
}
public void setReqId(Integer reqId) {
this.reqId = reqId;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public Integer getStartingSlot() {
return startingSlot;
}
public void setStartingSlot(Integer startingSlot) {
this.startingSlot = startingSlot;
}
public Integer getEndingSlot() {
return endingSlot;
}
public void setEndingSlot(Integer endingSlot) {
this.endingSlot = endingSlot;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public String getBookingStatus() {
return bookingStatus;
}
public void setBookingStatus(String bookingStatus) {
this.bookingStatus = bookingStatus;
}
public Integer getHallId() {
return hallId;
}
public void setHallId(Integer hallId) {
this.hallId = hallId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getOrgType() {
return orgType;
}
public void setOrgType(String orgType) {
this.orgType = orgType;
}
public String getEventDescription() {
return eventDescription;
}
public void setEventDescription(String eventDescription) {
this.eventDescription = eventDescription;
}
public String getOfficeDetails() {
return officeDetails;
}
public void setOfficeDetails(String officeDetails) {
this.officeDetails = officeDetails;
}
public String getBonafidePath() {
return bonafidePath;
}
public void setBonafidePath(String bonafidePath) {
this.bonafidePath = bonafidePath;
}
public LocalDateTime getCdate() {
return cdate;
}
// public Users getUsers() {
// return users;
// }
// public void setUsers(Users users) {
// this.users = users;
// }
// public HallDetails getHallDetails() {
// return hallDetails;
// }
// public void setHallDetails(HallDetails hallDetails) {
// this.hallDetails = hallDetails;
// }
public Integer getBookingId() {
return bookingId;
}
public void setBookingId(Integer bookingId) {
this.bookingId = bookingId;
}
public BookingDetails getBookingDetails() {
return bookingDetails;
}
public void setBookingDetails(BookingDetails bookingDetails) {
this.bookingDetails = bookingDetails;
}
}

19
src/main/java/com/gcc/communityHall/entity/ReasonMaster.java

@ -23,6 +23,9 @@ public class ReasonMaster {
private String updatedBy; private String updatedBy;
private int maxdays; private int maxdays;
private boolean isActive;
private boolean isDelete;
@OneToMany(mappedBy = "reasonMaster", fetch = FetchType.LAZY, cascade = CascadeType.ALL) @OneToMany(mappedBy = "reasonMaster", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<ReasonDocumentMaster> reasonDocumentMasterList; private List<ReasonDocumentMaster> reasonDocumentMasterList;
@ -82,4 +85,20 @@ public class ReasonMaster {
this.reasoncode = reasoncode; this.reasoncode = reasoncode;
} }
public void setActive(boolean isActive) {
this.isActive = isActive;
}
public boolean getActive() {
return isActive;
}
public void setDelete(boolean isDelete) {
this.isDelete = isDelete;
}
public boolean getDelete() {
return isDelete;
}
} }

1
src/main/java/com/gcc/communityHall/exception/PaymentRefundSlotOccupiedException.java

@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
public class PaymentRefundSlotOccupiedException extends RuntimeException { public class PaymentRefundSlotOccupiedException extends RuntimeException {
// @Autowired // @Autowired
// BookingService bookingService; // BookingService bookingService;

668
src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java

@ -41,7 +41,6 @@ import com.gcc.communityHall.service.UserService;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
@Controller @Controller
@RequestMapping("/victoriahallbooking/payment") @RequestMapping("/victoriahallbooking/payment")
public class PaymentController { public class PaymentController {
@ -122,7 +121,8 @@ public String response(Model model, @RequestParam(required = false) String msg)
try { try {
amount = Double.parseDouble(response.getAmount()); amount = Double.parseDouble(response.getAmount());
} catch (Exception e) {}
} catch (Exception e) {
}
payment.setAmountReceived(amount); payment.setAmountReceived(amount);
payment.setPaymentStatus("Not Completed"); payment.setPaymentStatus("Not Completed");
@ -191,212 +191,253 @@ public String response(Model model, @RequestParam(required = false) String msg)
return "redirect:/victoriahallbooking/user/acknowledgement?ref_id=" + refId; return "redirect:/victoriahallbooking/user/acknowledgement?ref_id=" + refId;
} }
/* @PostMapping(value = "/response")
public String response(Model model, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException {
String salt = this.paymentConfig.getEncryptionKey();
String confirmToken = "";
String status = this.paymentConfig.getTransactionSuccessCode();
String s = new String(msg);
String c = new String();
String res[] = s.split("\\|");
TransactionResponse response = this.paymentService.getTransactionResponseByTxansactionId(res[3], "temp");
Payments payment = new Payments();
payment.setTransactionId(response.getTxansactionId());
double amount = 0;
for (int i = 0; i < res.length; i++) {
if (i == res.length - 1) {
c = c + salt;
confirmToken = res[i];
} else if (res[i].isEmpty()) {
c = c + "|";
} else if (res[i].equals("NA")) {
c = c + "NA|";
} else {
c = c + res[i] + "|";
}
if (i == 5) {
response.setTpslTxnId(res[i]);
response.setAmount(res[6]);
response.setTxansactionId(res[3]);
//String[] tDate = res[8].split(" ");
response.setDate(res[8]);
}
}
int bookingId = response.getBookingId();
try {
amount = Double.parseDouble(response.getAmount());
} catch (Exception e) {
// TODO: handle exception
//System.out.println("payment Controller lineNo-67");
}
payment.setAmountReceived(amount);
payment.setPaymentStatus("Not Completed");
BookingDetails bookingsDetails = bookser.getBookingsById(bookingId);
payment.setBookingDetails(bookingsDetails);
response.setResponse(msg);
response.setStatusCode(res[0]);
bookingsDetails.setPayments(payment);
payment.setCdate(new Date());
System.out.println("bookingsDetails.getAmountReceived().." + bookingsDetails.getAmountReceived());
System.out.println("amount: " + amount);
TransactionResponse save = transactionResRepo.save(response);
if (bookingsDetails.getAmountReceived() != amount) { // Reject booking if the amount is incorrect
if(paymentService.generateToken(c).equals(confirmToken) && status.equals(res[0])){
payment.setPaymentStatus("Success");
bookingsDetails.setPayments(payment);
paymentRepo.save(payment);
bookser.bookingFailure(bookingsDetails, 1);
}
//ak
model.addAttribute("bookingsDetails", bookingsDetails);
return "redirect:/victoriahallbooking/user/acknowledgement?bookingId=" + bookingsDetails.getBookingId();
}
if (paymentService.generateToken(c).equals(confirmToken) && status.equals(res[0])) {
payment.setPaymentStatus("Success");
bookingsDetails.setPayments(payment);
try {
String confirmBooking = bookser.confirmBooking(response.getBookingId());
}catch (Exception e){
// return "redirect:/communityhall/user/acknowledgement?bookingId=" + bookingsDetails.getBookingId();
}
// postDataToERP(payment, response); // post payment details to ERP
// System.out.println("\n confirmBooking:- paymentController 111"+confirmBooking+"\n");
// if(confirmBooking.equals("Booking confirmed successfully")) {
// //bookser.updateBookingStatusById(bookingsDetails.getBookingId(), BookingDetails.BookingStatus.APPROVED, "confirm");
// // String bookingconfimationsms = "Your booking with ID "+bookingsDetails.getBookingId()+" on" +bookingsDetails.getBookingId()+" has been successfully confirmed. Thanks for using GCC Community Hall Booking System.";
// }else if(confirmBooking.equals("Slot occupied")) {
//// System.out.println("Slot occupied line 115");
//// BookingDetails crrSts = bookser.updateBookingStatusById(bookingsDetails.getBookingId(), BookingDetails.BookingStatus.REFUNDED, "slot occupied Refund will happen shortly");
//// System.out.println("BookingDetails:-"+crrSts.getBookingStatus());
// }
// else if(confirmBooking.equals("Error confirming booking")) {
// bookser.updateBookingStatusById(bookingsDetails.getBookingId(), BookingDetails.BookingStatus.PENDING, "Error");
//
// }
}
// System.out.println(response.toString());
model.addAttribute("bookingsDetails", bookingsDetails); // Add single BookingDetails object
//System.out.println(save.toString());
paymentRepo.save(payment);
return "redirect:/victoriahallbooking/user/acknowledgement?bookingId=" + bookingsDetails.getBookingId();
}*/
/*public void postDataToERP(Payments payment, TransactionResponse res) {
RestTemplate restTemplate = new RestTemplate();
erpPostData erpData = new erpPostData();
SimpleDateFormat outputFormat = new SimpleDateFormat("dd/MM/yyyy");
String txDate = outputFormat.format(payment.getCdate());
String assesNo = LocalDate.now().getYear() + "/COMM/" + res.getBookingId();
Map<String, Object> data = new TreeMap<>();
/*
* @PostMapping(value = "/response")
* public String response(Model model, @RequestParam(required = false) String
* msg) throws NoSuchAlgorithmException {
*
* String salt = this.paymentConfig.getEncryptionKey();
*
* String confirmToken = "";
* String status = this.paymentConfig.getTransactionSuccessCode();
* String s = new String(msg);
* String c = new String();
* String res[] = s.split("\\|");
*
* TransactionResponse response =
* this.paymentService.getTransactionResponseByTxansactionId(res[3], "temp");
* Payments payment = new Payments();
* payment.setTransactionId(response.getTxansactionId());
* double amount = 0;
*
*
* for (int i = 0; i < res.length; i++) {
* if (i == res.length - 1) {
* c = c + salt;
* confirmToken = res[i];
* } else if (res[i].isEmpty()) {
* c = c + "|";
* } else if (res[i].equals("NA")) {
* c = c + "NA|";
* } else {
* c = c + res[i] + "|";
* }
*
* if (i == 5) {
* response.setTpslTxnId(res[i]);
* response.setAmount(res[6]);
* response.setTxansactionId(res[3]);
* //String[] tDate = res[8].split(" ");
* response.setDate(res[8]);
* }
* }
* int bookingId = response.getBookingId();
* try {
* amount = Double.parseDouble(response.getAmount());
* } catch (Exception e) {
* // TODO: handle exception
* //System.out.println("payment Controller lineNo-67");
* }
* payment.setAmountReceived(amount);
* payment.setPaymentStatus("Not Completed");
*
* BookingDetails bookingsDetails = bookser.getBookingsById(bookingId);
* payment.setBookingDetails(bookingsDetails);
* response.setResponse(msg);
* response.setStatusCode(res[0]);
* bookingsDetails.setPayments(payment);
* payment.setCdate(new Date());
*
* System.out.println("bookingsDetails.getAmountReceived().." +
* bookingsDetails.getAmountReceived());
* System.out.println("amount: " + amount);
*
* TransactionResponse save = transactionResRepo.save(response);
*
* if (bookingsDetails.getAmountReceived() != amount) { // Reject booking if the
* amount is incorrect
* if(paymentService.generateToken(c).equals(confirmToken) &&
* status.equals(res[0])){
* payment.setPaymentStatus("Success");
* bookingsDetails.setPayments(payment);
* paymentRepo.save(payment);
* bookser.bookingFailure(bookingsDetails, 1);
* }
* //ak
*
*
*
* model.addAttribute("bookingsDetails", bookingsDetails);
* return "redirect:/victoriahallbooking/user/acknowledgement?bookingId=" +
* bookingsDetails.getBookingId();
* }
*
*
* if (paymentService.generateToken(c).equals(confirmToken) &&
* status.equals(res[0])) {
* payment.setPaymentStatus("Success");
* bookingsDetails.setPayments(payment);
* try {
* String confirmBooking = bookser.confirmBooking(response.getBookingId());
* }catch (Exception e){
* // return "redirect:/communityhall/user/acknowledgement?bookingId=" +
* bookingsDetails.getBookingId();
*
* }
* // postDataToERP(payment, response); // post payment details to ERP
* //
* System.out.println("\n confirmBooking:- paymentController 111"+confirmBooking
* +"\n");
* // if(confirmBooking.equals("Booking confirmed successfully")) {
* // //bookser.updateBookingStatusById(bookingsDetails.getBookingId(),
* BookingDetails.BookingStatus.APPROVED, "confirm");
* // // String bookingconfimationsms =
* "Your booking with ID "+bookingsDetails.getBookingId()+" on"
* +bookingsDetails.getBookingId()
* +" has been successfully confirmed. Thanks for using GCC Community Hall Booking System."
* ;
* // }else if(confirmBooking.equals("Slot occupied")) {
* //// System.out.println("Slot occupied line 115");
* //// BookingDetails crrSts =
* bookser.updateBookingStatusById(bookingsDetails.getBookingId(),
* BookingDetails.BookingStatus.REFUNDED,
* "slot occupied Refund will happen shortly");
* //// System.out.println("BookingDetails:-"+crrSts.getBookingStatus());
* // }
* // else if(confirmBooking.equals("Error confirming booking")) {
* // bookser.updateBookingStatusById(bookingsDetails.getBookingId(),
* BookingDetails.BookingStatus.PENDING, "Error");
* //
* // }
*
* }
*
* // System.out.println(response.toString());
* model.addAttribute("bookingsDetails", bookingsDetails); // Add single
* BookingDetails object
* //System.out.println(save.toString());
* paymentRepo.save(payment);
* return "redirect:/victoriahallbooking/user/acknowledgement?bookingId=" +
* bookingsDetails.getBookingId();
* }
*/
/*
* public void postDataToERP(Payments payment, TransactionResponse res) {
* RestTemplate restTemplate = new RestTemplate();
* erpPostData erpData = new erpPostData();
*
* SimpleDateFormat outputFormat = new SimpleDateFormat("dd/MM/yyyy");
* String txDate = outputFormat.format(payment.getCdate());
* String assesNo = LocalDate.now().getYear() + "/COMM/" + res.getBookingId();
*
* Map<String, Object> data = new TreeMap<>();
*//* static mandatory input to be sent *//* *//* static mandatory input to be sent *//*
data.put("serviceId", "getOtherCollection");
data.put("COLLECTION_TYPE", "Community Hall");
data.put("TOTALTRANSACTIONCODE", "450310000");
// /end of static/
// /unique data to be send/
data.put("ASSESSMENTNO", assesNo);
data.put("UNIQUERECEIPTID", res.getBookingId());
data.put("TRANSACTIONNO", payment.getTransactionId());
data.put("TRANSACTIONREFNO", res.getTpslTxnId());
data.put("TRANSACTIONDATE", txDate); //payment date format dd/mm/yyyy -> 19/02/2025
data.put("TOTALTRANSACTIONAMOUNT", payment.getBookingDetails().getAmountReceived());
data.put("MSTRCODEONE", "061");
data.put("SPLITAMOUNTONE", payment.getBookingDetails().getHallAmount());
data.put("MSTRCODETWO", "062");
data.put("SPLITAMOUNTTWO", payment.getBookingDetails().getDepositAmount());
data.put("MSTRCODETHREE", "063");
data.put("SPLITAMOUNTTHREE", payment.getBookingDetails().getGst());
// /Amount Collected from party/
data.put("PARTYNAME", payment.getBookingDetails().getUsers().getName());
data.put("PARTYADDRESS", payment.getBookingDetails().getUsers().getStreet() + "," +
payment.getBookingDetails().getUsers().getArea() + "," + payment.getBookingDetails().getUsers().getLocation() + "," +
payment.getBookingDetails().getUsers().getPinCode());
data.put("PARTYMOBILE", payment.getBookingDetails().getUsers().getMobileNo());
* data.put("serviceId", "getOtherCollection");
* data.put("COLLECTION_TYPE", "Community Hall");
* data.put("TOTALTRANSACTIONCODE", "450310000");
* // /end of static/
* // /unique data to be send/
* data.put("ASSESSMENTNO", assesNo);
* data.put("UNIQUERECEIPTID", res.getBookingId());
* data.put("TRANSACTIONNO", payment.getTransactionId());
* data.put("TRANSACTIONREFNO", res.getTpslTxnId());
* data.put("TRANSACTIONDATE", txDate); //payment date format dd/mm/yyyy
* -> 19/02/2025
* data.put("TOTALTRANSACTIONAMOUNT",
* payment.getBookingDetails().getAmountReceived());
*
* data.put("MSTRCODEONE", "061");
* data.put("SPLITAMOUNTONE",
* payment.getBookingDetails().getHallAmount());
* data.put("MSTRCODETWO", "062");
* data.put("SPLITAMOUNTTWO",
* payment.getBookingDetails().getDepositAmount());
* data.put("MSTRCODETHREE", "063");
* data.put("SPLITAMOUNTTHREE", payment.getBookingDetails().getGst());
* // /Amount Collected from party/
* data.put("PARTYNAME",
* payment.getBookingDetails().getUsers().getName());
* data.put("PARTYADDRESS",
* payment.getBookingDetails().getUsers().getStreet() + "," +
* payment.getBookingDetails().getUsers().getArea() + "," +
* payment.getBookingDetails().getUsers().getLocation() + "," +
* payment.getBookingDetails().getUsers().getPinCode());
* data.put("PARTYMOBILE",
* payment.getBookingDetails().getUsers().getMobileNo());
*//* end *//* *//* end *//*
System.out.println(data);
System.out.println(appConfig.getCommErpUrl());
// ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity(appConfig.getErpUrl(), data, String.class);
// System.out.println(stringResponseEntity.getBody());
erpData.setTx_id(payment.getTransactionId());
erpData.setBooking_det_booking_id(res.getBookingId());
erpData.setStatus(true);
erpData.setCdate(LocalDate.now());
erpData.setPay_status(1);
erpPostDataRepository.save(erpData);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(appConfig.getCommErpUrl());
for (Map.Entry<String, Object> entry : data.entrySet()) {
builder.queryParam(entry.getKey(), entry.getValue());
}
String urlMsg = builder.toUriString();
System.out.println(urlMsg);
try {
HttpURLConnection connection = null;
URL url = new URL(urlMsg);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
int responseCode = connection.getResponseCode();
// response=responseCode+"";
System.out.println("Response Code: " + responseCode);
if (responseCode == HttpURLConnection.HTTP_OK) { // 200 OK
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println("Response: " + response.toString());
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(response.toString());
String resultStatus = jsonNode.get("ResultStatus").asText();
if (!resultStatus.isEmpty() && resultStatus.equals("false")) {
erpData.setStatus(false);
erpPostDataRepository.save(erpData);
}
} else {
System.out.println("GET request failed.");
}
} catch (Exception e) {
e.printStackTrace();
}
}*/
* System.out.println(data);
* System.out.println(appConfig.getCommErpUrl());
* // ResponseEntity<String> stringResponseEntity =
* restTemplate.postForEntity(appConfig.getErpUrl(), data,
* String.class);
* // System.out.println(stringResponseEntity.getBody());
*
* erpData.setTx_id(payment.getTransactionId());
* erpData.setBooking_det_booking_id(res.getBookingId());
* erpData.setStatus(true);
* erpData.setCdate(LocalDate.now());
* erpData.setPay_status(1);
* erpPostDataRepository.save(erpData);
*
* UriComponentsBuilder builder =
* UriComponentsBuilder.fromHttpUrl(appConfig.getCommErpUrl())
* ;
* for (Map.Entry<String, Object> entry : data.entrySet()) {
* builder.queryParam(entry.getKey(), entry.getValue());
* }
*
* String urlMsg = builder.toUriString();
* System.out.println(urlMsg);
*
* try {
* HttpURLConnection connection = null;
*
* URL url = new URL(urlMsg);
* connection = (HttpURLConnection) url.openConnection();
* connection.setRequestMethod("GET");
*
* int responseCode = connection.getResponseCode();
* // response=responseCode+"";
* System.out.println("Response Code: " + responseCode);
*
* if (responseCode == HttpURLConnection.HTTP_OK) { // 200 OK
* BufferedReader in = new BufferedReader(new
* InputStreamReader(connection.getInputStream()));
* String inputLine;
* StringBuilder response = new StringBuilder();
* while ((inputLine = in.readLine()) != null) {
* response.append(inputLine);
* }
* in.close();
* System.out.println("Response: " + response.toString());
*
* ObjectMapper objectMapper = new ObjectMapper();
* JsonNode jsonNode =
* objectMapper.readTree(response.toString());
*
* String resultStatus =
* jsonNode.get("ResultStatus").asText();
*
* if (!resultStatus.isEmpty() &&
* resultStatus.equals("false")) {
* erpData.setStatus(false);
* erpPostDataRepository.save(erpData);
* }
*
* } else {
* System.out.println("GET request failed.");
* }
*
* } catch (Exception e) {
* e.printStackTrace();
* }
* }
*/
@PostMapping(value = "/additionaldamage-response") @PostMapping(value = "/additionaldamage-response")
public String additionaldamagePaymentresponse(Model model, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException {
public String additionaldamagePaymentresponse(Model model, @RequestParam(required = false) String msg)
throws NoSuchAlgorithmException {
String salt = this.paymentConfig.getEncryptionKey(); String salt = this.paymentConfig.getEncryptionKey();
@ -411,7 +452,6 @@ public String response(Model model, @RequestParam(required = false) String msg)
payment.setTransactionId(response.getTxansactionId()); payment.setTransactionId(response.getTxansactionId());
double amount = 0; double amount = 0;
for (int i = 0; i < res.length; i++) { for (int i = 0; i < res.length; i++) {
if (i == res.length - 1) { if (i == res.length - 1) {
c = c + salt; c = c + salt;
@ -463,107 +503,127 @@ public String response(Model model, @RequestParam(required = false) String msg)
model.addAttribute("bookingsDetails", bookingsDetails); model.addAttribute("bookingsDetails", bookingsDetails);
extraPaymentsRepository.save(payment); extraPaymentsRepository.save(payment);
// postEPDataToERP(payment, response); //post extra payments details to ERP // postEPDataToERP(payment, response); //post extra payments details to ERP
// return "redirect:/communityhall/user/collectionpendingacknowledgement?bookingId=" + bookingsDetails.getBookingId();
return "redirect:/victoriahallbooking/user/collectionpendingacknowledgement?bookingId=" + bookingsDetails.getBookingId();
}
/*public void postEPDataToERP(ExtraPayments payment, TransactionResponse res) {
RestTemplate restTemplate = new RestTemplate();
erpPostData erpData = new erpPostData();
SimpleDateFormat outputFormat = new SimpleDateFormat("dd/MM/yyyy");
String txDate = outputFormat.format(payment.getCdate());
String assesNo = LocalDate.now().getYear() + "/COMM/ED/" + res.getBookingId();
Map<String, Object> data = new TreeMap<>();
// return
// "redirect:/communityhall/user/collectionpendingacknowledgement?bookingId=" +
// bookingsDetails.getBookingId();
return "redirect:/victoriahallbooking/user/collectionpendingacknowledgement?bookingId="
+ bookingsDetails.getBookingId();
}
/*
* public void postEPDataToERP(ExtraPayments payment, TransactionResponse res) {
* RestTemplate restTemplate = new RestTemplate();
* erpPostData erpData = new erpPostData();
*
* SimpleDateFormat outputFormat = new SimpleDateFormat("dd/MM/yyyy");
* String txDate = outputFormat.format(payment.getCdate());
* String assesNo = LocalDate.now().getYear() + "/COMM/ED/" +
* res.getBookingId();
*
* Map<String, Object> data = new TreeMap<>();
*//* static mandatory input to be sent *//* *//* static mandatory input to be sent *//*
data.put("serviceId", "getOtherCollection");
data.put("COLLECTION_TYPE", "Community Hall");
data.put("TOTALTRANSACTIONCODE", "450310000");
// /end of static/
// /unique data to be send/
data.put("ASSESSMENTNO", assesNo);
data.put("UNIQUERECEIPTID", res.getBookingId());
data.put("TRANSACTIONNO", payment.getTransactionId());
data.put("TRANSACTIONREFNO", res.getTpslTxnId());
data.put("TRANSACTIONDATE", txDate); //payment date format dd/mm/yyyy -> 19/02/2025
data.put("TOTALTRANSACTIONAMOUNT", payment.getAmountReceived());
data.put("MSTRCODEONE", "061");
data.put("SPLITAMOUNTONE", 0);
data.put("MSTRCODETWO", "062");
data.put("SPLITAMOUNTTWO", payment.getAmountReceived());
data.put("MSTRCODETHREE", "063");
data.put("SPLITAMOUNTTHREE", 0);
// /Amount Collected from party/
data.put("PARTYNAME", payment.getBookingDetails().getUsers().getName());
data.put("PARTYADDRESS", payment.getBookingDetails().getUsers().getStreet() + "," +
payment.getBookingDetails().getUsers().getArea() + "," + payment.getBookingDetails().getUsers().getLocation() + "," +
payment.getBookingDetails().getUsers().getPinCode());
data.put("PARTYMOBILE", payment.getBookingDetails().getUsers().getMobileNo());
* data.put("serviceId", "getOtherCollection");
* data.put("COLLECTION_TYPE", "Community Hall");
* data.put("TOTALTRANSACTIONCODE", "450310000");
* // /end of static/
* // /unique data to be send/
* data.put("ASSESSMENTNO", assesNo);
* data.put("UNIQUERECEIPTID", res.getBookingId());
* data.put("TRANSACTIONNO", payment.getTransactionId());
* data.put("TRANSACTIONREFNO", res.getTpslTxnId());
* data.put("TRANSACTIONDATE", txDate); //payment date format dd/mm/yyyy
* -> 19/02/2025
* data.put("TOTALTRANSACTIONAMOUNT", payment.getAmountReceived());
*
* data.put("MSTRCODEONE", "061");
* data.put("SPLITAMOUNTONE", 0);
* data.put("MSTRCODETWO", "062");
* data.put("SPLITAMOUNTTWO", payment.getAmountReceived());
* data.put("MSTRCODETHREE", "063");
* data.put("SPLITAMOUNTTHREE", 0);
* // /Amount Collected from party/
* data.put("PARTYNAME",
* payment.getBookingDetails().getUsers().getName());
* data.put("PARTYADDRESS",
* payment.getBookingDetails().getUsers().getStreet() + "," +
* payment.getBookingDetails().getUsers().getArea() + "," +
* payment.getBookingDetails().getUsers().getLocation() + "," +
* payment.getBookingDetails().getUsers().getPinCode());
* data.put("PARTYMOBILE",
* payment.getBookingDetails().getUsers().getMobileNo());
*//* end *//* *//* end *//*
System.out.println(data);
System.out.println(appConfig.getCommErpUrl());
// ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity(appConfig.getErpUrl(), data, String.class);
// System.out.println(stringResponseEntity.getBody());
erpData.setTx_id(payment.getTransactionId());
erpData.setBooking_det_booking_id(res.getBookingId());
erpData.setStatus(true);
erpData.setCdate(LocalDate.now());
erpData.setPay_status(2);
erpPostDataRepository.save(erpData);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(appConfig.getCommErpUrl());
for (Map.Entry<String, Object> entry : data.entrySet()) {
builder.queryParam(entry.getKey(), entry.getValue());
}
String urlMsg = builder.toUriString();
System.out.println(urlMsg);
try {
HttpURLConnection connection = null;
URL url = new URL(urlMsg);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
int responseCode = connection.getResponseCode();
// response=responseCode+"";
System.out.println("Response Code: " + responseCode);
if (responseCode == HttpURLConnection.HTTP_OK) { // 200 OK
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println("Response: " + response.toString());
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(response.toString());
String resultStatus = jsonNode.get("ResultStatus").asText();
if (!resultStatus.isEmpty() && resultStatus.equals("false")) {
erpData.setStatus(false);
erpPostDataRepository.save(erpData);
}
} else {
System.out.println("GET request failed.");
}
} catch (Exception e) {
e.printStackTrace();
}
}*/
* System.out.println(data);
* System.out.println(appConfig.getCommErpUrl());
* // ResponseEntity<String> stringResponseEntity =
* restTemplate.postForEntity(appConfig.getErpUrl(), data,
* String.class);
* // System.out.println(stringResponseEntity.getBody());
*
* erpData.setTx_id(payment.getTransactionId());
* erpData.setBooking_det_booking_id(res.getBookingId());
* erpData.setStatus(true);
* erpData.setCdate(LocalDate.now());
* erpData.setPay_status(2);
* erpPostDataRepository.save(erpData);
*
* UriComponentsBuilder builder =
* UriComponentsBuilder.fromHttpUrl(appConfig.getCommErpUrl())
* ;
* for (Map.Entry<String, Object> entry : data.entrySet()) {
* builder.queryParam(entry.getKey(), entry.getValue());
* }
*
* String urlMsg = builder.toUriString();
* System.out.println(urlMsg);
*
* try {
* HttpURLConnection connection = null;
*
* URL url = new URL(urlMsg);
* connection = (HttpURLConnection) url.openConnection();
* connection.setRequestMethod("GET");
*
* int responseCode = connection.getResponseCode();
* // response=responseCode+"";
* System.out.println("Response Code: " + responseCode);
*
* if (responseCode == HttpURLConnection.HTTP_OK) { // 200 OK
* BufferedReader in = new BufferedReader(new
* InputStreamReader(connection.getInputStream()));
* String inputLine;
* StringBuilder response = new StringBuilder();
* while ((inputLine = in.readLine()) != null) {
* response.append(inputLine);
* }
* in.close();
* System.out.println("Response: " + response.toString());
*
* ObjectMapper objectMapper = new ObjectMapper();
* JsonNode jsonNode =
* objectMapper.readTree(response.toString());
*
* String resultStatus =
* jsonNode.get("ResultStatus").asText();
*
* if (!resultStatus.isEmpty() &&
* resultStatus.equals("false")) {
* erpData.setStatus(false);
* erpPostDataRepository.save(erpData);
* }
*
* } else {
* System.out.println("GET request failed.");
* }
*
* } catch (Exception e) {
* e.printStackTrace();
* }
* }
*/
@PostMapping(value = "/updatetransaction") @PostMapping(value = "/updatetransaction")
public String updatetransaction(Model model, @RequestParam(required = false) String txansactionId, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException {
public String updatetransaction(Model model, @RequestParam(required = false) String txansactionId,
@RequestParam(required = false) String msg) throws NoSuchAlgorithmException {
Optional<TransactionResponse> transactionresponse = transactionResRepo.findByTxansactionId(txansactionId); Optional<TransactionResponse> transactionresponse = transactionResRepo.findByTxansactionId(txansactionId);
TransactionResponse transactionres = transactionresponse.get(); TransactionResponse transactionres = transactionresponse.get();
@ -581,7 +641,6 @@ public String response(Model model, @RequestParam(required = false) String msg)
payment.setTransactionId(response.getTxansactionId()); payment.setTransactionId(response.getTxansactionId());
double amount = 0; double amount = 0;
for (int i = 0; i < res.length; i++) { for (int i = 0; i < res.length; i++) {
if (i == res.length - 1) { if (i == res.length - 1) {
c = c + salt; c = c + salt;
@ -639,7 +698,8 @@ public String response(Model model, @RequestParam(required = false) String msg)
} }
@PostMapping(value = "/refundcompleted") @PostMapping(value = "/refundcompleted")
public String refundCompleted(Model model, @RequestParam String txansactionId, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException {
public String refundCompleted(Model model, @RequestParam String txansactionId,
@RequestParam(required = false) String msg) throws NoSuchAlgorithmException {
Optional<TransactionResponse> transactionresponse = transactionResRepo.findByTxansactionId(txansactionId); Optional<TransactionResponse> transactionresponse = transactionResRepo.findByTxansactionId(txansactionId);
if (transactionresponse.isPresent()) { if (transactionresponse.isPresent()) {
TransactionResponse transactionres = transactionresponse.get(); TransactionResponse transactionres = transactionresponse.get();

56
src/main/java/com/gcc/communityHall/paymentService/repository/TransactionResponseRepository.java

@ -11,21 +11,21 @@ import org.springframework.stereotype.Repository;
import com.gcc.communityHall.paymentService.entity.TransactionResponse; import com.gcc.communityHall.paymentService.entity.TransactionResponse;
@Repository @Repository
public interface TransactionResponseRepository extends JpaRepository<TransactionResponse, Integer> { public interface TransactionResponseRepository extends JpaRepository<TransactionResponse, Integer> {
Optional<TransactionResponse> findByBookingId(int bookingId); Optional<TransactionResponse> findByBookingId(int bookingId);
List<TransactionResponse> findByuserId(String userId); List<TransactionResponse> findByuserId(String userId);
Optional<TransactionResponse> findByTxansactionId(String txansactionId); Optional<TransactionResponse> findByTxansactionId(String txansactionId);
Optional<TransactionResponse> findByTxansactionIdAndStatusCode(String txansactionId, String statusCode); Optional<TransactionResponse> findByTxansactionIdAndStatusCode(String txansactionId, String statusCode);
Optional<TransactionResponse> findByBookingIdAndStatusCode(int bookingId, String statusCode); Optional<TransactionResponse> findByBookingIdAndStatusCode(int bookingId, String statusCode);
Optional<TransactionResponse> findByBookingIdAndTxansactionIdAndStatusCode(int bookingId,String txansactionId, String statusCode);
Optional<TransactionResponse> findByBookingIdAndTxansactionIdAndStatusCode(int bookingId, String txansactionId,
String statusCode);
@Query(value = "SELECT tr.booking_id, tr.hall_id, tr.amount, tr.status_code, tr.txansaction_id, tr.user_id " + @Query(value = "SELECT tr.booking_id, tr.hall_id, tr.amount, tr.status_code, tr.txansaction_id, tr.user_id " +
// ", p.payment_status " + // ", p.payment_status " +
@ -34,7 +34,8 @@ public interface TransactionResponseRepository extends JpaRepository<Transaction
// "LEFT JOIN payments p ON tr.booking_id = p.booking_details_booking_id " + // "LEFT JOIN payments p ON tr.booking_id = p.booking_details_booking_id " +
"LEFT JOIN booking_details bd ON tr.booking_id = bd.booking_id " + "LEFT JOIN booking_details bd ON tr.booking_id = bd.booking_id " +
"WHERE DATE(STR_TO_DATE(tr.cdate, '%Y-%m-%d')) >= STR_TO_DATE(:fromDate, '%Y-%m-%d') " + "WHERE DATE(STR_TO_DATE(tr.cdate, '%Y-%m-%d')) >= STR_TO_DATE(:fromDate, '%Y-%m-%d') " +
// "WHERE DATE(STR_TO_DATE(tr.cdate, '%d-%m-%Y %H:%i:%s')) >= STR_TO_DATE(:fromDate, '%Y-%m-%d') " +
// "WHERE DATE(STR_TO_DATE(tr.cdate, '%d-%m-%Y %H:%i:%s')) >=
// STR_TO_DATE(:fromDate, '%Y-%m-%d') " +
"AND DATE(STR_TO_DATE(tr.cdate, '%Y-%m-%d')) <= STR_TO_DATE(:toDate, '%Y-%m-%d') " + "AND DATE(STR_TO_DATE(tr.cdate, '%Y-%m-%d')) <= STR_TO_DATE(:toDate, '%Y-%m-%d') " +
"AND (:bookingId IS NULL OR tr.booking_id = :bookingId) " + "AND (:bookingId IS NULL OR tr.booking_id = :bookingId) " +
"AND (:hallId IS NULL OR tr.hall_id = :hallId)", nativeQuery = true) "AND (:hallId IS NULL OR tr.hall_id = :hallId)", nativeQuery = true)
@ -43,19 +44,38 @@ public interface TransactionResponseRepository extends JpaRepository<Transaction
@Param("bookingId") Long bookingId, @Param("bookingId") Long bookingId,
@Param("hallId") Long hallId); @Param("hallId") Long hallId);
// @Transactional // @Transactional
// @Query (value = "UPDATE transaction_response SET amount = :amount, booking_id =:booking_id , date = :date, hall_id = :hall_id, response = :response, status_code = :status_code, tpsl_txn_id = :tpsl_txn_id, txansaction_id = :txansaction_id, user_id = :user_id WHERE (id = :id)",nativeQuery = true)
// void updateTransactionResponse ( @Param("id") Integer id, @Param("amount") String amount, @Param("booking_id") int booking_id ,@Param("date" ) String date,@Param("hall_id" ) int hall_id ,@Param("response")String response,@Param("status_code")String status_code,@Param("tpsl_txn_id")String tpsl_txn_id,@Param("txansaction_id")String txansaction_id,@Param("user_id")String user_id );
// TransactionResponse saveTransactionResponse(Integer id, String amount, int bookingId, String date, int hallId, String response,
// @Query (value = "UPDATE transaction_response SET amount = :amount, booking_id
// =:booking_id , date = :date, hall_id = :hall_id, response = :response,
// status_code = :status_code, tpsl_txn_id = :tpsl_txn_id, txansaction_id =
// :txansaction_id, user_id = :user_id WHERE (id = :id)",nativeQuery = true)
// void updateTransactionResponse ( @Param("id") Integer id, @Param("amount")
// String amount, @Param("booking_id") int booking_id ,@Param("date" ) String
// date,@Param("hall_id" ) int hall_id ,@Param("response")String
// response,@Param("status_code")String status_code,@Param("tpsl_txn_id")String
// tpsl_txn_id,@Param("txansaction_id")String
// txansaction_id,@Param("user_id")String user_id );
// TransactionResponse saveTransactionResponse(Integer id, String amount, int
// bookingId, String date, int hallId, String response,
// String statusCode, String tpslTxnId, String txansactionId, String userId); // String statusCode, String tpslTxnId, String txansactionId, String userId);
// @Query(value = "INSERT INTO transaction_response ('id','amount','booking_id','date','hall_id','response','status_code','tpsl_txn_id','txansaction_id','user_id') VALUES (:id, :amount, :booking_id, :date, :hall_id, :response, :status_code, :tpsl_txn_id, :txansaction_id, :user_id)", nativeQuery = true)
// void saveTransactionResponse(@Param("id") int id, @Param("amount") String amount, @Param("booking_id") int booking_id ,@Param("date" ) String date,@Param("hall_id" ) int hall_id ,@Param("response")String response,@Param("status_code")String status_code,@Param("tpsl_txn_id")String tpsl_txn_id,@Param("txansaction_id")String txansaction_id,@Param("user_id")String user_id );
// @Query(value = "INSERT INTO transaction_response
// ('id','amount','booking_id','date','hall_id','response','status_code','tpsl_txn_id','txansaction_id','user_id')
// VALUES (:id, :amount, :booking_id, :date, :hall_id, :response, :status_code,
// :tpsl_txn_id, :txansaction_id, :user_id)", nativeQuery = true)
// void saveTransactionResponse(@Param("id") int id, @Param("amount") String
// amount, @Param("booking_id") int booking_id ,@Param("date" ) String
// date,@Param("hall_id" ) int hall_id ,@Param("response")String
// response,@Param("status_code")String status_code,@Param("tpsl_txn_id")String
// tpsl_txn_id,@Param("txansaction_id")String
// txansaction_id,@Param("user_id")String user_id );
// //
//@Query (value = "UPDATE transaction_response SET 'amount' = :amount, 'booking_id' =:booking_id , 'date' = :date, 'hall_id' = :hall_id, 'response' = :response, 'status_code' = :status_code, 'tpsl_txn_id' = :tpsl_txn_id, 'txansaction_id' = :txansaction_id, 'user_id' = :user_id WHERE ('id' = :id)", nativeQuery = true)
// @Query (value = "UPDATE transaction_response SET 'amount' = :amount,
// 'booking_id' =:booking_id , 'date' = :date, 'hall_id' = :hall_id, 'response'
// = :response, 'status_code' = :status_code, 'tpsl_txn_id' = :tpsl_txn_id,
// 'txansaction_id' = :txansaction_id, 'user_id' = :user_id WHERE ('id' = :id)",
// nativeQuery = true)
@Query(value = "SELECT tr.id, tr.amount, tr.booking_id, tr.hall_id, tr.response, tr.status_code, " + @Query(value = "SELECT tr.id, tr.amount, tr.booking_id, tr.hall_id, tr.response, tr.status_code, " +
"tr.tpsl_txn_id, tr.txansaction_id, tr.user_id, bd.booking_date " + "tr.tpsl_txn_id, tr.txansaction_id, tr.user_id, bd.booking_date " +
@ -64,10 +84,12 @@ public interface TransactionResponseRepository extends JpaRepository<Transaction
"WHERE tr.status_code = ? AND bd.booking_date < DATE_SUB(CURDATE(), INTERVAL 2 DAY", nativeQuery = true) "WHERE tr.status_code = ? AND bd.booking_date < DATE_SUB(CURDATE(), INTERVAL 2 DAY", nativeQuery = true)
List<Map<String, Object>> getTransactionResponseByStatus(String status); List<Map<String, Object>> getTransactionResponseByStatus(String status);
@Query(value = "SELECT tr.id, tr.amount, tr.booking_id, tr.hall_id, tr.response, tr.tpsl_txn_id, tr.txansaction_id, tr.cdate, " +
@Query(value = "SELECT tr.id, tr.amount, tr.booking_id, tr.hall_id, tr.response, tr.tpsl_txn_id, tr.txansaction_id, tr.cdate, "
+
"tr.user_id, bd.booking_date FROM transaction_response tr " + "tr.user_id, bd.booking_date FROM transaction_response tr " +
"INNER JOIN booking_details bd ON tr.booking_id = bd.booking_id " + "INNER JOIN booking_details bd ON tr.booking_id = bd.booking_id " +
"WHERE tr.status_code = 'temp' AND tr.cdate < DATE_SUB(NOW(), INTERVAL 1 HOUR);", nativeQuery = true) "WHERE tr.status_code = 'temp' AND tr.cdate < DATE_SUB(NOW(), INTERVAL 1 HOUR);", nativeQuery = true)
List<Map<String, Object>> getTransResBycdateandStatus(String status); List<Map<String, Object>> getTransResBycdateandStatus(String status);
boolean existsByBookingId(int bookingId);
} }

39
src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java

@ -1712,4 +1712,43 @@ public interface BookingDetailsRepository extends JpaRepository<BookingDetails,
" AND bd.counter_id IS NOT NULL " + " AND bd.counter_id IS NOT NULL " +
"GROUP BY bd.counter_id, bd.hall_details_hall_id ", nativeQuery = true) "GROUP BY bd.counter_id, bd.hall_details_hall_id ", nativeQuery = true)
List<Object> getCounterWiseBookingList(String fromDate, String toDate); List<Object> getCounterWiseBookingList(String fromDate, String toDate);
@Query(value = "SELECT "
+ " u.user_id as userId,"
+ " u.name as UserName,"
+ " u.mobile_no as UserMobile,"
+ " u. usertype as UserType,"
+ " CONCAT("
+ " IFNULL(u.doorno,''), ', ', "
+ " IFNULL(u.street,''), ', ', "
+ " IFNULL(u.area,''), ', ', "
+ " IFNULL(u.location,''), ' - ', "
+ " IFNULL(u.pin_code,'') "
+ " ) AS UserAddress, "
+ "hd.hall_name as hallName,"
+ " CONCAT("
+ " IFNULL(hd.door_no,''), ', ', "
+ " IFNULL(hd.street,''), ', ', "
+ " IFNULL(hd.area,''), ', ', "
+ " IFNULL(hd.city,''), ' - ', "
+ " IFNULL(hd.pin_code,'') "
+ " ) AS HallAddress, "
+ " hd.hall_incharge_name as CareTakerName,"
+ " hd.hall_incharge_no as CareTakerMobile,"
+ " bd.booking_id as bookingId,"
+ " bd.booking_date as bookingDate,"
+ " bd.start_date as start_date,"
+ " bd.end_date as end_date,"
+ "bd.deposit_amount as depositAmount,"
+ "bd.gst as gst,"
+ "bd.hall_amount as hallAmount,"
+ " bd.amount_received as totalAmount "
+ "FROM booking_details bd "
+ "INNER JOIN hall_request_details hrd "
+ "ON hrd.booking_id = bd.booking_id "
+ "LEFT JOIN hall_details hd ON hd.hall_id=bd.hall_details_hall_id "
+ "LEFT JOIN users u ON u.user_id=bd.users_user_id "
+ "WHERE bd.booking_id = :bookingId "
+ "AND hrd.booking_status = 'APPROVED'", nativeQuery = true)
List<Map<String, Object>> findApprovedBookingWithHallRequest(@Param("bookingId") int bookingId);
} }

39
src/main/java/com/gcc/communityHall/repository/HallRequestDetailsRepository.java

@ -0,0 +1,39 @@
package com.gcc.communityHall.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import com.gcc.communityHall.entity.HallRequestDetails;
@Repository
public interface HallRequestDetailsRepository extends JpaRepository<HallRequestDetails, Integer> {
@Query(value =" SELECT r.*, b.*, h.*, u.* "+
" FROM hall_request_details r "+
" JOIN booking_details b ON r.booking_id = b.booking_id "+
" JOIN hall_details h ON b.hall_details_hall_id = h.hall_id "+
" JOIN users u ON b.users_user_id = u.user_id "+
" WHERE b.booking_status = 'PENDING'", nativeQuery = true)
List<HallRequestDetails> findPendingRequests();
@Query("""
SELECT hrd FROM HallRequestDetails hrd
JOIN FETCH hrd.bookingDetails b
JOIN FETCH b.hallDetails
JOIN FETCH b.users
WHERE b.bookingStatus IN ('APPROVED', 'WAITING_FOR_NOC')
""")
List<HallRequestDetails> findApprovedRequests();
@Query("""
SELECT hrd FROM HallRequestDetails hrd
JOIN FETCH hrd.bookingDetails b
JOIN FETCH b.hallDetails
JOIN FETCH b.users
WHERE b.bookingStatus = 'REJECTED'
""")
List<HallRequestDetails> findRejectedRequests();
}

5
src/main/java/com/gcc/communityHall/repository/PaymentsRepository.java

@ -1,6 +1,5 @@
package com.gcc.communityHall.repository; package com.gcc.communityHall.repository;
import com.gcc.communityHall.entity.Payments; import com.gcc.communityHall.entity.Payments;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
@ -16,13 +15,17 @@ public interface PaymentsRepository extends JpaRepository<Payments,Integer> {
@Query(value = "SELECT * FROM payments WHERE payment_status in ('paid') ", nativeQuery = true) @Query(value = "SELECT * FROM payments WHERE payment_status in ('paid') ", nativeQuery = true)
List<Payments> getPaymentlist(); List<Payments> getPaymentlist();
@Query(value = "SELECT p.* " @Query(value = "SELECT p.* "
+ "FROM payments p " + "FROM payments p "
+ "JOIN booking_details b ON p.booking_details_booking_id = b.booking_id " + "JOIN booking_details b ON p.booking_details_booking_id = b.booking_id "
+ "JOIN hall_details h ON b.hall_details_hall_id = h.hall_id " + "JOIN hall_details h ON b.hall_details_hall_id = h.hall_id "
+ "WHERE h.zone = :zone", nativeQuery = true) + "WHERE h.zone = :zone", nativeQuery = true)
List<Payments> getPaymentListByzone(@Param("zone") String zone); List<Payments> getPaymentListByzone(@Param("zone") String zone);
// List<Payments> findAllWithBookingDetailsAndUsers(); // List<Payments> findAllWithBookingDetailsAndUsers();
@Query(value = "select * from payments where booking_details_booking_id=?", nativeQuery = true) @Query(value = "select * from payments where booking_details_booking_id=?", nativeQuery = true)
Payments findByBookingId(int bookingId); Payments findByBookingId(int bookingId);
boolean existsByBookingDetails_BookingId(int bookingId);
} }

3
src/main/java/com/gcc/communityHall/repository/ReasonMasterRepository.java

@ -12,4 +12,7 @@ import com.gcc.communityHall.entity.ReasonMaster;
public interface ReasonMasterRepository extends JpaRepository<ReasonMaster, Integer> { public interface ReasonMasterRepository extends JpaRepository<ReasonMaster, Integer> {
ReasonMaster findByReason(String reason); ReasonMaster findByReason(String reason);
@Query(value = "select * from reason_master where is_active =1 and is_delete=0 ", nativeQuery = true)
List<ReasonMaster> getAllReasonsWithStatus();
} }

92
src/main/java/com/gcc/communityHall/service/BookingService.java

@ -1,6 +1,5 @@
package com.gcc.communityHall.service; package com.gcc.communityHall.service;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -16,17 +15,21 @@ import com.gcc.communityHall.entity.BookingDetails.BookingStatus;
import com.gcc.communityHall.entity.BookingDetails.RefundStatus; import com.gcc.communityHall.entity.BookingDetails.RefundStatus;
import com.gcc.communityHall.entity.EbDetails; import com.gcc.communityHall.entity.EbDetails;
import com.gcc.communityHall.entity.GccBlockingDate; import com.gcc.communityHall.entity.GccBlockingDate;
import com.gcc.communityHall.entity.HallRequestDetails;
public interface BookingService { public interface BookingService {
BookingDetails getBookingsById(int BookingId); BookingDetails getBookingsById(int BookingId);
// ak // ak
BookingDetails getBookingByRefId(String refId); BookingDetails getBookingByRefId(String refId);
// ak // ak
void migrateOldBookingsToRefId(); void migrateOldBookingsToRefId();
BookingDetails updateBookingDetails(BookingDetails bd); BookingDetails updateBookingDetails(BookingDetails bd);
public String confirmTheDateAndSlot(String fromDate, String toDate, int days, int fromStartingSlot, int fromEndingSlot, int toStartingSlot, int toEndingSlot, int bookingId, int userId);
public String confirmTheDateAndSlot(String fromDate, String toDate, int days, int fromStartingSlot,
int fromEndingSlot, int toStartingSlot, int toEndingSlot, int bookingId, int userId);
public Map<String, Object> saveBookingDetails(Map<String, Object> formData); public Map<String, Object> saveBookingDetails(Map<String, Object> formData);
@ -45,7 +48,6 @@ public interface BookingService {
public BookingDetails getBookingDetailsWithSettlement(int settlementId); public BookingDetails getBookingDetailsWithSettlement(int settlementId);
// sreeja // sreeja
List<BookingDetails> getPresentsEventsByUserId(Integer hallId); List<BookingDetails> getPresentsEventsByUserId(Integer hallId);
@ -71,8 +73,8 @@ public interface BookingService {
List<Map<String, Object>> getAllBookingEventsByUserId(Integer userId); List<Map<String, Object>> getAllBookingEventsByUserId(Integer userId);
//List<BookingDetails> getAllBookingDetailsWithStatus(String fromDate, String toDate, String bookingStatus);
// List<BookingDetails> getAllBookingDetailsWithStatus(String fromDate, String
// toDate, String bookingStatus);
// List<Object[]> getAllPaymentsDetails( String fromDate, String toDate); // List<Object[]> getAllPaymentsDetails( String fromDate, String toDate);
@ -93,7 +95,8 @@ public interface BookingService {
// officer service // officer service
List<BookingDetails> getAllBookingDetailsByZone(String fromDate, String toDate, String zone); List<BookingDetails> getAllBookingDetailsByZone(String fromDate, String toDate, String zone);
List<BookingDetails> getAllBookingDetailsByZoneWithStatus(String fromDate, String toDate, String zone, String bookingStatus);
List<BookingDetails> getAllBookingDetailsByZoneWithStatus(String fromDate, String toDate, String zone,
String bookingStatus);
List<Object[]> getAllPaymentsDetailsByZone(String fromDate, String toDate, String zone); List<Object[]> getAllPaymentsDetailsByZone(String fromDate, String toDate, String zone);
@ -109,67 +112,86 @@ public interface BookingService {
@Transactional @Transactional
void cancelAllBookings(String fromDate, String toDate, List<Long> hallIdsList, void cancelAllBookings(String fromDate, String toDate, List<Long> hallIdsList,
String reasonforblocking, List<String> selectedBookings, String updatedBy, String[] descriptions, MultipartFile[] documents);
String reasonforblocking, List<String> selectedBookings, String updatedBy, String[] descriptions,
MultipartFile[] documents);
List<BookingDetails> findBookingDetailsByBookingId(Long bookingId); List<BookingDetails> findBookingDetailsByBookingId(Long bookingId);
// admin dashboard // admin dashboard
Map<String, Map<String, Integer>> getBookingStatistics(LocalDate fromDate, LocalDate toDate, String zone, String division, Integer hallid, String userType);
Map<String, Map<String, Integer>> getBookingStatistics(LocalDate fromDate, LocalDate toDate, String zone,
String division, Integer hallid, String userType);
public List<Map<String, Object>> getBookingDetailsByHallId(int hallId); public List<Map<String, Object>> getBookingDetailsByHallId(int hallId);
// officer dashboard // officer dashboard
Map<String, Map<String, Integer>> getOfficerDashboard(LocalDate fromDate, LocalDate toDate, String zone, String division, Integer hallid, String userType);
Map<String, Map<String, Integer>> getOfficerDashboard(LocalDate fromDate, LocalDate toDate, String zone,
String division, Integer hallid, String userType);
List<Map<String, Object>> getHallDetailsForOfficer(Integer hallIid); List<Map<String, Object>> getHallDetailsForOfficer(Integer hallIid);
//List<Object[]> getAllPaymentsDetails(String fromDate, String toDate, String paymentStatus);
// List<Object[]> getAllPaymentsDetails(String fromDate, String toDate, String
// paymentStatus);
// admin reports // admin reports
List<Object[]> getBookingDetailsByBookingDate(String fromDate, String toDate, String zone, String division, Integer hallid);
List<Object[]> getBookingDetailsByBookingDate(String fromDate, String toDate, String zone, String division,
Integer hallid);
List<Object[]> getBookingDetailsByEventDate(String fromDate, String toDate, String zone, String division, Integer hallid);
List<Object[]> getBookingDetailsByEventDate(String fromDate, String toDate, String zone, String division,
Integer hallid);
List<Object[]> getBookingDetailsByBookingDateWithStatus(String fromDate, String toDate, String bookingStatus, String zone, String division, Integer hallid);
List<Object[]> getBookingDetailsByBookingDateWithStatus(String fromDate, String toDate, String bookingStatus,
String zone, String division, Integer hallid);
List<Object[]> getBookingDetailsByEventDateWithStatus(String fromDate, String toDate, String bookingStatus, String zone, String division, Integer hallid);
List<Object[]> getBookingDetailsByEventDateWithStatus(String fromDate, String toDate, String bookingStatus,
String zone, String division, Integer hallid);
List<Object[]> getAllPaymentsDetails(String fromDate, String toDate, String paymentStatus, String zone, String division, Integer hallid);
List<Object[]> getAllPaymentsDetails(String fromDate, String toDate, String paymentStatus, String zone,
String division, Integer hallid);
List<Object[]> getBookingHallDetailsReportByBookingDate(String fromDate, String toDate, String zone, String division, Integer hallid);
List<Object[]> getBookingHallDetailsReportByBookingDate(String fromDate, String toDate, String zone, String division,
Integer hallid);
List<Object[]> getBookingHallDetailsReportByEventDate(String fromDate, String toDate, String zone, String division, Integer hallid);
List<Object[]> getBookingHallDetailsReportByEventDate(String fromDate, String toDate, String zone, String division,
Integer hallid);
List<BookingDetails> getAllBookingsettlementDetailsByBookingDate(String fromDate, String toDate); List<BookingDetails> getAllBookingsettlementDetailsByBookingDate(String fromDate, String toDate);
List<BookingDetails> getAllBookingsettlementDetailsByBookingDateWithStatus(String fromDate, String toDate, String refundStatus);
List<BookingDetails> getAllBookingsettlementDetailsByBookingDateWithStatus(String fromDate, String toDate,
String refundStatus);
List<BookingDetails> getAllBookingsettlementDetailsByEventDate(String fromDate, String toDate); List<BookingDetails> getAllBookingsettlementDetailsByEventDate(String fromDate, String toDate);
List<BookingDetails> getAllBookingsettlementDetailsByEventDateWithStatus(String fromDate, String toDate, String refundStatus);
List<BookingDetails> getAllBookingsettlementDetailsByEventDateWithStatus(String fromDate, String toDate,
String refundStatus);
List<BookingDetails> getAllBookingDetailsBookingDateByZone(String fromDate, String toDate, String zone); List<BookingDetails> getAllBookingDetailsBookingDateByZone(String fromDate, String toDate, String zone);
List<BookingDetails> getAllBookingDetailsEventDateByZone(String fromDate, String toDate, String zone); List<BookingDetails> getAllBookingDetailsEventDateByZone(String fromDate, String toDate, String zone);
List<BookingDetails> getAllBookingDetailsBookingDateByZoneWithStatus(String fromDate, String toDate, String zone, String bookingStatus);
List<BookingDetails> getAllBookingDetailsBookingDateByZoneWithStatus(String fromDate, String toDate, String zone,
String bookingStatus);
List<BookingDetails> getAllBookingDetailsEventDateByZoneWithStatus(String fromDate, String toDate, String zone, String bookingStatus);
List<BookingDetails> getAllBookingDetailsEventDateByZoneWithStatus(String fromDate, String toDate, String zone,
String bookingStatus);
List<BookingDetails> getAllBookingsettlementDetailsByZoneByBookingDate(String fromDate, String toDate, String zone); List<BookingDetails> getAllBookingsettlementDetailsByZoneByBookingDate(String fromDate, String toDate, String zone);
List<BookingDetails> getAllBookingsettlementDetailsByZoneByEventDate(String fromDate, String toDate, String zone); List<BookingDetails> getAllBookingsettlementDetailsByZoneByEventDate(String fromDate, String toDate, String zone);
List<BookingDetails> getAllBookingsettlementDetailsByZoneByBookingDateWithStatus(String fromDate, String toDate, String zone, String refundStatus);
List<BookingDetails> getAllBookingsettlementDetailsByZoneByBookingDateWithStatus(String fromDate, String toDate,
String zone, String refundStatus);
List<BookingDetails> getAllBookingsettlementDetailsByZoneByEventDateWithStatus(String fromDate, String toDate, String zone, String refundStatus);
List<BookingDetails> getAllBookingsettlementDetailsByZoneByEventDateWithStatus(String fromDate, String toDate,
String zone, String refundStatus);
List<Object[]> getBookingHallDetailsReportByZoneByBookingDate(String fromDate, String toDate, String zone); List<Object[]> getBookingHallDetailsReportByZoneByBookingDate(String fromDate, String toDate, String zone);
List<Object[]> getBookingHallDetailsReportByZoneByEventDate(String fromDate, String toDate, String zone); List<Object[]> getBookingHallDetailsReportByZoneByEventDate(String fromDate, String toDate, String zone);
List<Object[]> getBookingHallDetailsReportByZoneByBookingDateHallname(String fromDate, String toDate, String zone, Integer hallId);
List<Object[]> getBookingHallDetailsReportByZoneByBookingDateHallname(String fromDate, String toDate, String zone,
Integer hallId);
List<Object[]> getBookingHallDetailsReportByZoneByEventDateHallname(String fromDate, String toDate, String zone, Integer hallId);
List<Object[]> getBookingHallDetailsReportByZoneByEventDateHallname(String fromDate, String toDate, String zone,
Integer hallId);
BookingDetails saveebdetails(int bookingId, double startingReading, MultipartFile startingReadingimage); BookingDetails saveebdetails(int bookingId, double startingReading, MultipartFile startingReadingimage);
@ -196,7 +218,8 @@ public interface BookingService {
List<BookingDetails> getWaitingforNOCapproval(); List<BookingDetails> getWaitingforNOCapproval();
List<Object[]> getAllExtraPaymentsDetails(String fromDate, String toDate, String paymentStatus, String zone, String division, Integer hallid);
List<Object[]> getAllExtraPaymentsDetails(String fromDate, String toDate, String paymentStatus, String zone,
String division, Integer hallid);
// developer // developer
List<Object[]> getTransactionresponse(String fromDate, String toDate, Long bookingId, Long hallId); List<Object[]> getTransactionresponse(String fromDate, String toDate, Long bookingId, Long hallId);
@ -222,7 +245,24 @@ public interface BookingService {
List<Object> getAllHallWiseBookingList(String fromDate, String toDate); List<Object> getAllHallWiseBookingList(String fromDate, String toDate);
List<Object> getAllCounterWiseBookingList(String fromDate, String toDate); List<Object> getAllCounterWiseBookingList(String fromDate, String toDate);
// ak // ak
List<Object[]> getSettlementInitiatedReport(String fromDate, String toDate); List<Object[]> getSettlementInitiatedReport(String fromDate, String toDate);
public String saveHallRequestDetails(String fromDate, String toDate, int startingSlot,
int endingSlot, String relationship, String reason, int hallId, int userId,
String orgType, String eventDesc, String offAddress, MultipartFile bonafide);
List<HallRequestDetails> getPendingGovtRequests();
List<HallRequestDetails> getApprovedGovtRequests();
List<HallRequestDetails> getRejectedGovtRequests();
void updateGovtRequest(int reqId, String action, double discountPercentage, boolean nocRequired);
List<Map<String, Object>> getvphcollectionpending(int bookingId);
boolean isPaymentAlreadyDoneOrInitiated(int bookingId);
} }

348
src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java

@ -3,6 +3,7 @@ package com.gcc.communityHall.service.Impl;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.ParseException; import java.text.ParseException;
@ -46,6 +47,7 @@ import com.gcc.communityHall.entity.GccBlockingHistory;
import com.gcc.communityHall.entity.GccblockingDocuments; import com.gcc.communityHall.entity.GccblockingDocuments;
import com.gcc.communityHall.entity.HallDetails; import com.gcc.communityHall.entity.HallDetails;
import com.gcc.communityHall.entity.HallDetailsConcession; import com.gcc.communityHall.entity.HallDetailsConcession;
import com.gcc.communityHall.entity.HallRequestDetails;
import com.gcc.communityHall.entity.ReasonDocumentMaster; import com.gcc.communityHall.entity.ReasonDocumentMaster;
import com.gcc.communityHall.entity.ReasonMaster; import com.gcc.communityHall.entity.ReasonMaster;
import com.gcc.communityHall.entity.Settlement; import com.gcc.communityHall.entity.Settlement;
@ -72,6 +74,8 @@ import com.gcc.communityHall.repository.ReasonMasterRepository;
import com.gcc.communityHall.repository.SettlementHistoryRepository; import com.gcc.communityHall.repository.SettlementHistoryRepository;
import com.gcc.communityHall.repository.SettlementRepository; import com.gcc.communityHall.repository.SettlementRepository;
import com.gcc.communityHall.repository.UsersRepository; import com.gcc.communityHall.repository.UsersRepository;
import com.gcc.communityHall.repository.HallRequestDetailsRepository;
import com.gcc.communityHall.repository.PaymentsRepository;
import com.gcc.communityHall.service.ApplicationLogService; import com.gcc.communityHall.service.ApplicationLogService;
import com.gcc.communityHall.service.BookingService; import com.gcc.communityHall.service.BookingService;
import com.gcc.communityHall.service.DiscountRangeService; import com.gcc.communityHall.service.DiscountRangeService;
@ -163,6 +167,12 @@ public class BookingServiceImpl implements BookingService {
@Autowired @Autowired
private TransRefundResRepository transRefundResRepository; private TransRefundResRepository transRefundResRepository;
@Autowired
private HallRequestDetailsRepository hallRequestDetailsRepository;
@Autowired
private PaymentsRepository paymentsRepository;
@Value("${file.upload.directory}") @Value("${file.upload.directory}")
private String uploadDirectory; private String uploadDirectory;
@ -242,6 +252,16 @@ public class BookingServiceImpl implements BookingService {
@Override @Override
public BookingDetails updateBookingStatus(int bookingId, BookingDetails.BookingStatus status, String comments) { public BookingDetails updateBookingStatus(int bookingId, BookingDetails.BookingStatus status, String comments) {
Optional<BookingDetails> booking = bookingDetailsRepository.findById(bookingId); Optional<BookingDetails> booking = bookingDetailsRepository.findById(bookingId);
String apikey = "5c995535-6244-11f0-98fc-02c8a5e042bd";
String from = "919445061913";
String hallName, userName, endDate;
// String[] numbers = { "9123565217", "9789091845", "9894935693", "8667881667"
// }; // for testing purpose
String[] numbers = { "9123565217", "9789091845", "9894935693",
"9444173345", "9994697909", "9176617754", "9445190998", "9381013498",
"9789977111" };
if (booking.isPresent()) { if (booking.isPresent()) {
BookingDetails book = booking.get(); BookingDetails book = booking.get();
/* /*
@ -260,6 +280,39 @@ public class BookingServiceImpl implements BookingService {
book.setBookingStatus(status); book.setBookingStatus(status);
book.setComments(comments); book.setComments(comments);
BookingDetails bookings = bookingDetailsRepository.save(book); BookingDetails bookings = bookingDetailsRepository.save(book);
if ("APPROVED".equals(status)) {
for (String mobNo : numbers) {
hallName = bookings.getHallDetails().getHallName();
userName = bookings.getUsers().getName();
// Format endDate from yyyy-MM-dd to dd-MM-yyyy
String rawEndDate = bookings.getEndDate();
try {
LocalDate date = LocalDate.parse(rawEndDate, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
endDate = date.format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
} catch (Exception e) {
endDate = rawEndDate; // Fallback to original if parsing fails
}
String placeholders = "";
try {
placeholders = URLEncoder.encode(userName + "|~|" + hallName + "|~|" + endDate, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String whatsappMsg = "https://sendapiv1.pinbot.ai/pinwa/sendMessage?apikey=" + apikey + "&from="
+ from
+ "&to=91" + mobNo + ""
+ "&type=template&templateid=2815237&placeholders=" + placeholders + "";
System.out.println(whatsappMsg + ":" + mobNo);
whatsappMsgServiceImpl.sendMsg(whatsappMsg);
}
}
return bookings; return bookings;
} }
return null; return null;
@ -471,13 +524,21 @@ public class BookingServiceImpl implements BookingService {
public String processBookingStatusAndSendMessages(BookingDetails bookingDetails, String hallName, String userName, public String processBookingStatusAndSendMessages(BookingDetails bookingDetails, String hallName, String userName,
LocalDate endDate) { LocalDate endDate) {
try { try {
String apikey = "5c995535-6244-11f0-98fc-02c8a5e042bd";
String from = "919445061913";
String reason = bookingDetails.getReason(); String reason = bookingDetails.getReason();
ReasonMaster reasonDetails = reasonMasterRepository.findByReason(reason); ReasonMaster reasonDetails = reasonMasterRepository.findByReason(reason);
String reasonCode = (reasonDetails != null && reasonDetails.getReasoncode() != null) String reasonCode = (reasonDetails != null && reasonDetails.getReasoncode() != null)
? reasonDetails.getReasoncode() ? reasonDetails.getReasoncode()
: ""; : "";
String[] numbers = { "9123565217", "9789091845", "9894935693", "9444173345", "9840562783", "9842042722", "9176617754" };
// String[] numbers = { "9123565217", "9789091845", "9894935693", "8667881667"
// }; // for testing purpose
String[] numbers = { "9123565217", "9789091845", "9894935693",
"9444173345", "9994697909", "9176617754", "9445190998", "9381013498",
"9789977111" };
String bookingconfirmationmsg, urlString, whatsupmsg, bookingmsg; String bookingconfirmationmsg, urlString, whatsupmsg, bookingmsg;
@ -507,16 +568,25 @@ public class BookingServiceImpl implements BookingService {
// String endDateStr = endDate+"-%20Test%20message%20please%20ignore"; // String endDateStr = endDate+"-%20Test%20message%20please%20ignore";
String msg = "A%20new%20"+ encodedHN + "%20booking%20has%20been%20successfully%20made%20by%20"+ userName +"%20for%20" + endDate+ ".";
String msg = "A%20new%20" + encodedHN + "%20booking%20has%20been%20successfully%20made%20by%20"
+ userName + "%20for%20" + endDate + ".";
String encodedFooter = URLEncoder.encode("- GCC IT Cell", StandardCharsets.UTF_8); String encodedFooter = URLEncoder.encode("- GCC IT Cell", StandardCharsets.UTF_8);
bookingmsg = "https://mediaapi.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ" + bookingmsg = "https://mediaapi.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ" +
"&send_to=" + mobNo + "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg="+msg+"&isTemplate=true&footer="+encodedFooter+"";
"&send_to=" + mobNo + "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=" + msg
+ "&isTemplate=true&footer=" + encodedFooter + "";
System.out.println(bookingmsg + ":" + mobNo); System.out.println(bookingmsg + ":" + mobNo);
whatsappMsgServiceImpl.sendMsg(bookingmsg);
String placeholders = URLEncoder.encode(hallName + "|~|" + userName + "|~|" + endDate, "UTF-8");
String whatsappMsg = "https://sendapiv1.pinbot.ai/pinwa/sendMessage?apikey=" + apikey + "&from="
+ from + "&to=91" + mobNo + ""
+ "&type=template&templateid=2815236&placeholders=" + placeholders + "";
System.out.println(whatsappMsg + ":" + mobNo);
whatsappMsgServiceImpl.sendMsg(whatsappMsg);
} }
// whatsappMsgServiceImpl.sendSMS(urlString); // whatsappMsgServiceImpl.sendSMS(urlString);
return "Waiting For NOC Documents"; return "Waiting For NOC Documents";
@ -817,10 +887,12 @@ public class BookingServiceImpl implements BookingService {
} }
@Override @Override
@Transactional
public Map<String, Object> saveBookingDetails(Map<String, Object> formData) { public Map<String, Object> saveBookingDetails(Map<String, Object> formData) {
Map<String, Object> hs = new HashMap<>(); Map<String, Object> hs = new HashMap<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
BookingDetails bookingDetails = null; BookingDetails bookingDetails = null;
List<BookingDocuments> uploadedDocs = new ArrayList<>();
Integer userId = userSession.getUserId(); Integer userId = userSession.getUserId();
String counterId = userSession.getCounter(); String counterId = userSession.getCounter();
@ -926,7 +998,7 @@ public class BookingServiceImpl implements BookingService {
hs.put("reasoncode", reasoncode); hs.put("reasoncode", reasoncode);
HallDetailsConcession governmentevents = hallDetailsConcessionRepo HallDetailsConcession governmentevents = hallDetailsConcessionRepo
.findbyhallId(hallDetails.getHallId()); .findbyhallId(hallDetails.getHallId());
if (reasoncode.equals("SGE")) {
if (reasoncode.equals("CGE")) {
discountAmount = (governmentevents.getFulldayhallamount() * hallDetails.getSGEdiscount()) / 100; discountAmount = (governmentevents.getFulldayhallamount() * hallDetails.getSGEdiscount()) / 100;
// hallAmount = governmentevents.getFulldayhallamount(); // hallAmount = governmentevents.getFulldayhallamount();
hallAmount = hallAmount - discountAmount; hallAmount = hallAmount - discountAmount;
@ -946,7 +1018,7 @@ public class BookingServiceImpl implements BookingService {
bookingDetails.setAmountReceived(truncatedTotalAmount); bookingDetails.setAmountReceived(truncatedTotalAmount);
hs.put("additionalcharges", additionalcharges); hs.put("additionalcharges", additionalcharges);
hs.put("totalAmount", truncatedTotalAmount); hs.put("totalAmount", truncatedTotalAmount);
} else if (reasoncode.equals("CGE")) {
} else if (reasoncode.equals("SGE")) {
discountAmount = (hallDetails.getFullDayRent() * hallDetails.getCGEdiscount()) / 100; discountAmount = (hallDetails.getFullDayRent() * hallDetails.getCGEdiscount()) / 100;
// hallAmount = hallDetails.getFullDayRent(); // hallAmount = hallDetails.getFullDayRent();
hallAmount = governmentevents.getFulldayhallamount(); hallAmount = governmentevents.getFulldayhallamount();
@ -1048,17 +1120,24 @@ public class BookingServiceImpl implements BookingService {
if (reasonMaster != null) { if (reasonMaster != null) {
List<ReasonDocumentMaster> reasonDocMaster = reasonMaster.getReasonDocumentMasterList(); List<ReasonDocumentMaster> reasonDocMaster = reasonMaster.getReasonDocumentMasterList();
List<BookingDocuments> uploadedDocs = new ArrayList<>();
for (ReasonDocumentMaster rm : reasonDocMaster) { for (ReasonDocumentMaster rm : reasonDocMaster) {
BookingDocuments bd = new BookingDocuments(); BookingDocuments bd = new BookingDocuments();
bd.setBookingDetails(bookingDetails); bd.setBookingDetails(bookingDetails);
boolean hasContent = false;
if (rm.isAddTextField()) { if (rm.isAddTextField()) {
bd.setName(formData.get(rm.getFieldName()).toString());
Object textFieldValue = formData.get(rm.getFieldName());
if (textFieldValue != null && !textFieldValue.toString().isEmpty()) {
bd.setName(textFieldValue.toString());
bd.setBooking_label(rm.getFieldName()); bd.setBooking_label(rm.getFieldName());
hasContent = true;
}
} }
if (rm.isAddDocumentField()) { if (rm.isAddDocumentField()) {
MultipartFile file = (MultipartFile) formData.get(rm.getDocFieldName()); MultipartFile file = (MultipartFile) formData.get(rm.getDocFieldName());
if (file != null && !file.isEmpty()) {
bd.setBookingDocUrl(serverPath + "images/" + reasonMaster.getReason() + "/" bd.setBookingDocUrl(serverPath + "images/" + reasonMaster.getReason() + "/"
+ bookingDetails.getBookingId() + "_" + file.getOriginalFilename()); + bookingDetails.getBookingId() + "_" + file.getOriginalFilename());
String filePath = uploadDirectory + "/" + reasonMaster.getReason() + "/" String filePath = uploadDirectory + "/" + reasonMaster.getReason() + "/"
@ -1066,12 +1145,23 @@ public class BookingServiceImpl implements BookingService {
bd.setDocumentName(file.getOriginalFilename()); bd.setDocumentName(file.getOriginalFilename());
bd.setDocumentType(file.getContentType()); bd.setDocumentType(file.getContentType());
// Ensure directory exists
File dir = new File(uploadDirectory + "/" + reasonMaster.getReason());
if (!dir.exists()) {
dir.mkdirs();
}
try (FileOutputStream fos = new FileOutputStream(filePath)) { try (FileOutputStream fos = new FileOutputStream(filePath)) {
byte[] bytes = file.getBytes(); byte[] bytes = file.getBytes();
fos.write(bytes); fos.write(bytes);
hasContent = true;
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
}
}
if (hasContent) {
bookingDocumentsRepository.save(bd); bookingDocumentsRepository.save(bd);
uploadedDocs.add(bd); uploadedDocs.add(bd);
} }
@ -1080,6 +1170,12 @@ public class BookingServiceImpl implements BookingService {
} }
} }
if (bookingDetails != null) {
String refId = getBookingRefIdByBookingId(bookingDetails.getBookingId());
hs.put("bookingRefId", refId);
}
hs.put("uploadedDocs", uploadedDocs);
return hs; return hs;
} }
@ -3009,4 +3105,238 @@ public class BookingServiceImpl implements BookingService {
return bookingDetailsRepository.getCounterWiseBookingList(fromDate, toDate); return bookingDetailsRepository.getCounterWiseBookingList(fromDate, toDate);
} }
@Override
public String saveHallRequestDetails(String fromDate, String toDate, int startingSlot, int endingSlot,
String relationship, String reason, int hallId, int userId,
String orgType, String eventDesc, String offAddress, MultipartFile bonafide) {
String exMsg = "Slot occupied";
HallDetails hallDetails = hallDetailService.getHallById(hallId);
Users user = userService.getUserById(userId);
HallRequestDetails hallRequestDetails = new HallRequestDetails();
hallRequestDetails.setStartDate(fromDate);
hallRequestDetails.setEndDate(toDate);
hallRequestDetails.setStartingSlot(startingSlot);
hallRequestDetails.setEndingSlot(endingSlot);
hallRequestDetails.setReason(reason);
hallRequestDetails.setHallId(hallId);
hallRequestDetails.setUserId(userId);
hallRequestDetails.setOrgType(orgType);
hallRequestDetails.setEventDescription(eventDesc);
hallRequestDetails.setOfficeDetails(offAddress);
if (bonafide != null && !bonafide.isEmpty()) {
hallRequestDetails.setBonafidePath(serverPath + "images/" + bonafide.getOriginalFilename());
String filePath = uploadDirectory + "/" + bonafide.getOriginalFilename();
// File saving logic is missing here in original method, but NCP is fixed.
} else {
hallRequestDetails.setBonafidePath(null);
}
hallRequestDetailsRepository.save(hallRequestDetails);
BookingDetails bookingDetails = new BookingDetails();
bookingDetails.setBookingDate(LocalDate.now());
bookingDetails.setBookingStatus(BookingStatus.PENDING);
bookingDetails.setBookingtype(BookingDetails.BookingType.ONLINE);
bookingDetails.setEndDate(toDate);
bookingDetails.setStartDate(fromDate);
bookingDetails.setStartingSlot(startingSlot);
bookingDetails.setEndingSlot(endingSlot);
bookingDetails.setReason(reason);
bookingDetails.setNoOfDays(1);
bookingDetails.setRefundStatus(RefundStatus.WAITING);
bookingDetails.setScheduleCount(0);
bookingDetails.setRelationship(relationship);
bookingDetails.setComments("Booking Slot not Confirmed.");
bookingDetails.setUsers(user);
bookingDetails.setHallDetails(hallDetails);
BookingDetails SavedBookingDetails = bookingDetailsRepository.save(bookingDetails);
int bookingId = SavedBookingDetails.getBookingId();
// BookingCalendar bookingCalendar = new BookingCalendar();
// bookingCalendar.setBookingDetails(bookingDetails);
// bookingCalendar.setBookingDate(LocalDate.parse(fromDate));
// bookingCalendar.setStartingSlot(startingSlot);
// bookingCalendar.setEndingSlot(endingSlot);
// bookingCalendar.setHallDetails(hallDetails);
// bookingCalendar.setUsers(user);
// bookingCalendarRepository.save(bookingCalendar);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startDate = LocalDate.parse(fromDate, formatter);
LocalDate endDate = LocalDate.parse(toDate, formatter);
int i = 0;
for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
BookingCalendar bookingCalendar = bookingCalendarRepository.findByBdateAndHallId(date, hallId);
if (bookingCalendar != null) {
if (bookingCalendar.getIs_blocked()) {
throw new RuntimeException("GCC Blocked Date");
} else if ((date.equals(startDate) && bookingDetails.getStartingSlot() == 1
&& bookingCalendar.isMorningSlot()) ||
(date.equals(startDate) && bookingDetails.getStartingSlot() == 2
&& bookingCalendar.isEveningSlot())
||
(date.equals(endDate) && bookingDetails.getEndingSlot() == 1
&& bookingCalendar.isMorningSlot())
||
(date.equals(endDate) && bookingDetails.getEndingSlot() == 2
&& bookingCalendar.isEveningSlot())) {
// System.out.println("booking slot occupied:- 218");
throw new RuntimeException(exMsg);
} else if (bookingCalendar.isMorningSlot() && bookingCalendar.isEveningSlot()) {
// System.out.println("booking slot occupied:- 221");
throw new RuntimeException(exMsg);
} else if (!date.equals(endDate) && i != 0 && i != Math.round(bookingDetails.getNoOfDays() - 1)
&& (bookingCalendar.isMorningSlot() || bookingCalendar.isEveningSlot())) {
// System.out.println("booking slot occupied:- 227
// :-"+Math.round(bookingDetails.getNoOfDays()-1) );
throw new RuntimeException(exMsg);
} else if (date.equals(endDate) && bookingDetails.getEndingSlot() == 2
&& bookingCalendar.isMorningSlot()
&& i != 0 && i == Math.round(bookingDetails.getNoOfDays() - 1)) {
// System.out.println("booking slot occupied:- 240
// :-"+Math.round(bookingDetails.getNoOfDays()-1) );
throw new RuntimeException(exMsg);
}
} else {
String uniqueId = date.format(DateTimeFormatter.ofPattern("yyyyMMdd")) + hallId;
System.out.println("uniqueId....." + uniqueId);
bookingCalendar = new BookingCalendar();
bookingCalendar.setBdate(date);
bookingCalendar.setHallId(hallId);
bookingCalendar.setIs_booked(0);
bookingCalendar.setIs_active(true);
bookingCalendar.setUnique_id(uniqueId);
}
// Mark the appropriate slot as booked based on starting and ending slots
if (date.equals(startDate)) {
// System.out.println(i + "start :-"+bookingCalendar.toString());
if (bookingDetails.getStartingSlot() == 1) {
bookingCalendar.setMorningSlot(true);
bookingCalendar.setBookingId_1(String.valueOf(bookingId));
bookingCalendar.setIs_booked(bookingCalendar.getIs_booked() + 1);
if (!date.equals(endDate)) {
bookingCalendar.setEveningSlot(true);
bookingCalendar.setBookingId_2(String.valueOf(bookingId));
bookingCalendar.setIs_booked(bookingCalendar.getIs_booked() + 1);
} else if (startDate.equals(endDate) && bookingDetails.getStartingSlot() == 1
&& bookingDetails.getEndingSlot() == 2) {
bookingCalendar.setEveningSlot(true);
bookingCalendar.setBookingId_2(String.valueOf(bookingId));
bookingCalendar.setIs_booked(bookingCalendar.getIs_booked() + 1);
}
} else {
bookingCalendar.setEveningSlot(true);
bookingCalendar.setBookingId_2(String.valueOf(bookingId));
bookingCalendar.setIs_booked(bookingCalendar.getIs_booked() + 1);
}
} else if (date.equals(endDate)) {
if (bookingDetails.getEndingSlot() == 1) {
bookingCalendar.setMorningSlot(true);
bookingCalendar.setBookingId_1(String.valueOf(bookingId));
bookingCalendar.setIs_booked(bookingCalendar.getIs_booked() + 1);
} else {
bookingCalendar.setEveningSlot(true);
bookingCalendar.setBookingId_2(String.valueOf(bookingId));
bookingCalendar.setIs_booked(bookingCalendar.getIs_booked() + 1);
if (bookingDetails.getEndingSlot() == 2) {
bookingCalendar.setMorningSlot(true);
bookingCalendar.setBookingId_1(String.valueOf(bookingId));
bookingCalendar.setIs_booked(bookingCalendar.getIs_booked() + 1);
}
}
} else {
// For dates between start and end date, mark both slots as booked
bookingCalendar.setMorningSlot(true);
bookingCalendar.setEveningSlot(true);
bookingCalendar.setBookingId_1(String.valueOf(bookingId));
bookingCalendar.setBookingId_2(String.valueOf(bookingId));
bookingCalendar.setIs_booked(bookingCalendar.getIs_booked() + 2);
}
// System.out.println(i + "end:-"+bookingCalendar.toString());
bookingCalendarRepository.save(bookingCalendar);
i++;
}
bookingDetailsRepository.save(bookingDetails);
return "success";
}
@Override
public List<HallRequestDetails> getPendingGovtRequests() {
return hallRequestDetailsRepository.findPendingRequests();
}
@Override
public List<HallRequestDetails> getApprovedGovtRequests() {
return hallRequestDetailsRepository.findApprovedRequests();
}
@Override
public List<HallRequestDetails> getRejectedGovtRequests() {
return hallRequestDetailsRepository.findRejectedRequests();
}
@Override
@Transactional
public void updateGovtRequest(int reqId, String action, double discountPercentage, boolean nocRequired) {
HallRequestDetails request = hallRequestDetailsRepository.findById(reqId)
.orElseThrow(() -> new RuntimeException("Request not found"));
BookingDetails booking = bookingDetailsRepository.findById(request.getBookingId())
.orElseThrow(() -> new RuntimeException("Booking not found"));
if ("ACCEPT".equalsIgnoreCase(action)) {
if (nocRequired) {
request.setBookingStatus("WAITING_FOR_NOC");
booking.setBookingStatus(BookingStatus.WAITING_FOR_NOC);
} else {
request.setBookingStatus("APPROVED");
booking.setBookingStatus(BookingStatus.APPROVED);
}
// Apply discount
if (discountPercentage > 0) {
float discountFactor = (float) (1 - (discountPercentage / 100));
booking.setHallAmount(booking.getHallAmount() * discountFactor);
booking.setDepositAmount(booking.getDepositAmount() * discountFactor);
booking.setGst(booking.getGst() * discountFactor);
}
} else if ("REJECT".equalsIgnoreCase(action)) {
request.setBookingStatus("REJECTED");
booking.setBookingStatus(BookingStatus.REJECTED);
}
hallRequestDetailsRepository.save(request);
bookingDetailsRepository.save(booking);
}
@Override
public List<Map<String, Object>> getvphcollectionpending(int bookingId) {
return bookingDetailsRepository.findApprovedBookingWithHallRequest(bookingId);
}
public boolean isPaymentAlreadyDoneOrInitiated(int bookingId) {
boolean existsInPayments = paymentsRepository.existsByBookingDetails_BookingId(bookingId);
boolean existsInTransaction = transactionResponseRepository.existsByBookingId(bookingId);
return existsInPayments || existsInTransaction;
}
} }

7
src/main/java/com/gcc/communityHall/service/Impl/ReasonMasterImpl.java

@ -77,6 +77,7 @@ public class ReasonMasterImpl implements ReasonMasterService {
public List<ReasonMaster> getAllReasons() { public List<ReasonMaster> getAllReasons() {
return reasonMasterRepository.findAll(); return reasonMasterRepository.findAll();
} }
@Override @Override
public List<ReasonDocumentMaster> getReasonDocumentDetailsByReasonId(int reasonId) { public List<ReasonDocumentMaster> getReasonDocumentDetailsByReasonId(int reasonId) {
return reasonDocMasterRepository.findByReasonMasterReasonId(reasonId); return reasonDocMasterRepository.findByReasonMasterReasonId(reasonId);
@ -86,4 +87,10 @@ public class ReasonMasterImpl implements ReasonMasterService {
public ReasonMaster getReasonByName(String reasonName) { public ReasonMaster getReasonByName(String reasonName) {
return reasonMasterRepository.findByReason(reasonName); return reasonMasterRepository.findByReason(reasonName);
} }
@Override
public List<ReasonMaster> getAllReasonsWithStatus() {
return reasonMasterRepository.getAllReasonsWithStatus();
}
} }

6
src/main/java/com/gcc/communityHall/service/ReasonMasterService.java

@ -8,8 +8,14 @@ import com.gcc.communityHall.entity.ReasonMaster;
public interface ReasonMasterService { public interface ReasonMasterService {
String saveTheReason(ReasonMaster reasonMaster); String saveTheReason(ReasonMaster reasonMaster);
ReasonMaster getReasonById(int reasonId); ReasonMaster getReasonById(int reasonId);
List<ReasonMaster> getAllReasons(); List<ReasonMaster> getAllReasons();
List<ReasonDocumentMaster> getReasonDocumentDetailsByReasonId(int reasonId); List<ReasonDocumentMaster> getReasonDocumentDetailsByReasonId(int reasonId);
ReasonMaster getReasonByName(String reasonName); ReasonMaster getReasonByName(String reasonName);
List<ReasonMaster> getAllReasonsWithStatus();
} }

2
src/main/resources/templates/user/hallbookingform.html

@ -2188,7 +2188,7 @@
// $("#rentamount_td").html(response.rentAmount); // $("#rentamount_td").html(response.rentAmount);
$("#actualhallAmount_td").html(response.actualhallamount); $("#actualhallAmount_td").html(response.actualhallamount);
// $("#hallAmount_td").html(response.netAmount); // $("#hallAmount_td").html(response.netAmount);
$("#gst_td").html(response.gstAmount);
$("#gst_td").html(response.gst);
$("#depositAmount_td").html(response.depositAmount); $("#depositAmount_td").html(response.depositAmount);
// $("#discount_td").html(response.discount + "%"); // $("#discount_td").html(response.discount + "%");
$("#totalAmount_td").html(response.totalAmount); $("#totalAmount_td").html(response.totalAmount);

Loading…
Cancel
Save