Browse Source

Community hall updated code with the following changes

1. Admin login --> In Transaction response report temp transactions will be visible
2. Settlement Pending List --> If any error/issue occurs during settlement it will be moved to Refund Failed List
3. Admin Reports --> i) Users -> User Id added in ascending order
                                      ii) Users Booking List --> User Id added in ascending order
                                      iii) Hall Booking List --> Hall Id added in total bookings in descending order
4. Cancel Booking Enabled for booking status Waiting for NOC and Waiting for NOC Approval.
master
kanimozhi 1 year ago
parent
commit
aa384aae16
  1. 2
      src/main/java/com/gcc/communityHall/controller/OfficerAPIController.java
  2. 1973
      src/main/java/com/gcc/communityHall/controller/UserAPIController.java
  3. 6
      src/main/java/com/gcc/communityHall/entity/BookingHistory.java
  4. 13
      src/main/java/com/gcc/communityHall/entity/RefundTransaction.java
  5. 146
      src/main/java/com/gcc/communityHall/paymentService/scheduler/PaymentStatusScheduler.java
  6. 2
      src/main/java/com/gcc/communityHall/repository/BookingCalendarRepository.java
  7. 3
      src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java
  8. 13
      src/main/java/com/gcc/communityHall/repository/RefundTransactionRepository.java
  9. 2
      src/main/java/com/gcc/communityHall/service/BookingService.java
  10. 3
      src/main/java/com/gcc/communityHall/service/CalendarService.java
  11. 129
      src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java
  12. 8
      src/main/java/com/gcc/communityHall/service/Impl/CalendarServiceImpl.java
  13. 16
      src/main/java/com/gcc/communityHall/service/Impl/TransactionServiceImpl.java
  14. 2
      src/main/java/com/gcc/communityHall/service/TransactionService.java
  15. 3935
      src/main/resources/templates/admin/reports.html
  16. 4
      src/main/resources/templates/user/calculatehallamount.html
  17. 5340
      src/main/resources/templates/user/viewhistory.html

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

@ -176,7 +176,7 @@ public class OfficerAPIController {
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}")
@PostMapping("/updateApprovedSettlementStatus/{settlementId}") // need to check this API for settlement approval
public ResponseEntity<Object> updateApprovedSettlementStatus(
@PathVariable("settlementId") int settlementId,
@RequestParam("status") BookingDetails.RefundStatus status,

1973
src/main/java/com/gcc/communityHall/controller/UserAPIController.java
File diff suppressed because it is too large
View File

6
src/main/java/com/gcc/communityHall/entity/BookingHistory.java

@ -44,7 +44,11 @@ public class BookingHistory {
@Column(name="end_date")
private String endDate;
@ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
/*@ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
@JsonIgnore
private BookingDetails bookingDetails;*/
@ManyToOne(fetch = FetchType.EAGER)
@JsonIgnore
private BookingDetails bookingDetails;

13
src/main/java/com/gcc/communityHall/entity/RefundTransaction.java

@ -67,4 +67,17 @@ public class RefundTransaction {
public void setRefundIdentifier(String refundIdentifier) {
this.refundIdentifier = refundIdentifier;
}
@Override
public String toString() {
return "RefundTransaction{" +
"refundId=" + refundId +
", amountRefunded=" + amountRefunded +
", TransactionId='" + TransactionId + '\'' +
", refundStatus='" + refundStatus + '\'' +
", cdate=" + cdate +
", refundIdentifier='" + refundIdentifier + '\'' +
", bookingDetails=" + bookingDetails +
'}';
}
}

146
src/main/java/com/gcc/communityHall/paymentService/scheduler/PaymentStatusScheduler.java

@ -5,6 +5,7 @@ package com.gcc.communityHall.paymentService.scheduler;
//package com.gcc.communityHall.paymentService.Scheduler;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gcc.communityHall.entity.BookingCalendar;
import com.gcc.communityHall.entity.BookingDetails;
import com.gcc.communityHall.entity.Payments;
import com.gcc.communityHall.entity.RefundTransaction;
@ -20,6 +21,7 @@ import com.gcc.communityHall.paymentService.repository.TransactionStatusLogRepos
import com.gcc.communityHall.paymentService.service.PaymentGatewayServiceImpl;
import com.gcc.communityHall.repository.PaymentsRepository;
import com.gcc.communityHall.service.BookingService;
import com.gcc.communityHall.service.CalendarService;
import com.gcc.communityHall.service.TransactionService;
import com.google.gson.Gson;
import jakarta.transaction.Transactional;
@ -31,10 +33,7 @@ import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.time.LocalDate;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Component
@EnableScheduling
@ -68,11 +67,14 @@ public class PaymentStatusScheduler {
@Autowired
private PaymentGatewayServiceImpl paymentGatewayServiceImpl;
// @Scheduled(cron = "0 0 0 * * ?", zone = "Asia/Kolkata") //executed at 12:00 AM
// @Scheduled(fixedRate = 900000)
@Autowired
private CalendarService calendarService;
// @Scheduled(cron = "0 0 0 * * ?", zone = "Asia/Kolkata") //executed at 12:00 AM
// @Scheduled(fixedRate = 900000)
@Scheduled(fixedRate = 30000)
public void fetchAndSavePaymentStatus() {
// System.out.println("Fetching Payment Status...At 12:00 AM IST");
// System.out.println("Fetching Payment Status...At 12:00 AM IST");
System.out.println("Fetching Payment Status...At 15 min Testing");
try {
@ -93,21 +95,21 @@ public class PaymentStatusScheduler {
transaction.put("token", "");
transaction.put("reference", "");
System.out.println("====================================="+ transactionRecord.get("txansaction_id"));
System.out.println("=====================================" + transactionRecord.get("txansaction_id"));
System.out.println(merchant);
System.out.println(transaction);
System.out.println(status);
System.out.println(transactionRecord.toString());
System.out.println("======================================");
String bookingDate = transactionRecord.get("booking_date").toString();
// System.out.println("cdate check"+transactionRecord.get("cdate").toString());
// System.out.println("cdate check"+transactionRecord.get("cdate").toString());
String cdate = transactionRecord.get("cdate").toString();
if (cdate != null && !cdate.isEmpty()) {
String[] dateParts1 = cdate.split(" ");
String[] dateParts = dateParts1[0].split("-");
String formattedDate = dateParts[2] + "-" + dateParts[1] + "-" + dateParts[0];
transaction.put("dateTime", formattedDate);
System.out.println("formattedDate"+formattedDate);
System.out.println("formattedDate" + formattedDate);
} else {
transaction.put("dateTime", "");
}
@ -115,7 +117,7 @@ public class PaymentStatusScheduler {
Gson gson = new Gson();
String json = gson.toJson(status);
System.out.println("Hello json "+json);
System.out.println("Hello json " + json);
String encryptHxRefund = paymentGatewayService.encryptHxRefund(json);
RestTemplate restTemplate = new RestTemplate();
@ -124,12 +126,12 @@ public class PaymentStatusScheduler {
String decryptHxTRefund = paymentGatewayService.decryptHxTRefund(postForEntity.getBody());
Map<String, Object> myObj = new ObjectMapper().readValue(decryptHxTRefund, Map.class);
Map<String, Object> paymentMethod = (Map<String, Object>)myObj.get("paymentMethod");
Map<String, Object> response = (Map<String, Object>)paymentMethod.get("paymentTransaction");
Map<String, Object> paymentMethod = (Map<String, Object>) myObj.get("paymentMethod");
Map<String, Object> response = (Map<String, Object>) paymentMethod.get("paymentTransaction");
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
System.out.println("hello2" + response);
System.out.println("hello "+myObj);
System.out.println("hello " + myObj);
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
TransactionStatusLog log = new TransactionStatusLog();
@ -141,7 +143,7 @@ public class PaymentStatusScheduler {
log.setStatusMessage(response.get("statusMessage").toString());
log.setStatusCode(response.get("statusCode").toString());
log.setRefundIdentifier(response.get("refundIdentifier").toString());
// log.setResponse(response.toString());
// log.setResponse(response.toString());
log.setAmount(response.get("amount").toString());
log.setBalanceAmt(response.get("balanceAmount").toString());
log.setReceivedDate(response.get("dateTime").toString());
@ -163,21 +165,21 @@ public class PaymentStatusScheduler {
Payments payments = paymentsRepository.findByBookingId(Integer.valueOf(String.valueOf(transRes.getBookingId())));
System.out.println("payments hello"+payments);
if(payments!=null && response.get("statusCode").toString().equals("0300")) {
System.out.println("payments hello" + payments);
if (payments != null && response.get("statusCode").toString().equals("0300")) {
// payments.setBookingDetails(payments.getBookingDetails());
payments.setTransactionId(transRes.getTxansactionId());
payments.setAmountReceived(Double.parseDouble(response.get("amount").toString()));
payments.setAmountReceived(Double.parseDouble(response.get("amount").toString()));
payments.setPaymentStatus("Success");
Date date = new Date(payments.getCdate().getTime());
//paymentsRepository.updatePaymentInfo(payments.getPaymentId(),payments.getTransactionId(),payments.getAmountReceived(),payments.getPaymentStatus(),transRes.getBookingId());
//paymentsRepository.updatePaymentInfo(payments.getPaymentId(),payments.getTransactionId(),payments.getAmountReceived(),payments.getPaymentStatus(),transRes.getBookingId());
bookingService.updateBookingStatus(transRes.getBookingId(), BookingDetails.BookingStatus.REFUNDED, "Booking Not Confirmed. Amount will be refunded shortly.");
intiateRefund(transRes.getBookingId(),Integer.parseInt(transRes.getUserId()));
intiateRefund(transRes.getBookingId(), Integer.parseInt(transRes.getUserId()));
}else if(response.get("statusCode").toString().equals("0300")){
} else if (response.get("statusCode").toString().equals("0300")) {
payments = new Payments();
@ -191,13 +193,12 @@ public class PaymentStatusScheduler {
//paymentsRepository.insertPaymentinfo(payments.getPaymentId(),payments.getTransactionId(),payments.getAmountReceived(),payments.getPaymentStatus(),transRes.getBookingId(),payments.getCdate() );
bookingService.updateBookingStatus(transRes.getBookingId(), BookingDetails.BookingStatus.REFUNDED, "Booking Not Confirmed. Amount will be refunded shortly.");
intiateRefund(transRes.getBookingId(),Integer.parseInt(transRes.getUserId()));
}
else{
intiateRefund(transRes.getBookingId(), Integer.parseInt(transRes.getUserId()));
} else {
payments.setBookingDetails(payments.getBookingDetails());
payments.setTransactionId(transRes.getTxansactionId());
payments.setAmountReceived(Double.parseDouble(response.get("amount")!=null?response.get("amount").toString():"0")); payments.setPaymentStatus("Not Completed");
payments.setAmountReceived(Double.parseDouble(response.get("amount") != null ? response.get("amount").toString() : "0"));
payments.setPaymentStatus("Not Completed");
payments.setCdate(new Date());
paymentsRepository.save(payments);
@ -205,7 +206,7 @@ public class PaymentStatusScheduler {
}
updateRefundInfo(response,log);
updateRefundInfo(response, log);
} catch (Exception ex) {
System.err.println("Error processing transaction record: " + ex.getMessage());
@ -221,26 +222,31 @@ public class PaymentStatusScheduler {
}
public void updateRefundInfo(Map<String,Object> response,TransactionStatusLog log){
public void updateRefundInfo(Map<String, Object> response, TransactionStatusLog log) {
if(response.get("refundDdetails") != null ){
if (response.get("refundDdetails") != null) {
Map<String,Object> refundInfo= (Map<String, Object>) response.get("refundDdetails");
List<Map<String ,Object>> refundDetails = (List<Map<String, Object>>) refundInfo.get("RefundDetails");
System.out.println("inifcon :"+ refundDetails);
if(refundDetails != null && !refundDetails.isEmpty()){
Map<String, Object> refundInfo = (Map<String, Object>) response.get("refundDdetails");
List<Map<String, Object>> refundDetails = (List<Map<String, Object>>) refundInfo.get("RefundDetails");
System.out.println("inifcon :" + refundDetails);
if (refundDetails != null && !refundDetails.isEmpty()) {
RefundResponse refundResponse = new RefundResponse();
refundResponse.setAmount(response.get("amount")!=null?response.get("amount").toString():"");
refundResponse.setBalaceAmount(response.get("balanceAmount")!=null?response.get("balanceAmount").toString():"");
refundResponse.setAmount(response.get("amount") != null ? response.get("amount").toString() : "");
refundResponse.setBalaceAmount(response.get("balanceAmount") != null ? response.get("balanceAmount").toString() : "");
refundResponse.setTxansactionId(log.getTransactionId());
Map<String ,Object> mapRef = refundDetails.get(refundDetails.size()-1);
Map<String, Object> mapRef = refundDetails.get(refundDetails.size() - 1);
LocalDate df = LocalDate.now();
try{df =LocalDate.parse(mapRef.get("REF_TXN_DATE").toString());}catch (Exception e){df = LocalDate.now();};
try {
df = LocalDate.parse(mapRef.get("REF_TXN_DATE").toString());
} catch (Exception e) {
df = LocalDate.now();
}
;
refundResponse.setDate(df);
if(mapRef.get("STATUS")!=null && mapRef.get("STATUS").toString().equals("INITIATED")){
if (mapRef.get("STATUS") != null && mapRef.get("STATUS").toString().equals("INITIATED")) {
refundResponse.setStatusCode("0400");
}else{
} else {
refundResponse.setStatusCode("0399");
}
refundResponse.setResponse(refundDetails.toString());
@ -250,7 +256,7 @@ public class PaymentStatusScheduler {
Double amt = Double.parseDouble(response.get("amount").toString());
Double balAmt = Double.parseDouble(response.get("balanceAmount").toString());
if(amt != balAmt ) {
if (amt != balAmt) {
RefundTransaction refundTrans = transactionService.getRefundTrans(saverRefundResponse.getBookingId());
if (refundTrans != null) {
@ -263,31 +269,36 @@ public class PaymentStatusScheduler {
transactionService.saveRefundTransaction(refundTrans);
} else {
refundTrans = new RefundTransaction();
refundTrans.setAmountRefunded(amt - balAmt);
double refundAmt = amt - balAmt;
System.out.println("refundAmt.."+refundAmt);
refundTrans.setAmountRefunded(refundAmt);
refundTrans.setRefundStatus("0400");
refundTrans.setRefundIdentifier(response.get("refundIdentifier").toString());
refundTrans.setCdate(new Date());
refundTrans.setTransactionId(log.getTransactionId());
BookingDetails bookings = new BookingDetails();
BookingDetails bookingsById = bookingService.getBookingsById(Integer.parseInt(log.getBookingId()));
refundTrans.setBookingDetails(bookingsById);
transactionService.saveRefundTransaction(refundTrans);
System.out.println("bookingsById"+bookingsById.getBookingId());
bookings.setBookingId(bookingsById.getBookingId());
refundTrans.setBookingDetails(bookings);
System.out.println(refundTrans.toString());
transactionService.saveRefundTransactionDetails(refundTrans);
}
bookingService.updateRefundStatus(saverRefundResponse.getBookingId(),BookingDetails.RefundStatus.COMPLETED); }
// bookingService.updateRefundStatus(saverRefundResponse.getBookingId(), BookingDetails.RefundStatus.COMPLETED);
bookingService.updateRefundStatusScheduler(saverRefundResponse.getBookingId(), BookingDetails.RefundStatus.COMPLETED);
}
saveRefundClientInfo(refundDetails,log.getUserId() ,log.getBookingId(), log.getTransactionId());
saveRefundClientInfo(refundDetails, log.getUserId(), log.getBookingId(), log.getTransactionId());
}
}
}
public String saveRefundClientInfo(List<Map<String, Object>> refundDetail,String userId,String bookingId,String transactionId) {
public String saveRefundClientInfo(List<Map<String, Object>> refundDetail, String userId, String bookingId, String transactionId) {
if (refundDetail == null || refundDetail.isEmpty()) {
@ -301,38 +312,39 @@ public class PaymentStatusScheduler {
refundClientInfo.setUserId(Integer.parseInt(userId));
refundClientInfo.setBookingId(Integer.parseInt(bookingId));
refundClientInfo.setTransactionId(transactionId);
refundClientInfo.setClntRfndId(refund.get("clnt_rfnd_id")!=null?refund.get("clnt_rfnd_id").toString():"");
refundClientInfo.setArnNo(refund.get("ARN_Number")!=null?refund.get("ARN_Number").toString():"");
refundClientInfo.setGetRefTxnDate(refund.get("REF_TXN_DATE")!=null?refund.get("REF_TXN_DATE").toString():"");
refundClientInfo.setRefTxnAmt(refund.get("REF_TXN_AMT")!=null?refund.get("REF_TXN_AMT").toString():"");
refundClientInfo.setRefTxnId(refund.get("REF_TXN_ID")!=null?refund.get("REF_TXN_ID").toString():"");
refundClientInfo.setStatus(refund.get("STATUS")!=null?refund.get("STATUS").toString():"");
refundClientInfo.setSrno(refund.get("SR_NO")!=null?refund.get("SR_NO").toString():"");
refundClientInfo.setClntRfndId(refund.get("clnt_rfnd_id") != null ? refund.get("clnt_rfnd_id").toString() : "");
refundClientInfo.setArnNo(refund.get("ARN_Number") != null ? refund.get("ARN_Number").toString() : "");
refundClientInfo.setGetRefTxnDate(refund.get("REF_TXN_DATE") != null ? refund.get("REF_TXN_DATE").toString() : "");
refundClientInfo.setRefTxnAmt(refund.get("REF_TXN_AMT") != null ? refund.get("REF_TXN_AMT").toString() : "");
refundClientInfo.setRefTxnId(refund.get("REF_TXN_ID") != null ? refund.get("REF_TXN_ID").toString() : "");
refundClientInfo.setStatus(refund.get("STATUS") != null ? refund.get("STATUS").toString() : "");
refundClientInfo.setSrno(refund.get("SR_NO") != null ? refund.get("SR_NO").toString() : "");
refundClientInfoRepository.save(refundClientInfo);
}
return "success";
}
}
@Transactional
public void intiateRefund(int bookingId,int userId) throws Exception {
@Transactional
public void intiateRefund(int bookingId, int userId) throws Exception {
List<BookingCalendar> bc = calendarService.getCalendarByBookingId(bookingId);
if (bc != null && bc.isEmpty()) {
String s = paymentGatewayServiceImpl.refundTheAmount(bookingId, userId);
if(s.equals("Refunded")){
bookingService.updateRefundStatus(bookingId,BookingDetails.RefundStatus.COMPLETED);
}else
{
bookingService.updateRefundStatus(bookingId,BookingDetails.RefundStatus.FAILURE);
if (s.equals("Refunded")) {
bookingService.updateRefundStatus(bookingId, BookingDetails.RefundStatus.COMPLETED);
}
} else {
bookingService.updateRefundStatus(bookingId, BookingDetails.RefundStatus.FAILURE);
}
}
}
*/

2
src/main/java/com/gcc/communityHall/repository/BookingCalendarRepository.java

@ -73,4 +73,6 @@ public interface BookingCalendarRepository extends JpaRepository<BookingCalendar
@Param("bookingId") Long bookingId,
@Param("hallName") String hallName);
@Query(value="SELECT * from booking_calendar where booking_id_1 = :bookingId or booking_id_2 = :bookingId ", nativeQuery = true)
List<BookingCalendar> getCalendarByBookingId(int bookingId);
}

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

@ -337,8 +337,7 @@ public interface BookingDetailsRepository extends JpaRepository<BookingDetails,
+ "LEFT JOIN counter_details cd ON cd.counter_id = bd.counterdetails_counter_id\r\n"
+ "LEFT JOIN payments pd ON bd.booking_id = pd.booking_details_booking_id \r\n"
+ "WHERE bd.users_user_id = :userId and booking_status IN ('GCC_BLOCKED', 'APPROVED','CANCELED','REJECTED','COMPLETED','WAITING_FOR_NOC','WAITING_FOR_NOC_APPROVAL') \r\n"
+ "ORDER BY bd.booking_id DESC;\r\n"
+ "", nativeQuery = true)
+ "ORDER BY bd.booking_id DESC\r\n", nativeQuery = true)
List<Map<String, Object>> getAllBookingEventsByUserId(Integer userId);
//counter

13
src/main/java/com/gcc/communityHall/repository/RefundTransactionRepository.java

@ -3,8 +3,10 @@ package com.gcc.communityHall.repository;
import com.gcc.communityHall.entity.RefundTransaction;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@Repository
public interface RefundTransactionRepository extends JpaRepository<RefundTransaction,Integer> {
@ -13,4 +15,15 @@ public interface RefundTransactionRepository extends JpaRepository<RefundTransac
@Query(value = "select * from refund_transaction where booking_details_booking_id = ?",nativeQuery = true)
RefundTransaction findByBookingId(int bookingId);
@Modifying
@Transactional
@Query(value = "INSERT INTO refund_transaction (transaction_id, amount_refunded, cdate, refund_status, booking_details_booking_id, refund_identifier) " +
"VALUES (?, ?, ?, ?, ?, ?)", nativeQuery = true)
void insertRefundTransaction(String transactionId,
Double amountRefunded,
java.util.Date cdate,
String refundStatus,
Integer bookingId,
String refundIdentifier);
}

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

@ -202,4 +202,6 @@ public interface BookingService {
List<Object[]> getBookingCalendarDetails(String fromDate, String toDate, Long bookingId, String hallName);
List<BookingDetails> getBookingsByDateAndHall(String bookingDate, Long hallId);
BookingDetails updateRefundStatusScheduler(int bookingId, RefundStatus status);
}

3
src/main/java/com/gcc/communityHall/service/CalendarService.java

@ -10,4 +10,7 @@ public interface CalendarService {
List<BookingCalendar> getCalendarByDateAndHallIdAndSlot(
String fromDate,String toDate,String startingSlot,String endingSlot,
int hallId);
List<BookingCalendar> getCalendarByBookingId(int bookingId);
}

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

@ -170,6 +170,7 @@ public class BookingServiceImpl implements BookingService {
@Override
public BookingDetails getBookingsById(int BookingId) {
Optional<BookingDetails> OPBookingDetails = bookingDetailsRepository.findById(BookingId);
if (OPBookingDetails.isPresent()) {
return OPBookingDetails.get();
}
@ -186,7 +187,7 @@ public class BookingServiceImpl implements BookingService {
Optional<BookingDetails> booking = bookingDetailsRepository.findById(bookingId);
if (booking.isPresent()) {
BookingDetails book = booking.get();
BookingHistory bookingHistory = new BookingHistory();
/*BookingHistory bookingHistory = new BookingHistory();
bookingHistory.setBookingDetails(book);
bookingHistory.setStartDate(book.getStartDate());
bookingHistory.setEndDate(book.getEndDate());
@ -194,7 +195,8 @@ public class BookingServiceImpl implements BookingService {
bookingHistory.setComments(book.getComments());
bookingHistory.setCdate(new Date());
bookingHistory.setRefundStatus(book.getRefundStatus());
bookingHistoryRepository.save(bookingHistory);
System.out.println("bookingHistory.."+bookingHistory);
bookingHistoryRepository.save(bookingHistory);*/
book.setBookingStatus(status);
book.setComments(comments);
@ -365,50 +367,50 @@ public class BookingServiceImpl implements BookingService {
@Transactional
public String processBookingStatusAndSendMessages(BookingDetails bookingDetails) {
try{
String reason = bookingDetails.getReason();
ReasonMaster reasonDetails = reasonMasterRepository.findByReason(reason);
String reasonCode = (reasonDetails != null && reasonDetails.getReasoncode() != null) ? reasonDetails.getReasoncode() : "";
try {
String reason = bookingDetails.getReason();
ReasonMaster reasonDetails = reasonMasterRepository.findByReason(reason);
String reasonCode = (reasonDetails != null && reasonDetails.getReasoncode() != null) ? reasonDetails.getReasoncode() : "";
String bookingconfirmationmsg, urlString, whatsupmsg;
String bookingconfirmationmsg, urlString, whatsupmsg;
if (reasonCode.equals("CGE") || reasonCode.equals("CAO") || reasonCode.equals("SGE")) {
updateBookingStatusById(bookingDetails.getBookingId(), BookingDetails.BookingStatus.WAITING_FOR_NOC, "Waiting For NOC Documents");
if (reasonCode.equals("CGE") || reasonCode.equals("CAO") || reasonCode.equals("SGE")) {
updateBookingStatusById(bookingDetails.getBookingId(), BookingDetails.BookingStatus.WAITING_FOR_NOC, "Waiting For NOC Documents");
bookingconfirmationmsg = "Your booking ID " + bookingDetails.getBookingId() + " on " + bookingDetails.getBookingDate() + " has been confirmed successfully. Thanks for using GCC Community Hall Booking System.";
bookingconfirmationmsg = "Your booking ID " + bookingDetails.getBookingId() + " on " + bookingDetails.getBookingDate() + " has been confirmed successfully. Thanks for using GCC Community Hall Booking System.";
urlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + bookingDetails.getUsers().getMobileNo() +
"&from=GCCCRP&body=" + bookingconfirmationmsg + "&entityid=1401572690000011081&templateid=1407172346459428987";
urlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + bookingDetails.getUsers().getMobileNo() +
"&from=GCCCRP&body=" + bookingconfirmationmsg + "&entityid=1401572690000011081&templateid=1407172346459428987";
whatsupmsg = "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+" +
bookingDetails.getBookingId() + "+on+" + bookingDetails.getBookingDate() +
"+has+been+successfully+confirmed.+%0AThanks+for+using+GCC+Community+Hall+Booking+System.";
whatsupmsg = "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+" +
bookingDetails.getBookingId() + "+on+" + bookingDetails.getBookingDate() +
"+has+been+successfully+confirmed.+%0AThanks+for+using+GCC+Community+Hall+Booking+System.";
whatsappMsgServiceImpl.sendMsg(whatsupmsg);
whatsappMsgServiceImpl.sendSMS(urlString);
return "Waiting For NOC Documents";
whatsappMsgServiceImpl.sendMsg(whatsupmsg);
whatsappMsgServiceImpl.sendSMS(urlString);
return "Waiting For NOC Documents";
} else {
updateBookingStatusById(bookingDetails.getBookingId(), BookingDetails.BookingStatus.APPROVED, "Booking Confirmed Successfully");
} else {
updateBookingStatusById(bookingDetails.getBookingId(), BookingDetails.BookingStatus.APPROVED, "Booking Confirmed Successfully");
bookingconfirmationmsg = "Your booking ID " + bookingDetails.getBookingId() + " on " + bookingDetails.getStartDate() + " has been confirmed successfully. Thanks for using GCC Community Hall Booking System.";
bookingconfirmationmsg = "Your booking ID " + bookingDetails.getBookingId() + " on " + bookingDetails.getStartDate() + " has been confirmed successfully. Thanks for using GCC Community Hall Booking System.";
urlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + bookingDetails.getUsers().getMobileNo() +
"&from=GCCCRP&body=" + bookingconfirmationmsg + "&entityid=1401572690000011081&templateid=1407172346459428987";
urlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + bookingDetails.getUsers().getMobileNo() +
"&from=GCCCRP&body=" + bookingconfirmationmsg + "&entityid=1401572690000011081&templateid=1407172346459428987";
whatsupmsg = "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+" +
bookingDetails.getBookingId() + "+on+" + bookingDetails.getStartDate() +
"+has+been+successfully+confirmed.+%0AThanks+for+using+GCC+Community+Hall+Booking+System.";
whatsupmsg = "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+" +
bookingDetails.getBookingId() + "+on+" + bookingDetails.getStartDate() +
"+has+been+successfully+confirmed.+%0AThanks+for+using+GCC+Community+Hall+Booking+System.";
whatsappMsgServiceImpl.sendMsg(whatsupmsg);
whatsappMsgServiceImpl.sendSMS(urlString);
return "Booking confirmed successfully";
}
}catch (Exception e){
whatsappMsgServiceImpl.sendMsg(whatsupmsg);
whatsappMsgServiceImpl.sendSMS(urlString);
return "Booking confirmed successfully";
}
} catch (Exception e) {
e.printStackTrace();
return "error";
}
@ -979,6 +981,9 @@ public class BookingServiceImpl implements BookingService {
bd.setBookingDetails(bookingDetails); // Set the associated booking details
bookingDetails.setBookingStatus(BookingStatus.WAITING_FOR_NOC_APPROVAL);
bookingDetails.setComments("Waiting for Admin Approval");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formattedDate = LocalDateTime.now().format(formatter);
bookingDetails.setUpdatedDate(formattedDate);
// Save the file to the server
try (FileOutputStream fos = new FileOutputStream(filePath)) {
@ -1603,17 +1608,18 @@ public class BookingServiceImpl implements BookingService {
String adminname = (String) session.getAttribute("usertype");
BookingDetails book = booking.get();
book.setRefundStatus(status);
// BookingHistory bookingHistory=new BookingHistory();
// bookingHistory.setStartDate(book.getStartDate());
// bookingHistory.setEndDate(book.getEndDate());
// bookingHistory.setComments(book.getComments());
// bookingHistory.setBookingDetails(book);
// bookingHistory.setBookingStatus(book.getBookingStatus());
// bookingHistory.setUpdatedBy(adminname);
// bookingHistory.setCdate(new Date());
// bookingHistory.setRefundStatus(book.getRefundStatus());
BookingHistory bookingHistory = new BookingHistory();
bookingHistory.setStartDate(book.getStartDate());
bookingHistory.setEndDate(book.getEndDate());
bookingHistory.setComments(book.getComments());
bookingHistory.setBookingDetails(book);
bookingHistory.setBookingStatus(book.getBookingStatus());
bookingHistory.setUpdatedBy(adminname);
bookingHistory.setCdate(new Date());
bookingHistory.setRefundStatus(book.getRefundStatus());
bookingHistoryRepository.save(bookingHistory);
book.setComments("Refund status Updated to:-" + status);
// bookingHistoryRepository.save(bookingHistory);
BookingDetails bookings = bookingDetailsRepository.save(book);
return bookings;
}
@ -1778,6 +1784,9 @@ public class BookingServiceImpl implements BookingService {
Optional<BookingDetails> book = bookingDetailsRepository.findById(bookingId);
BookingDetails bookingDetails = book.get();
bookingDetails.setScheduleCount(bookingDetails.getScheduleCount() + 1);
if (bookingDetails.getReason().equals("Commercial")) {
bookingDetails.setBookingStatus(BookingStatus.WAITING_FOR_NOC);
}
//Updating Bookinghistory startDate and End Date
BookingHistory bookingHistory = new BookingHistory();
bookingHistory.setStartDate(bookingDetails.getStartDate());
@ -1791,6 +1800,9 @@ public class BookingServiceImpl implements BookingService {
bookingDetails.setEndDate(endDate);
bookingHistory.setRefundStatus(bookingDetails.getRefundStatus());
bookingDetails.setComments("slots Resheduled the Dates");
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);
}
@ -2396,5 +2408,32 @@ public class BookingServiceImpl implements BookingService {
return bookingDetailsRepository.findByBookingDateAndHallId(date, hallId);
}
@Override
@Transactional
public BookingDetails updateRefundStatusScheduler(int bookingId, RefundStatus status) {
Optional<BookingDetails> booking = bookingDetailsRepository.findById(bookingId);
if (booking.isPresent()) {
String adminname = "Refund Scheduler";
BookingDetails book = booking.get();
book.setRefundStatus(status);
book.setComments("Refund status Updated to:-" + status);
BookingDetails bookings = bookingDetailsRepository.save(book);
BookingHistory bookingHistory = new BookingHistory();
bookingHistory.setStartDate(book.getStartDate());
bookingHistory.setEndDate(book.getEndDate());
bookingHistory.setComments(book.getComments());
bookingHistory.setBookingDetails(book);
bookingHistory.setBookingStatus(book.getBookingStatus());
bookingHistory.setUpdatedBy(adminname);
bookingHistory.setCdate(new Date());
bookingHistory.setRefundStatus(book.getRefundStatus());
bookingHistoryRepository.save(bookingHistory);
return bookings;
}
return null;
}
}

8
src/main/java/com/gcc/communityHall/service/Impl/CalendarServiceImpl.java

@ -30,4 +30,12 @@ public class CalendarServiceImpl implements CalendarService {
}
}
@Override
public List<BookingCalendar> getCalendarByBookingId(int bookingId) {
if(bookingId!=0){
return bookingCalendarRepository.getCalendarByBookingId(bookingId);
}
return null;
}
}

16
src/main/java/com/gcc/communityHall/service/Impl/TransactionServiceImpl.java

@ -3,6 +3,7 @@ package com.gcc.communityHall.service.Impl;
import com.gcc.communityHall.entity.RefundTransaction;
import com.gcc.communityHall.repository.RefundTransactionRepository;
import com.gcc.communityHall.service.TransactionService;
import jakarta.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -21,4 +22,19 @@ public class TransactionServiceImpl implements TransactionService {
public RefundTransaction saveRefundTransaction(RefundTransaction refundTransaction) {
return refundTransactionRepository.save(refundTransaction);
}
@Transactional
@Override
public void saveRefundTransactionDetails(RefundTransaction refundTransaction) {
refundTransactionRepository.insertRefundTransaction(
refundTransaction.getTransactionId(),
refundTransaction.getAmountRefunded(),
refundTransaction.getCdate(),
refundTransaction.getRefundStatus(),
refundTransaction.getBookingDetails().getBookingId(),
refundTransaction.getRefundIdentifier()
);
// return refundTransaction; // returning the same object after manual insert
}
}

2
src/main/java/com/gcc/communityHall/service/TransactionService.java

@ -7,4 +7,6 @@ public interface TransactionService {
RefundTransaction getRefundTrans(int bookingId);
RefundTransaction saveRefundTransaction(RefundTransaction refundTransaction);
void saveRefundTransactionDetails(RefundTransaction refundTrans);
}

3935
src/main/resources/templates/admin/reports.html
File diff suppressed because it is too large
View File

4
src/main/resources/templates/user/calculatehallamount.html

@ -503,8 +503,9 @@
var startPeriod = $('#startPeriodDropdown').val();
var endPeriod = $('#endPeriodDropdown').val();
var reasonForBooking = $('#reasonforBooking').val();
// console.log("reasonForBooking="+reasonForBooking);
if (reasonforBooking === '') {
if (reasonForBooking.trim() === '') {
$('#reasonforBooking')[0].setCustomValidity('Please select reason for booking.');
$('#reasonforBooking')[0].reportValidity();
return;
@ -514,6 +515,7 @@
// Validate input fields
if (isNaN(numDays) || numDays < 1 || numDays > 7) {
console.log("num of days")
$('#numDaysCount')[0].setCustomValidity('Please select a valid number of days.');
$('#numDaysCount')[0].reportValidity();
return;

5340
src/main/resources/templates/user/viewhistory.html
File diff suppressed because it is too large
View File

Loading…
Cancel
Save