@ -1,7 +1,6 @@
package com.gcc.communityHall.controller ;
import java.io.File ;
import java.io.FileOutputStream ;
import java.io.IOException ;
@ -101,7 +100,9 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest ;
import jakarta.servlet.http.HttpSession ;
import lombok.AllArgsConstructor ;
import static org.hibernate.query.sqm.tree.SqmNode.log ;
import org.springframework.web.bind.annotation.GetMapping ;
import org.springframework.web.bind.annotation.RequestParam ;
import org.springframework.web.bind.annotation.ResponseBody ;
@ -232,24 +233,24 @@ public class UserAPIController {
)
/ / SendOTP
@GetMapping ( value = "/sendOTP" )
public String sendOtp ( HttpServletRequest request , @RequestParam Long mobileNo , @RequestParam String purpose ) {
public String sendOtp ( HttpServletRequest request , @RequestParam Long mobileNo , @RequestParam String purpose ) {
Long MobileNo = mobileNo ;
Long MobileNo = mobileNo ;
/ / System . out . println ( purpose ) ;
/ / System . out . print ( "\n MobileNo---:" + mobileNo ) ;
Random rand = new Random ( ) ;
/ / int otp = rand . nextInt ( 90000 ) + 10000 ;
int otp = 11111 ;
System . out . print ( "\n otp---:" + otp ) ;
System . out . print ( "\n otp---:" + otp ) ;
DateTimeFormatter dtf = DateTimeFormatter . ofPattern ( "dd-MMM-yyyy%20HH:mm" ) ;
LocalDateTime now = LocalDateTime . now ( ) ;
/ / System . out . println ( dtf . format ( now ) ) ;
String key = "pfTEYN6H" ;
String generatedToken = "Welcome to GCC! Your OTP for GCC Community Centre is " + otp ;
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" ;
String key = "pfTEYN6H" ;
String generatedToken = "Welcome to GCC! Your OTP for GCC Community Centre is " + otp ;
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 ( "\n urlString---: " + urlString ) ;
String bodyMessage = "" + otp ;
System . out . println ( "\n urlString---: " + urlString ) ;
String bodyMessage = "" + otp ;
/ * try {
RestTemplate restTemplate = new RestTemplate ( ) ;
String Response = restTemplate . getForObject ( urlString , String . class ) ;
@ -268,7 +269,6 @@ public class UserAPIController {
/ / System . out . print ( "ERROR in Sending---: " + e ) ;
bodyMessage = "Error" ;
} * /
HttpSession session = request . getSession ( ) ;
session . setAttribute ( "otp" , otp ) ;
return bodyMessage ;
@ -280,7 +280,7 @@ public class UserAPIController {
)
/ / VerifyOTP
@GetMapping ( value = "/verifyOTP" )
public String verifyOtp ( HttpServletRequest request , @RequestParam String otp , @RequestParam long mobileNo ) {
public String verifyOtp ( HttpServletRequest request , @RequestParam String otp , @RequestParam long mobileNo ) {
HttpSession session = request . getSession ( ) ;
try {
Integer session_otp = ( Integer ) session . getAttribute ( "otp" ) ;
@ -290,7 +290,7 @@ public class UserAPIController {
if ( session_otp ! = null & & session_otp . equals ( entered_otp ) ) {
System . out . println ( "Entered OTP Correct user API" ) ;
Users user = userservice . findByMobileno ( mobileNo ) ;
if ( user ! = null ) {
if ( user ! = null ) {
userSession . setMobileno ( user . getMobileNo ( ) ) ;
/ / userSession . setUserType ( user . getUserType ( ) ) ;
userSession . setDispayName ( user . getName ( ) ) ;
@ -303,9 +303,9 @@ public class UserAPIController {
} else {
System . out . println ( "Incorrect OTP. Please enter correct OTPs." ) ;
session . setAttribute ( "user" , "" ) ;
session . setAttribute ( "user" , "" ) ;
session . setAttribute ( "mobileNo" , "" ) ;
session . setAttribute ( "id" , "" ) ;
session . setAttribute ( "id" , "" ) ;
session . setAttribute ( "verifiedotp" , "error" ) ;
return "Error" ;
}
@ -317,6 +317,7 @@ public class UserAPIController {
return "Error" ;
}
}
@GetMapping ( value = "/verifyofficialOTP" )
public String verifyOtp ( HttpServletRequest request , @RequestParam String otp ) {
HttpSession session = request . getSession ( ) ;
@ -393,7 +394,6 @@ public class UserAPIController {
}
@GetMapping ( "/checkEmployee" )
public Map < String , Boolean > checkEmployee ( @RequestParam String id ) {
boolean isRegistered = usersRepository . existsByGovernmentId ( id ) ;
@ -434,10 +434,10 @@ public class UserAPIController {
)
/ / Getting the Past Data from the Calendar
@GetMapping ( "/getPastData" )
public List < BookingCalendar > getPastData ( @RequestParam ( "hall_id" ) int hall_id ) {
public List < BookingCalendar > getPastData ( @RequestParam ( "hall_id" ) int hall_id ) {
List < BookingCalendar > data = new ArrayList ( ) ;
data = bookingService . getPastData ( hall_id ) ;
if ( data ! = null ) {
if ( data ! = null ) {
return data ;
}
return data ;
@ -452,7 +452,7 @@ public class UserAPIController {
public PensionerDetailsResponse getPensionerDetails ( @RequestParam ( "pensionerId" ) String pensionerId ) {
/ / System . out . println ( pensionerId ) ;
RestTemplate restTemplate = new RestTemplate ( ) ;
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getPensionerDetailsList&pensionerId=" + pensionerId ;
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getPensionerDetailsList&pensionerId=" + pensionerId ;
ResponseEntity < String > responseEntity = restTemplate . getForEntity ( url , String . class ) ;
@ -486,7 +486,7 @@ public class UserAPIController {
public EmployeeDetailsResponse getEmployeeDetails ( @RequestParam ( "employeeId" ) Long employeeId ) {
/ / System . out . println ( "Employee ID:" + employeeId ) ;
RestTemplate restTemplate = new RestTemplate ( ) ;
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getEmployeeDetail&EmployeeID=" + employeeId ;
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getEmployeeDetail&EmployeeID=" + employeeId ;
ResponseEntity < String > responseEntity = restTemplate . getForEntity ( url , String . class ) ;
@ -520,7 +520,7 @@ public class UserAPIController {
@GetMapping ( "/FamilyPensionerDetail" )
public FamilyPensionerDetailsResponse getFamilyPensionerDetails ( @RequestParam ( "id" ) Long id ) {
RestTemplate restTemplate = new RestTemplate ( ) ;
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getFamPensionerDetailsList&familPensionId=" + id ;
String url = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getFamPensionerDetailsList&familPensionId=" + id ;
ResponseEntity < String > responseEntity = restTemplate . getForEntity ( url , String . class ) ;
@ -562,7 +562,7 @@ public class UserAPIController {
details . put ( "longitude" , hallDetails . getLongitude ( ) ) ;
details . put ( "hallId" , String . valueOf ( hallDetails . getHallId ( ) ) ) ;
details . put ( "hallName" , hallDetails . getHallName ( ) ) ;
details . put ( "seatingCapacity" , String . valueOf ( hallDetails . getSeatingCapacity ( ) ) ) ;
details . put ( "seatingCapacity" , String . valueOf ( hallDetails . getSeatingCapacity ( ) ) ) ;
details . put ( "parkingCapacity" , hallDetails . getParkingCapacity ( ) ) ;
details . put ( "hallImage" , hallDetails . getHallImagesList ( ) ) ;
details . put ( "fullDayRent" , hallDetails . getFullDayRent ( ) ) ;
@ -585,7 +585,7 @@ public class UserAPIController {
public String CheckbookingLimitation ( Model model ) {
int userId = userSession . getUserId ( ) ;
Users userById = userService . getUserById ( userId ) ;
if ( userById ! = null & & userById . getUserstatus ( ) = = Users . userStatus . PENDING ) {
if ( userById ! = null & & userById . getUserstatus ( ) = = Users . userStatus . PENDING ) {
return "pending" ;
}
if ( userById ! = null & & userById . getUserstatus ( ) = = Users . userStatus . REJECTED ) {
@ -671,7 +671,7 @@ public class UserAPIController {
@GetMapping ( value = "/getZoneNo" )
public String getZoneNo ( ) {
String urlString = appConfig . getErpUrl ( ) + "serviceId=getZones" ;
String urlString = appConfig . getErpUrl ( ) + "serviceId=getZones" ;
ResponseEntity < String > response = null ;
RestTemplate restTemplate = new RestTemplate ( ) ;
String bodyMessage = "" ;
@ -696,7 +696,7 @@ public class UserAPIController {
/ / Rest Api From ERP for getting Divisions
@GetMapping ( value = "/getDiv" )
public String getDiv ( @RequestParam String zoneId ) {
String urlString = appConfig . getErpUrl ( ) + "serviceId=getWards&Zoneid=" + zoneId + "" ;
String urlString = appConfig . getErpUrl ( ) + "serviceId=getWards&Zoneid=" + zoneId + "" ;
ResponseEntity < String > response = null ;
RestTemplate restTemplate = new RestTemplate ( ) ;
String bodyMessage = "" ;
@ -741,7 +741,24 @@ public class UserAPIController {
/ / retrieving the Booking Details based on BookingId
@GetMapping ( "/viewAllBookingDetails" )
public ResponseEntity < ? > getUserDetailsByBookingId ( @RequestParam ( "bookingId" ) int bookingId ) {
LocalDateTime rescheduledUpdatedDate = null ;
BookingDetails bookingDetails = bookingService . getBookingsById ( bookingId ) ;
if ( bookingDetails . getComments ( ) . equals ( "slots Resheduled the Dates" ) ) {
rescheduledUpdatedDate = LocalDateTime . parse ( bookingDetails . getUpdatedDate ( ) ) ;
} / * else if ( bookingDetails . getScheduleCount ( ) = = 1 ) {
List < BookingHistory > histories = bookingDetails . getBookingHistories ( ) ;
if ( histories ! = null & & ! histories . isEmpty ( ) ) {
rescheduledUpdatedDate = histories . stream ( )
. filter ( history - > "slots Resheduled the Dates" . equals ( history . getComments ( ) ) )
. map ( BookingHistory : : getUpdatedDate )
. findFirst ( )
. orElse ( null ) ; }
} * /
if ( bookingDetails ! = null ) {
return ResponseEntity . ok ( bookingDetails ) ;
} else {
@ -917,8 +934,8 @@ public class UserAPIController {
@RequestParam ( value = "area" , required = false ) String area ,
@RequestParam ( value = "location" , required = false ) String location ,
@RequestParam ( value = "usertype" , required = false ) String userType ,
@RequestParam ( value = "pinCode" , required = false ) int pinCode ,
@RequestParam ( value = "email" , required = false ) String email ,
@RequestParam ( value = "pinCode" , required = false ) int pinCode ,
@RequestParam ( value = "email" , required = false ) String email ,
@RequestParam ( value = "profilephoto" , required = false ) MultipartFile profilephoto ) {
Users userDetails = new Users ( ) ;
@ -969,8 +986,8 @@ public class UserAPIController {
)
/ / Retrive user details for counter
@GetMapping ( "/getuserforcounter" )
public ResponseEntity < ? > getCounterUserById ( @RequestParam int userId ) {
if ( userId = = 0 ) {
public ResponseEntity < ? > getCounterUserById ( @RequestParam int userId ) {
if ( userId = = 0 ) {
userId = userSession . getUserId ( ) ;
/ / System . out . println ( "User ID retrieved from session: " + userId ) ;
} else {
@ -978,7 +995,7 @@ public class UserAPIController {
}
Users user = userService . getUserById ( userId ) ;
if ( user = = null ) {
if ( user = = null ) {
return ResponseEntity . status ( HttpStatus . NOT_FOUND ) . body ( "User not found" ) ;
}
return ResponseEntity . ok ( user ) ;
@ -996,7 +1013,7 @@ public class UserAPIController {
}
Users user = userService . getUserById ( userId ) ;
Map < String , Object > response = new HashMap < > ( ) ;
response . put ( "userId" , user . getUserId ( ) ) ;
response . put ( "userId" , user . getUserId ( ) ) ;
response . put ( "name" , user . getName ( ) ) ;
response . put ( "email" , user . getEmail ( ) ) ;
response . put ( "mobileNo" , user . getMobileNo ( ) ) ;
@ -1027,15 +1044,15 @@ public class UserAPIController {
description = "REST API to Save the Booking Details"
)
/ / APi for Saving the Booking Details
@PostMapping ( path = "/saveTheRequest2" , consumes = { "multipart/form-data" } )
@PostMapping ( path = "/saveTheRequest2" , consumes = { "multipart/form-data" } )
public ResponseEntity < ? > saveTheBookingDetails2 ( HttpServletRequest request ) {
MultipartHttpServletRequest multipartRequest = ( MultipartHttpServletRequest ) request ;
Map < String , Object > bookingDetails = splitFormData ( multipartRequest ) ;
Map < String , Object > bookingDetails = splitFormData ( multipartRequest ) ;
Map < String , Object > saveBookingDetails = bookingService . saveBookingDetails ( bookingDetails ) ;
return ResponseEntity . ok ( saveBookingDetails ) ;
}
public Map < String , Object > splitFormData ( MultipartHttpServletRequest multipartRequest ) {
public Map < String , Object > splitFormData ( MultipartHttpServletRequest multipartRequest ) {
Map < String , Object > formData = new HashMap < > ( ) ;
/ / Iterate through the request parameters
@ -1067,7 +1084,7 @@ public class UserAPIController {
)
/ / retrieving the Booking Details BY Booking ID
@GetMapping ( "/getBooking" )
public ResponseEntity < ? > getBookingByID ( @RequestParam int bookingId ) {
public ResponseEntity < ? > getBookingByID ( @RequestParam int bookingId ) {
return ResponseEntity . ok ( bookingService . getBookingsById ( bookingId ) ) ;
}
@ -1077,24 +1094,24 @@ public class UserAPIController {
)
/ / Booking Cancelling by BookingId
/ / Booking Cancelling by BookingId
@GetMapping ( "/cancelBookingbyId" )
@GetMapping ( "/cancelBookingbyId" )
public ResponseEntity < ? > cancelBooking ( @RequestParam int bookingId ,
@RequestParam BookingDetails . BookingStatus status ,
@RequestParam String comments ) {
log . info ( "Received request to cancel booking with ID: {}" ) ;
log . info ( "Status: {}, Comments: {}" ) ;
Optional < BookingDetails > bookings = bookingDetailsRepository . findById ( bookingId ) ;
BookingDetails bookingDetails = bookings . get ( ) ;
Optional < BookingDetails > bookings = bookingDetailsRepository . findById ( bookingId ) ;
BookingDetails bookingDetails = bookings . get ( ) ;
try {
BookingDetails cancelledBooking = bookingService . updateCancelledBookingStatus ( bookingId , status , comments ) ;
String cancelledbookingsms = "Your booking ID " + bookingId + " on " + bookingDetails . getStartDate ( ) + " has been cancelled successfully. The deposit amount will be refunded to your account within 3 to 15 days. Thanks for using the GCC Community Hall Booking System." ;
String cancelledurlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + bookingDetails . getUsers ( ) . getMobileNo ( ) + "&from=GCCCRP&body=" + cancelledbookingsms + "&entityid=1401572690000011081&templateid=1407172346829376988" ;
String cancelledwhatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=" + bookingDetails . getUsers ( ) . getMobileNo ( ) + "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+booking+with+ID+" + bookingId + "+on+" + bookingDetails . getStartDate ( ) + "+has+been+cancelled+successfully.+%0AThe+deposit+amount+will+be+refunded+to+your+account+within+3+to+15+days." ;
String cancelledbookingsms = "Your booking ID " + bookingId + " on " + bookingDetails . getStartDate ( ) + " has been cancelled successfully. The deposit amount will be refunded to your account within 3 to 15 days. Thanks for using the GCC Community Hall Booking System." ;
String cancelledurlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + bookingDetails . getUsers ( ) . getMobileNo ( ) + "&from=GCCCRP&body=" + cancelledbookingsms + "&entityid=1401572690000011081&templateid=1407172346829376988" ;
String cancelledwhatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=" + bookingDetails . getUsers ( ) . getMobileNo ( ) + "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+booking+with+ID+" + bookingId + "+on+" + bookingDetails . getStartDate ( ) + "+has+been+cancelled+successfully.+%0AThe+deposit+amount+will+be+refunded+to+your+account+within+3+to+15+days." ;
whatsappMsgServiceImpl . sendMsg ( cancelledwhatsupmsg ) ;
whatsappMsgServiceImpl . sendSMS ( cancelledurlString ) ;
Optional < BookingDetails > book = bookingDetailsRepository . findById ( bookingDetails . getBookingId ( ) ) ;
BookingDetails booking = book . get ( ) ;
Optional < BookingDetails > book = bookingDetailsRepository . findById ( bookingDetails . getBookingId ( ) ) ;
BookingDetails booking = book . get ( ) ;
DateTimeFormatter formatter = DateTimeFormatter . ofPattern ( "yyyy-MM-dd HH:mm:ss" ) ;
String formattedDate = LocalDateTime . now ( ) . format ( formatter ) ;
booking . setUpdatedDate ( formattedDate ) ;
@ -1106,7 +1123,7 @@ public class UserAPIController {
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( "Error cancelling booking: " + e . getMessage ( ) ) ;
}
}
}
@Operation (
summary = "Family Pensioner Details from ERP REST API" ,
@ -1187,9 +1204,9 @@ public class UserAPIController {
/ / Long mobileNo = 8220798933l ;
/ / System . out . println ( "step 1" ) ;
responseMap . put ( "EmployeeDetailsResult" , employeeDetails ) ;
} else {
responseMap . put ( "EmployeeDetailsResult" , null ) ;
responseMap . put ( "EmployeeDetailsResult" , employeeDetails ) ;
} else {
responseMap . put ( "EmployeeDetailsResult" , null ) ;
}
}
} catch ( IOException e ) {
@ -1251,99 +1268,94 @@ public class UserAPIController {
description = "REST API to save the Counter Details"
)
/ / Saving the Counter Details
@PostMapping ( path = "/counter-booking" , consumes = { "multipart/form-data" } )
@PostMapping ( path = "/counter-booking" , consumes = { "multipart/form-data" } )
public ResponseEntity < ? > saveCounterBookingDetails ( HttpServletRequest request ) {
MultipartHttpServletRequest multipartRequest = ( MultipartHttpServletRequest ) request ;
Map < String , Object > bookingDetails = splitFormData ( multipartRequest ) ;
Map < String , Object > bookingDetails = splitFormData ( multipartRequest ) ;
Map < String , Object > saveCounterBooking = counterService . saveCounterBooking ( bookingDetails ) ;
return ResponseEntity . ok ( saveCounterBooking ) ;
}
@GetMapping ( "/checkAvail" )
public List < HallDetails > checkAvail ( @RequestParam ( "fromDate" ) String fromDate ,
@RequestParam ( "toDate" ) String toDate ,
@RequestParam ( "starting" ) String starting ,
@RequestParam ( "ending" ) String ending ,
@RequestParam ( name = "hallId" , required = false ) String hallId ) {
@RequestParam ( name = "hallId" , required = false ) String hallId ) {
List < BookingCalendar > data = new ArrayList < > ( ) ;
HashSet < Integer > removeHallId = new HashSet < Integer > ( ) ;
int hallIdd = 0 ;
if ( hallId ! = null & & ! hallId . equals ( "" ) ) {
int hallIdd = 0 ;
if ( hallId ! = null & & ! hallId . equals ( "" ) ) {
hallIdd = Integer . parseInt ( hallId ) ;
}
if ( ! fromDate . equals ( toDate ) & & ( starting . equals ( ending ) | | starting . equals ( "evening" ) & & ending . equals ( "morning" ) ) ) {
Map < String , String > mp = incrementAndDecrementAndDaysCount ( fromDate , toDate ) ;
long noOfDays = Long . parseLong ( mp . get ( "NoOfDays" ) . toString ( ) ) ;
if ( noOfDays > 2 ) {
data = calendarService . getCalendarByDateAndHallIdAndSlot ( mp . get ( "fromDate" ) , mp . get ( "toDate" ) , starting , ending , hallIdd ) ;
for ( int i = 0 ; i < data . size ( ) ; i + + ) {
if ( ! fromDate . equals ( toDate ) & & ( starting . equals ( ending ) | | starting . equals ( "evening" ) & & ending . equals ( "morning" ) ) ) {
Map < String , String > mp = incrementAndDecrementAndDaysCount ( fromDate , toDate ) ;
long noOfDays = Long . parseLong ( mp . get ( "NoOfDays" ) . toString ( ) ) ;
if ( noOfDays > 2 ) {
data = calendarService . getCalendarByDateAndHallIdAndSlot ( mp . get ( "fromDate" ) , mp . get ( "toDate" ) , starting , ending , hallIdd ) ;
for ( int i = 0 ; i < data . size ( ) ; i + + ) {
removeHallId . add ( data . get ( i ) . getHallId ( ) ) ;
}
}
}
data = calendarService . getCalendarByDateAndHallIdAndSlot ( fromDate , toDate , starting , ending , hallIdd ) ;
data = calendarService . getCalendarByDateAndHallIdAndSlot ( fromDate , toDate , starting , ending , hallIdd ) ;
/ / System . out . println ( "data size :-" + data . size ( ) ) ;
if ( starting ! = null & & ending ! = null ) {
boolean checkAvail = false ;
int checkHallId = 0 ;
for ( int i = 0 ; i < data . size ( ) ; i + + ) {
if ( starting ! = null & & ending ! = null ) {
boolean checkAvail = false ;
int checkHallId = 0 ;
for ( int i = 0 ; i < data . size ( ) ; i + + ) {
if ( ( starting . equals ( "evening" ) | | ending . equals ( "morning" ) ) & & fromDate . equals ( data . get ( i ) . getBdate ( ) . toString ( ) ) & & toDate . equals ( fromDate ) ) {
if ( data . get ( i ) . isEveningSlot ( ) = = false ) {
if ( ( starting . equals ( "evening" ) | | ending . equals ( "morning" ) ) & & fromDate . equals ( data . get ( i ) . getBdate ( ) . toString ( ) ) & & toDate . equals ( fromDate ) ) {
if ( data . get ( i ) . isEveningSlot ( ) = = false ) {
continue ;
}
else if ( data . get ( i ) . isMorningSlot ( ) = = false ) {
} else if ( data . get ( i ) . isMorningSlot ( ) = = false ) {
continue ;
}
} else if ( ( starting . equals ( ending ) | | starting . equals ( "evening" ) & & ending . equals ( "morning" ) ) & & ! toDate . equals ( fromDate ) ) {
if ( checkHallId = = 0 | | checkHallId ! = data . get ( i ) . getHallId ( ) ) {
if ( checkHallId = = 0 | | checkHallId ! = data . get ( i ) . getHallId ( ) ) {
checkHallId = data . get ( i ) . getHallId ( ) ;
checkAvail = false ;
checkAvail = false ;
}
if ( starting . equals ( "morning" ) & & ending . equals ( "morning" ) ) {
if ( fromDate . equals ( data . get ( i ) . getBdate ( ) . toString ( ) ) & & data . get ( i ) . isMorningSlot ( ) = = false ) {
if ( checkHallId = = data . get ( i ) . getHallId ( ) ) {
if ( starting . equals ( "morning" ) & & ending . equals ( "morning" ) ) {
if ( fromDate . equals ( data . get ( i ) . getBdate ( ) . toString ( ) ) & & data . get ( i ) . isMorningSlot ( ) = = false ) {
if ( checkHallId = = data . get ( i ) . getHallId ( ) ) {
continue ;
}
}
else if ( toDate . equals ( data . get ( i ) . getBdate ( ) . toString ( ) ) & & data . get ( i ) . isMorningSlot ( ) = = false ) {
if ( checkHallId = = data . get ( i ) . getHallId ( ) & & checkAvail = = false ) {
checkHallId = data . get ( i ) . getHallId ( ) ;
} else if ( toDate . equals ( data . get ( i ) . getBdate ( ) . toString ( ) ) & & data . get ( i ) . isMorningSlot ( ) = = false ) {
if ( checkHallId = = data . get ( i ) . getHallId ( ) & & checkAvail = = false ) {
checkHallId = data . get ( i ) . getHallId ( ) ;
continue ;
}
}
} else if ( starting . equals ( "evening" ) & & ending . equals ( "morning" ) ) {
} else if ( starting . equals ( "evening" ) & & ending . equals ( "morning" ) ) {
if ( fromDate . equals ( data . get ( i ) . getBdate ( ) . toString ( ) ) & & data . get ( i ) . isEveningSlot ( ) = = false ) {
if ( checkHallId = = data . get ( i ) . getHallId ( ) ) {
if ( fromDate . equals ( data . get ( i ) . getBdate ( ) . toString ( ) ) & & data . get ( i ) . isEveningSlot ( ) = = false ) {
if ( checkHallId = = data . get ( i ) . getHallId ( ) ) {
continue ;
}
}
else if ( toDate . equals ( data . get ( i ) . getBdate ( ) . toString ( ) ) & & data . get ( i ) . isMorningSlot ( ) = = false ) {
if ( checkHallId = = data . get ( i ) . getHallId ( ) & & checkAvail = = false ) {
checkHallId = data . get ( i ) . getHallId ( ) ;
} else if ( toDate . equals ( data . get ( i ) . getBdate ( ) . toString ( ) ) & & data . get ( i ) . isMorningSlot ( ) = = false ) {
if ( checkHallId = = data . get ( i ) . getHallId ( ) & & checkAvail = = false ) {
checkHallId = data . get ( i ) . getHallId ( ) ;
continue ;
}
}
} else if ( starting . equals ( "evening" ) & & ending . equals ( "evening" ) ) {
if ( fromDate . equals ( data . get ( i ) . getBdate ( ) . toString ( ) ) & & data . get ( i ) . isEveningSlot ( ) = = false ) {
if ( checkHallId = = data . get ( i ) . getHallId ( ) ) {
} else if ( starting . equals ( "evening" ) & & ending . equals ( "evening" ) ) {
if ( fromDate . equals ( data . get ( i ) . getBdate ( ) . toString ( ) ) & & data . get ( i ) . isEveningSlot ( ) = = false ) {
if ( checkHallId = = data . get ( i ) . getHallId ( ) ) {
continue ;
}
}
else if ( toDate . equals ( data . get ( i ) . getBdate ( ) . toString ( ) ) & & data . get ( i ) . isEveningSlot ( ) = = false ) {
if ( checkHallId = = data . get ( i ) . getHallId ( ) & & checkAvail = = false ) {
checkHallId = data . get ( i ) . getHallId ( ) ;
} else if ( toDate . equals ( data . get ( i ) . getBdate ( ) . toString ( ) ) & & data . get ( i ) . isEveningSlot ( ) = = false ) {
if ( checkHallId = = data . get ( i ) . getHallId ( ) & & checkAvail = = false ) {
checkHallId = data . get ( i ) . getHallId ( ) ;
continue ;
}
}
}
else {
if ( checkHallId = = data . get ( i ) . getHallId ( ) ) {
} else {
if ( checkHallId = = data . get ( i ) . getHallId ( ) ) {
checkAvail = true ;
}
}
@ -1353,37 +1365,37 @@ public class UserAPIController {
}
}
List < HallDetails > removeHallByid = new ArrayList < > ( ) ;
if ( hallIdd ! = 0 ) {
if ( hallIdd ! = data . get ( 0 ) . getHallId ( ) ) {
if ( hallIdd ! = 0 ) {
if ( hallIdd ! = data . get ( 0 ) . getHallId ( ) ) {
HallDetails hallDetails = hallDetailService . getHallById ( hallIdd ) ;
removeHallByid . add ( hallDetails ) ;
}
} else {
} else {
removeHallByid = hallDetailService . removeHallById ( removeHallId ) ;
}
return removeHallByid ;
}
Map < String , String > incrementAndDecrementAndDaysCount ( String fromdate , String todate ) {
Map < String , String > incrementAndDecrementAndDaysCount ( String fromdate , String todate ) {
Map mp = new HashMap < > ( ) ;
LocalDate increasement = LocalDate . parse ( fromdate ) ;
LocalDate decrement = LocalDate . parse ( todate ) ;
LocalDate outputDateFrom = increasement ;
LocalDate outputDateFrom = increasement ;
LocalDate outputDateToday = decrement ;
long daysDifference = increasement . until ( decrement ) . getDays ( ) ;
daysDifference = Math . abs ( daysDifference ) ;
if ( fromdate ! = todate ) {
if ( fromdate ! = todate ) {
outputDateFrom = increasement . plusDays ( 1 ) ;
outputDateToday = decrement . minusDays ( 1 ) ;
}
mp . put ( "fromDate" , outputDateFrom . format ( DateTimeFormatter . ofPattern ( "yyyy-MM-dd" ) ) ) ;
mp . put ( "toDate" , outputDateToday . format ( DateTimeFormatter . ofPattern ( "yyyy-MM-dd" ) ) ) ;
mp . put ( "NoOfDays" , daysDifference + "" ) ;
mp . put ( "toDate" , outputDateToday . format ( DateTimeFormatter . ofPattern ( "yyyy-MM-dd" ) ) ) ;
mp . put ( "NoOfDays" , daysDifference + "" ) ;
return mp ;
}
@ -1475,7 +1487,7 @@ public class UserAPIController {
Map < String , Object > settlementRaisingDetail = new HashMap < > ( ) ;
settlementRaisingDetail . put ( "status" , "SETTLEMENT_RAISING" ) ;
settlementRaisingDetail . put ( "description" , "Settlement Raising" ) ;
settlementRaisingDetail . put ( "dateTime" , bookingDetails . getSettlement ( ) . getUpdatedDate ( ) ) ;
settlementRaisingDetail . put ( "dateTime" , bookingDetails . getSettlement ( ) . getUpdatedDate ( ) ) ;
trackingDetails . add ( settlementRaisingDetail ) ;
}
@ -1490,9 +1502,9 @@ public class UserAPIController {
}
if ( bookingDetails . getBookingStatus ( ) = = BookingStatus . CANCELED ) {
Map < String , Object > bookingCanceledDetail = new HashMap < > ( ) ;
bookingCanceledDetail . put ( "status" , "CANCELED" ) ;
if ( bookingDetails . getBookingStatus ( ) = = BookingStatus . CANCELED ) {
Map < String , Object > bookingCanceledDetail = new HashMap < > ( ) ;
bookingCanceledDetail . put ( "status" , "CANCELED" ) ;
bookingCanceledDetail . put ( "description" , "Booking Cancelled" ) ;
bookingCanceledDetail . put ( "dateTime" , bookingDetails . getUpdatedDate ( ) ) ; / / Assuming BookingDate is correct
trackingDetails . add ( bookingCanceledDetail ) ;
@ -1500,16 +1512,16 @@ public class UserAPIController {
if ( bookingDetails . getBookingStatus ( ) = = BookingStatus . CANCELED
& & bookingDetails . getRefundStatus ( ) = = RefundStatus . WAITING ) {
Map < String , Object > canceledRaisingDetail = new HashMap < > ( ) ;
canceledRaisingDetail . put ( "status" , "SETTLEMENT_RAISING" ) ;
& & bookingDetails . getRefundStatus ( ) = = RefundStatus . WAITING ) {
Map < String , Object > canceledRaisingDetail = new HashMap < > ( ) ;
canceledRaisingDetail . put ( "status" , "SETTLEMENT_RAISING" ) ;
canceledRaisingDetail . put ( "description" , "Settlement Raising" ) ;
canceledRaisingDetail . put ( "dateTime" , bookingDetails . getUpdatedDate ( ) ) ; / / Assuming BookingDate is correct
trackingDetails . add ( canceledRaisingDetail ) ;
}
if ( bookingDetails . getBookingStatus ( ) = = BookingStatus . CANCELED
& & bookingDetails . getRefundStatus ( ) = = BookingDetails . RefundStatus . COMPLETED ) {
& & bookingDetails . getRefundStatus ( ) = = BookingDetails . RefundStatus . COMPLETED ) {
Map < String , Object > cancelRefundCompletedDetail = new HashMap < > ( ) ;
cancelRefundCompletedDetail . put ( "status" , "COMPLETED" ) ;
cancelRefundCompletedDetail . put ( "description" , "Refund Completed" ) ;
@ -1517,9 +1529,9 @@ public class UserAPIController {
trackingDetails . add ( cancelRefundCompletedDetail ) ;
}
if ( bookingDetails . getBookingStatus ( ) = = BookingStatus . REJECTED ) {
Map < String , Object > bookingRejectedDetail = new HashMap < > ( ) ;
bookingRejectedDetail . put ( "status" , "REJECTED" ) ;
if ( bookingDetails . getBookingStatus ( ) = = BookingStatus . REJECTED ) {
Map < String , Object > bookingRejectedDetail = new HashMap < > ( ) ;
bookingRejectedDetail . put ( "status" , "REJECTED" ) ;
bookingRejectedDetail . put ( "description" , "Booking Rejected" ) ;
bookingRejectedDetail . put ( "dateTime" , bookingDetails . getUpdatedDate ( ) ) ; / / Assuming BookingDate is correct
trackingDetails . add ( bookingRejectedDetail ) ;
@ -1527,16 +1539,16 @@ public class UserAPIController {
if ( bookingDetails . getBookingStatus ( ) = = BookingStatus . REJECTED
& & bookingDetails . getRefundStatus ( ) = = RefundStatus . WAITING ) {
Map < String , Object > rejectedRaisingDetail = new HashMap < > ( ) ;
rejectedRaisingDetail . put ( "status" , "SETTLEMENT_RAISING" ) ;
& & bookingDetails . getRefundStatus ( ) = = RefundStatus . WAITING ) {
Map < String , Object > rejectedRaisingDetail = new HashMap < > ( ) ;
rejectedRaisingDetail . put ( "status" , "SETTLEMENT_RAISING" ) ;
rejectedRaisingDetail . put ( "description" , "Settlement Raising" ) ;
rejectedRaisingDetail . put ( "dateTime" , bookingDetails . getUpdatedDate ( ) ) ; / / Assuming BookingDate is correct
trackingDetails . add ( rejectedRaisingDetail ) ;
}
if ( bookingDetails . getBookingStatus ( ) = = BookingStatus . REJECTED
& & bookingDetails . getRefundStatus ( ) = = BookingDetails . RefundStatus . COMPLETED ) {
& & bookingDetails . getRefundStatus ( ) = = BookingDetails . RefundStatus . COMPLETED ) {
Map < String , Object > rejectedRefundCompletedDetail = new HashMap < > ( ) ;
rejectedRefundCompletedDetail . put ( "status" , "COMPLETED" ) ;
rejectedRefundCompletedDetail . put ( "description" , "Refund Completed" ) ;
@ -1545,10 +1557,9 @@ public class UserAPIController {
}
if ( bookingDetails . getBookingStatus ( ) = = BookingStatus . GCC_BLOCKED ) {
Map < String , Object > gccBlockedDetail = new HashMap < > ( ) ;
gccBlockedDetail . put ( "status" , "GCC_BLOCKED" ) ;
if ( bookingDetails . getBookingStatus ( ) = = BookingStatus . GCC_BLOCKED ) {
Map < String , Object > gccBlockedDetail = new HashMap < > ( ) ;
gccBlockedDetail . put ( "status" , "GCC_BLOCKED" ) ;
gccBlockedDetail . put ( "description" , "GCC Blocked" ) ;
gccBlockedDetail . put ( "dateTime" , bookingDetails . getUpdatedDate ( ) ) ;
trackingDetails . add ( gccBlockedDetail ) ;
@ -1559,8 +1570,8 @@ public class UserAPIController {
@GetMapping ( "/confirmstatebooking" )
public String Confirmstatebookig ( @RequestParam int bookingId ) {
String response = bookingService . confirmStateBooking ( bookingId ) ;
public String Confirmstatebookig ( @RequestParam int bookingId ) {
String response = bookingService . confirmStateBooking ( bookingId ) ;
return response ;
}
@ -1734,22 +1745,22 @@ public class UserAPIController {
response . put ( "amount" , amount ) ;
response . put ( "totalAmount" , totalAmount ) ;
response . put ( "depositAmount" , totalDepositAmount ) ;
double gstValue = gstRate * amount / 100 . 0 ;
double gstValue = gstRate * amount / 100 . 0 ;
response . put ( "gst" , gstValue ) ;
response . put ( "discountAmount" , amount ) ;
} else {
if ( "SGE" . equals ( reasonforBooking ) ) {
double cleaningCharges = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getFullDayCleaningcharges ( ) ;
double pasystem = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getFulldayPAsystem ( ) ;
double ebCharges = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getFulldayEBcharges ( ) ;
double pasystem = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getFulldayPAsystem ( ) ;
double ebCharges = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getFulldayEBcharges ( ) ;
double halfcleaningCharges = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getHalfDayCleaningcharges ( ) ;
double halfpasystem = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getHalfdayPAsystem ( ) ;
double halfebCharges = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getHalfdayEBcharges ( ) ;
double fulladditionalCharges = cleaningCharges + pasystem + ebCharges ;
double halfadditionalCharges = halfcleaningCharges + halfpasystem + halfebCharges ;
double fulldayhallAmount = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getFulldayhallamount ( ) ;
double halfdayhallAmount = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getHalfdayhallamount ( ) ;
double additionalCharges = calculateAmount ( numDays , startPeriod , endPeriod , fulladditionalCharges , halfadditionalCharges ) ;
double halfpasystem = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getHalfdayPAsystem ( ) ;
double halfebCharges = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getHalfdayEBcharges ( ) ;
double fulladditionalCharges = cleaningCharges + pasystem + ebCharges ;
double halfadditionalCharges = halfcleaningCharges + halfpasystem + halfebCharges ;
double fulldayhallAmount = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getFulldayhallamount ( ) ;
double halfdayhallAmount = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getHalfdayhallamount ( ) ;
double additionalCharges = calculateAmount ( numDays , startPeriod , endPeriod , fulladditionalCharges , halfadditionalCharges ) ;
totalAmount = additionalCharges + totalDepositAmount + ( additionalCharges * gstRate / 100 . 0 ) ;
discountAmount = ( fulldayhallAmount * hallDetails . getSGEdiscount ( ) ) / 100 . 0 ;
response . put ( "startperiod" , startPeriod ) ;
@ -1766,18 +1777,18 @@ public class UserAPIController {
response . put ( "discountAmount" , discountAmount ) ;
} else if ( "CGE" . equals ( reasonforBooking ) ) {
double cleaningCharges = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getFullDayCleaningcharges ( ) ;
double pasystem = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getFulldayPAsystem ( ) ;
double ebCharges = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getFulldayEBcharges ( ) ;
double pasystem = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getFulldayPAsystem ( ) ;
double ebCharges = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getFulldayEBcharges ( ) ;
double halfcleaningCharges = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getHalfDayCleaningcharges ( ) ;
double halfpasystem = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getHalfdayPAsystem ( ) ;
double halfebCharges = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getHalfdayEBcharges ( ) ;
double fulladditionalCharges = cleaningCharges + pasystem + ebCharges ;
double halfadditionalCharges = halfcleaningCharges + halfpasystem + halfebCharges ;
double additionalCharges = calculateAmount ( numDays , startPeriod , endPeriod , fulladditionalCharges , halfadditionalCharges ) ;
double halfpasystem = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getHalfdayPAsystem ( ) ;
double halfebCharges = hallDetails . getHallDetailsConcession ( ) . get ( 0 ) . getHalfdayEBcharges ( ) ;
double fulladditionalCharges = cleaningCharges + pasystem + ebCharges ;
double halfadditionalCharges = halfcleaningCharges + halfpasystem + halfebCharges ;
double additionalCharges = calculateAmount ( numDays , startPeriod , endPeriod , fulladditionalCharges , halfadditionalCharges ) ;
double rentAmount = ( amount * hallDetails . getCGEdiscount ( ) ) / 100 . 0 ;
double netAmount = rentAmount + additionalCharges ;
double gst = ( ( additionalCharges + rentAmount ) * gstRate / 100 . 0 ) ;
totalAmount = Math . floor ( ( netAmount + gst + totalDepositAmount ) * 100 ) / 100 . 0 ;
double gst = ( ( additionalCharges + rentAmount ) * gstRate / 100 . 0 ) ;
totalAmount = Math . floor ( ( netAmount + gst + totalDepositAmount ) * 100 ) / 100 . 0 ;
response . put ( "startperiod" , startPeriod ) ;
response . put ( "endPeriod" , endPeriod ) ;
response . put ( "fulldayhallAmount" , fullDayAmount ) ;
@ -1791,7 +1802,7 @@ public class UserAPIController {
response . put ( "totalAmount" , totalAmount ) ;
response . put ( "discountAmount" , discountAmount ) ;
} else {
double gstValue = ( gstRate * amount ) / 100 . 0 ;
double gstValue = ( gstRate * amount ) / 100 . 0 ;
totalAmount = Math . ceil ( ( amount + gstValue + totalDepositAmount ) * 100 ) / 100 ;
response . put ( "discount" , 0 ) ;
response . put ( "amount" , amount ) ;
@ -1804,6 +1815,7 @@ public class UserAPIController {
return ResponseEntity . ok ( response ) ;
}
public double calculateAmount ( double numDays , String startPeriod , String endPeriod , double fullDayAmount , double halfDayAmount ) {
double amount = 0 ;
@ -1815,8 +1827,8 @@ public class UserAPIController {
amount = halfDayAmount ;
} else if ( "2" . equals ( startPeriod ) & & "2" . equals ( endPeriod ) ) {
amount = halfDayAmount ;
} else {
amount = numDays ;
} else {
amount = numDays ;
}
} else {
/ / For multiple days
@ -1828,8 +1840,8 @@ public class UserAPIController {
amount = fullDayAmount * ( numDays - 1 ) + halfDayAmount ;
} else if ( "2" . equals ( startPeriod ) & & "1" . equals ( endPeriod ) ) {
amount = fullDayAmount * ( numDays - 2 ) + halfDayAmount * 2 ;
} else {
amount = numDays ;
} else {
amount = numDays ;
}
}
@ -1856,10 +1868,10 @@ public class UserAPIController {
@GetMapping ( "/collectionpendingacknowledgementsss" )
public BookingDetails viewCollectionpendingAck ( Model model , int bookingId ) {
public BookingDetails viewCollectionpendingAck ( Model model , int bookingId ) {
BookingDetails bookingsDetails = bookingService . getBookingsById ( bookingId ) ;
model . addAttribute ( "bookingsDetails" , bookingsDetails ) ; / / Add single BookingDetails object
model . addAttribute ( "userName" , userSession . getDispayName ( ) ) ;
model . addAttribute ( "bookingsDetails" , bookingsDetails ) ; / / Add single BookingDetails object
model . addAttribute ( "userName" , userSession . getDispayName ( ) ) ;
return bookingsDetails ;
}
@ -1908,6 +1920,5 @@ public class UserAPIController {
}
}