13 changed files with 670 additions and 13 deletions
-
41src/main/java/com/gcc/communityHall/configuration/EncryptionUtil.java
-
78src/main/java/com/gcc/communityHall/configuration/UuidBookingUtil.java
-
78src/main/java/com/gcc/communityHall/controller/UserController.java
-
13src/main/java/com/gcc/communityHall/entity/BookingDetails.java
-
238src/main/java/com/gcc/communityHall/entity/SettlementHistory.java
-
125src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java
-
22src/main/java/com/gcc/communityHall/repository/BookingDetailsRepository.java
-
9src/main/java/com/gcc/communityHall/repository/SettlementHistoryRepository.java
-
4src/main/java/com/gcc/communityHall/service/BookingService.java
-
63src/main/java/com/gcc/communityHall/service/Impl/BookingServiceImpl.java
-
4src/main/resources/templates/admin/settlement-list.html
-
4src/main/resources/templates/headquarters/settlement-list.html
-
4src/main/resources/templates/officer/settlement-list.html
@ -0,0 +1,41 @@ |
|||||
|
package com.gcc.communityHall.configuration; |
||||
|
|
||||
|
|
||||
|
import org.springframework.stereotype.Component; |
||||
|
import javax.crypto.Cipher; |
||||
|
import javax.crypto.spec.SecretKeySpec; |
||||
|
import java.util.Base64; |
||||
|
|
||||
|
|
||||
|
@Component |
||||
|
public class EncryptionUtil { |
||||
|
|
||||
|
private static final String SECRET_KEY = "MySecretKey12345"; // 16 chars |
||||
|
private static final String ALGORITHM = "AES"; |
||||
|
|
||||
|
|
||||
|
public String encrypt(String value) { |
||||
|
try { |
||||
|
SecretKeySpec key = new SecretKeySpec(SECRET_KEY.getBytes(), ALGORITHM); |
||||
|
Cipher cipher = Cipher.getInstance(ALGORITHM); |
||||
|
cipher.init(Cipher.ENCRYPT_MODE, key); |
||||
|
byte[] encrypted = cipher.doFinal(value.getBytes()); |
||||
|
return Base64.getUrlEncoder().encodeToString(encrypted); // URL safe |
||||
|
} catch (Exception e) { |
||||
|
throw new RuntimeException(e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public String decrypt(String encryptedValue) { |
||||
|
try { |
||||
|
SecretKeySpec key = new SecretKeySpec(SECRET_KEY.getBytes(), ALGORITHM); |
||||
|
Cipher cipher = Cipher.getInstance(ALGORITHM); |
||||
|
cipher.init(Cipher.DECRYPT_MODE, key); |
||||
|
byte[] decoded = Base64.getUrlDecoder().decode(encryptedValue); |
||||
|
return new String(cipher.doFinal(decoded)); |
||||
|
} catch (Exception e) { |
||||
|
throw new RuntimeException(e); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,78 @@ |
|||||
|
package com.gcc.communityHall.configuration; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
import java.util.UUID; |
||||
|
import java.util.concurrent.ConcurrentHashMap; |
||||
|
|
||||
|
/** |
||||
|
* Utility class for handling UUID-based ref_id for booking verification |
||||
|
* This provides a secure and URL-friendly approach for booking reference IDs |
||||
|
*/ |
||||
|
public class UuidBookingUtil { |
||||
|
|
||||
|
// In-memory cache to store UUID to booking ID mapping |
||||
|
// In production, this should be replaced with a database table or Redis |
||||
|
private static final Map<String, Integer> uuidToBookingIdMap = new ConcurrentHashMap<>(); |
||||
|
private static final Map<Integer, String> bookingIdToUuidMap = new ConcurrentHashMap<>(); |
||||
|
|
||||
|
/** |
||||
|
* Generate a UUID ref_id for a booking ID |
||||
|
* @param bookingId The original booking ID |
||||
|
* @return UUID string that can be used as ref_id |
||||
|
*/ |
||||
|
public static String generateRefIdForBooking(int bookingId) { |
||||
|
String uuid = UUID.randomUUID().toString(); |
||||
|
|
||||
|
// Store the mapping |
||||
|
uuidToBookingIdMap.put(uuid, bookingId); |
||||
|
bookingIdToUuidMap.put(bookingId, uuid); |
||||
|
|
||||
|
return uuid; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Get booking ID from ref_id UUID |
||||
|
* @param refId The UUID string from URL |
||||
|
* @return Original booking ID, or null if not found |
||||
|
*/ |
||||
|
public static Integer getBookingIdFromRefId(String refId) { |
||||
|
return uuidToBookingIdMap.get(refId); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Get ref_id UUID for existing booking ID (if already generated) |
||||
|
* @param bookingId The booking ID |
||||
|
* @return UUID string, or null if not found |
||||
|
*/ |
||||
|
public static String getRefIdForBooking(int bookingId) { |
||||
|
return bookingIdToUuidMap.get(bookingId); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Remove mapping when booking is cancelled or expired |
||||
|
* @param bookingId The booking ID to remove |
||||
|
*/ |
||||
|
public static void removeBookingMapping(int bookingId) { |
||||
|
String uuid = bookingIdToUuidMap.remove(bookingId); |
||||
|
if (uuid != null) { |
||||
|
uuidToBookingIdMap.remove(uuid); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Check if ref_id UUID is valid |
||||
|
* @param refId The UUID string to validate |
||||
|
* @return true if UUID exists in mapping |
||||
|
*/ |
||||
|
public static boolean isValidRefId(String refId) { |
||||
|
return uuidToBookingIdMap.containsKey(refId); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Get total number of active mappings (for monitoring) |
||||
|
* @return Number of active UUID mappings |
||||
|
*/ |
||||
|
public static int getActiveMappingCount() { |
||||
|
return uuidToBookingIdMap.size(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,238 @@ |
|||||
|
package com.gcc.communityHall.entity; |
||||
|
|
||||
|
import java.time.Instant; |
||||
|
import java.time.LocalDate; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
|
||||
|
import jakarta.persistence.CascadeType; |
||||
|
import jakarta.persistence.Column; |
||||
|
import jakarta.persistence.Entity; |
||||
|
import jakarta.persistence.FetchType; |
||||
|
import jakarta.persistence.GeneratedValue; |
||||
|
import jakarta.persistence.GenerationType; |
||||
|
import jakarta.persistence.Id; |
||||
|
import jakarta.persistence.OneToOne; |
||||
|
import jakarta.persistence.Transient; |
||||
|
|
||||
|
@Entity |
||||
|
public class SettlementHistory { |
||||
|
|
||||
|
@Id |
||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY) |
||||
|
@Column(name = "history_id") |
||||
|
private int historyId; |
||||
|
|
||||
|
private int settlementId; |
||||
|
private String comments; |
||||
|
private LocalDate cdate; |
||||
|
private double damageAmount; |
||||
|
private double ebAmount; |
||||
|
private double depositAmount; |
||||
|
private double refundedAmount; |
||||
|
private Date updatedDate; |
||||
|
private String updatedId; |
||||
|
@Column(name = "challon_url") |
||||
|
private String challon; |
||||
|
private String dddate; |
||||
|
private long ddnumber; |
||||
|
private double collectionPending; |
||||
|
private String collectionStatus; |
||||
|
private long challonnumber; |
||||
|
private long challonamount; |
||||
|
private long ddamount; |
||||
|
//ak |
||||
|
@Column(name = "approved_flag") |
||||
|
private Integer approvedFlag = 0; |
||||
|
|
||||
|
@Column(name = "approved_flag_date") |
||||
|
private Date approvedFlagDate; |
||||
|
@Column(name = "sh_date") |
||||
|
private Date ShDate; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
@OneToOne(fetch = FetchType.EAGER,cascade = CascadeType.ALL) |
||||
|
@JsonIgnore |
||||
|
private BookingDetails bookingDetails; |
||||
|
public int getHistoryId() { |
||||
|
return historyId; |
||||
|
} |
||||
|
|
||||
|
public void setHistoryId(int historyId) { |
||||
|
this.historyId = historyId; |
||||
|
} |
||||
|
|
||||
|
public int getSettlementId() { |
||||
|
return settlementId; |
||||
|
} |
||||
|
public void setSettlementId(int settlementId) { |
||||
|
this.settlementId = settlementId; |
||||
|
} |
||||
|
public String getComments() { |
||||
|
return comments; |
||||
|
} |
||||
|
public void setComments(String comments) { |
||||
|
this.comments = comments; |
||||
|
} |
||||
|
public LocalDate getCdate() { |
||||
|
return cdate; |
||||
|
} |
||||
|
public void setCdate(LocalDate cdate) { |
||||
|
this.cdate = cdate; |
||||
|
} |
||||
|
public double getDamageAmount() { |
||||
|
return damageAmount; |
||||
|
} |
||||
|
public void setDamageAmount(double damageAmount) { |
||||
|
this.damageAmount = damageAmount; |
||||
|
} |
||||
|
public double getEbAmount() { |
||||
|
return ebAmount; |
||||
|
} |
||||
|
public void setEbAmount(double ebAmount) { |
||||
|
this.ebAmount = ebAmount; |
||||
|
} |
||||
|
public double getDepositAmount() { |
||||
|
return depositAmount; |
||||
|
} |
||||
|
public void setDepositAmount(double depositAmount) { |
||||
|
this.depositAmount = depositAmount; |
||||
|
} |
||||
|
public double getRefundedAmount() { |
||||
|
return refundedAmount; |
||||
|
} |
||||
|
public void setRefundedAmount(double refundedAmount) { |
||||
|
this.refundedAmount = refundedAmount; |
||||
|
} |
||||
|
public Date getUpdatedDate() { |
||||
|
return updatedDate; |
||||
|
} |
||||
|
public void setUpdatedDate(Date updatedDate) { |
||||
|
this.updatedDate = updatedDate; |
||||
|
} |
||||
|
public String getUpdatedId() { |
||||
|
return updatedId; |
||||
|
} |
||||
|
public void setUpdatedId(String updatedId) { |
||||
|
this.updatedId = updatedId; |
||||
|
} |
||||
|
public BookingDetails getBookingDetails() { |
||||
|
return bookingDetails; |
||||
|
} |
||||
|
public void setBookingDetails(BookingDetails bookingDetails) { |
||||
|
this.bookingDetails = bookingDetails; |
||||
|
} |
||||
|
public String getChallon() { |
||||
|
return challon; |
||||
|
} |
||||
|
public void setChallon(String challon) { |
||||
|
this.challon = challon; |
||||
|
} |
||||
|
public String getDddate() { |
||||
|
return dddate; |
||||
|
} |
||||
|
public void setDddate(String dddate) { |
||||
|
this.dddate = dddate; |
||||
|
} |
||||
|
public long getDdnumber() { |
||||
|
return ddnumber; |
||||
|
} |
||||
|
public void setDdnumber(long ddnumber) { |
||||
|
this.ddnumber = ddnumber; |
||||
|
} |
||||
|
|
||||
|
public double getCollectionPending() { |
||||
|
return collectionPending; |
||||
|
} |
||||
|
public void setCollectionPending(double collectionPending) { |
||||
|
this.collectionPending = collectionPending; |
||||
|
} |
||||
|
|
||||
|
public long getChallonnumber() { |
||||
|
return challonnumber; |
||||
|
} |
||||
|
public void setChallonnumber(long challonnumber) { |
||||
|
this.challonnumber = challonnumber; |
||||
|
} |
||||
|
public long getDdamount() { |
||||
|
return ddamount; |
||||
|
} |
||||
|
public void setDdamount(long ddamount) { |
||||
|
this.ddamount = ddamount; |
||||
|
} |
||||
|
|
||||
|
public long getChallonamount() { |
||||
|
return challonamount; |
||||
|
} |
||||
|
public void setChallonamount(long challonamount) { |
||||
|
this.challonamount = challonamount; |
||||
|
} |
||||
|
public String getCollectionStatus() { |
||||
|
return collectionStatus; |
||||
|
} |
||||
|
|
||||
|
public void setCollectionStatus(String collectionStatus) { |
||||
|
this.collectionStatus = collectionStatus; |
||||
|
} |
||||
|
// Getter for approvedFlag |
||||
|
public Integer getApprovedFlag() { |
||||
|
return approvedFlag; |
||||
|
} |
||||
|
|
||||
|
// Setter for approvedFlag |
||||
|
public void setApprovedFlag(Integer approvedFlag) { |
||||
|
this.approvedFlag = approvedFlag; |
||||
|
} |
||||
|
|
||||
|
// Getter for approvedFlagDate |
||||
|
public Date getApprovedFlagDate() { |
||||
|
return approvedFlagDate; |
||||
|
} |
||||
|
|
||||
|
// Setter for approvedFlagDate |
||||
|
public void setApprovedFlagDate(Date approvedFlagDate) { |
||||
|
this.approvedFlagDate = approvedFlagDate; |
||||
|
} |
||||
|
|
||||
|
// Getter for ShDate |
||||
|
public Date getShDate() { |
||||
|
return ShDate; |
||||
|
} |
||||
|
|
||||
|
// Setter for ShDate |
||||
|
public void setShDate(Date shDate) { |
||||
|
ShDate = shDate; |
||||
|
} |
||||
|
|
||||
|
public SettlementHistory(int settlementId, String comments, LocalDate cdate, double damageAmount, double ebAmount, |
||||
|
double depositAmount, double refundedAmount, Date updatedDate, String updatedId, String challon, |
||||
|
String dddate, long ddnumber, BookingDetails bookingDetails,double collectionPending, long ddamount, long challonnumber, String collectionStatus) { |
||||
|
super(); |
||||
|
this.settlementId = settlementId; |
||||
|
this.comments = comments; |
||||
|
this.cdate = cdate; |
||||
|
this.damageAmount = damageAmount; |
||||
|
this.ebAmount = ebAmount; |
||||
|
this.depositAmount = depositAmount; |
||||
|
this.refundedAmount = refundedAmount; |
||||
|
this.updatedDate = updatedDate; |
||||
|
this.updatedId = updatedId; |
||||
|
this.challon = challon; |
||||
|
this.dddate = dddate; |
||||
|
this.ddnumber = ddnumber; |
||||
|
this.bookingDetails = bookingDetails; |
||||
|
this.collectionPending=collectionPending; |
||||
|
this.ddamount=ddamount; |
||||
|
this.challonnumber=challonnumber; |
||||
|
this.collectionStatus=collectionStatus; |
||||
|
} |
||||
|
public SettlementHistory() { |
||||
|
super(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
package com.gcc.communityHall.repository; |
||||
|
|
||||
|
import org.springframework.data.jpa.repository.JpaRepository; |
||||
|
import org.springframework.stereotype.Repository; |
||||
|
import com.gcc.communityHall.entity.SettlementHistory; |
||||
|
|
||||
|
@Repository |
||||
|
public interface SettlementHistoryRepository extends JpaRepository<SettlementHistory, Integer> { |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue