@ -1,19 +1,18 @@
package com.gcc.communityHall.controller ;
package com.gcc.communityHall.controller ;
import java.io.FileOutputStream ;
import java.net.InetAddress ;
import java.net.InetAddress ;
import java.net.UnknownHostException ;
import java.net.UnknownHostException ;
import java.time.Instant ;
import java.time.LocalDate ;
import java.time.LocalDate ;
import java.util.Arrays ;
import java.util.Collections ;
import java.util.Date ;
import java.util.Date ;
import java.util.HashMap ;
import java.util.HashMap ;
import java.util.List ;
import java.util.List ;
import java.util.Map ;
import java.util.Map ;
import java.util.Optional ;
import java.util.Optional ;
import java.util.stream.Collectors ;
import ch.qos.logback.core.CoreConstants ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Value ;
import org.springframework.format.annotation.DateTimeFormat ;
import org.springframework.format.annotation.DateTimeFormat ;
import org.springframework.http.HttpStatus ;
import org.springframework.http.HttpStatus ;
import org.springframework.http.ResponseEntity ;
import org.springframework.http.ResponseEntity ;
@ -21,31 +20,26 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping ;
import org.springframework.web.bind.annotation.GetMapping ;
import org.springframework.web.bind.annotation.PathVariable ;
import org.springframework.web.bind.annotation.PathVariable ;
import org.springframework.web.bind.annotation.PostMapping ;
import org.springframework.web.bind.annotation.PostMapping ;
import org.springframework.web.bind.annotation.RequestBody ;
import org.springframework.web.bind.annotation.RequestMapping ;
import org.springframework.web.bind.annotation.RequestMapping ;
import org.springframework.web.bind.annotation.RequestParam ;
import org.springframework.web.bind.annotation.RequestParam ;
import org.springframework.web.bind.annotation.RestController ;
import org.springframework.web.bind.annotation.RestController ;
import org.springframework.web.multipart.MultipartFile ;
import org.springframework.web.multipart.MultipartFile ;
import java.net.InetAddress ;
import com.gcc.communityHall.dto.PaymentsDTO ;
import com.gcc.communityHall.dto.PaymentsDTO ;
import com.gcc.communityHall.entity.ApplicationLogs ;
import com.gcc.communityHall.entity.ApplicationLogs ;
import com.gcc.communityHall.entity.BookingCalendar ;
import com.gcc.communityHall.entity.BookingCalendar ;
import com.gcc.communityHall.entity.BookingDetails ;
import com.gcc.communityHall.entity.BookingDetails ;
import com.gcc.communityHall.entity.BookingDetails.BookingStatus ;
import com.gcc.communityHall.entity.BookingDetails.BookingStatus ;
import com.gcc.communityHall.entity.BookingDetails.RefundStatus ;
import com.gcc.communityHall.entity.BookingDetails.RefundStatus ;
import com.gcc.communityHall.entity.Users.userType ;
import com.gcc.communityHall.paymentService.entity.TransactionResponse ;
import com.gcc.communityHall.entity.BookingHistory ;
import com.gcc.communityHall.entity.CounterRefundList ;
import com.gcc.communityHall.entity.CounterRefundList ;
import com.gcc.communityHall.entity.GccBlockingDate ;
import com.gcc.communityHall.entity.Settlement ;
import com.gcc.communityHall.entity.Settlement ;
import com.gcc.communityHall.entity.SettlementHistory ;
import com.gcc.communityHall.entity.Users ;
import com.gcc.communityHall.entity.Users ;
import com.gcc.communityHall.repository.ApplicationLogsRepository ;
import com.gcc.communityHall.repository.ApplicationLogsRepository ;
import com.gcc.communityHall.repository.BookingCalendarRepository ;
import com.gcc.communityHall.repository.BookingCalendarRepository ;
import com.gcc.communityHall.repository.BookingDetailsRepository ;
import com.gcc.communityHall.repository.BookingDetailsRepository ;
import com.gcc.communityHall.repository.BookingHistoryRepository ;
import com.gcc.communityHall.repository.BookingHistoryRepository ;
import com.gcc.communityHall.repository.CounterRefundListRepository ;
import com.gcc.communityHall.repository.CounterRefundListRepository ;
import com.gcc.communityHall.repository.SettlementHistory Repository ;
import com.gcc.communityHall.repository.GccBlockingDate Repository ;
import com.gcc.communityHall.repository.SettlementRepository ;
import com.gcc.communityHall.repository.SettlementRepository ;
import com.gcc.communityHall.repository.UsersRepository ;
import com.gcc.communityHall.repository.UsersRepository ;
import com.gcc.communityHall.service.BookingService ;
import com.gcc.communityHall.service.BookingService ;
@ -55,7 +49,6 @@ import com.gcc.communityHall.service.ReasonMasterService;
import com.gcc.communityHall.service.SettlementService ;
import com.gcc.communityHall.service.SettlementService ;
import com.gcc.communityHall.service.UserService ;
import com.gcc.communityHall.service.UserService ;
import com.gcc.communityHall.service.Impl.BookingServiceImpl ;
import com.gcc.communityHall.service.Impl.BookingServiceImpl ;
import com.gcc.communityHall.service.Impl.SettlementServiceImpl ;
import com.gcc.communityHall.service.Impl.UserServiceImpl ;
import com.gcc.communityHall.service.Impl.UserServiceImpl ;
import com.gcc.communityHall.service.Impl.WhatsappMsgServiceImpl ;
import com.gcc.communityHall.service.Impl.WhatsappMsgServiceImpl ;
@ -65,20 +58,13 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession ;
import jakarta.servlet.http.HttpSession ;
import lombok.AllArgsConstructor ;
import lombok.AllArgsConstructor ;
@Tag (
name = "CRUD REST APIs for Officer in CommunityHall" ,
description = "CRUD REST APIs in CommunityHall to CREATE, UPDATE, FETCH AND DELETE Booking details"
)
@Tag ( name = "CRUD REST APIs for Officer in CommunityHall" , description = "CRUD REST APIs in CommunityHall to CREATE, UPDATE, FETCH AND DELETE Booking details" )
@RestController
@RestController
@RequestMapping ( "/communityhall/api/officer" )
@RequestMapping ( "/communityhall/api/officer" )
@AllArgsConstructor
@AllArgsConstructor
@Validated
@Validated
public class OfficerAPIController {
public class OfficerAPIController {
/ / ak / / ak
/ / ak / / ak
@Autowired
private SettlementHistoryRepository settlementHistoryRepository ;
@Autowired
@Autowired
private UserService userService ;
private UserService userService ;
@ -91,9 +77,6 @@ public class OfficerAPIController {
@Autowired
@Autowired
private UserServiceImpl userServiceImpl ;
private UserServiceImpl userServiceImpl ;
@Autowired
private SettlementServiceImpl settlementServiceImpl ;
@Autowired
@Autowired
private SettlementRepository settlementRepository ;
private SettlementRepository settlementRepository ;
@ -119,8 +102,9 @@ public class OfficerAPIController {
private WhatsappMsgServiceImpl whatsappMsgServiceImpl ;
private WhatsappMsgServiceImpl whatsappMsgServiceImpl ;
@Autowired
@Autowired
private PaymentsService paymentsService ;
private PaymentsService paymentsService ;
@Autowired
@Autowired
private BookingHistoryRepository bookingHistory Repository;
private GccBlockingDateRepository blockingDate Repository;
@Autowired
@Autowired
private HttpSession session ;
private HttpSession session ;
@ -128,10 +112,7 @@ public class OfficerAPIController {
@Autowired
@Autowired
private ApplicationLogsRepository applicationLogsRepository ;
private ApplicationLogsRepository applicationLogsRepository ;
@Operation (
summary = "Retriving the User Details by userId REST API" ,
description = "REST API for Retriving the User Details by UserId"
)
@Operation ( summary = "Retriving the User Details by userId REST API" , description = "REST API for Retriving the User Details by UserId" )
/ / Getting User Details by User Id
/ / Getting User Details by User Id
@GetMapping ( "/getUserDetails" )
@GetMapping ( "/getUserDetails" )
public ResponseEntity < ? > getUsersByID ( HttpServletRequest request , @RequestParam String usersid ) {
public ResponseEntity < ? > getUsersByID ( HttpServletRequest request , @RequestParam String usersid ) {
@ -139,39 +120,32 @@ public class OfficerAPIController {
return ResponseEntity . ok ( user ) ;
return ResponseEntity . ok ( user ) ;
}
}
@Operation (
summary = "Settlement List where the Refund Status is WAITING REST API" ,
description = "REST API for Retriving the Settlement List where the Refund Status is WAITING"
)
@Operation ( summary = "Settlement List where the Refund Status is WAITING REST API" , description = "REST API for Retriving the Settlement List where the Refund Status is WAITING" )
/ / retrieving the Settlement List by Refund Status is WAITING
/ / retrieving the Settlement List by Refund Status is WAITING
@GetMapping ( "/waiting-refund" )
@GetMapping ( "/waiting-refund" )
public List < Settlement > getSettlementsWithWaitingRefund ( ) {
public List < Settlement > getSettlementsWithWaitingRefund ( ) {
return settlementService . getSettlementListWithWaitingRefund ( ) ;
return settlementService . getSettlementListWithWaitingRefund ( ) ;
}
}
@Operation (
summary = "Settlement List by Settlement Id REST API" ,
description = "REST API for Retriving the Settlement List by Settlement Id"
)
@Operation ( summary = "Settlement List by Settlement Id REST API" , description = "REST API for Retriving the Settlement List by Settlement Id" )
/ / retrieving the Settlement List by Settlement Id
/ / retrieving the Settlement List by Settlement Id
@GetMapping ( "/getSettlementList" )
@GetMapping ( "/getSettlementList" )
public ResponseEntity < BookingDetails > getBookingDetailsWithSettlement ( HttpServletRequest request , @RequestParam String settlementsid ) {
BookingDetails bookingDetails = bookingServiceImpl . getBookingDetailsWithSettlement ( Integer . parseInt ( settlementsid ) ) ;
public ResponseEntity < BookingDetails > getBookingDetailsWithSettlement ( HttpServletRequest request ,
@RequestParam String settlementsid ) {
BookingDetails bookingDetails = bookingServiceImpl
. getBookingDetailsWithSettlement ( Integer . parseInt ( settlementsid ) ) ;
System . out . println ( "bookingDetails:12 " + bookingDetails ) ;
System . out . println ( "bookingDetails:12 " + bookingDetails ) ;
return ResponseEntity . ok ( bookingDetails ) ;
return ResponseEntity . ok ( bookingDetails ) ;
}
}
@GetMapping ( "/getsettlementListbyid" )
@GetMapping ( "/getsettlementListbyid" )
public ResponseEntity < Optional < Settlement > > getsettlementlist ( HttpServletRequest request , @RequestParam int settlementsid ) {
public ResponseEntity < Optional < Settlement > > getsettlementlist ( HttpServletRequest request ,
@RequestParam int settlementsid ) {
Optional < Settlement > settlementlist = settlementRepository . findById ( settlementsid ) ;
Optional < Settlement > settlementlist = settlementRepository . findById ( settlementsid ) ;
return ResponseEntity . ok ( settlementlist ) ;
return ResponseEntity . ok ( settlementlist ) ;
}
}
@Operation (
summary = "Booking Details by Booking Id REST API" ,
description = "REST API for Retriving the Booking Details by Booking Id"
)
@Operation ( summary = "Booking Details by Booking Id REST API" , description = "REST API for Retriving the Booking Details by Booking Id" )
/ / retrieving the Booking Details by Booking Id
/ / retrieving the Booking Details by Booking Id
@GetMapping ( "/getBookingDetails" )
@GetMapping ( "/getBookingDetails" )
public ResponseEntity < ? > getBookingsById ( HttpServletRequest request , @RequestParam String bookingsId ) {
public ResponseEntity < ? > getBookingsById ( HttpServletRequest request , @RequestParam String bookingsId ) {
@ -179,11 +153,9 @@ public class OfficerAPIController {
return ResponseEntity . ok ( book ) ;
return ResponseEntity . ok ( book ) ;
}
}
@Operation (
summary = "Settlement APPROVED REST API" ,
description = "REST API for Updating the Refund Status to Approved by Settlement Id If the settlement is Approved"
)
/ / Updating the Refund Status to Approved by Settlement Id If the settlement is Approved
@Operation ( summary = "Settlement APPROVED REST API" , description = "REST API for Updating the Refund Status to Approved by Settlement Id If the settlement is Approved" )
/ / Updating the Refund Status to Approved by Settlement Id If the settlement is
/ / Approved
@PostMapping ( "/updateApprovedSettlementStatus/{settlementId}" ) / / need to check this API for settlement approval
@PostMapping ( "/updateApprovedSettlementStatus/{settlementId}" ) / / need to check this API for settlement approval
public ResponseEntity < Object > updateApprovedSettlementStatus (
public ResponseEntity < Object > updateApprovedSettlementStatus (
@PathVariable ( "settlementId" ) int settlementId ,
@PathVariable ( "settlementId" ) int settlementId ,
@ -191,7 +163,6 @@ public class OfficerAPIController {
@RequestParam ( "comments" ) String comments ) {
@RequestParam ( "comments" ) String comments ) {
Map < String , Object > response = new HashMap < > ( ) ;
Map < String , Object > response = new HashMap < > ( ) ;
try {
try {
System . out . println ( "settlementId1: " + settlementId ) ;
System . out . println ( "settlementId1: " + settlementId ) ;
System . out . println ( "status" + status ) ;
System . out . println ( "status" + status ) ;
@ -231,7 +202,8 @@ public class OfficerAPIController {
applicationLogsRepository . save ( logs ) ;
applicationLogsRepository . save ( logs ) ;
/ / Process refund request
/ / Process refund request
String refundResponse = bookingServiceImpl . processRefundRequest ( updateSettlement . getBookingDetails ( ) . getBookingId ( ) ) ;
String refundResponse = bookingServiceImpl
. processRefundRequest ( updateSettlement . getBookingDetails ( ) . getBookingId ( ) ) ;
/ / ak
/ / ak
/ / Prepare response map
/ / Prepare response map
@ -246,14 +218,16 @@ public class OfficerAPIController {
} else {
} else {
/ / Refund failure , update refund status to FAILURE
/ / Refund failure , update refund status to FAILURE
bookingService . updateRefundStatus ( updateSettlement . getBookingDetails ( ) . getBookingId ( ) , BookingDetails . RefundStatus . FAILURE ) ;
bookingService . updateRefundStatus ( updateSettlement . getBookingDetails ( ) . getBookingId ( ) ,
BookingDetails . RefundStatus . FAILURE ) ;
Map < String , Object > responses = new HashMap < > ( ) ;
Map < String , Object > responses = new HashMap < > ( ) ;
responses . put ( "approvedFlag" , 1 ) ;
responses . put ( "approvedFlag" , 1 ) ;
responses . put ( "message" , "Refund processing failed: " + refundResponse ) ;
responses . put ( "message" , "Refund processing failed: " + refundResponse ) ;
responses . put ( "status" , "FAILURE" ) ;
responses . put ( "status" , "FAILURE" ) ;
return new ResponseEntity < > ( responses , HttpStatus . INTERNAL_SERVER_ERROR ) ;
return new ResponseEntity < > ( responses , HttpStatus . INTERNAL_SERVER_ERROR ) ;
/ / return new ResponseEntity < > ( "Refund processing failed: " + refundResponse , HttpStatus . INTERNAL_SERVER_ERROR ) ;
/ / return new ResponseEntity < > ( "Refund processing failed: " + refundResponse ,
/ / HttpStatus . INTERNAL_SERVER_ERROR ) ;
}
}
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -261,15 +235,15 @@ public class OfficerAPIController {
response . put ( "message" , "Exception while approving settlement: " + e . getMessage ( ) ) ;
response . put ( "message" , "Exception while approving settlement: " + e . getMessage ( ) ) ;
return new ResponseEntity < > ( response , HttpStatus . INTERNAL_SERVER_ERROR ) ;
return new ResponseEntity < > ( response , HttpStatus . INTERNAL_SERVER_ERROR ) ;
/ / return new ResponseEntity < > ( "An error occurred while processing the settlement for Settlement ID: " + settlementId , HttpStatus . INTERNAL_SERVER_ERROR ) ;
/ / return new ResponseEntity < > ( " An error occurred while processing the
/ / settlement for Settlement ID : " + settlementId ,
/ / HttpStatus . INTERNAL_SERVER_ERROR ) ;
}
}
}
}
@Operation (
summary = "Settlement APPROVED REST API" ,
description = "REST API for Updating the Refund Status to Approved by Settlement Id If the settlement is Approved"
)
/ / Updating the Refund Status to Rejected by Settlement Id If the settlement is Rejected
@Operation ( summary = "Settlement APPROVED REST API" , description = "REST API for Updating the Refund Status to Approved by Settlement Id If the settlement is Approved" )
/ / Updating the Refund Status to Rejected by Settlement Id If the settlement is
/ / Rejected
@PostMapping ( "/updateRejectSettlementStatus/{settlementId}" )
@PostMapping ( "/updateRejectSettlementStatus/{settlementId}" )
public ResponseEntity < Settlement > updateRejectSettlementStatus (
public ResponseEntity < Settlement > updateRejectSettlementStatus (
@PathVariable ( "settlementId" ) int settlementId ,
@PathVariable ( "settlementId" ) int settlementId ,
@ -300,10 +274,7 @@ public class OfficerAPIController {
}
}
}
}
@Operation (
summary = "USER STATUS APPROVED REST API" ,
description = "REST API for Updating the user Status Approved"
)
@Operation ( summary = "USER STATUS APPROVED REST API" , description = "REST API for Updating the user Status Approved" )
/ / Updating the user Status Approved
/ / Updating the user Status Approved
@PostMapping ( "/updateApprovedStatus/{userId}" )
@PostMapping ( "/updateApprovedStatus/{userId}" )
public ResponseEntity < Users > updateApprovedStatus (
public ResponseEntity < Users > updateApprovedStatus (
@ -319,10 +290,7 @@ public class OfficerAPIController {
}
}
}
}
@Operation (
summary = "USER STATUS REJECTED REST API" ,
description = "REST API for Updating the user Status Rejected"
)
@Operation ( summary = "USER STATUS REJECTED REST API" , description = "REST API for Updating the user Status Rejected" )
/ / Updating the user Status Rejected
/ / Updating the user Status Rejected
@PostMapping ( "/updateRejectStatus/{userId}" )
@PostMapping ( "/updateRejectStatus/{userId}" )
public ResponseEntity < Users > updateRejectStatus (
public ResponseEntity < Users > updateRejectStatus (
@ -339,10 +307,7 @@ public class OfficerAPIController {
}
}
}
}
@Operation (
summary = "BOOKING STATUS APPROVED REST API" ,
description = "REST API for Updating the Booking Status Approved by Booking Id"
)
@Operation ( summary = "BOOKING STATUS APPROVED REST API" , description = "REST API for Updating the Booking Status Approved by Booking Id" )
/ / Updating the Booking Status Approved by Booking Id
/ / Updating the Booking Status Approved by Booking Id
@PostMapping ( "/updateBookingApproved/{bookingId}" )
@PostMapping ( "/updateBookingApproved/{bookingId}" )
public ResponseEntity < BookingDetails > updateBookingApproved (
public ResponseEntity < BookingDetails > updateBookingApproved (
@ -377,13 +342,12 @@ public class OfficerAPIController {
}
}
/ / ak
/ / ak
@PostMapping ( "/toggleStatus" )
@PostMapping ( "/toggleStatus" )
public ResponseEntity < String > toggleUserStatus (
public ResponseEntity < String > toggleUserStatus (
@RequestParam Integer userId ,
@RequestParam Integer userId ,
@RequestParam boolean active
) {
/ / System . out . println ( "userID: " + userId + ", active or deactivate: " + active ) ;
@RequestParam boolean active ) {
/ / System . out . println ( "userID: " + userId + ", active or deactivate: " +
/ / active ) ;
try {
try {
userService . toggleUserStatus ( userId , active ) ;
userService . toggleUserStatus ( userId , active ) ;
return ResponseEntity . ok ( "User status updated successfully" ) ;
return ResponseEntity . ok ( "User status updated successfully" ) ;
@ -392,11 +356,7 @@ public class OfficerAPIController {
}
}
}
}
@Operation (
summary = "BOOKING STATUS REJECTED REST API" ,
description = "REST API for Updating the Booking Status Rejected by Booking Id"
)
@Operation ( summary = "BOOKING STATUS REJECTED REST API" , description = "REST API for Updating the Booking Status Rejected by Booking Id" )
/ / Updating the Booking Status Rejected by Booking Id
/ / Updating the Booking Status Rejected by Booking Id
@PostMapping ( "/updateBookingReject/{bookingId}" )
@PostMapping ( "/updateBookingReject/{bookingId}" )
public ResponseEntity < ? > updateBookingReject (
public ResponseEntity < ? > updateBookingReject (
@ -410,7 +370,8 @@ public class OfficerAPIController {
BookingDetails result = book . get ( ) ;
BookingDetails result = book . get ( ) ;
result . setBookingStatus ( BookingStatus . REJECTED ) ;
result . setBookingStatus ( BookingStatus . REJECTED ) ;
result . setRefundStatus ( RefundStatus . NA ) ;
result . setRefundStatus ( RefundStatus . NA ) ;
List < BookingCalendar > bookingCalendarList = bookingCalendarRepository . getCancellingdata1 ( String . valueOf ( result . getBookingId ( ) ) ) ;
List < BookingCalendar > bookingCalendarList = bookingCalendarRepository
. getCancellingdata1 ( String . valueOf ( result . getBookingId ( ) ) ) ;
for ( BookingCalendar calendar : bookingCalendarList ) {
for ( BookingCalendar calendar : bookingCalendarList ) {
boolean isUpdated = false ;
boolean isUpdated = false ;
@ -458,10 +419,17 @@ public class OfficerAPIController {
BookingDetails rejectBooking = bookingService . updateCancelledBookingStatus ( bookingId , status , comments ) ;
BookingDetails rejectBooking = bookingService . updateCancelledBookingStatus ( bookingId , status , comments ) ;
Optional < BookingDetails > book = bookingDetailsRepository . findById ( bookingId ) ;
Optional < BookingDetails > book = bookingDetailsRepository . findById ( bookingId ) ;
BookingDetails bookingDetails = book . get ( ) ;
BookingDetails bookingDetails = book . get ( ) ;
String rejectionsms = "Your booking ID " + bookingDetails . getBookingId ( ) + " on " + bookingDetails . getStartDate ( ) + " has been rejected by GCC due to insufficient details." ;
String rejectedurlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + bookingDetails . getUsers ( ) . getMobileNo ( ) + "&from=GCCCRP&body=" + rejectionsms + "&entityid=1401572690000011081&templateid=1407172346485956648" ;
/ / String rejectedwhatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=" + bookingDetails . getUsers ( ) . getMobileNo ( ) + "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+booking+with+ID+" + bookingId + "+on+" + bookingDetails . getStartDate ( ) + "+has+been+rejected+by+GCC+due+to+insufficient+details.+%0AThanks+for+using+GCC+Community+Hall+Booking+System." ;
String rejectedwhatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=" + bookingDetails . getUsers ( ) . getMobileNo ( ) + "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+booking+with+ID+" + bookingId + "+on+" + bookingDetails . getStartDate ( ) + "+has+been+rejected+by+GCC+due+to+insufficient+details." ;
String rejectionsms = "Your booking ID " + bookingDetails . getBookingId ( ) + " on "
+ bookingDetails . getStartDate ( ) + " has been rejected by GCC due to insufficient details." ;
String rejectedurlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to="
+ bookingDetails . getUsers ( ) . getMobileNo ( ) + "&from=GCCCRP&body=" + rejectionsms
+ "&entityid=1401572690000011081&templateid=1407172346485956648" ;
/ / String
/ / rejectedwhatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to=" + bookingDetails . getUsers ( ) . getMobileNo ( ) + "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+booking+with+ID+" + bookingId + "+on+" + bookingDetails . getStartDate ( ) + "+has+been+rejected+by+GCC+due+to+insufficient+details.+%0AThanks+for+using+GCC+Community+Hall+Booking+System." ;
String rejectedwhatsupmsg = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="
+ bookingDetails . getUsers ( ) . getMobileNo ( )
+ "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+booking+with+ID+" + bookingId
+ "+on+" + bookingDetails . getStartDate ( ) + "+has+been+rejected+by+GCC+due+to+insufficient+details." ;
whatsappMsgServiceImpl . sendMsg ( rejectedwhatsupmsg ) ;
whatsappMsgServiceImpl . sendMsg ( rejectedwhatsupmsg ) ;
whatsappMsgServiceImpl . sendSMS ( rejectedurlString ) ;
whatsappMsgServiceImpl . sendSMS ( rejectedurlString ) ;
String adminname = ( String ) session . getAttribute ( "usertype" ) ;
String adminname = ( String ) session . getAttribute ( "usertype" ) ;
@ -487,10 +455,7 @@ public class OfficerAPIController {
}
}
}
}
@Operation (
summary = "Retrieving BOOKING STATUS APPROVED REST API" ,
description = "REST API for retrieving the Booking Status Approved"
)
@Operation ( summary = "Retrieving BOOKING STATUS APPROVED REST API" , description = "REST API for retrieving the Booking Status Approved" )
/ / retrieving the Booking Status Approved
/ / retrieving the Booking Status Approved
@GetMapping ( "/user-Approved" )
@GetMapping ( "/user-Approved" )
public ResponseEntity < List < Users > > getUserApprovedList ( ) {
public ResponseEntity < List < Users > > getUserApprovedList ( ) {
@ -498,10 +463,7 @@ public class OfficerAPIController {
return new ResponseEntity < > ( userApproved , HttpStatus . OK ) ;
return new ResponseEntity < > ( userApproved , HttpStatus . OK ) ;
}
}
@Operation (
summary = "Retrieving BOOKING STATUS REJECTED REST API" ,
description = "REST API for retrieving the Booking Status Rejected"
)
@Operation ( summary = "Retrieving BOOKING STATUS REJECTED REST API" , description = "REST API for retrieving the Booking Status Rejected" )
/ / retrieving the Booking Status Rejected
/ / retrieving the Booking Status Rejected
@GetMapping ( "/user-Reject" )
@GetMapping ( "/user-Reject" )
public ResponseEntity < List < Users > > getUserRejectedList ( ) {
public ResponseEntity < List < Users > > getUserRejectedList ( ) {
@ -509,11 +471,7 @@ public class OfficerAPIController {
return new ResponseEntity < > ( userReject , HttpStatus . OK ) ;
return new ResponseEntity < > ( userReject , HttpStatus . OK ) ;
}
}
@Operation (
summary = "Counter Refund Approval by Officer REST API" ,
description = "REST API to approve the Counter Refund by Officer"
)
@Operation ( summary = "Counter Refund Approval by Officer REST API" , description = "REST API to approve the Counter Refund by Officer" )
/ / RefundApproval by Officer
/ / RefundApproval by Officer
@PostMapping ( "/approveRefund/{id}" )
@PostMapping ( "/approveRefund/{id}" )
public ResponseEntity < String > approveRefund ( @PathVariable int id ) {
public ResponseEntity < String > approveRefund ( @PathVariable int id ) {
@ -529,10 +487,7 @@ public class OfficerAPIController {
}
}
}
}
@Operation (
summary = "Counter Refund Reject by Officer REST API" ,
description = "REST API to Reject the Counter Refund by Officer"
)
@Operation ( summary = "Counter Refund Reject by Officer REST API" , description = "REST API to Reject the Counter Refund by Officer" )
/ / RefundReject by Officer
/ / RefundReject by Officer
@PostMapping ( "/rejectRefund/{id}" )
@PostMapping ( "/rejectRefund/{id}" )
public ResponseEntity < String > rejectRefund ( @PathVariable int id ) {
public ResponseEntity < String > rejectRefund ( @PathVariable int id ) {
@ -548,10 +503,7 @@ public class OfficerAPIController {
}
}
}
}
@Operation (
summary = "Reason By reasonName REST API" ,
description = "REST API to get the Reason Details with the reason"
)
@Operation ( summary = "Reason By reasonName REST API" , description = "REST API to get the Reason Details with the reason" )
/ / retrieving the Reason Details with the reason
/ / retrieving the Reason Details with the reason
@GetMapping ( "/getReasonByName" )
@GetMapping ( "/getReasonByName" )
public ResponseEntity < ? > getReasonByName ( @RequestParam String reasonName ) {
public ResponseEntity < ? > getReasonByName ( @RequestParam String reasonName ) {
@ -591,9 +543,11 @@ public class OfficerAPIController {
@RequestParam ( "status" ) BookingDetails . RefundStatus status ) {
@RequestParam ( "status" ) BookingDetails . RefundStatus status ) {
try {
try {
/ / Update refund status preliminarily
/ / Update refund status preliminarily
/ / / / BookingDetails updatedBooking = bookingService . updateRefundStatus ( bookingId , status ) ;
/ / / / BookingDetails updatedBooking =
/ / bookingService . updateRefundStatus ( bookingId , status ) ;
/ / if ( updatedBooking = = null ) {
/ / if ( updatedBooking = = null ) {
/ / return new ResponseEntity < > ( "Booking not found for ID: " + bookingId , HttpStatus . NOT_FOUND ) ;
/ / return new ResponseEntity < > ( "Booking not found for ID: " + bookingId ,
/ / HttpStatus . NOT_FOUND ) ;
/ / }
/ / }
/ / Log the action
/ / Log the action
@ -629,11 +583,11 @@ public class OfficerAPIController {
}
}
} catch ( Exception e ) {
} catch ( Exception e ) {
return new ResponseEntity < > ( "An error occurred while processing the refund for Booking ID: " + bookingId , HttpStatus . INTERNAL_SERVER_ERROR ) ;
return new ResponseEntity < > ( "An error occurred while processing the refund for Booking ID: " + bookingId ,
HttpStatus . INTERNAL_SERVER_ERROR ) ;
}
}
}
}
@GetMapping ( "/bookingstatistics" )
@GetMapping ( "/bookingstatistics" )
public ResponseEntity < Map < String , Map < String , Integer > > > getBookingStatistics (
public ResponseEntity < Map < String , Map < String , Integer > > > getBookingStatistics (
@RequestParam ( required = false ) @DateTimeFormat ( iso = DateTimeFormat . ISO . DATE ) LocalDate fromDate ,
@RequestParam ( required = false ) @DateTimeFormat ( iso = DateTimeFormat . ISO . DATE ) LocalDate fromDate ,
@ -643,18 +597,15 @@ public class OfficerAPIController {
@RequestParam ( required = false , defaultValue = "1000" ) Integer hallid ,
@RequestParam ( required = false , defaultValue = "1000" ) Integer hallid ,
@RequestParam ( required = false ) String userType ) {
@RequestParam ( required = false ) String userType ) {
String zone = ( String ) session . getAttribute ( "zone" ) ;
String zone = ( String ) session . getAttribute ( "zone" ) ;
Map < String , Map < String , Integer > > statistics = bookingService . getOfficerDashboard ( fromDate , toDate , zone , division , hallid , userType ) ;
Map < String , Map < String , Integer > > statistics = bookingService . getOfficerDashboard ( fromDate , toDate , zone ,
division , hallid , userType ) ;
return ResponseEntity . ok ( statistics ) ;
return ResponseEntity . ok ( statistics ) ;
}
}
@GetMapping ( "/getHallsDetailsByZone" )
@GetMapping ( "/getHallsDetailsByZone" )
public ResponseEntity < Map < String , Object > > getHallsDetailsByZone ( @RequestParam String zone )
{
public ResponseEntity < Map < String , Object > > getHallsDetailsByZone ( @RequestParam String zone ) {
Map < String , Object > hallzones = hallDetailService . getHallsDetailsForOfficer ( zone ) ;
Map < String , Object > hallzones = hallDetailService . getHallsDetailsForOfficer ( zone ) ;
return ResponseEntity . ok ( hallzones ) ;
return ResponseEntity . ok ( hallzones ) ;
@ -676,6 +627,7 @@ public class OfficerAPIController {
public List < BookingDetails > getRejectedBookingDetails ( ) {
public List < BookingDetails > getRejectedBookingDetails ( ) {
return bookingService . getRejectedBookingDetails ( ) ;
return bookingService . getRejectedBookingDetails ( ) ;
}
}
@GetMapping ( "/getwaitingforNOCapproval" )
@GetMapping ( "/getwaitingforNOCapproval" )
public List < BookingDetails > getWaitingforNOCapproval ( ) {
public List < BookingDetails > getWaitingforNOCapproval ( ) {
return bookingService . getWaitingforNOCapproval ( ) ;
return bookingService . getWaitingforNOCapproval ( ) ;
@ -685,4 +637,219 @@ public class OfficerAPIController {
public List < PaymentsDTO > getAllPaymentList ( ) {
public List < PaymentsDTO > getAllPaymentList ( ) {
return paymentsService . getAllPaymentDetails ( ) ;
return paymentsService . getAllPaymentDetails ( ) ;
}
}
/ / Added for GCC Blocking ( New ) option
@Operation ( summary = "GCC Blocking REST API" , description = "REST API to Block the Halls by Admin" )
/ / GccBlocking Api
@PostMapping ( "/cancelAll" )
public ResponseEntity < String > cancelAllBookings (
@RequestParam ( "fromDate" ) String fromDate ,
@RequestParam ( "toDate" ) String toDate ,
@RequestParam ( "hallID" ) String hallID ,
@RequestParam ( "reasonforblocking" ) String reasonforblocking ,
@RequestParam ( value = "selectedBookings" , required = false ) List < String > selectedBookings ,
@RequestParam ( value = "description" , required = false ) String [ ] descriptions , / / Handle descriptions
@RequestParam ( value = "document" , required = false ) MultipartFile [ ] documents , / / Handle documents
HttpSession session ) {
/ / Your existing logic
String updatedBy = ( String ) session . getAttribute ( "employeeId" ) ;
/ / Split and convert hall IDs
List < Long > hallIdsList = Arrays . stream ( hallID . split ( "," ) )
. map ( Long : : parseLong )
. collect ( Collectors . toList ( ) ) ;
/ / Call the service with descriptions and documents
bookingService . cancelAllBookings ( fromDate , toDate , hallIdsList , reasonforblocking , selectedBookings , updatedBy ,
descriptions , documents ) ;
String adminname = ( String ) session . getAttribute ( "usertype" ) ;
Integer loginid = ( Integer ) session . getAttribute ( "id" ) ;
ApplicationLogs logs = new ApplicationLogs ( ) ;
logs . setComments ( "Action by " + adminname ) ;
logs . setLoginId ( loginid ) ;
logs . setLogType ( "Gcc Blocking for the Reason:-" + reasonforblocking ) ;
InetAddress inetAddress ;
try {
inetAddress = InetAddress . getLocalHost ( ) ;
String hostname = InetAddress . getLocalHost ( ) . getHostName ( ) ;
logs . setIpaddress ( inetAddress . getHostAddress ( ) ) ;
logs . setSystemName ( hostname ) ;
} catch ( UnknownHostException e ) {
e . printStackTrace ( ) ;
}
applicationLogsRepository . save ( logs ) ;
return ResponseEntity . ok ( "Success" ) ;
}
@Operation ( summary = "GCC Block Without Cancelling REST API" , description = "REST API to Block halls without cancelling existing bookings (smart slot logic)" )
@PostMapping ( "/blockWithoutCancel" )
public ResponseEntity < String > blockWithoutCancel (
@RequestParam ( "fromDate" ) String fromDate ,
@RequestParam ( "toDate" ) String toDate ,
@RequestParam ( "hallID" ) String hallID ,
@RequestParam ( "reasonforblocking" ) String reasonforblocking ,
@RequestParam ( value = "description" , required = false ) String [ ] descriptions ,
@RequestParam ( value = "document" , required = false ) MultipartFile [ ] documents ,
HttpSession session ) {
String updatedBy = ( String ) session . getAttribute ( "employeeId" ) ;
List < Long > hallIdsList = Arrays . stream ( hallID . split ( "," ) )
. map ( Long : : parseLong )
. collect ( Collectors . toList ( ) ) ;
bookingService . blockWithoutCancellingBookings ( fromDate , toDate , hallIdsList , reasonforblocking ,
updatedBy , descriptions , documents ) ;
String adminname = ( String ) session . getAttribute ( "usertype" ) ;
Integer loginid = ( Integer ) session . getAttribute ( "id" ) ;
ApplicationLogs logs = new ApplicationLogs ( ) ;
logs . setComments ( "Action by " + adminname ) ;
logs . setLoginId ( loginid ) ;
logs . setLogType ( "Gcc Block Without Cancel for the Reason:-" + reasonforblocking ) ;
InetAddress inetAddress ;
try {
inetAddress = InetAddress . getLocalHost ( ) ;
String hostname = InetAddress . getLocalHost ( ) . getHostName ( ) ;
logs . setIpaddress ( inetAddress . getHostAddress ( ) ) ;
logs . setSystemName ( hostname ) ;
} catch ( UnknownHostException e ) {
e . printStackTrace ( ) ;
}
applicationLogsRepository . save ( logs ) ;
return ResponseEntity . ok ( "Success" ) ;
}
@GetMapping ( "/filter" )
public ResponseEntity < Map < String , Object > > getFilteredBookings (
@RequestParam ( "fromDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate fromDate ,
@RequestParam ( "toDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate toDate ,
@RequestParam ( "hallIds" ) List < Long > hallIds ) {
List < BookingDetails > bookings = bookingService . getFilteredBookings ( fromDate , toDate , hallIds ) ;
List < GccBlockingDate > gccBlockedList = blockingDateRepository
. findByFromDateAndToDateBetweenAndHallIdIn ( fromDate , toDate , hallIds ) ;
Map < String , Object > response = new HashMap < > ( ) ;
response . put ( "bookings" , bookings ) ;
response . put ( "blockedEvents" , gccBlockedList ) ;
return ResponseEntity . ok ( response ) ;
}
@Operation ( summary = "UNBLOCK the gcc Blocked Event REST API" , description = "REST API to unblocking the Gcc blocked Events for blocking" )
@GetMapping ( "/cancelByid" )
public ResponseEntity < String > cancellationById ( @RequestParam int blockingId ,
@RequestParam ( "fromDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate fromDate ,
@RequestParam ( "endDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate endDate ) {
/ / Fetch the blocking date entity
GccBlockingDate blockingDate = blockingDateRepository . findById ( blockingId ) . orElse ( null ) ;
if ( blockingDate = = null ) {
return ResponseEntity . status ( HttpStatus . NOT_FOUND ) . body ( "Blocking ID not found." ) ;
}
/ / Get the booking IDs from the blocking date entity ( may be null / empty for
/ / block - only entries )
String bookingIds = blockingDate . getBookingIds ( ) ;
String hallIds = blockingDate . getHallId ( ) ;
/ / Parse booking IDs only if present
List < Integer > bookingIdList = ( bookingIds ! = null & & ! bookingIds . trim ( ) . isEmpty ( ) )
? Arrays . stream ( bookingIds . split ( "," ) )
. map ( String : : trim )
. filter ( s - > ! s . isEmpty ( ) )
. map ( Integer : : parseInt )
. collect ( Collectors . toList ( ) )
: Collections . emptyList ( ) ;
/ / Convert the hall IDs to a list of longs if provided
List < Long > hallIdList = ( hallIds ! = null & & ! hallIds . trim ( ) . isEmpty ( ) )
? Arrays . stream ( hallIds . split ( "," ) )
. map ( Long : : parseLong )
. collect ( Collectors . toList ( ) )
: Collections . emptyList ( ) ;
/ / Fetch the booking calendar entries within the date range
List < BookingCalendar > bookingCalendars = bookingService . getBookedslots ( fromDate , endDate , hallIdList ) ;
/ / ─ ─ Smart unblock : per - slot decision ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
/ / If morning + evening + is_blocked are all true AND an APPROVED user booking
/ / exists for that hall / date → only clear is_blocked ( leave slots intact ) .
/ / Otherwise ( GCC - owned slot ) → clear everything .
for ( BookingCalendar bookingslots : bookingCalendars ) {
if ( bookingslots . isMorningSlot ( ) & & bookingslots . isEveningSlot ( ) & & bookingslots . getIs_blocked ( ) ) {
List < BookingDetails > approvedBookings = bookingDetailsRepository . findByHallIdAndDate (
bookingslots . getBdate ( ) , bookingslots . getHallId ( ) ) ;
if ( ! approvedBookings . isEmpty ( ) ) {
/ / Approved user booking owns the slots — only remove gcc flag
bookingslots . setIs_blocked ( false ) ;
} else {
/ / GCC owned this slot fully — release everything
bookingslots . setBookingId_1 ( null ) ;
bookingslots . setBookingId_2 ( null ) ;
bookingslots . setMorningSlot ( false ) ;
bookingslots . setEveningSlot ( false ) ;
bookingslots . setIs_blocked ( false ) ;
}
} else {
/ / Partial slot scenario — only clear the gcc overlay flag
bookingslots . setIs_blocked ( false ) ;
}
bookingCalendarRepository . save ( bookingslots ) ;
}
blockingDate . setBlockedStatus ( GccBlockingDate . BlockedStatus . UNBLOCKED ) ;
blockingDateRepository . save ( blockingDate ) ;
/ / Update GCC_BLOCKED booking_details entries back to GCC_UNBLOCKED
for ( int bookingId : bookingIdList ) {
Optional < BookingDetails > bookingDetails = bookingDetailsRepository . findById ( bookingId ) ;
if ( bookingDetails . isPresent ( ) ) {
BookingDetails bookings = bookingDetails . get ( ) ;
if ( bookings . getBookingStatus ( ) = = BookingDetails . BookingStatus . GCC_BLOCKED ) {
bookings . setBookingStatus ( BookingDetails . BookingStatus . GCC_UNBLOCKED ) ;
bookings . setRefundStatus ( BookingDetails . RefundStatus . NA ) ;
bookingDetailsRepository . save ( bookings ) ;
}
}
}
String adminname = ( String ) session . getAttribute ( "usertype" ) ;
Integer loginid = ( Integer ) session . getAttribute ( "id" ) ;
ApplicationLogs logs = new ApplicationLogs ( ) ;
logs . setComments ( "Action by " + adminname ) ;
logs . setLoginId ( loginid ) ;
logs . setLogType ( "Gcc UnBlocking for the Id:-" + blockingDate . getBlockingId ( ) ) ;
InetAddress inetAddress ;
try {
inetAddress = InetAddress . getLocalHost ( ) ;
String hostname = InetAddress . getLocalHost ( ) . getHostName ( ) ;
logs . setIpaddress ( inetAddress . getHostAddress ( ) ) ;
logs . setSystemName ( hostname ) ;
} catch ( UnknownHostException e ) {
e . printStackTrace ( ) ;
}
applicationLogsRepository . save ( logs ) ;
return ResponseEntity . ok ( "Success" ) ;
}
@Operation ( summary = " GCC Blocked Booking Details REST API" , description = "REST API to get the GCC Blocked BookingDetails" )
/ / retrieving the GCC Blocked BookingDetails
@GetMapping ( "/blockedevents" )
public ResponseEntity < List < GccBlockingDate > > getBlockedEvents ( ) {
List < GccBlockingDate > blockedBookings = bookingService . getBlockedEvents ( ) ;
if ( blockedBookings . isEmpty ( ) ) {
/ / System . out . println ( "No blocked bookings found." ) ;
return ResponseEntity . ok ( blockedBookings ) ;
}
for ( GccBlockingDate blockedBooking : blockedBookings ) {
/ / System . out . println ( "Blocked Event: " + blockedBooking ) ;
}
return ResponseEntity . ok ( blockedBookings ) ;
}
}
}