From 270046d60ea2278d7a29955ca453828d6f18d4bb Mon Sep 17 00:00:00 2001 From: KaNi-04 <136799210+KaNi-04@users.noreply.github.com> Date: Thu, 20 Aug 2026 10:53:59 +0530 Subject: [PATCH] Sysout removed and CRO Login newly created --- .../controller/AdminAPIController.java | 2 - .../controller/Admincontroller.java | 12 +- .../controller/CROAPIController.java | 61 + .../controller/CROController.java | 80 + .../controller/CareTakerAPIController.java | 6 +- .../controller/CounterController.java | 16 +- .../controller/HQAPIController.java | 21 +- .../controller/HeadquartersController.java | 6 +- .../controller/OfficerAPIController.java | 12 +- .../controller/OfficerController.java | 8 +- .../controller/UserAPIController.java | 147 +- .../controller/UserController.java | 18 +- .../controller/apicontroller.java | 57 +- .../communityHall/entity/BookingHistory.java | 85 +- .../controller/PaymentAPIController.java | 8 +- .../controller/PaymentController.java | 782 +++--- .../repository/BookingDetailsRepository.java | 3 + .../service/Impl/BookingServiceImpl.java | 90 +- .../service/Impl/SettlementServiceImpl.java | 78 +- .../service/Impl/UserServiceImpl.java | 23 +- .../resources/templates/cro/booking-list.html | 2139 +++++++++++++++++ .../templates/cro/booking-status.html | 0 .../resources/templates/cro/noc-details.html | 0 .../templates/fragments/adminMenu.html | 2 +- .../templates/fragments/croMenu.html | 199 ++ .../templates/fragments/head-cro.html | 46 + .../templates/fragments/header-cro.html | 98 + .../templates/fragments/loginhead.html | 4 +- .../templates/fragments/loginscript.html | 163 +- .../templates/fragments/nav-cro.html | 13 + .../resources/templates/officiallogin.html | 3 + .../resources/templates/user/viewhistory.html | 64 +- 32 files changed, 3584 insertions(+), 662 deletions(-) create mode 100644 src/main/java/com/gcc/communityHall/controller/CROAPIController.java create mode 100644 src/main/java/com/gcc/communityHall/controller/CROController.java create mode 100644 src/main/resources/templates/cro/booking-list.html create mode 100644 src/main/resources/templates/cro/booking-status.html create mode 100644 src/main/resources/templates/cro/noc-details.html create mode 100644 src/main/resources/templates/fragments/croMenu.html create mode 100644 src/main/resources/templates/fragments/head-cro.html create mode 100644 src/main/resources/templates/fragments/header-cro.html create mode 100644 src/main/resources/templates/fragments/nav-cro.html diff --git a/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java b/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java index 946aea7c..a5b8d7f0 100644 --- a/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java +++ b/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java @@ -1505,8 +1505,6 @@ public class AdminAPIController { public ResponseEntity uploadnoc(@RequestParam("nocFile") MultipartFile file, @RequestParam("bookingid") int bookingId) { try { - System.out.println("Received file: " + file.getOriginalFilename()); - System.out.println("Booking ID: " + bookingId); bookingService.uploadNOCFile(file, bookingId); return ResponseEntity.ok("File uploaded and saved successfully"); diff --git a/src/main/java/com/gcc/communityHall/controller/Admincontroller.java b/src/main/java/com/gcc/communityHall/controller/Admincontroller.java index 045ff91c..17df6602 100644 --- a/src/main/java/com/gcc/communityHall/controller/Admincontroller.java +++ b/src/main/java/com/gcc/communityHall/controller/Admincontroller.java @@ -278,7 +278,7 @@ public class Admincontroller { model.addAttribute("settlementIntiated", settlementIntiated); model.addAttribute("cancelledbookings", cancelledbookings); model.addAttribute("rejectedbookings", rejectedbookings); - System.out.println("Settlement List: " + settlement); + // System.out.println("Settlement List: " + settlement); return "admin/settlement-list"; } else { session.invalidate(); @@ -675,7 +675,7 @@ public class Admincontroller { List counterBookingList = new ArrayList<>(); counterBookingList = bookingService.getCounterWiseBookingCount(fromDate, toDate); model.addAttribute("counterBookingList", counterBookingList); - System.out.println("counterBookingList.." + counterBookingList); + // System.out.println("counterBookingList.." + counterBookingList); List hallBookingByCounter = bookingService.getHallWiseBookingDetails(fromDate, toDate, counterId); @@ -716,7 +716,7 @@ public class Admincontroller { if ("11".equals(request)) { // Fetch Settlement Initiated Report details List settlementInitiatedList = bookingService.getSettlementInitiatedReport(fromDate, toDate); - System.out.println("settlementInitatedList" + settlementInitiatedList); + // System.out.println("settlementInitatedList" + settlementInitiatedList); // Add the list to the model model.addAttribute("settlementInitiatedList", settlementInitiatedList); @@ -743,7 +743,7 @@ public class Admincontroller { model.addAttribute("division1", division); model.addAttribute("hall1", hallid); model.addAttribute("adminname", adminname); - System.out.println("request" + request); + // System.out.println("request" + request); return "admin/reports"; } else { @@ -987,7 +987,7 @@ public class Admincontroller { } List BookingCalendar = new ArrayList<>(); if (request.equals("3")) { - System.out.println("outside"); + // System.out.println("outside"); // if (hallName.isEmpty()) { // System.out.println("check1"); // // Fetch all details for the given date range @@ -1113,7 +1113,7 @@ public class Admincontroller { // Fetch waiting bookings List waitingBookings = bookingDetailsRepository.getAllwaitingNOC(); - System.out.println("Waiting Bookings: " + waitingBookings.size()); + // System.out.println("Waiting Bookings: " + waitingBookings.size()); model.addAttribute("waitingBookings", waitingBookings); return "admin/viewUploadNoc"; diff --git a/src/main/java/com/gcc/communityHall/controller/CROAPIController.java b/src/main/java/com/gcc/communityHall/controller/CROAPIController.java new file mode 100644 index 00000000..c23982b4 --- /dev/null +++ b/src/main/java/com/gcc/communityHall/controller/CROAPIController.java @@ -0,0 +1,61 @@ +package com.gcc.communityHall.controller; + +import java.util.HashMap; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.gcc.communityHall.entity.BookingDetails; +import com.gcc.communityHall.service.BookingService; + +import jakarta.servlet.http.HttpSession; + +@RestController +@RequestMapping("/communityhall/cro/api") +public class CROAPIController { + + @Autowired + private BookingService bookingService; + + /** + * Get booking details by booking ID. + * Used by the CRO booking-list page to search and display + * full booking info for a given booking ID. + * + * @param bookingId the booking ID to search for + * @return the BookingDetails or 404 if not found + */ + @GetMapping("/getBookingById") + public ResponseEntity getBookingById(@RequestParam("bookingId") int bookingId) { + BookingDetails bookingDetails = bookingService.getBookingsById(bookingId); + if (bookingDetails != null) { + return ResponseEntity.ok(bookingDetails); + } else { + return ResponseEntity.notFound().build(); + } + } + + /** + * Returns the currently logged-in CRO's mobile number from the HTTP session. + * Used by the CRO reschedule flow to send OTP to the CRO (not the user). + * + * @param session the current HTTP session + * @return JSON { "mobileNumber": } or 401 if not authenticated + */ + @GetMapping("/getCROMobileNumber") + public ResponseEntity getCROMobileNumber(HttpSession session) { + Object mobile = session.getAttribute("mobileno"); + if (mobile == null) { + return ResponseEntity.status(401).body("CRO session not found"); + } + Map response = new HashMap<>(); + response.put("mobileNumber", mobile); + return ResponseEntity.ok(response); + } + +} diff --git a/src/main/java/com/gcc/communityHall/controller/CROController.java b/src/main/java/com/gcc/communityHall/controller/CROController.java new file mode 100644 index 00000000..4a9a79a3 --- /dev/null +++ b/src/main/java/com/gcc/communityHall/controller/CROController.java @@ -0,0 +1,80 @@ +package com.gcc.communityHall.controller; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +import com.gcc.communityHall.entity.BookingDetails; +import com.gcc.communityHall.repository.BookingDetailsRepository; + +import jakarta.servlet.http.HttpSession; + +@Controller +@RequestMapping("/communityhall/cro") +public class CROController { + + @Autowired + private BookingDetailsRepository bookingDetailsRepository; + + @GetMapping("/booking-list") + public String viewBookingList(Model model, HttpSession session) { + String croname = (String) session.getAttribute("usertype"); + // System.out.println("croname..." + croname); + if (croname != null && "cro".equals(croname)) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("croname", croname); + List bookingList = bookingDetailsRepository.getApprovedBookingListforReschedule(); + model.addAttribute("bookingList", bookingList); + return "cro/booking-list"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes + return "redirect:/communityhall/login"; + } + } + + @GetMapping("/booking-status") + public String viewBookingStatus(Model model, HttpSession session) { + String croname = (String) session.getAttribute("usertype"); + // System.out.println("croname..." + croname); + if (croname != null && "cro".equals(croname)) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("croname", croname); + List bookingList = bookingDetailsRepository.getApprovedBookingListforReschedule(); + model.addAttribute("bookingList", bookingList); + return "cro/booking-status"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes + return "redirect:/communityhall/login"; + } + } + + @GetMapping("/nocdetails") + public String viewNOCDetails(Model model, HttpSession session) { + String croname = (String) session.getAttribute("usertype"); + // System.out.println("croname..." + croname); + if (croname != null && "cro".equals(croname)) { + long mobileno = (long) session.getAttribute("mobileno"); + model.addAttribute("mobileno", mobileno); + model.addAttribute("croname", croname); + List bookingList = bookingDetailsRepository.getApprovedBookingListforReschedule(); + model.addAttribute("bookingList", bookingList); + return "cro/noc-details"; + } else { + session.invalidate(); // Invalidate the session to clear all session attributes + return "redirect:/communityhall/login"; + } + } + + @GetMapping("/logout") + public String viewLogout(Model model, HttpSession session) { + session.invalidate(); + return "redirect:/communityhall/login"; + } + +} diff --git a/src/main/java/com/gcc/communityHall/controller/CareTakerAPIController.java b/src/main/java/com/gcc/communityHall/controller/CareTakerAPIController.java index d0dcc472..021d328a 100644 --- a/src/main/java/com/gcc/communityHall/controller/CareTakerAPIController.java +++ b/src/main/java/com/gcc/communityHall/controller/CareTakerAPIController.java @@ -162,7 +162,7 @@ public class CareTakerAPIController { ? login.getHallIds() : (login.getHallId() != 0 ? java.util.Arrays.asList(login.getHallId()) : new java.util.ArrayList<>()); - System.out.println("effectiveHallIds.." + effectiveHallIds); + // System.out.println("effectiveHallIds.." + effectiveHallIds); session.setAttribute("hall_ids", effectiveHallIds); session.setAttribute("mobileno", login.getMobileNumber()); session.setAttribute("usertype", login.getUserType()); @@ -170,7 +170,7 @@ public class CareTakerAPIController { session.setAttribute("zone", login.getZone()); InetAddress inetAddress = InetAddress.getLocalHost(); String hostname = InetAddress.getLocalHost().getHostName(); - System.out.println("Hostname: " + hostname); + // System.out.println("Hostname: " + hostname); ApplicationLogs logs = new ApplicationLogs(); logs.setComments("login as " + login.getName()); logs.setLoginId(login.getId()); @@ -354,7 +354,7 @@ public class CareTakerAPIController { // URL // Log the generated full URL for debugging - System.out.println("Generated Full URL for QR Code: " + baseUrl); + // System.out.println("Generated Full URL for QR Code: " + baseUrl); // Generate the QR code with the full URL String qrCodeImage = QRCodeGenerator.generateQRCode(baseUrl, bookingId); diff --git a/src/main/java/com/gcc/communityHall/controller/CounterController.java b/src/main/java/com/gcc/communityHall/controller/CounterController.java index 7f5491cf..30009a17 100644 --- a/src/main/java/com/gcc/communityHall/controller/CounterController.java +++ b/src/main/java/com/gcc/communityHall/controller/CounterController.java @@ -68,9 +68,9 @@ public class CounterController { @GetMapping(value = { "", "/", "/counterbooking" }) public String viewcounter(Model model, HttpSession session) { - System.out.println("viewcounter"); + // System.out.println("viewcounter"); String countername = (String) session.getAttribute("usertype"); - System.out.println("serverDate....." + LocalDate.now().toString()); + // System.out.println("serverDate....." + LocalDate.now().toString()); model.addAttribute("serverDate", LocalDate.now().toString()); // for server date model.addAttribute("countername", countername); return "counter/counter-booking"; @@ -149,15 +149,17 @@ public class CounterController { @RequestParam("username") String username, @RequestParam("password") String password, Model model, HttpSession session) { - System.out.println("username: " + username + "\n" + "password: " + password); + // System.out.println("username: " + username + "\n" + "password: " + password); try { Login login = loginRepository.findByUsernameAndPass(username, password); - System.out.println("counter controller\nCounter Id: " + userSession.getCounter() + "\nCounter Name: " - + userSession.getCounterName()); + // System.out.println("counter controller\nCounter Id: " + + // userSession.getCounter() + "\nCounter Name: " + // + userSession.getCounterName()); if (login != null) { - System.out.println("Login successful for mobile number: " + login.getMobileNumber()); + // System.out.println("Login successful for mobile number: " + + // login.getMobileNumber()); // Generate JWT token if login is successful String token = jwtUtil.generateToken( @@ -184,7 +186,7 @@ public class CounterController { InetAddress inetAddress = InetAddress.getLocalHost(); String hostname = InetAddress.getLocalHost().getHostName(); - System.out.println("Hostname: " + hostname); + // System.out.println("Hostname: " + hostname); ApplicationLogs logs = new ApplicationLogs(); logs.setComments("login as " + login.getName()); diff --git a/src/main/java/com/gcc/communityHall/controller/HQAPIController.java b/src/main/java/com/gcc/communityHall/controller/HQAPIController.java index 53760b4a..73158813 100644 --- a/src/main/java/com/gcc/communityHall/controller/HQAPIController.java +++ b/src/main/java/com/gcc/communityHall/controller/HQAPIController.java @@ -809,9 +809,12 @@ public class HQAPIController { .map(Long::parseLong) .collect(Collectors.toList()); - System.out.println("fromDate " + fromDate + "\n toDate " + toDate + "\n hallID " + hallID - + "\n reasonforblocking " + reasonforblocking + "\n selectedBookings " + selectedBookings - + "\n descriptions " + descriptions + "\n documents " + documents + "\n updatedBy " + updatedBy); + // System.out.println("fromDate " + fromDate + "\n toDate " + toDate + "\n + // hallID " + hallID + // + "\n reasonforblocking " + reasonforblocking + "\n selectedBookings " + + // selectedBookings + // + "\n descriptions " + descriptions + "\n documents " + documents + "\n + // updatedBy " + updatedBy); // Call the service with descriptions and documents bookingService.cancelAllBookings(fromDate, toDate, hallIdsList, reasonforblocking, selectedBookings, updatedBy, @@ -1493,8 +1496,8 @@ public class HQAPIController { public ResponseEntity uploadnoc(@RequestParam("nocFile") MultipartFile file, @RequestParam("bookingid") int bookingId) { try { - System.out.println("Received file: " + file.getOriginalFilename()); - System.out.println("Booking ID: " + bookingId); + // System.out.println("Received file: " + file.getOriginalFilename()); + // System.out.println("Booking ID: " + bookingId); bookingService.uploadNOCFile(file, bookingId); return ResponseEntity.ok("File uploaded and saved successfully"); @@ -1516,16 +1519,16 @@ public class HQAPIController { Map response = new HashMap<>(); try { - System.out.println("settlementId1: " + bookingId); - System.out.println("status" + status); - System.out.println("comments" + comments); + // System.out.println("settlementId1: " + bookingId); + // System.out.println("status" + status); + // System.out.println("comments" + comments); // Update settlement status Settlement updateSettlement = settlementService.updateSettlementStatus(bookingId, status, comments); if (updateSettlement == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } - System.out.println("updateSettlement12" + updateSettlement); + // System.out.println("updateSettlement12" + updateSettlement); // ak // Set approvedFlag and approvedFlagDate updateSettlement.setApprovedFlag(1); diff --git a/src/main/java/com/gcc/communityHall/controller/HeadquartersController.java b/src/main/java/com/gcc/communityHall/controller/HeadquartersController.java index f792789e..562ed9fe 100644 --- a/src/main/java/com/gcc/communityHall/controller/HeadquartersController.java +++ b/src/main/java/com/gcc/communityHall/controller/HeadquartersController.java @@ -325,7 +325,7 @@ public class HeadquartersController { List counterBookingList = new ArrayList<>(); counterBookingList = bookingService.getCounterWiseBookingCount(fromDate, toDate); model.addAttribute("counterBookingList", counterBookingList); - System.out.println("counterBookingList.." + counterBookingList); + // System.out.println("counterBookingList.." + counterBookingList); List hallBookingByCounter = bookingService.getHallWiseBookingDetails(fromDate, toDate, counterId); @@ -811,7 +811,7 @@ public class HeadquartersController { // Fetch waiting bookings List waitingBookings = bookingDetailsRepository.getAllwaitingNOC(); - System.out.println("Waiting Bookings: " + waitingBookings.size()); + // System.out.println("Waiting Bookings: " + waitingBookings.size()); model.addAttribute("waitingBookings", waitingBookings); return "headquarters/viewUploadNoc"; @@ -1265,6 +1265,8 @@ public class HeadquartersController { bookingHistory.setCdate(new Date()); bookingHistory.setStartDate(booking.getStartDate()); bookingHistory.setEndDate(booking.getEndDate()); + bookingHistory.setStartingSlot(booking.getStartingSlot()); + bookingHistory.setEndingSlot(booking.getEndingSlot()); bookingHistory.setBookingDetails(booking); bookingHistoryRepository.save(bookingHistory); diff --git a/src/main/java/com/gcc/communityHall/controller/OfficerAPIController.java b/src/main/java/com/gcc/communityHall/controller/OfficerAPIController.java index ba848344..abb9e2d7 100644 --- a/src/main/java/com/gcc/communityHall/controller/OfficerAPIController.java +++ b/src/main/java/com/gcc/communityHall/controller/OfficerAPIController.java @@ -141,7 +141,7 @@ public class OfficerAPIController { @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); } @@ -209,16 +209,16 @@ public class OfficerAPIController { Map response = new HashMap<>(); try { - System.out.println("settlementId1: " + settlementId); - System.out.println("status" + status); - System.out.println("comments" + comments); + // System.out.println("settlementId1: " + settlementId); + // System.out.println("status" + status); + // System.out.println("comments" + comments); // Update settlement status Settlement updateSettlement = settlementService.updateSettlementStatus(settlementId, status, comments); if (updateSettlement == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } - System.out.println("updateSettlement12" + updateSettlement); + // System.out.println("updateSettlement12" + updateSettlement); // ak // Set approvedFlag and approvedFlagDate updateSettlement.setApprovedFlag(1); @@ -698,7 +698,7 @@ public class OfficerAPIController { @RequestParam(value = "document", required = false) MultipartFile[] documents, // Handle documents HttpSession session) { - System.out.println("selectedBookings...." + selectedBookings); + // System.out.println("selectedBookings...." + selectedBookings); // Your existing logic String updatedBy = (String) session.getAttribute("employeeId"); diff --git a/src/main/java/com/gcc/communityHall/controller/OfficerController.java b/src/main/java/com/gcc/communityHall/controller/OfficerController.java index f6cd697d..b0177247 100644 --- a/src/main/java/com/gcc/communityHall/controller/OfficerController.java +++ b/src/main/java/com/gcc/communityHall/controller/OfficerController.java @@ -86,7 +86,7 @@ public class OfficerController { long mobileno = (long) session.getAttribute("mobileno"); List hallIds = (List) session.getAttribute("hall_ids"); - System.out.println("HallIds in officer Dashboard: " + hallIds.toString()); + // System.out.println("HallIds in officer Dashboard: " + hallIds.toString()); model.addAttribute("mobileno", mobileno); model.addAttribute("zone", zone); @@ -225,7 +225,7 @@ public class OfficerController { List hallIds = (List) session.getAttribute("hall_ids"); model.addAttribute("zone", zone); model.addAttribute("hallIds", hallIds); - System.out.println("Zone: " + zone); + // System.out.println("Zone: " + zone); List settlement = bookingDetailsRepository.findSettlementPendingByZone(zone, hallIds); // ak List settlementIntiated = bookingDetailsRepository @@ -237,7 +237,7 @@ public class OfficerController { model.addAttribute("settlementIntiated", settlementIntiated); model.addAttribute("cancelledbookings", cancelledbookings); model.addAttribute("rejectedbookings", rejectedbookings); - System.out.println("settlementIntiated" + settlementIntiated); + // System.out.println("settlementIntiated" + settlementIntiated); return "officer/settlement-list"; } else { session.invalidate(); @@ -642,7 +642,7 @@ public class OfficerController { List hallIds = (List) session.getAttribute("hall_ids"); model.addAttribute("zone", zone); model.addAttribute("hallIds", hallIds); - System.out.println("zone" + zone + "\nhallIds.." + hallIds); + // System.out.println("zone" + zone + "\nhallIds.." + hallIds); return "officer/gccblocking-new"; } else { session.invalidate(); diff --git a/src/main/java/com/gcc/communityHall/controller/UserAPIController.java b/src/main/java/com/gcc/communityHall/controller/UserAPIController.java index 18bfc3d4..dc3065e2 100644 --- a/src/main/java/com/gcc/communityHall/controller/UserAPIController.java +++ b/src/main/java/com/gcc/communityHall/controller/UserAPIController.java @@ -50,6 +50,7 @@ import com.gcc.communityHall.dto.FamilyPensionerDetails; import com.gcc.communityHall.dto.FamilyPensionerDetailsResponse; import com.gcc.communityHall.dto.PensionerDetails; import com.gcc.communityHall.dto.PensionerDetailsResponse; +import com.gcc.communityHall.entity.ApplicationLogs; import com.gcc.communityHall.entity.BookingCalendar; import com.gcc.communityHall.entity.BookingDetails; import com.gcc.communityHall.entity.Counsellordetails; @@ -74,6 +75,7 @@ import com.gcc.communityHall.paymentService.entity.TransactionResponse; import com.gcc.communityHall.paymentService.refund.DTO.TransactionRefundResponse; import com.gcc.communityHall.paymentService.repository.TransRefundResRepository; import com.gcc.communityHall.paymentService.service.PaymentGatewayServiceImpl; +import com.gcc.communityHall.repository.ApplicationLogsRepository; import com.gcc.communityHall.repository.BookingCalendarRepository; import com.gcc.communityHall.repository.BookingDetailsRepository; import com.gcc.communityHall.repository.BookingHistoryRepository; @@ -171,6 +173,9 @@ public class UserAPIController { @Autowired private TransRefundResRepository transRefundResRepository; + @Autowired + private ApplicationLogsRepository applicationLogsRepository; + @Autowired public UserAPIController(@Value("${file.upload.directory}") String uploadDirectory) { this.uploadDirectory = uploadDirectory; @@ -187,10 +192,11 @@ public class UserAPIController { // Optional hallDetails = hallDetailsRepository.findById(hallId); // return hallDetails.map(ResponseEntity::ok) // .orElseGet(() -> ResponseEntity.status(404).body(null)); + System.out.println("User is viewing hall Details for hall Id: " + hallId); HallDetails hallDetails = hallDetailsRepository.findHallActiveDetailsById(hallId); - System.out.println("hallDetails.." + hallDetails); + // System.out.println("hallDetails.." + hallDetails); if (hallDetails != null) { return ResponseEntity.ok(hallDetails); @@ -203,6 +209,7 @@ public class UserAPIController { @GetMapping("/gethallnames") public ResponseEntity> getHallNames() { + System.out.println("Calling hallnames API"); List hallDetailsList = hallDetailsRepository.findActiveHalls(); List hallDataList = new ArrayList<>(); for (HallDetails hallDetails : hallDetailsList) { @@ -219,6 +226,7 @@ public class UserAPIController { // SendOTP @GetMapping(value = "/sendOTP") public String sendOtp(HttpServletRequest request, @RequestParam Long mobileNo, @RequestParam String purpose) { + System.out.println("Calling Send OTP API for Mob No: " + mobileNo); Long MobileNo = mobileNo; // System.out.println(purpose); @@ -235,7 +243,7 @@ public class UserAPIController { String urlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + mobileNo + "&from=GCCCRP&body=Welcome to GCC! Your OTP for GCC Community Centre booking is " + otp + "&entityid=1401572690000011081&templateid=1407172346444550398"; - System.out.println(urlString); + // System.out.println(urlString); System.out.println("\n urlString---: " + urlString); String bodyMessage = "" + otp; @@ -271,14 +279,15 @@ public class UserAPIController { // VerifyOTP @GetMapping(value = "/verifyOTP") public String verifyOtp(HttpServletRequest request, @RequestParam String otp, @RequestParam long mobileNo) { + System.out.println("Calling Verify OTP API"); HttpSession session = request.getSession(); try { Integer session_otp = (Integer) session.getAttribute("otp"); - System.out.println("session_otp---:" + session_otp); + // System.out.println("session_otp---:" + session_otp); Integer entered_otp = Integer.parseInt(otp); if (session_otp != null && session_otp.equals(entered_otp)) { - System.out.println("Entered OTP Correct user API"); + // System.out.println("Entered OTP Correct user API"); Users user = userservice.findByMobileno(mobileNo); if (user != null) { userSession.setMobileno(user.getMobileNo()); @@ -292,7 +301,7 @@ public class UserAPIController { return "Success"; } else { - System.out.println("Incorrect OTP. Please enter correct OTPs."); + // System.out.println("Incorrect OTP. Please enter correct OTPs."); session.setAttribute("user", ""); session.setAttribute("mobileNo", ""); session.setAttribute("id", ""); @@ -310,6 +319,7 @@ public class UserAPIController { @GetMapping(value = "/verifyofficialOTP") public String verifyOtp(HttpServletRequest request, @RequestParam String otp) { + System.out.println("Calling Verify Official login OTP API"); HttpSession session = request.getSession(); try { Integer session_otp = (Integer) session.getAttribute("otp"); @@ -338,6 +348,7 @@ public class UserAPIController { // Validating User with the mobileno @GetMapping(value = "/checkMobileExits") public String checkMobileExits(@RequestParam long mobileno) { + System.out.println("Calling Check Mobile Exits API"); try { Users form = userservice.findByMobileno(mobileno); if (form != null) { @@ -359,6 +370,7 @@ public class UserAPIController { // Counsellor Mobile no Validation @GetMapping(value = "/checkCounsellorMobileExits") public ResponseEntity checkCounsellorMobileExits(@RequestParam long mobileno) { + System.out.println("Calling Check Counsellor Mobile Exits API"); // Find the counsellor by the provided mobile number Counsellordetails counsellor = userservice.findByMobile(mobileno); // This checks both mobileNo1 and mobileNo2 // in the counsellor table @@ -382,6 +394,7 @@ public class UserAPIController { @GetMapping("/checkEmployee") public Map checkEmployee(@RequestParam String id) { + System.out.println("Calling Check GCC Employee API"); boolean isRegistered = usersRepository.existsByGovernmentId(id); Map response = new HashMap<>(); response.put("isRegistered", isRegistered); @@ -392,6 +405,7 @@ public class UserAPIController { // retrieving the zone @GetMapping(value = "/getZone") public List> getZone() { + System.out.println("Calling Get Zone API in the User end"); return hallDetailsRepository.getZoneAndDivision(); } @@ -399,6 +413,7 @@ public class UserAPIController { // retrieving the zones by hall @GetMapping(value = "/hallsbyzone") public List> getHallsByZone(@RequestParam(required = false) String zones) { + System.out.println("Calling Halls By Zone API in the User end"); if (zones == null || zones.isEmpty()) { return hallDetailsRepository.getAllHalls(); } else { @@ -411,6 +426,7 @@ public class UserAPIController { // Getting the Past Data from the Calendar @GetMapping("/getPastData") public List> getPastData(@RequestParam("hall_id") int hall_id) { + System.out.println("Calling Past Data from the booking Calendar Hall API in the User end"); List> data = bookingService.getPastData(hall_id); if (data != null) { return data; @@ -422,6 +438,7 @@ public class UserAPIController { // retrieving the Pensioner Details From ERP @GetMapping("/PensionerDetail") public PensionerDetailsResponse getPensionerDetails(@RequestParam("pensionerId") String pensionerId) { + System.out.println("Calling Pensioner Detail API in the User end"); // System.out.println(pensionerId); RestTemplate restTemplate = new RestTemplate(); String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getPensionerDetailsList&pensionerId=" @@ -454,6 +471,7 @@ public class UserAPIController { @Operation(summary = "Employee Details ERP REST API", description = "REST API to retrieving the Employee Details From ERP") @GetMapping("/EmployeeDetails") public EmployeeDetailsResponse getEmployeeDetails(@RequestParam("employeeId") Long employeeId) { + System.out.println("Calling Employee Details API in the User end"); // System.out.println("Employee ID:"+employeeId); RestTemplate restTemplate = new RestTemplate(); String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getEmployeeDetail&EmployeeID=" @@ -487,6 +505,7 @@ public class UserAPIController { // retrieving the FamilyPensionerDetails Details From ERP @GetMapping("/FamilyPensionerDetail") public FamilyPensionerDetailsResponse getFamilyPensionerDetails(@RequestParam("id") Long id) { + System.out.println("Calling Family Pensioner Detail API in the User end"); RestTemplate restTemplate = new RestTemplate(); String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getFamPensionerDetailsList&familPensionId=" + id; @@ -517,6 +536,7 @@ public class UserAPIController { // retrieving the All Hall Details coordinates @GetMapping("/getallhallcoordinates") public List> getAllHallCoordinates() { + System.out.println("Calling All Hall Coordinates API in the User end"); List allHallDetails = hallDetailsRepository.findActiveHalls(); return allHallDetails.stream().map(this::extractRequiredDetails).collect(Collectors.toList()); } @@ -546,6 +566,7 @@ public class UserAPIController { // Booking Limitation & UserStatus pending @GetMapping("/bookingLimit") public String CheckbookingLimitation(Model model) { + System.out.println("Calling Booking Limitation API in the User end"); int userId = userSession.getUserId(); Users userById = userService.getUserById(userId); if (userById != null && userById.getUserstatus() == Users.userStatus.PENDING) { @@ -566,6 +587,7 @@ public class UserAPIController { @Operation(summary = "Counter Booikng Limit REST API", description = "REST API to check the Counter Booking Limitation") @GetMapping("/counterbookinglimit") public String checkCounterBookingLimitation(@RequestParam long mobileNo) { + System.out.println("Calling Counter Booking Limitation API in the User end"); Users user = userService.getUserDetailsByMobileNo(mobileNo); if (user == null) { @@ -590,6 +612,7 @@ public class UserAPIController { // UserStatus pending @GetMapping("/checkuserstatus") public String checkUserStatus(@RequestParam long mobileNo) { + System.out.println("Calling User Status Pending API in the User end"); Users user = userService.getUserDetailsByMobileNo(mobileNo); // Assuming you have a method to retrieve a user by // mobile number if (user != null && user.getUserstatus() == Users.userStatus.PENDING) { @@ -605,6 +628,7 @@ public class UserAPIController { // Getting Username and Mobileno from userSession @GetMapping("/getUsername") public ResponseEntity> checkUsername() { + System.out.println("Calling Username and Mobileno from userSession API in the User end"); Map userDetails = new HashMap<>(); userDetails.put("displayName", userSession.getDispayName()); userDetails.put("mobileNo", userSession.getMobileno()); @@ -615,6 +639,7 @@ public class UserAPIController { @GetMapping(value = "/getZonehalls") public List> getZonehalls() { + System.out.println("Calling Zone Halls API in the User end"); return hallDetailsRepository.getZonesAndDivisions(); } @@ -623,6 +648,7 @@ public class UserAPIController { @GetMapping(value = "/getZoneNo") public String getZoneNo() { + System.out.println("Calling Zone No API in the User end"); String urlString = appConfig.getErpUrl() + "serviceId=getZones"; ResponseEntity response = null; RestTemplate restTemplate = new RestTemplate(); @@ -645,6 +671,7 @@ public class UserAPIController { // Rest Api From ERP for getting Divisions @GetMapping(value = "/getDiv") public String getDiv(@RequestParam String zoneId) { + System.out.println("Calling Division API in the User end"); String urlString = appConfig.getErpUrl() + "serviceId=getWards&Zoneid=" + zoneId + ""; ResponseEntity response = null; RestTemplate restTemplate = new RestTemplate(); @@ -668,12 +695,14 @@ public class UserAPIController { // retrieving the Halls By Division @GetMapping("/hallsbydivision") public List getHallsByDivision(@RequestParam("division") String division) { + System.out.println("Calling Halls By Division API in the User end"); return hallDetailsRepository.findActiveHallsByDivision(division); } @Operation(summary = "HAlls By zone ERP REST API", description = "REST API to get the HAlls by zone") @GetMapping("/findhallsbyzone") public List getHallsByzone(@RequestParam("zone") String zone) { + System.out.println("Calling Halls By zone API in the User end"); return hallDetailsRepository.findActiveHallsByZone(zone); } @@ -682,6 +711,7 @@ public class UserAPIController { @GetMapping("/viewAllBookingDetails") public ResponseEntity getUserDetailsByBookingId(@RequestParam("bookingId") int bookingId) { + System.out.println("Calling Booking Details By bookingId API in the User end"); LocalDateTime rescheduledUpdatedDate = null; BookingDetails bookingDetails = bookingService.getBookingsById(bookingId); @@ -748,6 +778,7 @@ public class UserAPIController { // retrieving the User Details by Mobileno for Counter @GetMapping("/getUserDetails") public ResponseEntity getUserDetailsByMobileNo(@RequestParam("mobileNo") long mobileNo) { + System.out.println("Calling Counter User Details API in the User end"); try { // Call service method to retrieve user details by mobile number Users userDetails = userService.getUserDetailsByMobileNo(mobileNo); @@ -785,6 +816,8 @@ public class UserAPIController { @RequestParam("uploadLetter") MultipartFile uploadLetter, @RequestParam("reason") String reason) throws IOException { + System.out.println("Calling Counter Booking Cancellation by Letter and Reason API in the User end"); + // System.out.println("Received counterId: " + counterId); // System.out.println("Received file: " + uploadLetter.getOriginalFilename()); @@ -862,6 +895,8 @@ public class UserAPIController { @RequestParam(value = "email", required = false) String email, @RequestParam(value = "profilephoto", required = false) MultipartFile profilephoto) { + System.out.println("Calling Updating the User Details Mobileno Validation API in the User end"); + Users userDetails = new Users(); userDetails.setUserId(userId); userDetails.setName(name); @@ -909,6 +944,9 @@ public class UserAPIController { // Retrive user details for counter @GetMapping("/getuserforcounter") public ResponseEntity getCounterUserById(@RequestParam int userId) { + + System.out.println("Calling Counter User Details API in the User end"); + if (userId == 0) { userId = userSession.getUserId(); // System.out.println("User ID retrieved from session: " + userId); @@ -927,6 +965,9 @@ public class UserAPIController { // retrieving User Details @GetMapping("/getUser") public ResponseEntity getUserByID(@RequestParam int userId) { + + System.out.println("Calling User Details API in the User end"); + if (userId == 0) { userId = userSession.getUserId(); } @@ -962,6 +1003,9 @@ public class UserAPIController { // APi for Saving the Booking Details @PostMapping(path = "/saveTheRequest2", consumes = { "multipart/form-data" }) public ResponseEntity saveTheBookingDetails2(HttpServletRequest request) { + + System.out.println("Calling Saving the Booking Details API in the User end (Step3 to Step4)"); + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; Map bookingDetails = splitFormData(multipartRequest); Map saveBookingDetails = bookingService.saveBookingDetails(bookingDetails); @@ -998,6 +1042,7 @@ public class UserAPIController { // retrieving the Booking Details BY Booking ID @GetMapping("/getBooking") public ResponseEntity getBookingByID(@RequestParam int bookingId) { + System.out.println("Calling Retrieving the Booking Details by BookingId API in the User end"); return ResponseEntity.ok(bookingService.getBookingsById(bookingId)); } @@ -1008,6 +1053,7 @@ public class UserAPIController { public ResponseEntity cancelBooking(@RequestParam int bookingId, @RequestParam BookingDetails.BookingStatus status, @RequestParam String comments) { + System.out.println("Calling User Booking Cancelling by BookingId API in the User end"); log.info("Received request to cancel booking with ID: {}"); log.info("Status: {}, Comments: {}"); Optional bookings = bookingDetailsRepository.findById(bookingId); @@ -1047,6 +1093,7 @@ public class UserAPIController { @GetMapping("/FamilyPensionerDetails") @ResponseBody // Ensure Spring treats the returned object as the response body public Map getFamilyPensionerDetails(HttpServletRequest request, @RequestParam("id") Long id) { + System.out.println("Calling Checking Family Pensioner Details from ERP API in the User end"); String purpose = "Checking Pensioner"; RestTemplate restTemplate = new RestTemplate(); String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getFamPensionerDetailsList&familPensionId=" @@ -1089,6 +1136,7 @@ public class UserAPIController { @GetMapping("/gccemployee") @ResponseBody // Ensure Spring treats the returned object as the response body public Map getGccEmployee(HttpServletRequest request, @RequestParam("id") Long id) { + System.out.println("Calling GCC Employee Details ERP REST API in the User end"); String purpose = "Checking GccEmployee"; RestTemplate restTemplate = new RestTemplate(); String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getEmployeeDetail&EmployeeID=" @@ -1134,6 +1182,7 @@ public class UserAPIController { @GetMapping("/PensionerDetails") @ResponseBody public Map getPensionerDetails(HttpServletRequest request, @RequestParam("id") Long id) { + System.out.println("Calling Pensioner Details ERP REST API in the User end"); String purpose = "Checking Employee"; RestTemplate restTemplate = new RestTemplate(); String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getPensionerDetailsList&pensionerId=" @@ -1191,6 +1240,9 @@ public class UserAPIController { @RequestParam("starting") String starting, @RequestParam("ending") String ending, @RequestParam(name = "hallId", required = false) String hallId) { + System.out.println( + "Calling Hall Checking Availability API in the User end. fromDate: " + fromDate + " toDate: " + toDate + + " starting: " + starting + " ending: " + ending + " hallId: " + hallId); List data = new ArrayList<>(); HashSet removeHallId = new HashSet(); int hallIdd = 0; @@ -1331,12 +1383,88 @@ public class UserAPIController { @RequestParam String startDate, @RequestParam String endDate, @RequestParam(required = false, defaultValue = "0") int startingSlot, - @RequestParam(required = false, defaultValue = "0") int endingSlot) { + @RequestParam(required = false, defaultValue = "0") int endingSlot, + HttpServletRequest request, + HttpSession session) { + System.out.println( + "Calling Reschedule Booking Dates API in the User end. bookingId: " + bookingId + " startDate: " + + startDate + + " endDate: " + endDate + " startingSlot: " + startingSlot + " endingSlot: " + endingSlot); try { Optional updateResult = bookingService.updateBookingDatesAndCalendar( bookingId, startDate, endDate, startingSlot, endingSlot); if (updateResult.isPresent()) { if (updateResult.get().equals("Booking dates updated successfully.")) { + // Log the reschedule action in ApplicationLogs + try { + ApplicationLogs log = new ApplicationLogs(); + log.setBookingId(bookingId); + log.setLogType("RESCHEDULE_BOOKING"); + log.setCdate(new Date()); + + int actorUserId = 0; + String actorType = "USER"; + + String sessionUserType = session != null ? (String) session.getAttribute("usertype") : null; + Object sessionIdObj = session != null ? session.getAttribute("id") : null; + + if (sessionUserType != null && sessionUserType.equalsIgnoreCase("cro")) { + actorType = "CRO"; + if (sessionIdObj instanceof Integer) { + actorUserId = (Integer) sessionIdObj; + } else if (sessionIdObj != null) { + try { + actorUserId = Integer.parseInt(sessionIdObj.toString()); + } catch (Exception ignored) { + } + } + } else if (userSession != null && userSession.getUserId() != null + && userSession.getUserId() != 0) { + actorUserId = userSession.getUserId(); + if (userSession.getUserType() != null && !userSession.getUserType().trim().isEmpty()) { + actorType = userSession.getUserType().toUpperCase(); + } + } else if (sessionIdObj != null) { + try { + actorUserId = Integer.parseInt(sessionIdObj.toString()); + if (sessionUserType != null && !sessionUserType.trim().isEmpty()) { + actorType = sessionUserType.toUpperCase(); + } + } catch (Exception ignored) { + } + } + + // Fallback to Citizen userId from BookingDetails if not resolved from session + if (actorUserId == 0) { + Optional bdOpt = bookingDetailsRepository.findById(bookingId); + if (bdOpt.isPresent() && bdOpt.get().getUsers() != null) { + actorUserId = bdOpt.get().getUsers().getUserId(); + } + } + + log.setLoginId(actorUserId); + String startSlotStr = startingSlot == 1 ? "Morning" + : (startingSlot == 2 ? "Evening" : "Slot " + startingSlot); + String endSlotStr = endingSlot == 1 ? "Morning" + : (endingSlot == 2 ? "Evening" : "Slot " + endingSlot); + log.setComments("Booking rescheduled by " + actorType + " (User ID: " + actorUserId + + "). New Dates: " + startDate + " (" + startSlotStr + ") to " + endDate + " (" + + endSlotStr + ")"); + + if (request != null) { + String clientIp = request.getHeader("X-Forwarded-For"); + if (clientIp == null || clientIp.isEmpty() || "unknown".equalsIgnoreCase(clientIp)) { + clientIp = request.getRemoteAddr(); + } + log.setIpaddress(clientIp); + log.setSystemName(request.getRemoteHost()); + } + + applicationLogsRepository.save(log); + } catch (Exception logEx) { + logEx.printStackTrace(); + } + return new ResponseEntity<>(updateResult.get(), HttpStatus.OK); } else { // Any other message is treated as an error @@ -1353,6 +1481,7 @@ public class UserAPIController { @GetMapping("/trackBooking") public List> getTrackingDetails(@RequestParam int bookingId) { + System.out.println("Calling Tracking Details API in the User end. bookingId: " + bookingId); Optional booking = bookingDetailsRepository.findById(bookingId); List> trackingDetails = new ArrayList<>(); DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); @@ -1664,6 +1793,9 @@ public class UserAPIController { @RequestParam(value = "endPeriod", required = false) String endPeriod, @RequestParam(value = "reasonforBooking", required = false) String reasonforBooking, @RequestParam int hallId) { + System.out.println("Calling calculate hall amount API in the User end. numDays: " + numDays + " startPeriod: " + + startPeriod + " endPeriod: " + endPeriod + " reasonforBooking: " + reasonforBooking + " hallId: " + + hallId); Optional hallDetailsOpt = hallDetailsRepository.findById(hallId); @@ -1804,6 +1936,7 @@ public class UserAPIController { @GetMapping("/getTransactionDetails") public Map getTransactionDetails(@RequestParam String userId) { + System.out.println("Calling getTransactionDetails API in the User end. userId: " + userId); // Fetch all transaction details for the user List transactions = PaymentGatewayServiceImpl.getTransactionResponseByuserId(userId); @@ -1815,7 +1948,7 @@ public class UserAPIController { response.put("refundDetails", refundDetails); - System.out.println("Response: " + response); + // System.out.println("Response: " + response); return response; } diff --git a/src/main/java/com/gcc/communityHall/controller/UserController.java b/src/main/java/com/gcc/communityHall/controller/UserController.java index 52cf0dc2..044897ba 100644 --- a/src/main/java/com/gcc/communityHall/controller/UserController.java +++ b/src/main/java/com/gcc/communityHall/controller/UserController.java @@ -66,6 +66,8 @@ public class UserController { @GetMapping(value = { "", "/", "/dashboard", "/index" }) public String viewDashboard(Model model) { + + System.out.println("User in dashboard / index Page"); List halls = hallDetailsRepository.findActiveHalls(); List hallnames = hallDetailsService.getHallNames(); for (HallDetails hall : halls) { @@ -105,6 +107,7 @@ public class UserController { @RequestParam(name = "zone", required = false) String zone, Model model) { + System.out.println("User Checking availability for hall Id:" + hallId); List newnotification = notificationRepository.findActivenotifications(); // Create a string to concatenate all notifications descriptions @@ -228,6 +231,8 @@ public class UserController { @PostMapping("/newregistrationform") public String showRegistrationForm(@ModelAttribute("newform") Users newform, Model model) { + + System.out.println("New User Registration Page"); Users user = userService.user(newform); userSession.setMobileno(user.getMobileNo()); userSession.setDispayName(user.getName()); @@ -263,7 +268,7 @@ public class UserController { @GetMapping("/hallbookingform") public String viewform(Model model) { String username = userSession.getDispayName(); - // System.out.println("server Date22....."+LocalDate.now().toString()); + System.out.println("User in Hall Booking Form Page"); model.addAttribute("serverDate", LocalDate.now().toString()); // for server date model.addAttribute("userName", username); model.addAttribute("counter", userSession.getCounter()); @@ -274,6 +279,7 @@ public class UserController { @GetMapping("/acknowledgementwithoutrefid") public String viewakowledgement(Model model, int bookingId) { + System.out.println("User in Acknowledgement without Ref ID Page"); BookingDetails bookingsDetails = bookingService.getBookingsById(bookingId); model.addAttribute("bookingsDetails", bookingsDetails); // Add single BookingDetails object model.addAttribute("userName", userSession.getDispayName()); @@ -284,6 +290,7 @@ public class UserController { @GetMapping("/acknowledgement") public String viewAcknowledgement(@RequestParam("ref_id") String refId, Model model) { + System.out.println("User in Acknowledgement with Ref ID Page"); // Fetch booking using booking_ref_id BookingDetails bookingsDetails = bookingService.getBookingByRefId(refId); @@ -350,6 +357,8 @@ public class UserController { public String viewBookingDetails(Model model, @RequestParam(name = "bookingStatus", required = false) String bookingStatus) { + System.out.println("User in View History Page"); + Integer userId = userSession.getUserId(); // Extract booking_ref_id per booking Map refIdMap = new HashMap<>(); @@ -400,8 +409,6 @@ public class UserController { } } - System.out.println("Row keys: " + bookingPast.get(0).keySet()); - System.out.println("RefId Map: " + refIdMap); } else { System.out.println("No past bookings found for userId: " + userId); } @@ -415,6 +422,7 @@ public class UserController { @GetMapping("/CommunityHallList") public String viewhalllist(Model model) { + System.out.println("User in View Hall List Page"); model.addAttribute("userName", userSession.getDispayName()); model.addAttribute("counter", userSession.getCounter()); model.addAttribute("counterName", userSession.getCounterName()); @@ -423,6 +431,7 @@ public class UserController { @GetMapping("/hallAmountCalculation") public String viewCalculate(Model model) { + System.out.println("User in Calculate Hall Amount Page"); model.addAttribute("userName", userSession.getDispayName()); model.addAttribute("counter", userSession.getCounter()); model.addAttribute("counterName", userSession.getCounterName()); @@ -431,6 +440,7 @@ public class UserController { @GetMapping("/collectionpending") public String viewCollectionpending(Model model, int bookingId) { + System.out.println("User in Collection Pending Page"); BookingDetails bookingsDetails = bookingService.getBookingsById(bookingId); model.addAttribute("bookingsDetails", bookingsDetails); // Add single BookingDetails object model.addAttribute("userName", userSession.getDispayName()); @@ -439,6 +449,7 @@ public class UserController { @GetMapping("/collectionpendingacknowledgement") public String viewCollectionpendingAck(Model model, int bookingId) { + System.out.println("User in Collection Pending Acknowledgement Page"); BookingDetails bookingsDetails = bookingService.getBookingsById(bookingId); model.addAttribute("bookingsDetails", bookingsDetails); // Add single BookingDetails object model.addAttribute("userName", userSession.getDispayName()); @@ -447,6 +458,7 @@ public class UserController { @GetMapping("/viewhallform") public String viewhallform(Model model) { + System.out.println("User in View Hall Form Page"); String username = userSession.getDispayName(); model.addAttribute("userName", username); model.addAttribute("serverDate", LocalDate.now().toString()); // for server date diff --git a/src/main/java/com/gcc/communityHall/controller/apicontroller.java b/src/main/java/com/gcc/communityHall/controller/apicontroller.java index 4a74e351..ef450be9 100644 --- a/src/main/java/com/gcc/communityHall/controller/apicontroller.java +++ b/src/main/java/com/gcc/communityHall/controller/apicontroller.java @@ -14,39 +14,46 @@ import com.gcc.communityHall.service.Impl.WhatsappMsgServiceImpl; @RestController @RequestMapping("/communityhall/username") public class apicontroller { - + @Autowired WhatsappMsgServiceImpl whatsappMsgServiceImpl; - + @GetMapping("/systemname") - public String getUsername() { - String systemName=System.getProperty("user.name"); - System.out.println("System.name:-"+systemName); + public String getUsername() { + String systemName = System.getProperty("user.name"); + // System.out.println("System.name:-"+systemName); long mobile = 7989346866L; - int bookingId= 1; + int bookingId = 1; double refundAmt = 1000; - String settlementrefundsms="Your refund amount of Rs. "+refundAmt+" for Booking ID "+bookingId+" has been initiated. The amount will be credited to your account within 3 to 15 days. Thanks for using the GCC Community Hall Booking System."; - String settlementrefundurlString ="https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to="+mobile+"&from=GCCCRP&body="+settlementrefundsms+"&entityid=1401572690000011081&templateid=1407172346804951524"; - String settlementrefundwhatsupmsg="https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="+mobile+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+refund+of+Rs.+"+refundAmt+"+for+Booking+ID+"+bookingId+"+has+been+initiated.+%0AThe+amount+will+be+credited+to+your+account+within+3+to+15+days."; - whatsappMsgServiceImpl.sendMsg(settlementrefundwhatsupmsg); - whatsappMsgServiceImpl.sendSMS(settlementrefundurlString.trim()); - System.out.println(settlementrefundurlString); - return systemName; - } + String settlementrefundsms = "Your refund amount of Rs. " + refundAmt + " for Booking ID " + bookingId + + " has been initiated. The amount will be credited to your account within 3 to 15 days. Thanks for using the GCC Community Hall Booking System."; + String settlementrefundurlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + mobile + + "&from=GCCCRP&body=" + settlementrefundsms + + "&entityid=1401572690000011081&templateid=1407172346804951524"; + String settlementrefundwhatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=" + + mobile + "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+refund+of+Rs.+" + refundAmt + + "+for+Booking+ID+" + bookingId + + "+has+been+initiated.+%0AThe+amount+will+be+credited+to+your+account+within+3+to+15+days."; + whatsappMsgServiceImpl.sendMsg(settlementrefundwhatsupmsg); + whatsappMsgServiceImpl.sendSMS(settlementrefundurlString.trim()); + // System.out.println(settlementrefundurlString); + return systemName; + } + @GetMapping("/systemnamesss") public String getUsernamess() throws UnknownHostException { - // Get the local host (your computer) - InetAddress inetAddress = InetAddress.getLocalHost(); - - // Print the system IP address - System.out.println("System IP Address: " + inetAddress.getHostAddress()); - try { - String hostname = java.net.InetAddress.getLocalHost().getHostName(); - System.out.println("Hostname: " + hostname); - } catch (UnknownHostException e) { - e.printStackTrace(); - } + // Get the local host (your computer) + InetAddress inetAddress = InetAddress.getLocalHost(); + + // Print the system IP address + // System.out.println("System IP Address: " + inetAddress.getHostAddress()); + try { + String hostname = java.net.InetAddress.getLocalHost().getHostName(); + // System.out.println("Hostname: " + hostname); + } catch (UnknownHostException e) { + e.printStackTrace(); + } return inetAddress.getHostAddress(); } diff --git a/src/main/java/com/gcc/communityHall/entity/BookingHistory.java b/src/main/java/com/gcc/communityHall/entity/BookingHistory.java index ab077021..cbbd51e4 100644 --- a/src/main/java/com/gcc/communityHall/entity/BookingHistory.java +++ b/src/main/java/com/gcc/communityHall/entity/BookingHistory.java @@ -24,29 +24,40 @@ public class BookingHistory { private Date cdate; public enum BookingStatus { - PENDING, APPROVED, REJECTED, CANCELED, PAYMENT_FAILURE,GCC_BLOCKED,COMPLETED ,WAITING_FOR_NOC , WAITING_FOR_NOC_APPROVAL + PENDING, APPROVED, REJECTED, CANCELED, PAYMENT_FAILURE, GCC_BLOCKED, COMPLETED, WAITING_FOR_NOC, + WAITING_FOR_NOC_APPROVAL } - @Column(name="booking_status") + + @Column(name = "booking_status") @Enumerated(EnumType.STRING) private BookingDetails.BookingStatus bookingStatus; - + public enum RefundStatus { - APPROVED, WAITING, INITIATED, REJECTED, COMPLETED, NA + APPROVED, WAITING, INITIATED, REJECTED, COMPLETED, NA } - @Column(name="refund_status") + + @Column(name = "refund_status") @Enumerated(EnumType.STRING) private BookingDetails.RefundStatus refundStatus; private String comments; - private String updatedBy; - @Column(name="start_date") + private String updatedBy; + @Column(name = "start_date") private String startDate; - @Column(name="end_date") + @Column(name = "end_date") private String endDate; - /*@ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER) - @JsonIgnore - private BookingDetails bookingDetails;*/ + @Column(name = "starting_slot") + private int startingSlot; + @Column(name = "ending_slot") + private int endingSlot; + + /* + * @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER) + * + * @JsonIgnore + * private BookingDetails bookingDetails; + */ @ManyToOne(fetch = FetchType.EAGER) @JsonIgnore @@ -100,27 +111,43 @@ public class BookingHistory { this.bookingDetails = bookingDetails; } - public String getStartDate() { - return startDate; - } + public String getStartDate() { + return startDate; + } - public void setStartDate(String startDate) { - this.startDate = startDate; - } + public void setStartDate(String startDate) { + this.startDate = startDate; + } - public String getEndDate() { - return endDate; - } + public String getEndDate() { + return endDate; + } - public void setEndDate(String endDate) { - this.endDate = endDate; - } + public void setEndDate(String endDate) { + this.endDate = endDate; + } - public BookingDetails.RefundStatus getRefundStatus() { - return refundStatus; - } + public int getStartingSlot() { + return startingSlot; + } - public void setRefundStatus(BookingDetails.RefundStatus refundStatus) { - this.refundStatus = refundStatus; - } + public void setStartingSlot(int startingSlot) { + this.startingSlot = startingSlot; + } + + public int getEndingSlot() { + return endingSlot; + } + + public void setEndingSlot(int endingSlot) { + this.endingSlot = endingSlot; + } + + public BookingDetails.RefundStatus getRefundStatus() { + return refundStatus; + } + + public void setRefundStatus(BookingDetails.RefundStatus refundStatus) { + this.refundStatus = refundStatus; + } } diff --git a/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentAPIController.java b/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentAPIController.java index 79bb291a..bd775575 100644 --- a/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentAPIController.java +++ b/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentAPIController.java @@ -136,8 +136,7 @@ public class PaymentAPIController { @PostMapping(value = { "/payment-request" }) public HashMap startPayment(int userId, int bookingId) throws NoSuchAlgorithmException { - // System.out.println("I entered payment Service......"+bookingId+ "User Id :- - // "+userId); + System.out.println("User entered payment Service......" + bookingId + "User Id :- " + userId); HashMap hs = new HashMap<>(); Optional findById = bookRepo.findById(bookingId); @@ -271,8 +270,7 @@ public class PaymentAPIController { @PostMapping(value = { "/additionaldamage-payment-request" }) public HashMap startextraPayment(int userId, int bookingId) throws NoSuchAlgorithmException { - // System.out.println("I entered payment Service......"+bookingId+ "User Id :- - // "+userId); + System.out.println("User entered Additional Damage payment Service......" + bookingId + "User Id :- " + userId); HashMap hs = new HashMap<>(); Optional findById = bookRepo.findById(bookingId); @@ -309,7 +307,7 @@ public class PaymentAPIController { String encryptedtoken = this.paymentService.getToken(merchantId + "|", txnId + "|", totalAmt + "|", "|", consumerId + "|", consumerMobileNo + "|", consumerEmailId + "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", this.paymentConfig.getEncryptionKey()); - System.out.println(totalAmt); + // System.out.println(totalAmt); hs.put("txansactionId", txnId); hs.put("token", encryptedtoken); hs.put("amount", totalAmt); diff --git a/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java b/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java index 17104a11..3d5e2295 100644 --- a/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java +++ b/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java @@ -41,11 +41,10 @@ import com.gcc.communityHall.service.UserService; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; - @Controller @RequestMapping("/communityhall/payment") public class PaymentController { - //ak + // ak @Autowired private EncryptionUtil encryptionUtil; @@ -73,143 +72,34 @@ public class PaymentController { @Autowired private AppConfig appConfig; -// @Autowired -// private ErpPostDataRepository erpPostDataRepository; + // @Autowired + // private ErpPostDataRepository erpPostDataRepository; @Autowired private PaymentsService paymentsService; -//ak -@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[] res = msg.split("\\|"); - String c = ""; - - TransactionResponse response = this.paymentService.getTransactionResponseByTxansactionId(res[3], "temp"); - - Payments payment = new Payments(); - payment.setTransactionId(response.getTxansactionId()); - double amount = 0; - - // ------------------ PAYMENT STRING PROCESSING ------------------ - 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]); - response.setDate(res[8]); - } - } - - int bookingId = response.getBookingId(); - - try { - amount = Double.parseDouble(response.getAmount()); - } catch (Exception e) {} - - payment.setAmountReceived(amount); - payment.setPaymentStatus("Not Completed"); - - BookingDetails bookingsDetails = bookser.getBookingsById(bookingId); // JPA fetch - payment.setBookingDetails(bookingsDetails); - response.setResponse(msg); - response.setStatusCode(res[0]); - bookingsDetails.setPayments(payment); - payment.setCdate(new Date()); - - // save transaction response - transactionResRepo.save(response); - - // ============================================================= - // CASE 1: FAILURE - AMOUNT MISMATCH - // ============================================================= - if (bookingsDetails.getAmountReceived() != amount) { - - if(paymentService.generateToken(c).equals(confirmToken) && status.equals(res[0])){ - payment.setPaymentStatus("Success"); - bookingsDetails.setPayments(payment); - paymentRepo.save(payment); - - // booking failure logic - bookser.bookingFailure(bookingsDetails, 1); - } - - // Fetch OR Generate booking_ref_id - String refId = bookser.getBookingRefIdByBookingId(bookingId); - - // encrypt bookingId (coworkspace logic) - String encryptedId = encryptionUtil.encrypt(String.valueOf(bookingId)); - - model.addAttribute("ref_id", refId); - model.addAttribute("encryptedId", encryptedId); - - return "redirect:/communityhall/user/acknowledgement?ref_id=" + refId; - } - - // ============================================================= - // CASE 2: SUCCESS FLOW - // ============================================================= - if (paymentService.generateToken(c).equals(confirmToken) && status.equals(res[0])) { - - payment.setPaymentStatus("Success"); - bookingsDetails.setPayments(payment); - paymentRepo.save(payment); - - try { - bookser.confirmBooking(bookingId); - } catch (Exception e) { - // ignore - } - } - - // 🔥 Fetch OR Generate booking_ref_id - String refId = bookser.getBookingRefIdByBookingId(bookingId); - - // 🔐 Encrypt bookingId - String encryptedId = encryptionUtil.encrypt(String.valueOf(bookingId)); - - model.addAttribute("ref_id", refId); - model.addAttribute("encryptedId", encryptedId); - - return "redirect:/communityhall/user/acknowledgement?ref_id=" + refId; -} - - - /* @PostMapping(value = "/response") + // ak + @PostMapping(value = "/response") public String response(Model model, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException { - String salt = this.paymentConfig.getEncryptionKey(); + System.out.println("Payment Response receiving from Payment Gateway..."); + 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("\\|"); + + String[] res = msg.split("\\|"); + String c = ""; TransactionResponse response = this.paymentService.getTransactionResponseByTxansactionId(res[3], "temp"); + Payments payment = new Payments(); payment.setTransactionId(response.getTxansactionId()); double amount = 0; - + // ------------------ PAYMENT STRING PROCESSING ------------------ for (int i = 0; i < res.length; i++) { + if (i == res.length - 1) { c = c + salt; confirmToken = res[i]; @@ -225,178 +115,331 @@ public String response(Model model, @RequestParam(required = false) String msg) 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); + BookingDetails bookingsDetails = bookser.getBookingsById(bookingId); // JPA fetch 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); + // save transaction response + transactionResRepo.save(response); - TransactionResponse save = transactionResRepo.save(response); + // ============================================================= + // CASE 1: FAILURE - AMOUNT MISMATCH + // ============================================================= + if (bookingsDetails.getAmountReceived() != amount) { - if (bookingsDetails.getAmountReceived() != amount) { // Reject booking if the amount is incorrect - if(paymentService.generateToken(c).equals(confirmToken) && status.equals(res[0])){ + if (paymentService.generateToken(c).equals(confirmToken) && status.equals(res[0])) { payment.setPaymentStatus("Success"); bookingsDetails.setPayments(payment); paymentRepo.save(payment); + + // booking failure logic bookser.bookingFailure(bookingsDetails, 1); } - //ak - + // Fetch OR Generate booking_ref_id + String refId = bookser.getBookingRefIdByBookingId(bookingId); - model.addAttribute("bookingsDetails", bookingsDetails); - return "redirect:/communityhall/user/acknowledgement?bookingId=" + bookingsDetails.getBookingId(); - } + // encrypt bookingId (coworkspace logic) + String encryptedId = encryptionUtil.encrypt(String.valueOf(bookingId)); + + model.addAttribute("ref_id", refId); + model.addAttribute("encryptedId", encryptedId); + return "redirect:/communityhall/user/acknowledgement?ref_id=" + refId; + } + // ============================================================= + // CASE 2: SUCCESS FLOW + // ============================================================= 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(); + paymentRepo.save(payment); + try { + bookser.confirmBooking(bookingId); + } catch (Exception e) { + // ignore } -// 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:/communityhall/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 data = new TreeMap<>(); - *//*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()); - *//* end *//* - System.out.println(data); - System.out.println(appConfig.getCommErpUrl()); -// ResponseEntity 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 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()); + // 🔥 Fetch OR Generate booking_ref_id + String refId = bookser.getBookingRefIdByBookingId(bookingId); - String resultStatus = jsonNode.get("ResultStatus").asText(); + // 🔐 Encrypt bookingId + String encryptedId = encryptionUtil.encrypt(String.valueOf(bookingId)); - if (!resultStatus.isEmpty() && resultStatus.equals("false")) { - erpData.setStatus(false); - erpPostDataRepository.save(erpData); - } + model.addAttribute("ref_id", refId); + model.addAttribute("encryptedId", encryptedId); - } else { - System.out.println("GET request failed."); - } + return "redirect:/communityhall/user/acknowledgement?ref_id=" + refId; + } - } catch (Exception e) { - e.printStackTrace(); - } - }*/ + /* + * @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:/communityhall/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:/communityhall/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 data = new TreeMap<>(); + *//* 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()); + *//* end *//* + * System.out.println(data); + * System.out.println(appConfig.getCommErpUrl()); + * // ResponseEntity 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 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") - 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(); @@ -411,7 +454,6 @@ public String response(Model model, @RequestParam(required = false) String msg) payment.setTransactionId(response.getTxansactionId()); double amount = 0; - for (int i = 0; i < res.length; i++) { if (i == res.length - 1) { c = c + salt; @@ -428,7 +470,7 @@ public String response(Model model, @RequestParam(required = false) String msg) response.setTpslTxnId(res[i]); response.setAmount(res[6]); response.setTxansactionId(res[3]); - //String[] tDate = res[8].split(" "); + // String[] tDate = res[8].split(" "); response.setDate(res[8]); } } @@ -437,7 +479,7 @@ public String response(Model model, @RequestParam(required = false) String msg) amount = Double.parseDouble(response.getAmount()); } catch (Exception e) { // TODO: handle exception - //System.out.println("payment Controller lineNo-67"); + // System.out.println("payment Controller lineNo-67"); } payment.setAmountReceived(amount); payment.setPaymentStatus("Not Completed"); @@ -462,108 +504,128 @@ public String response(Model model, @RequestParam(required = false) String msg) } model.addAttribute("bookingsDetails", bookingsDetails); extraPaymentsRepository.save(payment); -// postEPDataToERP(payment, response); //post extra payments details to ERP - // return "redirect:/communityhall/user/collectionpendingacknowledgement?bookingId=" + bookingsDetails.getBookingId(); - return "redirect:/communityhall/user/collectionpendingacknowledgement?bookingId=" + bookingsDetails.getBookingId(); + // postEPDataToERP(payment, response); //post extra payments details to ERP + // return + // "redirect:/communityhall/user/collectionpendingacknowledgement?bookingId=" + + // bookingsDetails.getBookingId(); + return "redirect:/communityhall/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 data = new TreeMap<>(); - *//*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()); - *//* end *//* - System.out.println(data); - System.out.println(appConfig.getCommErpUrl()); -// ResponseEntity 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 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(); - } - }*/ + /* + * 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 data = new TreeMap<>(); + *//* 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()); + *//* end *//* + * System.out.println(data); + * System.out.println(appConfig.getCommErpUrl()); + * // ResponseEntity 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 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") - 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 = transactionResRepo.findByTxansactionId(txansactionId); TransactionResponse transactionres = transactionresponse.get(); @@ -581,7 +643,6 @@ public String response(Model model, @RequestParam(required = false) String msg) payment.setTransactionId(response.getTxansactionId()); double amount = 0; - for (int i = 0; i < res.length; i++) { if (i == res.length - 1) { c = c + salt; @@ -598,7 +659,7 @@ public String response(Model model, @RequestParam(required = false) String msg) response.setTpslTxnId(res[i]); response.setAmount(res[6]); response.setTxansactionId(res[3]); - //String[] tDate = res[8].split(" "); + // String[] tDate = res[8].split(" "); response.setDate(res[8]); } } @@ -607,7 +668,7 @@ public String response(Model model, @RequestParam(required = false) String msg) amount = Double.parseDouble(response.getAmount()); } catch (Exception e) { // TODO: handle exception - //System.out.println("payment Controller lineNo-67"); + // System.out.println("payment Controller lineNo-67"); } payment.setAmountReceived(amount); payment.setPaymentStatus("Not Completed"); @@ -630,7 +691,7 @@ public String response(Model model, @RequestParam(required = false) String msg) // System.out.println(response.toString()); model.addAttribute("bookingsDetails", bookingsDetails); // Add single BookingDetails object - //System.out.println(save.toString()); + // System.out.println(save.toString()); paymentRepo.save(payment); return "success"; } else { @@ -639,7 +700,8 @@ public String response(Model model, @RequestParam(required = false) String msg) } @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 = transactionResRepo.findByTxansactionId(txansactionId); if (transactionresponse.isPresent()) { TransactionResponse transactionres = transactionresponse.get(); diff --git a/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java b/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java index 66dd6856..09a524bd 100644 --- a/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java +++ b/src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java @@ -1845,4 +1845,7 @@ public interface BookingDetailsRepository extends JpaRepository getApprovedBookingListforReschedule(); } diff --git a/src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java b/src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java index 282e5cf6..add697ce 100644 --- a/src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java +++ b/src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java @@ -214,8 +214,8 @@ public class BookingServiceImpl implements BookingService { // Save bookingDetailsRepository.save(booking); - System.out.println("Migrated booking ID " + bookingId + - " → ref_id = " + generatedRefId); + // System.out.println("Migrated booking ID " + bookingId + + // " → ref_id = " + generatedRefId); } } @@ -808,7 +808,7 @@ public class BookingServiceImpl implements BookingService { Integer userId = userSession.getUserId(); String counterId = userSession.getCounter(); - System.out.println("counterId.." + counterId); + // System.out.println("counterId.." + counterId); ReasonMaster reasonMaster = reasonMasterService .getReasonById(Integer.parseInt(formData.get("reasonId").toString())); @@ -878,14 +878,14 @@ public class BookingServiceImpl implements BookingService { // double depositeamount = hallDetails.getDepositAmount() * daysrange; double depositeamount = hallDetails.getDepositAmount(); - System.out.println("depositeamount...." + depositeamount); + // System.out.println("depositeamount...." + depositeamount); double halfDepositAmount = hallDetails.getHalfDepositAmount(); - System.out.println("halfDepositAmount...." + halfDepositAmount); - System.err.println("days.." + days); - System.err.println("daysrange.." + daysrange); + // System.out.println("halfDepositAmount...." + halfDepositAmount); + // System.err.println("days.." + days); + // System.err.println("daysrange.." + daysrange); double Totaldepositeamount = calculateDepositAmount(daysrange, startingSlot_txt, endingSlot_txt, depositeamount, halfDepositAmount); - System.out.println("Totaldepositeamount.." + Totaldepositeamount); + // System.out.println("Totaldepositeamount.." + Totaldepositeamount); depositeamount = Totaldepositeamount; // Calculate discount based on user type if (usertype.equals("COUNCILLOR") || usertype.equals("PENSIONER") || usertype.equals("GCC_EMPLOYEE") @@ -1182,9 +1182,9 @@ public class BookingServiceImpl implements BookingService { double damount = 0; // FOR FULL DAY // If there is only one day - System.err.println("in calculate numDays..." + numDays); - System.err.println("in calculate depositAmount..." + depositAmount); - System.err.println("in calculate HalfDepositAmount..." + HalfDepositAmount); + // System.err.println("in calculate numDays..." + numDays); + // System.err.println("in calculate depositAmount..." + depositAmount); + // System.err.println("in calculate HalfDepositAmount..." + HalfDepositAmount); if (numDays == 1) { if ("1".equals(startPeriod) && "2".equals(endPeriod)) { damount = depositAmount; @@ -1209,7 +1209,7 @@ public class BookingServiceImpl implements BookingService { damount = numDays; } } - System.err.println("in calculate damount..." + damount); + // System.err.println("in calculate damount..." + damount); return damount; } @@ -1235,6 +1235,8 @@ public class BookingServiceImpl implements BookingService { bookinghistory.setComments(bookingDetails.getComments()); bookinghistory.setCdate(new Date()); bookinghistory.setRefundStatus(bookingDetails.getRefundStatus()); + bookinghistory.setStartingSlot(bookingDetails.getStartingSlot()); + bookinghistory.setEndingSlot(bookingDetails.getEndingSlot()); bookingHistoryRepository.save(bookinghistory); BookingDocuments bd = new BookingDocuments(); @@ -1302,7 +1304,8 @@ public class BookingServiceImpl implements BookingService { bookingDetails = bookingDetailsRepository.save(bookingDetails); bookingIds.add(bookingDetails.getBookingId()); - System.out.println("BookingDetails saved with ID: " + bookingDetails.getBookingId()); + // System.out.println("BookingDetails saved with ID: " + + // bookingDetails.getBookingId()); } // Save the list of booking IDs in the GccBlockingDate entity @@ -1409,6 +1412,8 @@ public class BookingServiceImpl implements BookingService { bookHistory.setComments(bookDet.getComments()); bookHistory.setCdate(new Date()); bookHistory.setRefundStatus(bookDet.getRefundStatus()); + bookHistory.setStartingSlot(bookDet.getStartingSlot()); + bookHistory.setEndingSlot(bookDet.getEndingSlot()); bookingHistoryRepository.save(bookHistory); // Update Booking Status bookDet.setBookingStatus(status); @@ -1701,7 +1706,7 @@ public class BookingServiceImpl implements BookingService { if (SettleBookingDetails.isPresent()) { BookingDetails bookingDetails = SettleBookingDetails.get(); - System.out.println("settlement list: " + bookingDetails); + // System.out.println("settlement list: " + bookingDetails); // 🔹 Only do reset if settlement exists if (bookingDetails.getSettlement() != null) { // ✅ FIXED HERE @@ -1712,9 +1717,10 @@ public class BookingServiceImpl implements BookingService { long millisDiff = System.currentTimeMillis() - settlement.getApprovedFlagDate().getTime(); long daysDiff = millisDiff / (1000 * 60 * 60 * 24); - System.out.println("Approved Flag Date123: " + settlement.getApprovedFlagDate()); - System.out.println("Current Java Date: " + new Date()); - System.out.println("Days Difference: " + daysDiff); + // System.out.println("Approved Flag Date123: " + + // settlement.getApprovedFlagDate()); + // System.out.println("Current Java Date: " + new Date()); + // System.out.println("Days Difference: " + daysDiff); if (daysDiff > 4) { // settlement histoty insert @@ -1746,19 +1752,21 @@ public class BookingServiceImpl implements BookingService { history.setShDate(new Date()); settlementHistoryRepository.save(history); - System.out.println( - "✅ Record inserted into SettlementHistory for Settlement ID: " + settlementId); + // System.out.println( + // "✅ Record inserted into SettlementHistory for Settlement ID: " + + // settlementId); } settlement.setApprovedFlag(0); settlement.setApprovedFlagDate(null); settlementRepository.save(settlement); - System.out.println("✅ Approved flag reset after 3 days for Settlement ID: " - + settlement.getSettlementId()); + // System.out.println("✅ Approved flag reset after 3 days for Settlement ID: " + // + settlement.getSettlementId()); } } } else { - System.out.println("⚠️ No settlement found for booking ID: " + bookingDetails.getBookingId()); + // System.out.println("⚠️ No settlement found for booking ID: " + + // bookingDetails.getBookingId()); } // ✅ Return same object (your original logic) @@ -1999,6 +2007,8 @@ public class BookingServiceImpl implements BookingService { bookingHistory.setUpdatedBy(adminname); bookingHistory.setCdate(new Date()); bookingHistory.setRefundStatus(bookingDetails.getRefundStatus()); + bookingHistory.setStartingSlot(bookingDetails.getStartingSlot()); + bookingHistory.setEndingSlot(bookingDetails.getEndingSlot()); bookingDetails.setComments("Completed the Refund"); bookingHistoryRepository.save(bookingHistory); bookings.setBookingStatus(bookingStatus.COMPLETED); @@ -2107,6 +2117,8 @@ public class BookingServiceImpl implements BookingService { bookingHistory.setUpdatedBy(adminname); bookingHistory.setCdate(new Date()); bookingHistory.setRefundStatus(book.getRefundStatus()); + bookingHistory.setStartingSlot(book.getStartingSlot()); + bookingHistory.setEndingSlot(book.getEndingSlot()); bookingHistoryRepository.save(bookingHistory); book.setComments("Refund status Updated to:-" + status); @@ -2309,12 +2321,6 @@ public class BookingServiceImpl implements BookingService { LocalDate startDate = LocalDate.parse(startDat, formatter); LocalDate endDate = LocalDate.parse(endDat, formatter); - // Temporarily apply new slots for calendar-check logic - int origStartSlot = bookingDetails.getStartingSlot(); - int origEndSlot = bookingDetails.getEndingSlot(); - bookingDetails.setStartingSlot(startingSlot); - bookingDetails.setEndingSlot(endingSlot); - // Clear old calendar entries List existingCalendars = bookingCalendarRepository .getCancellingdata1(String.valueOf(bookingId)); @@ -2339,23 +2345,14 @@ public class BookingServiceImpl implements BookingService { (date.equals(startDate) && startingSlot == 2 && bookingCalendar.isEveningSlot()) || (date.equals(endDate) && endingSlot == 1 && bookingCalendar.isMorningSlot()) || (date.equals(endDate) && endingSlot == 2 && bookingCalendar.isEveningSlot())) { - // Restore original slots before throwing - bookingDetails.setStartingSlot(origStartSlot); - bookingDetails.setEndingSlot(origEndSlot); throw new SlotOccupiedException(slotOccExpMsg); } else if (bookingCalendar.isMorningSlot() && bookingCalendar.isEveningSlot()) { - bookingDetails.setStartingSlot(origStartSlot); - bookingDetails.setEndingSlot(origEndSlot); throw new SlotOccupiedException(slotOccExpMsg); } else if (!date.equals(endDate) && i != 0 && i != Math.round(bookingDetails.getNoOfDays() - 1) && (bookingCalendar.isMorningSlot() || bookingCalendar.isEveningSlot())) { - bookingDetails.setStartingSlot(origStartSlot); - bookingDetails.setEndingSlot(origEndSlot); throw new SlotOccupiedException(slotOccExpMsg); } else if (date.equals(endDate) && endingSlot == 2 && bookingCalendar.isMorningSlot() && i != 0 && i == Math.round(bookingDetails.getNoOfDays() - 1)) { - bookingDetails.setStartingSlot(origStartSlot); - bookingDetails.setEndingSlot(origEndSlot); throw new SlotOccupiedException(slotOccExpMsg); } } else { @@ -2453,6 +2450,8 @@ public class BookingServiceImpl implements BookingService { bookingHistory.setBookingStatus(BookingStatus.APPROVED); bookingHistory.setUpdatedBy(userSession.getDispayName()); bookingHistory.setCdate(new Date()); + bookingHistory.setStartingSlot(bookingDetails.getStartingSlot()); + bookingHistory.setEndingSlot(bookingDetails.getEndingSlot()); bookingDetails.setStartDate(startDate); bookingDetails.setEndDate(endDate); bookingHistory.setRefundStatus(bookingDetails.getRefundStatus()); @@ -2460,8 +2459,8 @@ public class BookingServiceImpl implements BookingService { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); String formattedDate = LocalDateTime.now().format(formatter); bookingDetails.setUpdatedDate(formattedDate); - bookingDetailsRepository.save(bookingDetails); bookingHistoryRepository.save(bookingHistory); + bookingDetailsRepository.save(bookingDetails); } /** Overload – also persists updated starting/ending slot values. */ @@ -2483,6 +2482,8 @@ public class BookingServiceImpl implements BookingService { bookingHistory.setUpdatedBy(userSession.getDispayName()); bookingHistory.setCdate(new Date()); bookingHistory.setRefundStatus(bookingDetails.getRefundStatus()); + bookingHistory.setStartingSlot(bookingDetails.getStartingSlot()); + bookingHistory.setEndingSlot(bookingDetails.getEndingSlot()); bookingDetails.setStartDate(startDate); bookingDetails.setEndDate(endDate); // ── Persist the updated slots ────────────────────────────────────── @@ -2491,8 +2492,9 @@ public class BookingServiceImpl implements BookingService { bookingDetails.setComments("slots Resheduled the Dates"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); bookingDetails.setUpdatedDate(LocalDateTime.now().format(formatter)); - bookingDetailsRepository.save(bookingDetails); bookingHistoryRepository.save(bookingHistory); + bookingDetailsRepository.save(bookingDetails); + } @Override @@ -2633,7 +2635,7 @@ public class BookingServiceImpl implements BookingService { BookingCalendar data = getbyDates(aa, hallId.toString()); int userbookingbookingId = bookingIds.get(hallIdsList.indexOf(hallId)); if (data != null) { - System.out.println("uniqueId...1" + uniqueId); + // System.out.println("uniqueId...1" + uniqueId); data.setBookingId_1(String.valueOf(userbookingbookingId)); data.setBookingId_2(String.valueOf(userbookingbookingId)); data.setMorningSlot(true); @@ -2642,7 +2644,7 @@ public class BookingServiceImpl implements BookingService { data.setUnique_id(uniqueId); updateBookingStatus(data); } else { - System.out.println("uniqueId...2" + uniqueId); + // System.out.println("uniqueId...2" + uniqueId); BookingCalendar book = new BookingCalendar(); book.setBdate(aa); book.setBookingId_1(String.valueOf(userbookingbookingId)); @@ -2745,7 +2747,7 @@ public class BookingServiceImpl implements BookingService { String uniqueId = date.format(DateTimeFormatter.ofPattern("yyyyMMdd")) + hallId; int userbookingbookingId = bookingIds.get(hallIdsList.indexOf(hallId)); if (data != null) { - System.out.println("uniqueId...11" + uniqueId); + // System.out.println("uniqueId...11" + uniqueId); // data.setBookingId_1(String.valueOf(userbookingbookingId)); // data.setBookingId_2(String.valueOf(userbookingbookingId)); // data.setMorningSlot(true); @@ -2754,7 +2756,7 @@ public class BookingServiceImpl implements BookingService { // data.setUnique_id(uniqueId); updateBookingStatus(data); } else { - System.out.println("uniqueId...21" + uniqueId); + // System.out.println("uniqueId...21" + uniqueId); BookingCalendar book = new BookingCalendar(); book.setBdate(date); book.setBookingId_1(String.valueOf(userbookingbookingId)); @@ -3209,6 +3211,8 @@ public class BookingServiceImpl implements BookingService { bookingHistory.setUpdatedBy(adminname); bookingHistory.setCdate(new Date()); bookingHistory.setRefundStatus(book.getRefundStatus()); + bookingHistory.setStartingSlot(book.getStartingSlot()); + bookingHistory.setEndingSlot(book.getEndingSlot()); bookingHistoryRepository.save(bookingHistory); return bookings; diff --git a/src/main/java/com/gcc/communityHall/service/Impl/SettlementServiceImpl.java b/src/main/java/com/gcc/communityHall/service/Impl/SettlementServiceImpl.java index 3841455e..c015b173 100644 --- a/src/main/java/com/gcc/communityHall/service/Impl/SettlementServiceImpl.java +++ b/src/main/java/com/gcc/communityHall/service/Impl/SettlementServiceImpl.java @@ -147,7 +147,7 @@ public class SettlementServiceImpl implements SettlementService { String adminname = (String) session.getAttribute("usertype"); if (settlementOptional.isPresent()) { Settlement settlement = settlementOptional.get(); - System.out.println("settlement@12345" + settlement); + // System.out.println("settlement@12345" + settlement); BookingDetails bookingDetails = settlement.getBookingDetails(); // Fetch associated BookingDetails // Update BookingDetails with new RefundStatus @@ -161,49 +161,45 @@ public class SettlementServiceImpl implements SettlementService { // to maintain history for settlement - - bookingDetailsRepository.save(bookingDetails); - //ak - //settlement histoty insert - - - if (settlementOptional.isPresent()) { - - - SettlementHistory history = new SettlementHistory(); - history.setSettlementId(settlement.getSettlementId()); - history.setComments(settlement.getComments()); - history.setCdate(settlement.getCdate()); - history.setDamageAmount(settlement.getDamageAmount()); - history.setEbAmount(settlement.getEbAmount()); - history.setDepositAmount(settlement.getDepositAmount()); - history.setRefundedAmount(settlement.getRefundedAmount()); - history.setUpdatedDate(new Date()); - history.setUpdatedId(adminname); - history.setChallon(settlement.getChallon()); - history.setDddate(settlement.getDddate()); - history.setDdnumber(settlement.getDdnumber()); - history.setBookingDetails(settlement.getBookingDetails()); - history.setCollectionPending(settlement.getCollectionPending()); - history.setDdamount(settlement.getDdamount()); - history.setChallonnumber(settlement.getChallonnumber()); - history.setCollectionStatus(settlement.getCollectionStatus()); - history.setChallonamount(settlement.getChallonamount()); - history.setApprovedFlag(settlement.getApprovedFlag()); - history.setApprovedFlagDate(settlement.getApprovedFlagDate()); - history.setShDate(new Date()); - - settlementHistoryRepository.save(history); - System.out.println("✅ Record inserted into SettlementHistory for Settlement ID: " + settlementId); - } - - + // ak + // settlement histoty insert + + if (settlementOptional.isPresent()) { + + SettlementHistory history = new SettlementHistory(); + history.setSettlementId(settlement.getSettlementId()); + history.setComments(settlement.getComments()); + history.setCdate(settlement.getCdate()); + history.setDamageAmount(settlement.getDamageAmount()); + history.setEbAmount(settlement.getEbAmount()); + history.setDepositAmount(settlement.getDepositAmount()); + history.setRefundedAmount(settlement.getRefundedAmount()); + history.setUpdatedDate(new Date()); + history.setUpdatedId(adminname); + history.setChallon(settlement.getChallon()); + history.setDddate(settlement.getDddate()); + history.setDdnumber(settlement.getDdnumber()); + history.setBookingDetails(settlement.getBookingDetails()); + history.setCollectionPending(settlement.getCollectionPending()); + history.setDdamount(settlement.getDdamount()); + history.setChallonnumber(settlement.getChallonnumber()); + history.setCollectionStatus(settlement.getCollectionStatus()); + history.setChallonamount(settlement.getChallonamount()); + history.setApprovedFlag(settlement.getApprovedFlag()); + history.setApprovedFlagDate(settlement.getApprovedFlagDate()); + history.setShDate(new Date()); + + settlementHistoryRepository.save(history); + // System.out.println("✅ Record inserted into SettlementHistory for Settlement + // ID: " + settlementId); + } + // checking ak - //settlement.setApprovedFlag(1); - //settlement.setApprovedFlagDate(new Date()); - + // settlement.setApprovedFlag(1); + // settlement.setApprovedFlagDate(new Date()); + settlement.setUpdatedDate(new Date()); // Update Settlement comments settlement.setComments(comments); diff --git a/src/main/java/com/gcc/communityHall/service/Impl/UserServiceImpl.java b/src/main/java/com/gcc/communityHall/service/Impl/UserServiceImpl.java index ce8e1a41..41478551 100644 --- a/src/main/java/com/gcc/communityHall/service/Impl/UserServiceImpl.java +++ b/src/main/java/com/gcc/communityHall/service/Impl/UserServiceImpl.java @@ -35,7 +35,6 @@ import jakarta.servlet.http.HttpSession; @Service public class UserServiceImpl implements UserService { - @Autowired UsersRepository usersRepository; @@ -59,7 +58,8 @@ public class UserServiceImpl implements UserService { @Override @Transactional public void approveUser(int userId) { - entityManager.createQuery("UPDATE Users u SET u.userstatus = 'APPROVED' WHERE u.userId = :userId AND u.userstatus = 'PENDING'") + entityManager.createQuery( + "UPDATE Users u SET u.userstatus = 'APPROVED' WHERE u.userId = :userId AND u.userstatus = 'PENDING'") .setParameter("userId", userId) .executeUpdate(); } @@ -80,10 +80,11 @@ public class UserServiceImpl implements UserService { if (user.getUsertype() == null || !user.getUsertype().equals(Users.userType.PUBLIC)) { user.setUserstatus(Users.userStatus.PENDING); } -// if(user.getUsertype().equals(Users.userType.COUNCILLOR)) { -// Counsellordetails counsellordetails=counsellorDetailsRepository.findByMobile(user.getMobileNo()); -// counsellordetails.getMobile1();counsellordetails.getMobile2() -// } + // if(user.getUsertype().equals(Users.userType.COUNCILLOR)) { + // Counsellordetails + // counsellordetails=counsellorDetailsRepository.findByMobile(user.getMobileNo()); + // counsellordetails.getMobile1();counsellordetails.getMobile2() + // } Users saveUser = usersRepository.save(user); if (user.getUserPhoto() != null && !user.getUserPhoto().isEmpty()) { @@ -102,7 +103,6 @@ public class UserServiceImpl implements UserService { return saveUser; } - @Override public Users getUserById(int userId) { Optional user = usersRepository.findById(userId); @@ -161,7 +161,6 @@ public class UserServiceImpl implements UserService { applicationLogsRepository.save(logs); return users; - } return null; } @@ -172,14 +171,13 @@ public class UserServiceImpl implements UserService { return usersRepository.findByMobileNo(mobileNo); } - //yoga + // yoga @Override public List getAllUsers(String fromDate, String toDate) { return usersRepository.getAllUsers(fromDate, toDate); } - @Override public List getAllUsersWithFilters(String fromDate, String toDate, String userStatus, String userType) { return usersRepository.getAllUsersWithFilters(fromDate, toDate, userStatus, userType); @@ -197,7 +195,6 @@ public class UserServiceImpl implements UserService { return usersRepository.getAllUsersWithTypeFilters(fromDate, toDate, userType); } - public void updateProfile(Users userProfileRequest) { // Retrieve the user entity from the repository based on the ID Optional optionalUser = usersRepository.findById(userProfileRequest.getUserId()); @@ -212,7 +209,8 @@ public class UserServiceImpl implements UserService { user.setEmail(userProfileRequest.getDoorNo()); usersRepository.save(user); } else { - System.out.println("User with ID " + userProfileRequest.getUserId() + " not found"); + // System.out.println("User with ID " + userProfileRequest.getUserId() + " not + // found"); } } @@ -246,7 +244,6 @@ public class UserServiceImpl implements UserService { return "failed"; } - @Override public void saveUsers(Users user) { // TODO Auto-generated method stub diff --git a/src/main/resources/templates/cro/booking-list.html b/src/main/resources/templates/cro/booking-list.html new file mode 100644 index 00000000..33aaf4d2 --- /dev/null +++ b/src/main/resources/templates/cro/booking-list.html @@ -0,0 +1,2139 @@ + + + + + + + + +