-
BIN.DS_Store
-
2.gitattributes
-
33.gitignore
-
BINco-workspaceDocuments/.DS_Store
-
BINco-workspaceDocuments/360.png
-
BINco-workspaceDocuments/Desk_Space_1.jpg
-
BINco-workspaceDocuments/Desk_Space_2.jpg
-
BINco-workspaceDocuments/Desk_Space_3.jpg
-
BINco-workspaceDocuments/Desk_Space_4.jpg
-
BINco-workspaceDocuments/Desk_Space_5.jpg
-
BINco-workspaceDocuments/Learning_Centre_1.jpg
-
BINco-workspaceDocuments/Learning_Centre_2.jpg
-
BINco-workspaceDocuments/Learning_Centre_3.jpg
-
BINco-workspaceDocuments/Learning_Centre_4.jpg
-
BINco-workspaceDocuments/Learning_Centre_5.jpg
-
BINco-workspaceDocuments/caretakercomplaintfile_uploads/2025/11/06112025115534r0nQfKCYZCkWKOq_img2.jpg
-
BINco-workspaceDocuments/co-work.png
-
BINco-workspaceDocuments/complaintfile_uploads/2025/11/06112025115320mya40qRzFCJmQDE_img1.jpg
-
BINco-workspaceDocuments/conference.png
-
BINco-workspaceDocuments/conhall.jpg
-
BINco-workspaceDocuments/home1.png
-
BINco-workspaceDocuments/home2.jpg
-
BINco-workspaceDocuments/home3.jpg
-
BINco-workspaceDocuments/icons/.DS_Store
-
BINco-workspaceDocuments/icons/1.png
-
BINco-workspaceDocuments/icons/10.png
-
BINco-workspaceDocuments/icons/2.png
-
BINco-workspaceDocuments/icons/3.png
-
BINco-workspaceDocuments/icons/4.png
-
BINco-workspaceDocuments/icons/5.png
-
BINco-workspaceDocuments/icons/6.png
-
BINco-workspaceDocuments/icons/7.png
-
BINco-workspaceDocuments/icons/8.png
-
BINco-workspaceDocuments/icons/9.png
-
BINco-workspaceDocuments/icons/cal.png
-
BINco-workspaceDocuments/icons/clo.png
-
BINco-workspaceDocuments/learning1.png
-
BINco-workspaceDocuments/learning2.png
-
BINco-workspaceDocuments/learning3.png
-
66256co-workspaceDocuments/logs/muthalvarpadaippagam_07072025.log
-
7974co-workspaceDocuments/logs/muthalvarpadaippagam_error_07072025.log
-
156457co-workspaceDocuments/muthalvarpadaippagam_03062025.log
-
BINco-workspaceDocuments/otp.png
-
BINco-workspaceDocuments/readzone.png
-
BINco-workspaceDocuments/readzone1.png
-
BINco-workspaceDocuments/readzone2.png
-
259mvnw
-
149mvnw.cmd
-
95pom.xml
-
BINsrc/.DS_Store
-
BINsrc/main/.DS_Store
-
BINsrc/main/java/.DS_Store
-
BINsrc/main/java/com/.DS_Store
-
BINsrc/main/java/com/gcc/.DS_Store
-
BINsrc/main/java/com/gcc/coworkspace/.DS_Store
-
13src/main/java/com/gcc/coworkspace/CoworkspaceApplication.java
-
50src/main/java/com/gcc/coworkspace/component/UserSession.java
-
61src/main/java/com/gcc/coworkspace/component/UserSessionInterceptor.java
-
BINsrc/main/java/com/gcc/coworkspace/configuration/.DS_Store
-
86src/main/java/com/gcc/coworkspace/configuration/AppConfig.java
-
88src/main/java/com/gcc/coworkspace/configuration/DataSourceConfig.java
-
44src/main/java/com/gcc/coworkspace/configuration/QrGenerator.java
-
442src/main/java/com/gcc/coworkspace/configuration/RefundScheduler.java
-
50src/main/java/com/gcc/coworkspace/configuration/WebConfig.java
-
11src/main/java/com/gcc/coworkspace/constants/AppConstants.java
-
BINsrc/main/java/com/gcc/coworkspace/controller/.DS_Store
-
217src/main/java/com/gcc/coworkspace/controller/AttendanceController.java
-
487src/main/java/com/gcc/coworkspace/controller/BookingController.java
-
70src/main/java/com/gcc/coworkspace/controller/BuildingController.java
-
72src/main/java/com/gcc/coworkspace/controller/CheckListController.java
-
154src/main/java/com/gcc/coworkspace/controller/ComplaintController.java
-
36src/main/java/com/gcc/coworkspace/controller/DateTimeUtil.java
-
28src/main/java/com/gcc/coworkspace/controller/GoogleReviewController.java
-
373src/main/java/com/gcc/coworkspace/controller/RefundController.java
-
169src/main/java/com/gcc/coworkspace/controller/ReportController.java
-
784src/main/java/com/gcc/coworkspace/controller/controller.java
-
29src/main/java/com/gcc/coworkspace/exception/ErrorResponse.java
-
46src/main/java/com/gcc/coworkspace/exception/GlobalExceptionHandler.java
-
7src/main/java/com/gcc/coworkspace/exception/NoSlotAvailable.java
-
1src/main/java/com/gcc/coworkspace/package-info.java
-
BINsrc/main/java/com/gcc/coworkspace/service/.DS_Store
-
33src/main/java/com/gcc/coworkspace/service/AmountConfigService.java
-
582src/main/java/com/gcc/coworkspace/service/AttendanceService.java
-
1111src/main/java/com/gcc/coworkspace/service/BookingService.java
-
198src/main/java/com/gcc/coworkspace/service/BookingServiceCopy.java
-
170src/main/java/com/gcc/coworkspace/service/BuildingService.java
-
27src/main/java/com/gcc/coworkspace/service/CalendarService.java
-
229src/main/java/com/gcc/coworkspace/service/CheckListService.java
-
348src/main/java/com/gcc/coworkspace/service/ComplaintService.java
-
43src/main/java/com/gcc/coworkspace/service/GoogleReviewService.java
-
161src/main/java/com/gcc/coworkspace/service/HomeService.java
-
96src/main/java/com/gcc/coworkspace/service/NormalSMS.java
-
173src/main/java/com/gcc/coworkspace/service/PaymentService.java
-
288src/main/java/com/gcc/coworkspace/service/RefundService.java
-
265src/main/java/com/gcc/coworkspace/service/RefundService_old.java
-
512src/main/java/com/gcc/coworkspace/service/ReportService.java
-
40src/main/java/com/gcc/coworkspace/service/SMSService.java
-
66src/main/java/com/gcc/coworkspace/service/WhatsAppService.java
-
BINsrc/main/resources/.DS_Store
-
11src/main/resources/application-dev.properties
@ -0,0 +1,2 @@ |
|||
/mvnw text eol=lf |
|||
*.cmd text eol=crlf |
|||
@ -0,0 +1,33 @@ |
|||
HELP.md |
|||
target/ |
|||
!.mvn/wrapper/maven-wrapper.jar |
|||
!**/src/main/**/target/ |
|||
!**/src/test/**/target/ |
|||
|
|||
### STS ### |
|||
.apt_generated |
|||
.classpath |
|||
.factorypath |
|||
.project |
|||
.settings |
|||
.springBeans |
|||
.sts4-cache |
|||
|
|||
### IntelliJ IDEA ### |
|||
.idea |
|||
*.iws |
|||
*.iml |
|||
*.ipr |
|||
|
|||
### NetBeans ### |
|||
/nbproject/private/ |
|||
/nbbuild/ |
|||
/dist/ |
|||
/nbdist/ |
|||
/.nb-gradle/ |
|||
build/ |
|||
!**/src/main/**/build/ |
|||
!**/src/test/**/build/ |
|||
|
|||
### VS Code ### |
|||
.vscode/ |
|||
|
After Width: 429 | Height: 117 | Size: 27 KiB |
|
After Width: 2880 | Height: 1620 | Size: 689 KiB |
|
After Width: 2880 | Height: 1620 | Size: 720 KiB |
|
After Width: 2880 | Height: 1620 | Size: 842 KiB |
|
After Width: 2880 | Height: 1620 | Size: 914 KiB |
|
After Width: 2880 | Height: 1620 | Size: 954 KiB |
|
After Width: 3034 | Height: 1707 | Size: 565 KiB |
|
After Width: 2880 | Height: 1620 | Size: 910 KiB |
|
After Width: 2880 | Height: 1620 | Size: 970 KiB |
|
After Width: 3034 | Height: 1707 | Size: 547 KiB |
|
After Width: 2880 | Height: 1620 | Size: 914 KiB |
|
After Width: 1600 | Height: 900 | Size: 326 KiB |
|
After Width: 1200 | Height: 756 | Size: 1.7 MiB |
|
After Width: 1920 | Height: 1080 | Size: 495 KiB |
|
After Width: 920 | Height: 518 | Size: 164 KiB |
|
After Width: 1199 | Height: 650 | Size: 106 KiB |
|
After Width: 1173 | Height: 640 | Size: 1.2 MiB |
|
After Width: 300 | Height: 168 | Size: 8.4 KiB |
|
After Width: 275 | Height: 183 | Size: 11 KiB |
|
After Width: 40 | Height: 40 | Size: 1.2 KiB |
|
After Width: 40 | Height: 40 | Size: 867 B |
|
After Width: 40 | Height: 40 | Size: 933 B |
|
After Width: 40 | Height: 40 | Size: 1.2 KiB |
|
After Width: 40 | Height: 40 | Size: 1017 B |
|
After Width: 40 | Height: 40 | Size: 814 B |
|
After Width: 40 | Height: 40 | Size: 812 B |
|
After Width: 40 | Height: 40 | Size: 982 B |
|
After Width: 40 | Height: 40 | Size: 580 B |
|
After Width: 40 | Height: 40 | Size: 1.1 KiB |
|
After Width: 30 | Height: 30 | Size: 570 B |
|
After Width: 30 | Height: 30 | Size: 722 B |
|
After Width: 592 | Height: 517 | Size: 312 KiB |
|
After Width: 592 | Height: 517 | Size: 443 KiB |
|
After Width: 592 | Height: 517 | Size: 357 KiB |
66256
co-workspaceDocuments/logs/muthalvarpadaippagam_07072025.log
File diff suppressed because it is too large
View File
7974
co-workspaceDocuments/logs/muthalvarpadaippagam_error_07072025.log
File diff suppressed because it is too large
View File
156457
co-workspaceDocuments/muthalvarpadaippagam_03062025.log
File diff suppressed because it is too large
View File
|
After Width: 1102 | Height: 1020 | Size: 234 KiB |
|
After Width: 800 | Height: 500 | Size: 927 KiB |
|
After Width: 800 | Height: 500 | Size: 881 KiB |
|
After Width: 1200 | Height: 756 | Size: 1.7 MiB |
@ -0,0 +1,259 @@ |
|||
#!/bin/sh |
|||
# ---------------------------------------------------------------------------- |
|||
# Licensed to the Apache Software Foundation (ASF) under one |
|||
# or more contributor license agreements. See the NOTICE file |
|||
# distributed with this work for additional information |
|||
# regarding copyright ownership. The ASF licenses this file |
|||
# to you under the Apache License, Version 2.0 (the |
|||
# "License"); you may not use this file except in compliance |
|||
# with the License. You may obtain a copy of the License at |
|||
# |
|||
# http://www.apache.org/licenses/LICENSE-2.0 |
|||
# |
|||
# Unless required by applicable law or agreed to in writing, |
|||
# software distributed under the License is distributed on an |
|||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|||
# KIND, either express or implied. See the License for the |
|||
# specific language governing permissions and limitations |
|||
# under the License. |
|||
# ---------------------------------------------------------------------------- |
|||
|
|||
# ---------------------------------------------------------------------------- |
|||
# Apache Maven Wrapper startup batch script, version 3.3.2 |
|||
# |
|||
# Optional ENV vars |
|||
# ----------------- |
|||
# JAVA_HOME - location of a JDK home dir, required when download maven via java source |
|||
# MVNW_REPOURL - repo url base for downloading maven distribution |
|||
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven |
|||
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output |
|||
# ---------------------------------------------------------------------------- |
|||
|
|||
set -euf |
|||
[ "${MVNW_VERBOSE-}" != debug ] || set -x |
|||
|
|||
# OS specific support. |
|||
native_path() { printf %s\\n "$1"; } |
|||
case "$(uname)" in |
|||
CYGWIN* | MINGW*) |
|||
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" |
|||
native_path() { cygpath --path --windows "$1"; } |
|||
;; |
|||
esac |
|||
|
|||
# set JAVACMD and JAVACCMD |
|||
set_java_home() { |
|||
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched |
|||
if [ -n "${JAVA_HOME-}" ]; then |
|||
if [ -x "$JAVA_HOME/jre/sh/java" ]; then |
|||
# IBM's JDK on AIX uses strange locations for the executables |
|||
JAVACMD="$JAVA_HOME/jre/sh/java" |
|||
JAVACCMD="$JAVA_HOME/jre/sh/javac" |
|||
else |
|||
JAVACMD="$JAVA_HOME/bin/java" |
|||
JAVACCMD="$JAVA_HOME/bin/javac" |
|||
|
|||
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then |
|||
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 |
|||
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 |
|||
return 1 |
|||
fi |
|||
fi |
|||
else |
|||
JAVACMD="$( |
|||
'set' +e |
|||
'unset' -f command 2>/dev/null |
|||
'command' -v java |
|||
)" || : |
|||
JAVACCMD="$( |
|||
'set' +e |
|||
'unset' -f command 2>/dev/null |
|||
'command' -v javac |
|||
)" || : |
|||
|
|||
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then |
|||
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 |
|||
return 1 |
|||
fi |
|||
fi |
|||
} |
|||
|
|||
# hash string like Java String::hashCode |
|||
hash_string() { |
|||
str="${1:-}" h=0 |
|||
while [ -n "$str" ]; do |
|||
char="${str%"${str#?}"}" |
|||
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) |
|||
str="${str#?}" |
|||
done |
|||
printf %x\\n $h |
|||
} |
|||
|
|||
verbose() { :; } |
|||
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } |
|||
|
|||
die() { |
|||
printf %s\\n "$1" >&2 |
|||
exit 1 |
|||
} |
|||
|
|||
trim() { |
|||
# MWRAPPER-139: |
|||
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. |
|||
# Needed for removing poorly interpreted newline sequences when running in more |
|||
# exotic environments such as mingw bash on Windows. |
|||
printf "%s" "${1}" | tr -d '[:space:]' |
|||
} |
|||
|
|||
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties |
|||
while IFS="=" read -r key value; do |
|||
case "${key-}" in |
|||
distributionUrl) distributionUrl=$(trim "${value-}") ;; |
|||
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; |
|||
esac |
|||
done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" |
|||
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" |
|||
|
|||
case "${distributionUrl##*/}" in |
|||
maven-mvnd-*bin.*) |
|||
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ |
|||
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in |
|||
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; |
|||
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;; |
|||
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;; |
|||
:Linux*x86_64*) distributionPlatform=linux-amd64 ;; |
|||
*) |
|||
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 |
|||
distributionPlatform=linux-amd64 |
|||
;; |
|||
esac |
|||
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" |
|||
;; |
|||
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; |
|||
*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; |
|||
esac |
|||
|
|||
# apply MVNW_REPOURL and calculate MAVEN_HOME |
|||
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash> |
|||
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" |
|||
distributionUrlName="${distributionUrl##*/}" |
|||
distributionUrlNameMain="${distributionUrlName%.*}" |
|||
distributionUrlNameMain="${distributionUrlNameMain%-bin}" |
|||
MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" |
|||
MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" |
|||
|
|||
exec_maven() { |
|||
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : |
|||
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" |
|||
} |
|||
|
|||
if [ -d "$MAVEN_HOME" ]; then |
|||
verbose "found existing MAVEN_HOME at $MAVEN_HOME" |
|||
exec_maven "$@" |
|||
fi |
|||
|
|||
case "${distributionUrl-}" in |
|||
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; |
|||
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; |
|||
esac |
|||
|
|||
# prepare tmp dir |
|||
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then |
|||
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } |
|||
trap clean HUP INT TERM EXIT |
|||
else |
|||
die "cannot create temp dir" |
|||
fi |
|||
|
|||
mkdir -p -- "${MAVEN_HOME%/*}" |
|||
|
|||
# Download and Install Apache Maven |
|||
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." |
|||
verbose "Downloading from: $distributionUrl" |
|||
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" |
|||
|
|||
# select .zip or .tar.gz |
|||
if ! command -v unzip >/dev/null; then |
|||
distributionUrl="${distributionUrl%.zip}.tar.gz" |
|||
distributionUrlName="${distributionUrl##*/}" |
|||
fi |
|||
|
|||
# verbose opt |
|||
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' |
|||
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v |
|||
|
|||
# normalize http auth |
|||
case "${MVNW_PASSWORD:+has-password}" in |
|||
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; |
|||
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; |
|||
esac |
|||
|
|||
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then |
|||
verbose "Found wget ... using wget" |
|||
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" |
|||
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then |
|||
verbose "Found curl ... using curl" |
|||
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" |
|||
elif set_java_home; then |
|||
verbose "Falling back to use Java to download" |
|||
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" |
|||
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" |
|||
cat >"$javaSource" <<-END |
|||
public class Downloader extends java.net.Authenticator |
|||
{ |
|||
protected java.net.PasswordAuthentication getPasswordAuthentication() |
|||
{ |
|||
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); |
|||
} |
|||
public static void main( String[] args ) throws Exception |
|||
{ |
|||
setDefault( new Downloader() ); |
|||
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); |
|||
} |
|||
} |
|||
END |
|||
# For Cygwin/MinGW, switch paths to Windows format before running javac and java |
|||
verbose " - Compiling Downloader.java ..." |
|||
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" |
|||
verbose " - Running Downloader.java ..." |
|||
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" |
|||
fi |
|||
|
|||
# If specified, validate the SHA-256 sum of the Maven distribution zip file |
|||
if [ -n "${distributionSha256Sum-}" ]; then |
|||
distributionSha256Result=false |
|||
if [ "$MVN_CMD" = mvnd.sh ]; then |
|||
echo "Checksum validation is not supported for maven-mvnd." >&2 |
|||
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 |
|||
exit 1 |
|||
elif command -v sha256sum >/dev/null; then |
|||
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then |
|||
distributionSha256Result=true |
|||
fi |
|||
elif command -v shasum >/dev/null; then |
|||
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then |
|||
distributionSha256Result=true |
|||
fi |
|||
else |
|||
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 |
|||
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 |
|||
exit 1 |
|||
fi |
|||
if [ $distributionSha256Result = false ]; then |
|||
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 |
|||
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 |
|||
exit 1 |
|||
fi |
|||
fi |
|||
|
|||
# unzip and move |
|||
if command -v unzip >/dev/null; then |
|||
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" |
|||
else |
|||
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" |
|||
fi |
|||
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" |
|||
mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" |
|||
|
|||
clean || : |
|||
exec_maven "$@" |
|||
@ -0,0 +1,149 @@ |
|||
<# : batch portion |
|||
@REM ---------------------------------------------------------------------------- |
|||
@REM Licensed to the Apache Software Foundation (ASF) under one |
|||
@REM or more contributor license agreements. See the NOTICE file |
|||
@REM distributed with this work for additional information |
|||
@REM regarding copyright ownership. The ASF licenses this file |
|||
@REM to you under the Apache License, Version 2.0 (the |
|||
@REM "License"); you may not use this file except in compliance |
|||
@REM with the License. You may obtain a copy of the License at |
|||
@REM |
|||
@REM http://www.apache.org/licenses/LICENSE-2.0 |
|||
@REM |
|||
@REM Unless required by applicable law or agreed to in writing, |
|||
@REM software distributed under the License is distributed on an |
|||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|||
@REM KIND, either express or implied. See the License for the |
|||
@REM specific language governing permissions and limitations |
|||
@REM under the License. |
|||
@REM ---------------------------------------------------------------------------- |
|||
|
|||
@REM ---------------------------------------------------------------------------- |
|||
@REM Apache Maven Wrapper startup batch script, version 3.3.2 |
|||
@REM |
|||
@REM Optional ENV vars |
|||
@REM MVNW_REPOURL - repo url base for downloading maven distribution |
|||
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven |
|||
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output |
|||
@REM ---------------------------------------------------------------------------- |
|||
|
|||
@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) |
|||
@SET __MVNW_CMD__= |
|||
@SET __MVNW_ERROR__= |
|||
@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% |
|||
@SET PSModulePath= |
|||
@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( |
|||
IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) |
|||
) |
|||
@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% |
|||
@SET __MVNW_PSMODULEP_SAVE= |
|||
@SET __MVNW_ARG0_NAME__= |
|||
@SET MVNW_USERNAME= |
|||
@SET MVNW_PASSWORD= |
|||
@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) |
|||
@echo Cannot start maven from wrapper >&2 && exit /b 1 |
|||
@GOTO :EOF |
|||
: end batch / begin powershell #> |
|||
|
|||
$ErrorActionPreference = "Stop" |
|||
if ($env:MVNW_VERBOSE -eq "true") { |
|||
$VerbosePreference = "Continue" |
|||
} |
|||
|
|||
# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties |
|||
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl |
|||
if (!$distributionUrl) { |
|||
Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" |
|||
} |
|||
|
|||
switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { |
|||
"maven-mvnd-*" { |
|||
$USE_MVND = $true |
|||
$distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" |
|||
$MVN_CMD = "mvnd.cmd" |
|||
break |
|||
} |
|||
default { |
|||
$USE_MVND = $false |
|||
$MVN_CMD = $script -replace '^mvnw','mvn' |
|||
break |
|||
} |
|||
} |
|||
|
|||
# apply MVNW_REPOURL and calculate MAVEN_HOME |
|||
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash> |
|||
if ($env:MVNW_REPOURL) { |
|||
$MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } |
|||
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" |
|||
} |
|||
$distributionUrlName = $distributionUrl -replace '^.*/','' |
|||
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' |
|||
$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" |
|||
if ($env:MAVEN_USER_HOME) { |
|||
$MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" |
|||
} |
|||
$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' |
|||
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" |
|||
|
|||
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { |
|||
Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" |
|||
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" |
|||
exit $? |
|||
} |
|||
|
|||
if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { |
|||
Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" |
|||
} |
|||
|
|||
# prepare tmp dir |
|||
$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile |
|||
$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" |
|||
$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null |
|||
trap { |
|||
if ($TMP_DOWNLOAD_DIR.Exists) { |
|||
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } |
|||
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } |
|||
} |
|||
} |
|||
|
|||
New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null |
|||
|
|||
# Download and Install Apache Maven |
|||
Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." |
|||
Write-Verbose "Downloading from: $distributionUrl" |
|||
Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" |
|||
|
|||
$webclient = New-Object System.Net.WebClient |
|||
if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { |
|||
$webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) |
|||
} |
|||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 |
|||
$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null |
|||
|
|||
# If specified, validate the SHA-256 sum of the Maven distribution zip file |
|||
$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum |
|||
if ($distributionSha256Sum) { |
|||
if ($USE_MVND) { |
|||
Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." |
|||
} |
|||
Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash |
|||
if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { |
|||
Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." |
|||
} |
|||
} |
|||
|
|||
# unzip and move |
|||
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null |
|||
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null |
|||
try { |
|||
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null |
|||
} catch { |
|||
if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { |
|||
Write-Error "fail to move MAVEN_HOME" |
|||
} |
|||
} finally { |
|||
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } |
|||
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } |
|||
} |
|||
|
|||
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" |
|||
@ -0,0 +1,95 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
<parent> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-parent</artifactId> |
|||
<version>3.3.4</version> |
|||
<relativePath/> <!-- lookup parent from repository --> |
|||
</parent> |
|||
<groupId>com.gcc</groupId> |
|||
<artifactId>coworkspace</artifactId> |
|||
<version>0.0.1-SNAPSHOT</version> |
|||
<name>muthalvarpadaippagam</name> |
|||
<description>GCC project for muthalvar padaippagam</description> |
|||
<url/> |
|||
<licenses> |
|||
<license/> |
|||
</licenses> |
|||
<developers> |
|||
<developer/> |
|||
</developers> |
|||
<scm> |
|||
<connection/> |
|||
<developerConnection/> |
|||
<tag/> |
|||
<url/> |
|||
</scm> |
|||
<properties> |
|||
<java.version>17</java.version> |
|||
</properties> |
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-data-jpa</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-thymeleaf</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-web</artifactId> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-devtools</artifactId> |
|||
<scope>runtime</scope> |
|||
<optional>true</optional> |
|||
</dependency> |
|||
<!-- <dependency>--> |
|||
<!-- <groupId>com.microsoft.sqlserver</groupId>--> |
|||
<!-- <artifactId>mssql-jdbc</artifactId>--> |
|||
<!-- <scope>runtime</scope>--> |
|||
<!-- </dependency>--> |
|||
<dependency> |
|||
<groupId>com.mysql</groupId> |
|||
<artifactId>mysql-connector-j</artifactId> |
|||
<scope>runtime</scope> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.razorpay</groupId> |
|||
<artifactId>razorpay-java</artifactId> |
|||
<version>1.4.3</version> |
|||
</dependency> |
|||
<!--<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-test</artifactId> |
|||
<scope>test</scope> |
|||
</dependency>--> |
|||
|
|||
<dependency> |
|||
<groupId>com.google.zxing</groupId> |
|||
<artifactId>javase</artifactId> |
|||
<version>3.5.1</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.google.zxing</groupId> |
|||
<artifactId>core</artifactId> |
|||
<version>3.5.1</version> |
|||
</dependency> |
|||
|
|||
</dependencies> |
|||
|
|||
<build> |
|||
<plugins> |
|||
<plugin> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-maven-plugin</artifactId> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
|
|||
</project> |
|||
@ -0,0 +1,13 @@ |
|||
package com.gcc.coworkspace; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
|
|||
@SpringBootApplication |
|||
public class CoworkspaceApplication { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(CoworkspaceApplication.class, args); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
package com.gcc.coworkspace.component; |
|||
|
|||
import org.springframework.context.annotation.Scope; |
|||
import org.springframework.context.annotation.ScopedProxyMode; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.web.context.WebApplicationContext; |
|||
|
|||
@Component |
|||
@Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS) |
|||
public class UserSession { |
|||
private Integer userId =0 ; |
|||
private String userType; |
|||
private String dispayName; |
|||
private Long mobileno =0L; |
|||
|
|||
public Integer getUserId() { |
|||
return userId; |
|||
} |
|||
|
|||
public void setUserId(Integer userId) { |
|||
this.userId = userId; |
|||
} |
|||
|
|||
public String getUserType() { |
|||
return userType; |
|||
} |
|||
|
|||
public void setUserType(String userType) { |
|||
this.userType = userType; |
|||
} |
|||
|
|||
public String getDispayName() { |
|||
return dispayName; |
|||
} |
|||
|
|||
public void setDispayName(String dispayName) { |
|||
this.dispayName = dispayName; |
|||
} |
|||
|
|||
public Long getMobileno() { |
|||
return mobileno; |
|||
} |
|||
|
|||
public void setMobileno(Long mobileno) { |
|||
this.mobileno = mobileno; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,61 @@ |
|||
package com.gcc.coworkspace.component; |
|||
|
|||
|
|||
|
|||
import com.gcc.coworkspace.configuration.AppConfig; |
|||
import jakarta.servlet.http.HttpServletRequest; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.web.servlet.HandlerInterceptor; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
|
|||
@Component |
|||
public class UserSessionInterceptor implements HandlerInterceptor { |
|||
|
|||
@Autowired |
|||
private UserSession userSession; |
|||
@Autowired |
|||
private AppConfig appConfig; |
|||
private static final List<String> EXCLUDED_URLS = Arrays.asList("/user", "/main"); |
|||
@Override |
|||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
|||
// Get the current request URL |
|||
String requestUrl = request.getRequestURI(); |
|||
|
|||
request.setAttribute("baseURL", appConfig.getBaseUrl()); |
|||
//System.out.println("App BaseURL:"+ appConfig.getBaseUrl()); |
|||
|
|||
// Exclude static resources from the check |
|||
if (requestUrl.startsWith("/user/") || requestUrl.startsWith("/admin/") || requestUrl.startsWith("/caretaker/") || requestUrl.startsWith("/careTaker/") || requestUrl.startsWith("/css/") || requestUrl.startsWith("/js/") || requestUrl.startsWith("/co-workspaceDocuments/") || requestUrl.startsWith("/api/") || requestUrl.startsWith("/payment/") || requestUrl.startsWith("/") ) { |
|||
return true; // Allow the request to proceed without checking the login status |
|||
} |
|||
|
|||
// Exclude the login page from the check |
|||
// Exclude specific URLs from the check |
|||
if (EXCLUDED_URLS.contains(requestUrl)) { |
|||
return true; // Allow the request to proceed without checking the login status |
|||
} |
|||
// Check if the user is logged in |
|||
// If logged in, add the userSession to the model |
|||
// Return true to allow the request to proceed |
|||
//if (isLoggedIn()) { |
|||
// if(userSession.getUserId() != null && userSession.getUserType() != null) { |
|||
// request.setAttribute("userSession", userSession); |
|||
// } else { |
|||
// request.setAttribute("title", "Login"); |
|||
|
|||
// response.sendRedirect(""); |
|||
// return false; // Stop further processing of the request |
|||
// } |
|||
return true; // Allow the request to proceed |
|||
} |
|||
|
|||
private boolean isLoggedIn() { |
|||
// Implement your login check logic here |
|||
// For example, check if the userSession contains the necessary information |
|||
return userSession.getUserId() != null && userSession.getUserType() != null; |
|||
} |
|||
} |
|||
@ -0,0 +1,86 @@ |
|||
package com.gcc.coworkspace.configuration; |
|||
|
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
@Component |
|||
@ConfigurationProperties(prefix = "app") |
|||
public class AppConfig { |
|||
|
|||
private String title; |
|||
private String baseUrl; |
|||
private String getOtpUrl; |
|||
private String erpUrl; |
|||
private String assetURL; |
|||
private String manualRefundCode; |
|||
|
|||
@Value("${payment.razorpay.my_key_id}") |
|||
private String keyId; |
|||
|
|||
private String full_URL; |
|||
|
|||
public String getTitle() { |
|||
return title; |
|||
} |
|||
|
|||
public void setTitle(String title) { |
|||
this.title = title; |
|||
} |
|||
|
|||
public String getBaseUrl() { |
|||
return baseUrl; |
|||
} |
|||
|
|||
public void setBaseUrl(String baseUrl) { |
|||
this.baseUrl = baseUrl; |
|||
} |
|||
|
|||
public String getGetOtpUrl() { |
|||
return getOtpUrl; |
|||
} |
|||
|
|||
public void setGetOtpUrl(String getOtpUrl) { |
|||
this.getOtpUrl = getOtpUrl; |
|||
} |
|||
|
|||
public String getErpUrl() { |
|||
return erpUrl; |
|||
} |
|||
|
|||
public void setErpUrl(String erpUrl) { |
|||
this.erpUrl = erpUrl; |
|||
} |
|||
|
|||
public String getAssetURL() { |
|||
return assetURL; |
|||
} |
|||
|
|||
public void setAssetURL(String assetURL) { |
|||
this.assetURL = assetURL; |
|||
} |
|||
|
|||
public String getManualRefundCode() { |
|||
return manualRefundCode; |
|||
} |
|||
|
|||
public void setManualRefundCode(String manualRefundCode) { |
|||
this.manualRefundCode = manualRefundCode; |
|||
} |
|||
|
|||
public String getKeyId() { |
|||
return keyId; |
|||
} |
|||
|
|||
public void setKeyId(String keyId) { |
|||
this.keyId = keyId; |
|||
} |
|||
|
|||
public String getFull_URL() { |
|||
return full_URL; |
|||
} |
|||
|
|||
public void setFull_URL(String full_URL) { |
|||
this.full_URL = full_URL; |
|||
} |
|||
} |
|||
@ -0,0 +1,88 @@ |
|||
package com.gcc.coworkspace.configuration; |
|||
|
|||
import org.hibernate.jpa.HibernatePersistenceProvider; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.context.annotation.Primary; |
|||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; |
|||
import org.springframework.jdbc.datasource.DriverManagerDataSource; |
|||
import org.springframework.orm.jpa.JpaTransactionManager; |
|||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; |
|||
import org.springframework.transaction.PlatformTransactionManager; |
|||
import org.springframework.transaction.annotation.EnableTransactionManagement; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import javax.sql.DataSource; |
|||
import java.util.Properties; |
|||
|
|||
@Configuration |
|||
@EnableTransactionManagement |
|||
public class DataSourceConfig { |
|||
// host - 13.232.20.48 |
|||
// user - root |
|||
// pass - Bonton#2K24 |
|||
// DB:- coworkspace |
|||
|
|||
//private static String host = "13.232.20.48"; |
|||
//private static String dbpassword = "Bonton#2K24"; |
|||
|
|||
// AWS |
|||
//private static String host = "gcc-facial-db-instance-1.cf48eqcciziq.ap-south-1.rds.amazonaws.com:3306"; |
|||
//private static String dbpassword = "gcc-facial-password"; |
|||
|
|||
private static String host ="localhost:3306"; |
|||
private static String dbpassword = "root"; |
|||
//private static String dbpassword = ""; |
|||
|
|||
// Sampath Local |
|||
// private static String host ="localhost"; |
|||
// private static String dbpassword = "12345678"; |
|||
|
|||
|
|||
@Configuration |
|||
@EnableTransactionManagement |
|||
@EnableJpaRepositories( |
|||
entityManagerFactoryRef = "appEntityManagerFactory", |
|||
transactionManagerRef = "appTransactionManager") |
|||
// basePackages = {"in.gov.chennaicorporation"}) |
|||
|
|||
public static class MysqlAppDataSourceConfig { |
|||
@Primary |
|||
@Bean(name = "mysqlAppDataSource") |
|||
public DataSource mysqlAppDataSource() { |
|||
DriverManagerDataSource dataSource = new DriverManagerDataSource(); |
|||
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); |
|||
dataSource.setUrl("jdbc:mysql://"+host+"/coworkingspace"); |
|||
dataSource.setUsername("root"); |
|||
dataSource.setPassword(dbpassword); |
|||
return dataSource; |
|||
} |
|||
|
|||
@Primary |
|||
@Bean(name="appEntityManagerFactory") |
|||
public LocalContainerEntityManagerFactoryBean entityManagerFactory( |
|||
@Qualifier("mysqlAppDataSource") DataSource dataSource) { |
|||
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); |
|||
entityManagerFactoryBean.setDataSource(dataSource); |
|||
entityManagerFactoryBean.setPackagesToScan("com.gcc.coworkspace"); |
|||
entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistenceProvider.class); |
|||
Properties properties = new Properties(); |
|||
properties.setProperty("hibernate.hbm2ddl.auto", "update"); |
|||
entityManagerFactoryBean.setJpaProperties(properties); |
|||
|
|||
return entityManagerFactoryBean; |
|||
} |
|||
|
|||
@Primary |
|||
@Bean(name = "appTransactionManager") |
|||
public PlatformTransactionManager transactionManager(@Qualifier("appEntityManagerFactory") jakarta.persistence.EntityManagerFactory entityManagerFactory) { |
|||
return new JpaTransactionManager(entityManagerFactory); |
|||
} |
|||
} |
|||
|
|||
@Bean |
|||
public RestTemplate restTemplate() { |
|||
return new RestTemplate(); |
|||
} |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
package com.gcc.coworkspace.configuration; |
|||
|
|||
|
|||
import com.google.zxing.BarcodeFormat; |
|||
import com.google.zxing.EncodeHintType; |
|||
import com.google.zxing.WriterException; |
|||
import com.google.zxing.client.j2se.MatrixToImageWriter; |
|||
import com.google.zxing.common.BitMatrix; |
|||
import com.google.zxing.qrcode.QRCodeWriter; |
|||
|
|||
import java.io.ByteArrayOutputStream; |
|||
import java.io.IOException; |
|||
import java.util.Base64; |
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
public class QrGenerator { |
|||
public static String generateQRCode(String url) throws WriterException, IOException { |
|||
int width = 1800; // width of the QR code image |
|||
int height = 1800; // height of the QR code image |
|||
String format = "png"; // format of the QR code image |
|||
String charset = "UTF-8"; // character set used to encode the data |
|||
|
|||
// create the QR code writer and hints |
|||
QRCodeWriter qrCodeWriter = new QRCodeWriter(); |
|||
Map<EncodeHintType, Object> hints = new HashMap<>(); |
|||
hints.put(EncodeHintType.CHARACTER_SET, charset); |
|||
|
|||
// generate the QR code matrix |
|||
BitMatrix matrix = qrCodeWriter.encode(url, BarcodeFormat.QR_CODE, width, height, hints); |
|||
|
|||
// create the QR code image as a byte array |
|||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
|||
MatrixToImageWriter.writeToStream(matrix, format, baos); |
|||
byte[] imageBytes = baos.toByteArray(); |
|||
|
|||
// encode the image data in base64 format |
|||
String base64EncodedImage = Base64.getEncoder().encodeToString(imageBytes); |
|||
|
|||
return base64EncodedImage; |
|||
} |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,442 @@ |
|||
package com.gcc.coworkspace.configuration; |
|||
|
|||
import com.gcc.coworkspace.constants.AppConstants; |
|||
import com.gcc.coworkspace.service.BookingService; |
|||
import com.gcc.coworkspace.service.PaymentService; |
|||
import com.gcc.coworkspace.service.RefundService; |
|||
import com.razorpay.Order; |
|||
import com.razorpay.Payment; |
|||
import com.razorpay.RazorpayClient; |
|||
import com.razorpay.RazorpayException; |
|||
import org.json.JSONObject; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.context.annotation.Lazy; |
|||
import org.springframework.dao.DataAccessException; |
|||
import org.springframework.dao.EmptyResultDataAccessException; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.scheduling.annotation.EnableScheduling; |
|||
import org.springframework.scheduling.annotation.Scheduled; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.time.Instant; |
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.time.ZoneId; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.*; |
|||
|
|||
@Component |
|||
@EnableScheduling |
|||
public class RefundScheduler { |
|||
@Autowired |
|||
@Lazy |
|||
RefundService refundService; |
|||
|
|||
@Autowired |
|||
PaymentService paymentService; |
|||
|
|||
@Autowired |
|||
public JdbcTemplate jdbcTemplate; |
|||
|
|||
//@Scheduled(cron = "0 0 1 * * *", zone = "Asia/Kolkata") // runs every 30 seconds (adjust as needed) |
|||
@Scheduled(cron = "0 30 23 * * *", zone = "Asia/Kolkata") //11:30 PM IST (Asia/Kolkata) |
|||
public void updateOrderPaymentStatus() { |
|||
System.out.println("Fetching payment status from Razorpay..."); |
|||
|
|||
try { |
|||
// Query orders with NULL order_status |
|||
String sql = "SELECT order_id, cdate FROM order_log WHERE (order_status IS NULL OR order_status = '') AND is_counter_booking = 0 and cdate < CURDATE() ORDER BY id ";// |
|||
List<Map<String, Object>> orders = jdbcTemplate.queryForList(sql); |
|||
|
|||
if (orders.isEmpty()) { |
|||
System.out.println("No orders with NULL status."); |
|||
return; |
|||
} |
|||
|
|||
// Collect orderIds into a list |
|||
List<String> orderIds = new ArrayList<>(); |
|||
for (Map<String, Object> order : orders) { |
|||
orderIds.add((String) order.get("order_id")); |
|||
} |
|||
|
|||
// Fetch payment status for all orders using the fetchPayments API for multiple orderIds |
|||
fetchAndUpdatePaymentStatus(orderIds); |
|||
} catch (Exception e) { |
|||
System.err.println("Error fetching payment status: " + e.getMessage()); |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
|
|||
public void fetchAndUpdatePaymentStatus(List<String> orderIds) { |
|||
try { |
|||
System.out.println("Fetching payment status for multiple orders..."); |
|||
|
|||
RazorpayClient razorpayClient = new RazorpayClient(AppConstants.key_id, AppConstants.key_secret); |
|||
|
|||
// Fetch payments for the specified orderIds |
|||
for (String orderId : orderIds) { |
|||
List<Payment> payments = razorpayClient.orders.fetchPayments(orderId); |
|||
System.out.println("Payment response line :100 :"+payments); |
|||
|
|||
String ps ="Not Processed"; |
|||
|
|||
// Check if there are payments for the order |
|||
if (payments != null && !payments.isEmpty()) { |
|||
int i=0; |
|||
int c =0; |
|||
for (Payment payment : payments) { |
|||
String paymentStatus = (payment.get("status") != null) ? payment.get("status").toString() : ""; |
|||
String paymentId = (payment.get("id") != null) ? payment.get("id").toString() : ""; |
|||
String amount = (payment.get("amount") != null) ? payment.get("amount").toString() : "0"; |
|||
String captured_at = ""; //(payment.get("captured_at") != null) ? payment.get("captured_at").toString() : "0"; |
|||
String contactNo = (payment.get("contact") != null) ? payment.get("contact").toString() : "0"; |
|||
|
|||
System.out.println("contactno line 157--> " + contactNo); |
|||
System.out.println("payments=================="+payment); |
|||
|
|||
String paymentDate =""; |
|||
Object createdAtObj =null; |
|||
//Date Convention |
|||
try { |
|||
//Object createdAtObj = payment.has("captured_at") ? payment.get("captured_at") : null; |
|||
createdAtObj = payment.get("captured_at") != null ? payment.get("captured_at") : null; |
|||
|
|||
if (createdAtObj != null) { |
|||
Instant createdAtInstant = (createdAtObj instanceof Date) |
|||
? ((Date) createdAtObj).toInstant() |
|||
: (createdAtObj instanceof Number) |
|||
? Instant.ofEpochSecond(((Number) createdAtObj).longValue()) |
|||
: Instant.ofEpochMilli(System.currentTimeMillis()); |
|||
|
|||
paymentDate = createdAtInstant |
|||
.atZone(ZoneId.of("Asia/Kolkata")) |
|||
.toLocalDateTime() |
|||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
|||
|
|||
// Convert to formatted datetime (e.g., 2025-04-19 17:00:00) |
|||
LocalDateTime dateTime = createdAtInstant |
|||
.atZone(ZoneId.of("Asia/Kolkata")) |
|||
.toLocalDateTime(); |
|||
} |
|||
}catch (Exception e){ |
|||
e.printStackTrace(); |
|||
} |
|||
//End of Date Convention |
|||
|
|||
System.out.println("Payment Status for Order ID " + orderId + ": " + paymentStatus); |
|||
|
|||
if(payments.size()==1) { |
|||
// Update the order status in the order_log table based on payment status |
|||
payment.get("id").toString() ; |
|||
updateOrderStatusInOrderLog(orderId, paymentStatus,payments.size(),paymentId,amount,paymentDate,contactNo); |
|||
c=1; |
|||
}else if(paymentStatus.equals("captured") && i ==0 ) { |
|||
updateOrderStatusInOrderLog(orderId, paymentStatus,payments.size(),paymentId,amount,paymentDate,contactNo); |
|||
c=1; |
|||
|
|||
} |
|||
else if(ps.equals(paymentStatus) && paymentStatus.equals("captured") ) { |
|||
//refund logic to be implemented |
|||
//razorpay will handle this scenario |
|||
c=1; |
|||
} |
|||
else if(paymentStatus.equals("captured") && c == 0) { |
|||
updateOrderStatusInOrderLog(orderId, paymentStatus,payments.size(),paymentId,amount,paymentDate,contactNo); |
|||
c=1; |
|||
} |
|||
|
|||
ps=paymentStatus; |
|||
i++; |
|||
} |
|||
System.out.println("line :-193 :--->"+ps); |
|||
if(c==0) { |
|||
updateOrderStatusInOrderLog(orderId, ps,payments.size(),null,null,null, null); |
|||
} |
|||
} else { |
|||
System.out.println("No payments found for Order ID: " + orderId); |
|||
updateOrderStatusInOrderLog(orderId, ps,payments.size(),null,null,null, null); |
|||
|
|||
} |
|||
} |
|||
} catch (RazorpayException e) { |
|||
System.err.println("Error fetching payment status: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
public void updateOrderStatusInOrderLog(String orderId, String paymentStatus,int pay_attemp, |
|||
String paymentId,String amountStr,String paymentDateTicks,String contactNo) { |
|||
// SQL query to update the order status in order_log table |
|||
String sqlUpdate = "UPDATE order_log SET order_status = ? WHERE order_id = ?"; |
|||
double amount = 0; |
|||
|
|||
try { |
|||
// Check the payment status and update accordingly |
|||
if ("captured".equalsIgnoreCase(paymentStatus)) { |
|||
// Update status to 'PAID' |
|||
jdbcTemplate.update(sqlUpdate, "captured", orderId); |
|||
|
|||
if(amountStr != null && !amountStr.equals("0")) { |
|||
amount= Double.parseDouble(amountStr) / 100.0; |
|||
} |
|||
|
|||
|
|||
String sqlGetTempId = "SELECT temp_booking_id FROM order_log WHERE order_id = ?"; |
|||
String tempid = jdbcTemplate.queryForObject(sqlGetTempId, String.class, orderId); |
|||
System.out.println("==========tempid=========="+tempid); |
|||
insertPaymentDetails(orderId, paymentId, paymentStatus, paymentDateTicks, contactNo, amount,tempid); |
|||
|
|||
System.out.println("Updated Order ID: " + orderId + " to PAID"); |
|||
} else if ("failed".equalsIgnoreCase(paymentStatus)) { |
|||
// Update status to 'FAILED' |
|||
jdbcTemplate.update(sqlUpdate, "failed", orderId); |
|||
System.out.println("Updated Order ID: " + orderId + " to FAILED"); |
|||
|
|||
} else if ("refunded".equalsIgnoreCase(paymentStatus)) { |
|||
// Update status to 'FAILED' |
|||
jdbcTemplate.update(sqlUpdate, "refunded", orderId); |
|||
System.out.println("Updated Order ID: " + orderId + " to refunded"); |
|||
|
|||
} else { |
|||
jdbcTemplate.update(sqlUpdate, paymentStatus, orderId); |
|||
|
|||
System.out.println("Payment status for Order ID " + orderId + " is not 'captured' or 'failed'. No update performed."); |
|||
} |
|||
} catch (DataAccessException e) { |
|||
System.err.println("Error while updating order status: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
public void insertPaymentDetails(String orderId, String paymentId, String paymentStatus, |
|||
String paymentDate, String mobileNumber, double amount, String tempid) { |
|||
|
|||
Integer pid = null; |
|||
int bookingId = 0; |
|||
try { |
|||
// Step 1: Check if order_id already exists in payment table |
|||
String checkSql = "SELECT * FROM payment WHERE order_id = ?"; |
|||
List<Map<String, Object>> ids = jdbcTemplate.queryForList(checkSql, orderId); |
|||
|
|||
|
|||
if (!ids.isEmpty()) { |
|||
// Already exists — pick first |
|||
pid = (Integer)ids.get(0).get("id"); |
|||
bookingId = ids.get(0).get("booking_id")!=null ? (Integer)ids.get(0).get("booking_id") : 0; |
|||
if(bookingId == 0){ |
|||
// checkBookingAndUpdateStatus(orderId, paymentStatus); |
|||
initiateRefund(orderId, bookingId); |
|||
}else { |
|||
String bkStatus = "success"; |
|||
bkStatus = jdbcTemplate.queryForObject("SELECT booking_status FROM booking WHERE booking_id = ?", String.class, bookingId); |
|||
|
|||
if ("pending".equalsIgnoreCase(bkStatus) || bkStatus == null) { |
|||
// checkBookingAndUpdateStatus(orderId, paymentStatus); |
|||
initiateRefund(orderId, bookingId); |
|||
} |
|||
} |
|||
|
|||
System.out.println("⚠️ Payment already exists for order_id: " + orderId + ", using pid: " + pid); |
|||
} else { |
|||
// Step 2: Normalize payment status |
|||
if ("captured".equalsIgnoreCase(paymentStatus)) { |
|||
paymentStatus = "paid"; // ✅ convert captured to paid |
|||
} |
|||
|
|||
// Step 3: Insert new payment |
|||
|
|||
String paymentIdStr = String.valueOf(paymentService.savePayment( String.valueOf(amount), paymentId, orderId, paymentStatus, String.valueOf(bookingId), mobileNumber)); |
|||
System.out.println("✅ Inserted new payment record for order_id: " + orderId); |
|||
System.out.println("======================>>>>>>"+paymentIdStr); |
|||
|
|||
initiateRefund(orderId, bookingId); |
|||
} |
|||
|
|||
|
|||
|
|||
} catch (Exception e) { |
|||
System.err.println("❌ Error during insertPaymentDetails for order_id: " + orderId); |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
/* public void checkBookingAndUpdateStatus(String orderId, String paymentStatus) { |
|||
// SQL to check the booking status for this order |
|||
String sqlBookingStatus = "SELECT b.booking_id, b.booking_status, py.id " + |
|||
"FROM order_log ol " + |
|||
"JOIN payment py ON ol.order_id = py.order_id " + |
|||
"JOIN booking b ON py.booking_id = b.booking_id " + |
|||
"WHERE ol.order_id = ?"; |
|||
|
|||
|
|||
try { |
|||
// Get the booking information |
|||
List<Map<String, Object>> bookingInfo = jdbcTemplate.queryForList(sqlBookingStatus, orderId); |
|||
|
|||
int bookingId = 0; |
|||
if (!bookingInfo.isEmpty()) { |
|||
Map<String, Object> bookingDetails = bookingInfo.get(0); |
|||
String bookingStatus = (String) bookingDetails.get("booking_status"); |
|||
bookingId = bookingDetails.get("booking_id")!=null?(Integer) bookingDetails.get("booking_id"):0; |
|||
|
|||
System.out.println("Booking Status for Order ID " + orderId + ": " + bookingId); |
|||
|
|||
// Case 1: If booking status is "null" or "pending", initiate refund |
|||
// Case 2: If payment status is "captured" (Paid) but no status in the booking table, initiate refund |
|||
System.out.println("Booking status for Order ID " + orderId + " is confirmed. No update required."); |
|||
initiateRefund(orderId, bookingId); |
|||
|
|||
} else { |
|||
System.out.println("No booking information found for Order ID: " + orderId); |
|||
initiateRefund(orderId, 0); |
|||
} |
|||
} catch (DataAccessException e) { |
|||
System.err.println("Error while checking and updating booking status: " + e.getMessage()); |
|||
} |
|||
} |
|||
*/ |
|||
|
|||
|
|||
|
|||
|
|||
// Method to initiate refund process |
|||
private void initiateRefund(String orderId, int bookingId) { |
|||
try { |
|||
System.out.println("Initiating refund for Order ID: " + orderId); |
|||
|
|||
// Fetch the primary key (`id`) from the `payment` table |
|||
String sql = "SELECT id FROM payment WHERE booking_id = ? and order_id = ? "; |
|||
List<Integer> paymentIds = jdbcTemplate.queryForList(sql, Integer.class, bookingId, orderId); |
|||
|
|||
|
|||
|
|||
|
|||
if (!paymentIds.isEmpty()) { |
|||
int paymentId = paymentIds.get(0); // ✅ Get the first result |
|||
System.out.println("Payment ID found: " + paymentId); |
|||
|
|||
// Call refundProcessOrder() with correct int pid |
|||
ResponseEntity<?> response = refundService.refundProcessOrder("Refund Initiated", bookingId, paymentId); |
|||
System.out.println("Refund API Response: " + response.getBody()); |
|||
} else { |
|||
System.err.println("No payment record found for Booking ID: " + bookingId); |
|||
} |
|||
} catch (Exception e) { |
|||
System.err.println("Error initiating refund for Order ID: " + orderId + ": " + e.getMessage()); |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
//@Scheduled(fixedRate = 3000) // 300000 milliseconds = 5 minutes |
|||
@Scheduled(cron = "0 0 1 * * *", zone = "Asia/Kolkata") |
|||
public void refundRrnScheduler() { |
|||
System.out.println("yes....REFUNDStatus_Check_Intiated"); |
|||
List<Map<String, Object>> list = refundService.getbyrefundstatus("REFUND_PROCESSED"); |
|||
for (Map<String, Object> map : list) { |
|||
// System.out.println(map); |
|||
if (map.get("refund_id") != null) { |
|||
String refund_id = (String) map.get("refund_id"); |
|||
String rrn = refundStatus(refund_id); |
|||
if (!rrn.equals("error")) { |
|||
int id = Integer.parseInt(map.get("id") + ""); |
|||
refundService.updateRefundRrnStatus(id, map.get("refund_id").toString(), rrn, "REFUNDED"); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
public String refundStatus(String refund_id) { |
|||
System.out.println("yes....REFUND_PROCESSED "); |
|||
try { |
|||
RazorpayClient razorpayClient = new RazorpayClient(AppConstants.key_id, AppConstants.key_secret); |
|||
com.razorpay.Refund refunds = razorpayClient.refunds.fetch(refund_id); |
|||
System.out.println(refunds.get("acquirer_data").toString()); |
|||
// if(refunds.get("acquirer_data")!= null){ |
|||
JSONObject map = refunds.get("acquirer_data"); |
|||
System.out.println(map); |
|||
if (map.get("rrn") != null && !map.get("rrn").equals("")) { |
|||
System.out.println(map.get("rrn")); |
|||
return map.get("rrn").toString(); |
|||
} |
|||
|
|||
// } |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return "error"; |
|||
} |
|||
return "error"; |
|||
|
|||
} |
|||
|
|||
|
|||
/* |
|||
public void checkBookingStatus(String orderId) { |
|||
System.out.println("🔍 Checking booking status for order_id: " + orderId); |
|||
|
|||
try { |
|||
// Step 1: Fetch booking_id from payment table using order_id |
|||
String getBookingIdSql = "SELECT booking_id FROM payment WHERE order_id = ?"; |
|||
Integer bookingId = jdbcTemplate.queryForObject(getBookingIdSql, Integer.class, orderId); |
|||
|
|||
if (bookingId != null) { |
|||
// Step 2: Fetch booking status using booking_id |
|||
String getBookingStatusSql = "SELECT booking_status FROM booking WHERE booking_id = ?"; |
|||
String bookingStatus = jdbcTemplate.queryForObject(getBookingStatusSql, String.class, bookingId); |
|||
|
|||
System.out.println("➡ Booking ID: " + bookingId + " | Status: " + bookingStatus); |
|||
|
|||
// If status is success, do nothing |
|||
if ("success".equalsIgnoreCase(bookingStatus)) { |
|||
System.out.println("✅ Booking is successful. No refund required."); |
|||
} else { |
|||
System.out.println("⚠️ Booking is not successful. Initiating refund..."); |
|||
|
|||
initiateRefund(orderId, bookingId); |
|||
} |
|||
} else { |
|||
|
|||
System.out.println("⚠️ No booking_id found for order_id: " + orderId + ". Initiating refund..."); |
|||
initiateRefund(orderId, 0); |
|||
} |
|||
|
|||
} catch (EmptyResultDataAccessException e) { |
|||
System.out.println("⚠️ No booking_id or status found for order_id: " + orderId + ". Initiating refund..."); |
|||
initiateRefund(orderId, 0); |
|||
} catch (Exception e) { |
|||
System.err.println("❌ Error in checkBookingStatus for order_id: " + orderId); |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
*/ |
|||
|
|||
// public void initiateRefundlog(String orderId, Integer bookingId) { |
|||
// System.out.println("yes....REFUNDStatus_Check_Intiated"); |
|||
// // String refundStatus = "refunded"; |
|||
// String sql = "INSERT INTO refund_log (order_id, booking_id) VALUES (?, ?)"; |
|||
// } |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@ -0,0 +1,50 @@ |
|||
package com.gcc.coworkspace.configuration; |
|||
|
|||
|
|||
import com.gcc.coworkspace.component.UserSessionInterceptor; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
|||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
|||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|||
|
|||
import java.io.File; |
|||
import java.util.List; |
|||
|
|||
@Configuration |
|||
public class WebConfig implements WebMvcConfigurer { |
|||
private final String uploadDirectory; |
|||
|
|||
|
|||
public ResourceHandlerRegistry registryHandler; |
|||
|
|||
@Autowired |
|||
public WebConfig(@Value("${file.upload.directory}") String uploadDirectory) { |
|||
this.uploadDirectory = uploadDirectory; |
|||
} |
|||
|
|||
@Autowired |
|||
private UserSessionInterceptor userSessionInterceptor; |
|||
|
|||
@Override |
|||
public void addInterceptors(InterceptorRegistry registry) { |
|||
registry.addInterceptor(userSessionInterceptor); |
|||
} |
|||
|
|||
@Override |
|||
public void addResourceHandlers(ResourceHandlerRegistry registry) { |
|||
System.out.println(uploadDirectory); |
|||
File f = new File(uploadDirectory); |
|||
|
|||
|
|||
File profile = new File(uploadDirectory); |
|||
if (!profile.exists()) { |
|||
profile.mkdirs(); |
|||
} |
|||
|
|||
registry.addResourceHandler("/co-workspaceDocuments/**").addResourceLocations("file:" +uploadDirectory+"/"); |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
package com.gcc.coworkspace.constants; |
|||
|
|||
public final class AppConstants { |
|||
// public static String key_id="rzp_live_ySI5Ns54Y7qOcJ"; |
|||
// public static String key_secret="Nwf1TjhUtaskof8vePkRR8Sb"; |
|||
|
|||
|
|||
//uncomment for testing payment |
|||
public static String key_id="rzp_test_tDkHFEqWXmuEi8"; |
|||
public static String key_secret="cBQUjMcKZ4J6vmOKSyNZ92py"; |
|||
} |
|||
@ -0,0 +1,217 @@ |
|||
package com.gcc.coworkspace.controller; |
|||
|
|||
import com.gcc.coworkspace.service.AttendanceService; |
|||
|
|||
import jakarta.servlet.http.HttpSession; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
|
|||
import java.time.LocalDate; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@RequestMapping("/muthalvarpadaippagam/book/api/attendance") |
|||
public class AttendanceController { |
|||
|
|||
@Autowired |
|||
AttendanceService attendanceService; |
|||
|
|||
@Autowired |
|||
JdbcTemplate jdbcTemplate; |
|||
|
|||
@GetMapping("/getAttendance") |
|||
public List<Map<String, Object>> getAttendance( |
|||
@RequestParam(value = "type", required = false) String type, |
|||
@RequestParam(value = "typeName", required = false) String typeName, |
|||
@RequestParam(value = "noOfPerson", required = false) Integer noOfPerson, |
|||
@RequestParam(value = "fromDate", required = false) String fromDate, |
|||
@RequestParam(value = "toDate", required = false) String toDate, |
|||
@RequestParam(value = "bid", required = false) Integer bid |
|||
) { |
|||
System.out.println("noOfPerson"); |
|||
System.out.println(noOfPerson); |
|||
System.out.println("bid"); |
|||
System.out.println(bid); |
|||
return attendanceService.getAttendance(type, typeName, noOfPerson, fromDate, toDate,bid); |
|||
} |
|||
|
|||
/* @GetMapping("/getAttendancereport") |
|||
public List<Map<String, Object>> getAttendance2( |
|||
@RequestParam(value = "type", required = false) String type, |
|||
@RequestParam(value = "typeName", required = false) String typeName, |
|||
@RequestParam(value = "noOfPerson", required = false) Integer noOfPerson, |
|||
@RequestParam(value = "fromDate", required = false) String fromDate, |
|||
@RequestParam(value = "toDate", required = false) String toDate |
|||
) { |
|||
System.out.println("noOfPerson"); |
|||
System.out.println(noOfPerson); |
|||
return attendanceService.getAttendance2(type, typeName, noOfPerson, fromDate, toDate); |
|||
}*/ |
|||
@GetMapping("/getAttendancereport") |
|||
public List<Map<String, Object>> getAttendance2( |
|||
@RequestParam(value = "type", required = false) String type, |
|||
@RequestParam(value = "typeName", required = false) String typeName, |
|||
@RequestParam(value = "bid", required = false) String bid, |
|||
@RequestParam(value = "noOfPerson", required = false) Integer noOfPerson, |
|||
@RequestParam(value = "fromDate", required = false) String fromDate, |
|||
@RequestParam(value = "toDate", required = false) String toDate |
|||
) { |
|||
System.out.println("noOfPerson"); |
|||
System.out.println(noOfPerson); |
|||
return attendanceService.getAttendance2(type, typeName, bid,noOfPerson, fromDate, toDate); |
|||
} |
|||
@GetMapping("/getAbsentCount") |
|||
public Map<String, Object> getAbsentCount(@RequestParam("bookingId") int bookingId) { |
|||
System.out.println("bookingId"); |
|||
System.out.println(bookingId); |
|||
return attendanceService.getAbsentCountByBookingId(bookingId); |
|||
} |
|||
@GetMapping("/updateAbsentCount") |
|||
public Map<String, Object> updateAbsentCount(@RequestParam("bookingId") int bookingId,@RequestParam("noOfAbsent") int noOfAbsent) { |
|||
System.out.println("bookingId"); |
|||
System.out.println(bookingId); |
|||
System.out.println("noOfAbsent"); |
|||
System.out.println(noOfAbsent); |
|||
return attendanceService.updateAbsentCountByBookingId(noOfAbsent,bookingId); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getAttendanceWithSlotDetails") |
|||
public List<Map<String, Object>> getAttendanceWithSlotDetails( |
|||
@RequestParam(value = "type", required = false) String type, |
|||
@RequestParam(value = "typeName", required = false) String typeName, |
|||
@RequestParam(value = "noOfPerson", required = false) Integer noOfPerson, |
|||
@RequestParam(value = "fromDate", required = false) String fromDate, |
|||
@RequestParam(value = "toDate", required = false) String toDate |
|||
) { System.out.println("noOfPerson"); |
|||
System.out.println(noOfPerson); |
|||
return attendanceService.getAttendanceWithSlotDetails(type, typeName, noOfPerson, fromDate, toDate); |
|||
} |
|||
@GetMapping("/hasTodayAttendance") |
|||
public boolean hasTodayAttendance(@RequestParam int bookingId) { |
|||
return attendanceService.hasTodayAttendance(bookingId); |
|||
} |
|||
|
|||
|
|||
// @PostMapping("/save") |
|||
// public String saveAttendance(@RequestParam int bookingId, @RequestBody Map<String, Object> requestData) { |
|||
// int rowsInserted = attendanceService.saveAttendanceByBookingId(bookingId, requestData); |
|||
// if (rowsInserted > 0) { |
|||
// return "Attendance record inserted successfully!"; |
|||
// } else { |
|||
// return "Failed to insert attendance record."; |
|||
// } |
|||
// } |
|||
|
|||
@PostMapping("/saveAndUpdate") |
|||
public ResponseEntity<Map<String, Object>> saveAndUpdateAttendance( |
|||
@RequestParam("bookingId") int bookingId, |
|||
@RequestBody Map<String, Object> payload) { |
|||
|
|||
int noOfAbsent = Integer.parseInt(payload.get("no_of_person_absent").toString()); |
|||
|
|||
boolean success = attendanceService.saveAndUpdateAttendance(bookingId, noOfAbsent); |
|||
|
|||
if (success) { |
|||
return ResponseEntity.ok(Map.of("success", true, "message", "Attendance saved and calendar updated.")); |
|||
} else { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Map.of("success", false, "message", "Failed to process attendance.")); |
|||
} |
|||
} |
|||
|
|||
@PostMapping("/saveAbsent") |
|||
public ResponseEntity<Map<String, Object>> saveAbsent( |
|||
@RequestBody List<Map<String, Object>> absentList, |
|||
@RequestParam("bid") String bid,@RequestParam("absentDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)LocalDate absentDate) { |
|||
|
|||
boolean success = attendanceService.saveAbsent(absentList,Integer.parseInt(bid)); |
|||
|
|||
|
|||
if (success) { |
|||
|
|||
int toadyAbsent=getabsentCount(Integer.parseInt(bid)); |
|||
System.out.println("todayAbsent: " + toadyAbsent); |
|||
System.out.println("absentDate"+absentDate); |
|||
System.out.println("bid"+bid); |
|||
|
|||
|
|||
|
|||
int inserted = attendanceService.insertAbsentCount(Integer.parseInt(bid),absentDate,toadyAbsent); |
|||
|
|||
if (inserted > 0) { |
|||
|
|||
return ResponseEntity.ok(Map.of("success", true, "message", "Attendance saved and calendar updated.")); |
|||
} |
|||
else { |
|||
return ResponseEntity.ok(Map.of("success", false, "message", "Failed to process attendance.")); |
|||
} |
|||
|
|||
|
|||
} else { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Map.of("success", false, "message", "Failed to process attendance.")); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
@PostMapping("/insertAbsentCount") |
|||
public ResponseEntity<Map<String,Object>> insertAbsentCount( |
|||
@RequestParam("bid") int bid, |
|||
@RequestParam("absentDate") |
|||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
|||
LocalDate absentDate |
|||
|
|||
) { |
|||
|
|||
int absentCount=getabsentCount(bid); |
|||
|
|||
int inserted = attendanceService.insertAbsentCount(bid,absentDate,absentCount); |
|||
|
|||
Map<String,Object> body = new HashMap<>(); |
|||
if (inserted > 0) { |
|||
body.put("success", true); |
|||
body.put("message", "Inserted " + inserted + " record" + (inserted > 1 ? "s" : "")); |
|||
return ResponseEntity |
|||
.status(HttpStatus.CREATED) |
|||
.body(body); |
|||
} else { |
|||
body.put("success", false); |
|||
body.put("message", "No records were inserted"); |
|||
return ResponseEntity |
|||
.status(HttpStatus.BAD_REQUEST) |
|||
.body(body); |
|||
} |
|||
} |
|||
|
|||
public int getabsentCount(int bid) { |
|||
String sql="SELECT COALESCE(SUM(absent_count), 0) AS total_absent_today " + |
|||
"FROM calendar " + |
|||
"WHERE DATE(bdate) = CURDATE() AND bid=? AND is_active = 1 AND is_delete = 0"; |
|||
|
|||
return jdbcTemplate.queryForObject(sql,Integer.class,bid); |
|||
} |
|||
|
|||
@GetMapping("/absentCountToday") |
|||
public ResponseEntity<Integer> getTodayAbsentCount(@RequestParam int bid) { |
|||
System.out.println("Building ID in Controller: " + bid); |
|||
try { |
|||
int totalAbsent = attendanceService.getTodayAbsentCount(bid); |
|||
System.out.println("Total Absent Today: " + totalAbsent); |
|||
return ResponseEntity.ok(totalAbsent); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.ok(0); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,487 @@ |
|||
package com.gcc.coworkspace.controller; |
|||
|
|||
|
|||
|
|||
import com.gcc.coworkspace.component.UserSession; |
|||
import com.gcc.coworkspace.configuration.AppConfig; |
|||
import com.gcc.coworkspace.configuration.QrGenerator; |
|||
import com.gcc.coworkspace.constants.AppConstants; |
|||
import com.gcc.coworkspace.service.BookingService; |
|||
import com.gcc.coworkspace.service.NormalSMS; |
|||
import com.gcc.coworkspace.service.PaymentService; |
|||
import com.google.zxing.WriterException; |
|||
import jakarta.servlet.http.HttpServletRequest; |
|||
import jakarta.servlet.http.HttpSession; |
|||
import org.json.JSONObject; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.io.IOException; |
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Random; |
|||
|
|||
import com.razorpay.Order; |
|||
import com.razorpay.RazorpayClient; |
|||
import com.razorpay.RazorpayException; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
@RestController |
|||
@RequestMapping("/muthalvarpadaippagam/book/api") |
|||
public class BookingController { |
|||
|
|||
@Autowired |
|||
private BookingService bookingService; |
|||
|
|||
@Autowired |
|||
private AppConfig appConfig; |
|||
@Autowired |
|||
private BookingService bookingser; |
|||
|
|||
@Autowired |
|||
private UserSession userSession; |
|||
|
|||
@Autowired |
|||
private PaymentService paymentService; |
|||
|
|||
@Autowired |
|||
private NormalSMS normalSMS; |
|||
|
|||
@PostMapping("/saveInTemp") |
|||
public Map<String, Object> booking(@RequestParam("catId") int catId, |
|||
@RequestParam("buildId") int buildId, |
|||
@RequestParam("subId") int subId, |
|||
@RequestParam("noOfPeople") int noOfPeople, |
|||
@RequestParam("fromDate") LocalDate fromDate, |
|||
@RequestParam("toDate") LocalDate toDate, |
|||
@RequestParam("userName") String userName, |
|||
@RequestParam("userMobile") long userMobile, |
|||
// @RequestParam("amount") double amount, |
|||
@RequestParam("slots") List<Integer> slots){ |
|||
|
|||
System.out.println(catId); |
|||
System.out.println(slots); |
|||
return bookingService.saveTempBooking(userName,userMobile, slots, fromDate, toDate,noOfPeople,catId,buildId,subId) ; |
|||
|
|||
} |
|||
|
|||
// @PostMapping("/saveBooking") |
|||
// public int saveBooking(@RequestParam("tempBookId") int tempBookId){ |
|||
// |
|||
// return bookingService.saveBooking(tempBookId); |
|||
// } |
|||
/* |
|||
@GetMapping("/checkAvail") |
|||
public Boolean checkAvailability(int bid,int cid,LocalDate bDate,int scid,int noOfPerson,int slotId){ |
|||
System.out.println("check Availability"); |
|||
return bookingService.checkAvailabilityByBdate(bid,cid,bDate,scid,noOfPerson,slotId); |
|||
} |
|||
*/ |
|||
|
|||
@GetMapping("/checkAvail") |
|||
public Boolean checkAvailability(int bid,int cid,LocalDate bDate,int scid,int noOfPerson,int slotId){ |
|||
System.out.println("check Availability"); |
|||
return bookingService.checkAvailabilityByBdate(bid,cid,bDate,scid,noOfPerson,slotId); |
|||
} |
|||
|
|||
@GetMapping("/hasTodayAttendance") |
|||
public ResponseEntity<Map<String,Object>> hasTodayAttendance( |
|||
@RequestParam("buildingid") int buildingid) { |
|||
|
|||
boolean exists = bookingService.hasTodayAttendance(buildingid); |
|||
Map<String,Object> response = new HashMap<>(); |
|||
response.put("exists", exists); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
@PostMapping(value="/create_order") |
|||
public String create_order(HttpServletRequest request,@RequestParam("id") int tempid) throws RazorpayException { |
|||
// Get data from the service |
|||
Map<String, Object> tempBookingInfo = bookingService.getTempBookingByTempId(tempid); |
|||
|
|||
|
|||
// Check if the list is not empty |
|||
if (tempBookingInfo!=null && !tempBookingInfo.isEmpty()) { |
|||
|
|||
|
|||
String tempbookid = tempBookingInfo.get("tempbookid").toString(); |
|||
String amount = tempBookingInfo.get("amount").toString(); |
|||
double amountDouble = 0.0; |
|||
|
|||
try { |
|||
amountDouble = Double.parseDouble(amount); |
|||
} catch (NumberFormatException e) { |
|||
System.out.println("Invalid number format for amount: " + amount); |
|||
} |
|||
|
|||
//To enable testing mode in appConstants if required for testing & development |
|||
var client = new RazorpayClient(AppConstants.key_id,AppConstants.key_secret); |
|||
JSONObject options = new JSONObject(); |
|||
options.put("amount", amountDouble * 100); |
|||
options.put("currency", "INR"); |
|||
Order od = client.orders.create(options); |
|||
System.out.println(od); |
|||
paymentService.saveorderLog(od.get("id").toString(),od.toString(),tempbookid); |
|||
return od.toString(); |
|||
|
|||
|
|||
} else { |
|||
System.out.println("No data found for tempid: " + tempid); |
|||
return "No data found for tempid: " + tempid; |
|||
} |
|||
|
|||
// return "error"; |
|||
} |
|||
|
|||
@PostMapping("/Confirm") |
|||
public String updateOrder(@RequestBody Map<String,Object> data){ |
|||
String tempid=data.get("id").toString();; |
|||
String pay_id= data.get("payment_id").toString(); |
|||
String order_id=data.get("order_id").toString(); |
|||
String status=data.get("status").toString(); |
|||
String amount =(Double.parseDouble(data.get("amount").toString())/100)+""; |
|||
|
|||
int pid = paymentService.savePayment(amount,pay_id,order_id,status,0+"",0+""); |
|||
try { |
|||
|
|||
int bookingId = bookingser.saveBooking(Integer.parseInt(tempid),pid); |
|||
// |
|||
// Print or use the values as required |
|||
System.out.println("Temp ID: " + tempid); |
|||
System.out.println("Booking ID:- "+bookingId); |
|||
return bookingId+""; |
|||
|
|||
|
|||
}catch (Exception e){ |
|||
System.out.println("error: "+e.getMessage()); |
|||
System.out.println("No booking data found for tempid: " + tempid); |
|||
|
|||
return "error"; |
|||
} |
|||
} |
|||
|
|||
|
|||
//mobile app development |
|||
@GetMapping("/bookings") |
|||
public ResponseEntity<List<Map<String, Object>>> getBookingsByMobileNo(@RequestParam long mobileNo) { |
|||
List<Map<String, Object>> bookings = bookingService.getBookingByMobileNo(mobileNo); |
|||
if (bookings.isEmpty()) { |
|||
return ResponseEntity.notFound().build(); // Return 404 if no bookings found |
|||
} |
|||
return ResponseEntity.ok(bookings); // Return 200 with the bookings data |
|||
} |
|||
@GetMapping("/generate-qrcode") |
|||
public ResponseEntity<?> generateQRCode(@RequestParam(required = true) String booking_id) { |
|||
if (booking_id == null) { |
|||
return ResponseEntity.badRequest().body("{\"error\":\"Mobile number is required\"}"); |
|||
} |
|||
try { |
|||
// URL for the booking details API |
|||
String url = appConfig.getFull_URL()+"/bookingQRCode?booking_id=" + booking_id; |
|||
|
|||
// Generate QR code as base64 string |
|||
String base64QRCode = QrGenerator.generateQRCode(url); |
|||
|
|||
return ResponseEntity.ok().body(base64QRCode); |
|||
} catch (WriterException | IOException e) { |
|||
((Throwable) e).printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("{\"error\":\"Error generating QR code\"}"); |
|||
} |
|||
} |
|||
|
|||
@GetMapping(value = "/sendOTP") |
|||
public String sendOtp(HttpServletRequest request, @RequestParam String mobileNo, @RequestParam String purpose) { |
|||
// Check if the mobile number exists in the database |
|||
// List<BookingDetails> bookingDetailsList = |
|||
// bookingDetailsRepository.findByMobileNo(Long.parseLong(mobileNo)); |
|||
List<?> bookingDetailsList = bookingser.findByMobileNo(Long.parseLong(mobileNo)); |
|||
if (bookingDetailsList == null || bookingDetailsList.isEmpty()) { |
|||
// If the mobile number is not registered, return an error message |
|||
return "Error: This number is not registered."; |
|||
} |
|||
|
|||
// Generate OTP logic as before |
|||
String MobileNo = mobileNo; |
|||
Random rand = new Random(); |
|||
int otp = rand.nextInt(90000) + 10000; |
|||
System.out.print("\n otp---:" + otp); |
|||
|
|||
String bodyMessage = normalSMS.sendOTPNsms(mobileNo,otp+""); |
|||
|
|||
HttpSession session = request.getSession(); |
|||
session.setAttribute("otp", otp); |
|||
session.setAttribute("mobileNo", mobileNo); |
|||
return bodyMessage; |
|||
} |
|||
|
|||
|
|||
@GetMapping(value = "/verifyOTP") |
|||
@ResponseBody |
|||
public Map<String, Object> verifyOtp(HttpServletRequest request, @RequestParam String otp) { |
|||
HttpSession session = request.getSession(); |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
Integer session_otp = (Integer) session.getAttribute("otp"); |
|||
System.out.println("session_otp---:" + session_otp); |
|||
Integer entered_otp = Integer.parseInt(otp); |
|||
|
|||
if (session_otp != null && session_otp.equals(entered_otp)) { |
|||
System.out.println("Entered OTP Correct"); |
|||
session.setAttribute("verifiedotp", "success"); |
|||
|
|||
String mobileStr = String.valueOf(session.getAttribute("mobileNo")); |
|||
Long mobileNo = Long.parseLong(mobileStr); |
|||
userSession.setMobileno(mobileNo); |
|||
|
|||
response.put("status", "Success"); |
|||
response.put("mobileNo", mobileStr); |
|||
|
|||
if (bookingService.isUserRegistered(mobileStr)) { |
|||
Map<String, Object> userDetails = bookingService.getComplaintAndUserDetailsByMobile(mobileStr); |
|||
if (userDetails != null) { |
|||
response.put("userName", userDetails.get("user_name")); |
|||
response.put("mobileNo", userDetails.get("mobile")); |
|||
response.put("complaints", userDetails.get("complaints")); // Will be a List |
|||
} |
|||
} |
|||
|
|||
} else { |
|||
System.out.println("Incorrect OTP. Please enter correct OTP."); |
|||
session.setAttribute("verifiedotp", "error"); |
|||
response.put("status", "Error"); |
|||
} |
|||
} catch (NumberFormatException e) { |
|||
System.out.println("Invalid OTP format: " + otp); |
|||
response.put("status", "Error"); |
|||
} catch (Exception e) { |
|||
System.out.println("Error verifying OTP: " + e.getMessage()); |
|||
response.put("status", "Error"); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
/* |
|||
@GetMapping(value = "/verifyOTP") |
|||
public String verifyOtp(HttpServletRequest request, @RequestParam String otp) { |
|||
HttpSession session = request.getSession(); |
|||
|
|||
try { |
|||
Integer session_otp = (Integer) session.getAttribute("otp"); |
|||
System.out.println("session_otp---:" + session_otp); |
|||
Integer entered_otp = Integer.parseInt(otp); |
|||
|
|||
if (session_otp != null && session_otp.equals(entered_otp)) { |
|||
System.out.println("Entered OTP Correct"); |
|||
session.setAttribute("verifiedotp", "success"); |
|||
userSession.setMobileno(Long.parseLong(session.getAttribute("mobileNo").toString())); |
|||
return "Success"; |
|||
} else { |
|||
System.out.println("Incorrect OTP. Please enter correct OTPs."); |
|||
session.setAttribute("verifiedotp", "error"); |
|||
return "Error"; |
|||
} |
|||
} catch (NumberFormatException e) { |
|||
System.out.println("Invalid OTP format: " + otp); |
|||
return "Error"; |
|||
} catch (Exception e) { |
|||
System.out.println("Error verifying OTP: " + e.getMessage()); |
|||
return "Error"; |
|||
} |
|||
} |
|||
*/ |
|||
|
|||
// @PostMapping("/validatelogin") |
|||
// public ResponseEntity<?> checkLogin(@RequestParam String usernametxt, @RequestParam String passwordtxt, HttpSession session) { |
|||
|
|||
// try { |
|||
// String userName = bookingser.validateLogin(usernametxt, passwordtxt); |
|||
|
|||
// if (userName != null) { |
|||
// // Set user info in the session |
|||
// session.setAttribute("mobileno", usernametxt); |
|||
// session.setAttribute("user_name",userName ); |
|||
|
|||
// return ResponseEntity.ok(userName); |
|||
// } else { |
|||
// return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body("error"); |
|||
// } |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Internal server error occurred"); |
|||
// } |
|||
// } |
|||
|
|||
|
|||
// added by yogi |
|||
@PostMapping("/validatelogin") |
|||
public ResponseEntity<?> checkLogin( |
|||
@RequestParam String usernametxt, |
|||
@RequestParam String passwordtxt, |
|||
HttpSession session) { |
|||
|
|||
try { |
|||
Map<String, Object> userData = bookingser.validateLogin(usernametxt, passwordtxt); |
|||
|
|||
if (userData != null) { |
|||
|
|||
String userName = (String) userData.get("user_name"); |
|||
//Integer bid = (Integer) userData.get("bid"); |
|||
|
|||
// FIX: Convert BID safely |
|||
Integer bid = Integer.valueOf(userData.get("bid").toString()); |
|||
|
|||
// Store in session |
|||
// Store in session |
|||
session.setAttribute("user_name", userName); |
|||
session.setAttribute("bid", bid); |
|||
// Return clean JSON |
|||
Map<String, Object> response = new HashMap<>(); |
|||
response.put("status", "success"); |
|||
response.put("user_name", userName); |
|||
response.put("bid", bid); |
|||
|
|||
|
|||
System.out.println("Logged in user=" + userName + ", BID=" + bid); |
|||
|
|||
return ResponseEntity.ok(response); |
|||
} else { |
|||
return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body("error"); |
|||
} |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Internal server error occurred"); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
//ak |
|||
|
|||
@GetMapping("/bookinghistorydetails") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> getBookingHistoryByMobileNo(@RequestParam String mobileno) { |
|||
long mobileNo = Long.parseLong(mobileno); |
|||
return bookingService.getBookingDetailsByMobileNo(mobileNo); |
|||
} |
|||
|
|||
@GetMapping("/bookingDetails") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> getBookingDetailsByMobileNo(@RequestParam String mobileno) { |
|||
long mobileNo = Long.parseLong(mobileno); |
|||
return bookingService.getBookingByMobileNo(mobileNo); |
|||
} |
|||
|
|||
@GetMapping("/getAvailabilityBySlot") |
|||
public List<Map<String, Object>> getAvailabilityBySlot(@RequestParam int scid, @RequestParam String selectedDate) { |
|||
|
|||
return bookingService.getCalendarBasedOnSubCatId(scid, selectedDate); |
|||
// Replace with the actual view name |
|||
} |
|||
|
|||
/* @GetMapping("/getbookingdetailDashBoard") |
|||
public List<Map<String, Object>> getbookingdetailDashBoard(@RequestParam String fromDate, @RequestParam String toDate, @RequestParam String status) { |
|||
return bookingService.getbookingdetailDashBoard(fromDate,toDate, status); |
|||
}*/ |
|||
//ak |
|||
@GetMapping("/getbookingdetailDashBoard") |
|||
public List<Map<String, Object>> getbookingdetailDashBoard( |
|||
@RequestParam String fromDate, |
|||
@RequestParam String toDate, |
|||
@RequestParam String status, |
|||
@RequestParam int bid) { |
|||
System.out.println("fromdate: " + fromDate); |
|||
System.out.println("bid: " + bid); |
|||
System.out.println("status: " + status); |
|||
System.out.println("toDate: " + toDate); |
|||
|
|||
return bookingService.getbookingdetailDashBoard(fromDate, toDate, status, bid); |
|||
} |
|||
|
|||
|
|||
/* @GetMapping("/amountCollected") |
|||
public List<Map<String, Object>> getAmountCollected(@RequestParam("fromDate") String fromDate, |
|||
@RequestParam("toDate") String toDate) { |
|||
// Convert the string dates to LocalDate |
|||
LocalDate parsedFromDate = LocalDate.parse(fromDate); |
|||
LocalDate parsedToDate = LocalDate.parse(toDate); |
|||
return bookingService.getAmountCollectedByDate(parsedFromDate, parsedToDate); |
|||
}*/ |
|||
@GetMapping("/amountCollected") |
|||
public List<Map<String, Object>> getAmountCollected( |
|||
@RequestParam("fromDate") String fromDate, |
|||
@RequestParam("toDate") String toDate, |
|||
@RequestParam("bid") int bid) { |
|||
|
|||
LocalDate parsedFromDate = LocalDate.parse(fromDate); |
|||
LocalDate parsedToDate = LocalDate.parse(toDate); |
|||
|
|||
return bookingService.getAmountCollectedByDate(parsedFromDate, parsedToDate, bid); |
|||
} |
|||
|
|||
|
|||
/*@GetMapping("/bookingCountByCategory") |
|||
public List<Map<String, Object>> getBookingCountsByCategory(@RequestParam("fromDate") String fromDate, |
|||
@RequestParam("toDate") String toDate,) { |
|||
// Call the service method to get the booking counts for the specified date range |
|||
return bookingService.getBookingCountsByCategory(fromDate, toDate); |
|||
}*/ |
|||
//ak |
|||
@GetMapping("/bookingCountByCategory") |
|||
public List<Map<String, Object>> getBookingCountsByCategory( |
|||
@RequestParam("fromDate") String fromDate, |
|||
@RequestParam("toDate") String toDate, |
|||
@RequestParam("bid") int bid) { |
|||
|
|||
return bookingService.getBookingCountsByCategory(fromDate, toDate, bid); |
|||
} |
|||
|
|||
/* @GetMapping("/totalBookingCounts") |
|||
public List<Map<String, Object>> getBookingCounts(@RequestParam("fromDate") String fromDate,@RequestParam("toDate")String toDate) { |
|||
// Call service method to get booking counts |
|||
return bookingService.getBookingCountsByDate(fromDate,toDate); |
|||
}*/ |
|||
//ak |
|||
@GetMapping("/totalBookingCounts") |
|||
public List<Map<String, Object>> getBookingCounts( |
|||
@RequestParam("fromDate") String fromDate, |
|||
@RequestParam("toDate") String toDate, |
|||
@RequestParam("bid") int bid) { |
|||
|
|||
return bookingService.getBookingCountsByDate(fromDate, toDate, bid); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/bookinghistory") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> getBookingHistory() { |
|||
if (userSession != null && userSession.getMobileno() != 0) { |
|||
return bookingService.getBookingByMobileNo(userSession.getMobileno()); |
|||
} |
|||
return Collections.emptyList(); |
|||
} |
|||
|
|||
@GetMapping("/getComplaintsByMobile") |
|||
public ResponseEntity<?> getComplaintAndUserDetailsByMobile(@RequestParam("mobileNo") String mobileNo) { |
|||
Map<String, Object> result = bookingService.getComplaintAndUserDetailsByMobile(mobileNo); |
|||
|
|||
if (result == null || result.isEmpty()) { |
|||
return ResponseEntity |
|||
.status(HttpStatus.NOT_FOUND) |
|||
.body("No user or complaints found for mobile number: " + mobileNo); |
|||
} |
|||
|
|||
return ResponseEntity.ok(result); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
package com.gcc.coworkspace.controller; |
|||
|
|||
import com.gcc.coworkspace.service.CalendarService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import com.gcc.coworkspace.service.BuildingService; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@RequestMapping("/muthalvarpadaippagam/api") |
|||
public class BuildingController { |
|||
|
|||
@Autowired |
|||
private CalendarService calendarService; |
|||
private final BuildingService buildingService; |
|||
|
|||
public BuildingController(BuildingService buildingService) { |
|||
this.buildingService = buildingService; |
|||
} |
|||
|
|||
@GetMapping("/details") |
|||
public List<Map<String, Object>> getBuildingDetails() { |
|||
List<Map<String, Object>> buildingDetails = buildingService.getBuildingDetails(); |
|||
|
|||
//System.out.println(buildingDetails); // Debugging line to print the fetched details |
|||
return buildingService.getBuildingDetails(); |
|||
|
|||
} |
|||
|
|||
// @GetMapping("/category") |
|||
// public List<Map<String, Object>> getBuildingCategoryDetails(@RequestParam int bcId) { |
|||
// return buildingService.getBuildingCategoryDetailsById(bcId); |
|||
// } |
|||
@GetMapping("/detailsbyid") |
|||
public List<Map<String, Object>> getBuildingDetailsbyId(@RequestParam String bid) { |
|||
List<Map<String, Object>> buildingDetails = buildingService.getBuildingDetailsbyId(bid); |
|||
|
|||
//System.out.println(buildingDetails); // Debugging line to print the fetched details |
|||
return buildingService.getBuildingDetailsbyId(bid); |
|||
|
|||
} |
|||
|
|||
@GetMapping("/getamenities") |
|||
public List<Map<String, Object>> getamenities() { |
|||
return buildingService.getamenities(); |
|||
// Replace with the actual view name |
|||
} |
|||
@GetMapping("/subcategory-display-names") |
|||
public List<Map<String, Object>> showSubcategoryDisplayNames() { |
|||
return buildingService.getSubcategoryDisplayNames(); |
|||
// Replace with the actual view name |
|||
} |
|||
|
|||
// @GetMapping("/buildings/category-details") |
|||
// public List<Map<String, Object>> getBuildingCategoryDetails(@RequestParam int categoryId) { |
|||
// return buildingService.getBuildingCategoryDetailsById(categoryId); |
|||
// } |
|||
|
|||
@GetMapping("/getSlotBySid") |
|||
public List<Map<String, Object>> showSlotBySubCatId(@RequestParam int scid) { |
|||
return calendarService.getCalendarBasedOnSubCatId(scid); |
|||
// Replace with the actual view name |
|||
} |
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
package com.gcc.coworkspace.controller; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
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.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import com.gcc.coworkspace.service.CheckListService; |
|||
|
|||
@RestController |
|||
@RequestMapping("/muthalvarpadaippagam/book/api/checklist") |
|||
public class CheckListController { |
|||
|
|||
@Autowired |
|||
private CheckListService checkListService; |
|||
|
|||
|
|||
@GetMapping("/questions-options/{shiftId}") |
|||
public List<Map<String, Object>> getQuestionsWithOptions(@PathVariable("shiftId") int shiftId) { |
|||
System.out.println("shifyid44444+" +shiftId); |
|||
return checkListService.getQuestionsWithOptions(shiftId); |
|||
} |
|||
|
|||
|
|||
|
|||
@PostMapping("/submit-feedback") |
|||
public void submitFeedback(@RequestBody Map<String, Object> payload) { |
|||
System.out.println("payload>>>>>>>>" + payload); |
|||
|
|||
// Extract "answers" and shiftId |
|||
Map<String, String> answers = (Map<String, String>) payload.get("answers"); |
|||
Integer shiftId = (Integer) payload.get("shiftId"); |
|||
//ak |
|||
String date = (String) payload.get("date"); |
|||
|
|||
// Save feedback including shiftId |
|||
checkListService.saveFeedback(answers, shiftId,date); |
|||
} |
|||
|
|||
|
|||
// report api |
|||
|
|||
@GetMapping("/report") |
|||
|
|||
public List<Map<String, Object>> getFeedbackSummary( |
|||
@RequestParam("from") String fromDate, |
|||
@RequestParam("to") String toDate) { |
|||
|
|||
return checkListService.getFeedbackSummary(fromDate, toDate); |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/reportfeedback/{shiftId}&{date}") |
|||
public List<Map<String, Object>> getReportFeedback( |
|||
@PathVariable("shiftId") int shiftId, |
|||
@PathVariable("date") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) { |
|||
return checkListService.getFeedbackQuestions(shiftId, date); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,154 @@ |
|||
package com.gcc.coworkspace.controller; |
|||
|
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.dao.EmptyResultDataAccessException; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
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.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import com.gcc.coworkspace.service.ComplaintService; |
|||
|
|||
|
|||
@RestController |
|||
@RequestMapping("/muthalvarpadaippagam/complaint/api") |
|||
public class ComplaintController { |
|||
|
|||
|
|||
|
|||
@Autowired |
|||
private ComplaintService complaintService; |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
|
|||
@PostMapping("/addnewcomplaint") |
|||
public ResponseEntity<String> addComplaint( |
|||
@RequestParam String userName, |
|||
@RequestParam String remarks, |
|||
@RequestParam String mobileNumber, |
|||
@RequestParam(required = false) MultipartFile uploadPhotoUrl |
|||
) { |
|||
try { |
|||
int rows = complaintService.complaintDetails(userName, remarks, mobileNumber, uploadPhotoUrl); |
|||
if (rows > 0) { |
|||
return ResponseEntity.ok("Complaint inserted successfully"); |
|||
} else { |
|||
return ResponseEntity.status(500).body("Failed to insert complaint"); |
|||
} |
|||
} catch (Exception e) { |
|||
return ResponseEntity.badRequest().body("Error: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
//reply to caretaker from user |
|||
@PostMapping("/addreplyagaintcomplaint") |
|||
public ResponseEntity<String> addReply( |
|||
@RequestParam("complaintNo") String complaintNo, |
|||
@RequestParam("userName") String userName, |
|||
@RequestParam("remarks") String remarks, |
|||
@RequestParam("mobileNumber") String mobileNumber, |
|||
@RequestParam(value = "uploadPhotoUrl", required = false) MultipartFile uploadPhotoFile) { |
|||
|
|||
try { |
|||
int result = complaintService.updateComplaintWithReply(complaintNo, userName, remarks, mobileNumber, uploadPhotoFile); |
|||
return result > 0 |
|||
? ResponseEntity.ok("Reply updated successfully") |
|||
: ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to update reply"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@PostMapping("/updateCaretakerRemarks") |
|||
public ResponseEntity<String> updateCaretakerRemarks( |
|||
@RequestParam("id") String complaint_no, |
|||
@RequestParam("caretakerRemarks") String caretakerRemarks, |
|||
@RequestParam(required = false) MultipartFile uploadPhotoUrlcaretaker) { |
|||
|
|||
try { |
|||
|
|||
complaintService.updateCaretakerDetails(complaint_no, caretakerRemarks, uploadPhotoUrlcaretaker); |
|||
return ResponseEntity.ok("Updated"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to update"); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@GetMapping("/getComplaintlist") |
|||
public ResponseEntity<?> getComplaintlist() { |
|||
String sql = "SELECT user_name,remarks,mobile_number,upload_photo_url,cdate FROM complaint_details"; |
|||
try { |
|||
List<Map<String, Object>> complaint = jdbcTemplate.queryForList(sql); |
|||
return ResponseEntity.ok(complaint); |
|||
} catch (EmptyResultDataAccessException e) { |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("No complaint found"); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
//AK |
|||
|
|||
@PostMapping("/closeComplaint") |
|||
public ResponseEntity<String> closeComplaint(@RequestBody String complaintNo) { |
|||
try { |
|||
complaintService.closeComplaint(complaintNo); // Forward to service |
|||
return ResponseEntity.ok("Complaint closed successfully."); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Failed to close complaint."); |
|||
} |
|||
} |
|||
//ak |
|||
@GetMapping("/getComplaintUserDetails") |
|||
public ResponseEntity<Map<String, Object>> getComplaintUserDetails(@RequestParam("complaintNo") String complaintNo) { |
|||
try { |
|||
Map<String, Object> userDetails = complaintService.getUserDetailsByComplaintNo(complaintNo); |
|||
if (userDetails == null || userDetails.isEmpty()) { |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(Collections.singletonMap("error", "Complaint not found")); |
|||
} |
|||
return ResponseEntity.ok(userDetails); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Collections.singletonMap("error", "Internal server error")); |
|||
} |
|||
} |
|||
@GetMapping("/complaintHistory") |
|||
public ResponseEntity<List<Map<String, Object>>> getComplaintHistory(@RequestParam("complaintNo") String complaintNo){ |
|||
|
|||
try { |
|||
List<Map<String, Object>> historyList = complaintService.getComplaintHistory(complaintNo); |
|||
return ResponseEntity.ok(historyList); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(Collections.emptyList()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package com.gcc.coworkspace.controller; |
|||
|
|||
import org.springframework.stereotype.Service; |
|||
|
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
|
|||
@Service |
|||
public class DateTimeUtil { |
|||
public static String getCurrentDateTime() { |
|||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("ddMMyyyyHHmmss"); |
|||
LocalDateTime now = LocalDateTime.now(); |
|||
return now.format(formatter); |
|||
} |
|||
public static String getCurrentYear() { |
|||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy"); |
|||
LocalDateTime now = LocalDateTime.now(); |
|||
return now.format(formatter); |
|||
} |
|||
public static String getCurrentMonth() { |
|||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM"); |
|||
LocalDateTime now = LocalDateTime.now(); |
|||
return now.format(formatter); |
|||
} |
|||
public static String getCurrentDay() { |
|||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd"); |
|||
LocalDateTime now = LocalDateTime.now(); |
|||
return now.format(formatter); |
|||
} |
|||
public static String getCurrentDateTimeMysql() { |
|||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|||
LocalDateTime now = LocalDateTime.now(); |
|||
return now.format(formatter); |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
package com.gcc.coworkspace.controller; |
|||
|
|||
|
|||
import com.gcc.coworkspace.service.GoogleReviewService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@RequestMapping("/muthalvarpadaippagam/book/api") |
|||
@CrossOrigin(origins = "*") // Remove or restrict in production |
|||
public class GoogleReviewController { |
|||
|
|||
@Autowired |
|||
private GoogleReviewService googleReviewService; |
|||
|
|||
@GetMapping("/reviews") |
|||
public Map<String, Object> getReviews() { |
|||
return googleReviewService.getGoogleReviews(); |
|||
} |
|||
|
|||
@GetMapping("/marquee") |
|||
public Map<String, Object> getMarquee() { |
|||
return googleReviewService.getmarquee(); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,373 @@ |
|||
package com.gcc.coworkspace.controller; |
|||
|
|||
import com.gcc.coworkspace.configuration.RefundScheduler; |
|||
import com.gcc.coworkspace.constants.AppConstants; |
|||
import com.gcc.coworkspace.service.BookingService; |
|||
import com.gcc.coworkspace.service.RefundService; |
|||
import com.razorpay.RazorpayClient; |
|||
import com.razorpay.RazorpayException; |
|||
import com.razorpay.Refund; |
|||
import org.json.JSONObject; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.dao.EmptyResultDataAccessException; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.time.Instant; |
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.time.ZoneId; |
|||
import java.util.*; |
|||
|
|||
@RestController |
|||
@RequestMapping("/muthalvarpadaippagam/book/api") |
|||
public class RefundController { |
|||
|
|||
@Autowired |
|||
private RefundService refundService; |
|||
@Autowired |
|||
private RefundScheduler refundScheduler; |
|||
|
|||
@Autowired |
|||
BookingService bookingService; |
|||
|
|||
@Autowired |
|||
JdbcTemplate jdbcTemplate; |
|||
|
|||
@GetMapping("/checkpaymentstatus") |
|||
public List<Map<String, Object>> checkPaymentStatus(@RequestParam("mobileno") long mobileno) { |
|||
return refundService.checkPaymentStatusByMobile(mobileno); |
|||
} |
|||
|
|||
@GetMapping("/getPaymentDetailsByTempId") |
|||
public List<Map<String, Object>> getPaymentDetails(@RequestParam("tempid") String tempid) { |
|||
String sql = "SELECT id, mobno, order_id, payment_id, payment_status, DATE(paymentdate) AS paymentdate , booking_id, amount, tempid FROM payment WHERE tempid = ?"; |
|||
return jdbcTemplate.queryForList(sql, tempid); |
|||
} |
|||
|
|||
// @PostMapping("/triggerPaymentStatus") |
|||
// public ResponseEntity<String> triggerPaymentStatusCheck(@RequestParam("tempid") String tempid) { |
|||
// try { |
|||
// // Step 1: Get order_id from order_log |
|||
// String sql = "SELECT order_id FROM order_log WHERE temp_booking_id = ? AND (order_status IS NULL OR order_status = '')"; |
|||
// List<Map<String, Object>> results = refundScheduler.jdbcTemplate.queryForList(sql, tempid); |
|||
// |
|||
// if (results.isEmpty()) { |
|||
// return ResponseEntity.ok("No pending order found for this tempid."); |
|||
// } |
|||
// |
|||
// List<String> orderIds = new ArrayList<>(); |
|||
// for (Map<String, Object> row : results) { |
|||
// orderIds.add((String) row.get("order_id")); |
|||
// } |
|||
// |
|||
// // Step 2: Call existing logic to fetch and update |
|||
// refundScheduler.fetchAndUpdatePaymentStatus(orderIds); |
|||
// |
|||
// return ResponseEntity.ok("Payment status updated successfully for " + orderIds.size() + " order(s)."); |
|||
// |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// return ResponseEntity.status(500).body("Error: " + e.getMessage()); |
|||
// } |
|||
// } |
|||
|
|||
@PostMapping("/triggerPaymentStatus") |
|||
public ResponseEntity<Map<String, Object>> triggerPaymentStatusCheck(@RequestParam("tempid") String tempid) { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
try { |
|||
// Step 1: Get order_id from order_log |
|||
String sql = "SELECT order_id FROM order_log WHERE temp_booking_id = ? AND (order_status IS NULL OR order_status = '')"; |
|||
List<Map<String, Object>> results = refundScheduler.jdbcTemplate.queryForList(sql, tempid); |
|||
|
|||
if (!results.isEmpty()) { |
|||
List<String> orderIds = new ArrayList<>(); |
|||
for (Map<String, Object> row : results) { |
|||
orderIds.add((String) row.get("order_id")); |
|||
} |
|||
|
|||
// Step 2: Call payment status update |
|||
refundScheduler.fetchAndUpdatePaymentStatus(orderIds); |
|||
|
|||
response.put("message", "Payment status updated successfully"); |
|||
response.put("ordersUpdated", orderIds.size()); |
|||
} else { |
|||
response.put("message", "No pending order found for this tempid."); |
|||
response.put("ordersUpdated", 0); |
|||
} |
|||
|
|||
// Step 3: Slot availability check |
|||
Map<String, Object> temp = bookingService.getTempBookingByTempId(Integer.parseInt(tempid)); |
|||
|
|||
int bid = Integer.parseInt(temp.get("bid").toString()); |
|||
int cid = Integer.parseInt(temp.get("cid").toString()); |
|||
int sid = Integer.parseInt(temp.get("sid").toString()); |
|||
int noOfPerson = Integer.parseInt(temp.get("no_of_person").toString()); |
|||
String[] slotIds = temp.get("slotids").toString().split(","); |
|||
LocalDate from = LocalDate.parse(temp.get("from_date").toString()); |
|||
LocalDate to = LocalDate.parse(temp.get("to_date").toString()); |
|||
|
|||
boolean isSlotAvailable = true; |
|||
List<LocalDate> dates = BookingService.getDatesBetween(from, to); |
|||
|
|||
for (String slotStr : slotIds) { |
|||
int slot = Integer.parseInt(slotStr); |
|||
for (LocalDate date : dates) { |
|||
if (bookingService.checkAvailabilityByBdate(bid, cid, date, sid, noOfPerson, slot)) { |
|||
isSlotAvailable = false; |
|||
break; |
|||
} |
|||
} |
|||
if (!isSlotAvailable) break; |
|||
} |
|||
|
|||
response.put("available", isSlotAvailable); |
|||
return ResponseEntity.ok(response); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
response.put("error", "Internal server error: " + e.getMessage()); |
|||
return ResponseEntity.status(500).body(response); |
|||
} |
|||
} |
|||
|
|||
// @PostMapping("/initiateRefund") |
|||
// public ResponseEntity<?> initiateRefund( |
|||
// @RequestParam("orderId") String orderId, |
|||
// @RequestParam("bookingId") int bookingId, |
|||
// @RequestParam(value = "reason", defaultValue = "Manual refund") String reason |
|||
// ) { |
|||
// try { |
|||
// // Step 1: Get payment ID and amount using orderId |
|||
// String sql = "SELECT id, payment_id, amount FROM payment WHERE order_id = ?"; |
|||
// Map<String, Object> result = jdbcTemplate.queryForMap(sql, orderId); |
|||
// |
|||
// int pid = (int) result.get("id"); |
|||
// String paymentId = (String) result.get("payment_id"); |
|||
// double amount = Double.parseDouble(result.get("amount").toString()); |
|||
// |
|||
// // Step 2: Initiate refund via Razorpay |
|||
// RazorpayClient razorpayClient = new RazorpayClient(AppConstants.key_id, AppConstants.key_secret); |
|||
// JSONObject refundRequest = new JSONObject(); |
|||
// refundRequest.put("amount", (int)(amount * 100)); // Razorpay expects paise |
|||
// |
|||
// Refund refund = razorpayClient.payments.refund(paymentId, refundRequest); |
|||
// |
|||
// // Step 3: Extract refund response |
|||
// String refundId = refund.get("id"); |
|||
// String refundStatus = refund.get("status"); |
|||
// double refundAmount = Double.parseDouble(refund.get("amount").toString()) / 100.0; |
|||
// |
|||
// long createdAtEpoch; |
|||
// Object createdAtObj = refund.get("created_at"); |
|||
// |
|||
// if (createdAtObj instanceof Number) { |
|||
// createdAtEpoch = ((Number) createdAtObj).longValue(); |
|||
// } else if (createdAtObj instanceof Date) { |
|||
// createdAtEpoch = ((Date) createdAtObj).toInstant().getEpochSecond(); |
|||
// } else { |
|||
// throw new IllegalArgumentException("Unexpected type for created_at: " + createdAtObj.getClass()); |
|||
// } |
|||
// |
|||
// LocalDateTime createdAt = Instant.ofEpochSecond(createdAtEpoch) |
|||
// .atZone(ZoneId.of("Asia/Kolkata")) |
|||
// .toLocalDateTime(); |
|||
// |
|||
// // Step 4: Save to refund_info table |
|||
// bookingService.saveRefund(bookingId, pid, refundAmount, refundId, refundStatus, reason); |
|||
// |
|||
// // Step 5: Print to console |
|||
// System.out.println("✅ Refund initiated successfully:"); |
|||
// System.out.println("Refund ID : " + refundId); |
|||
// System.out.println("Payment ID : " + paymentId); |
|||
// System.out.println("Refund Amount : ₹" + refundAmount); |
|||
// System.out.println("Refund Status : " + refundStatus); |
|||
// System.out.println("Refunded At : " + createdAt); |
|||
// |
|||
// // Step 6: Return JSON response |
|||
// Map<String, Object> responseMap = new HashMap<>(); |
|||
// responseMap.put("refund_id", refundId); |
|||
// responseMap.put("status", refundStatus); |
|||
// responseMap.put("amount", refundAmount); |
|||
// responseMap.put("created_at", createdAt); |
|||
// |
|||
// return ResponseEntity.ok(responseMap); |
|||
// |
|||
// } catch (RazorpayException e) { |
|||
// e.printStackTrace(); |
|||
// return ResponseEntity.status(500).body("Razorpay Error: " + e.getMessage()); |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// return ResponseEntity.status(500).body("Error: " + e.getMessage()); |
|||
// } |
|||
// } |
|||
@PostMapping("/initiateRefund") |
|||
public ResponseEntity<?> initiateRefund( |
|||
@RequestParam("orderId") String orderId, |
|||
@RequestParam("bookingId") int bookingId, |
|||
@RequestParam(value = "reason", defaultValue = "Manual refund") String reason |
|||
) { |
|||
try { |
|||
// Step 1: Get payment ID and amount using orderId |
|||
String sql = "SELECT id, payment_id, amount FROM payment WHERE order_id = ?"; |
|||
Map<String, Object> result = jdbcTemplate.queryForMap(sql, orderId); |
|||
|
|||
int pid = (int) result.get("id"); |
|||
String paymentId = (String) result.get("payment_id"); |
|||
double amount = Double.parseDouble(result.get("amount").toString()); |
|||
|
|||
// Step 2: Initiate refund via Razorpay |
|||
RazorpayClient razorpayClient = new RazorpayClient(AppConstants.key_id, AppConstants.key_secret); |
|||
JSONObject refundRequest = new JSONObject(); |
|||
refundRequest.put("amount", (int)(amount * 100)); // Razorpay expects paise |
|||
|
|||
Refund refund = razorpayClient.payments.refund(paymentId, refundRequest); |
|||
|
|||
// Step 3: Extract refund response details |
|||
String refundId = refund.get("id"); |
|||
String refundStatus = refund.get("status"); |
|||
double refundAmount = Double.parseDouble(refund.get("amount").toString()) / 100.0; |
|||
|
|||
Object createdAtObj = refund.get("created_at"); |
|||
long createdAtEpoch; |
|||
if (createdAtObj instanceof Number) { |
|||
createdAtEpoch = ((Number) createdAtObj).longValue(); |
|||
} else if (createdAtObj instanceof Date) { |
|||
createdAtEpoch = ((Date) createdAtObj).toInstant().getEpochSecond(); |
|||
} else { |
|||
throw new IllegalArgumentException("Unexpected type for created_at: " + createdAtObj.getClass()); |
|||
} |
|||
|
|||
LocalDateTime createdAt = Instant.ofEpochSecond(createdAtEpoch) |
|||
.atZone(ZoneId.of("Asia/Kolkata")) |
|||
.toLocalDateTime(); |
|||
|
|||
// Step 4: Save refund record |
|||
refundService.saveRefund(bookingId, pid, refundAmount, refundId, refundStatus, reason); |
|||
|
|||
// Step 5: Update status in payment and order_log tables |
|||
//jdbcTemplate.update("UPDATE order_log SET order_status = ? WHERE order_id = ?", "" orderId); |
|||
jdbcTemplate.update("UPDATE payment SET payment_status = ? WHERE order_id = ?", "refunded", orderId); |
|||
|
|||
// Step 6: Print refund info to console |
|||
System.out.println("✅ Refund initiated successfully:"); |
|||
System.out.println("Refund ID : " + refundId); |
|||
System.out.println("Payment ID : " + paymentId); |
|||
System.out.println("Refund Amount : ₹" + refundAmount); |
|||
System.out.println("Refund Status : " + refundStatus); |
|||
System.out.println("Refunded At : " + createdAt); |
|||
System.out.println("📝 payment tables updated to 'refund'."); |
|||
|
|||
// Step 7: Return response |
|||
Map<String, Object> responseMap = new HashMap<>(); |
|||
responseMap.put("refund_id", refundId); |
|||
responseMap.put("status", refundStatus); |
|||
responseMap.put("amount", refundAmount); |
|||
responseMap.put("created_at", createdAt.toString()); |
|||
|
|||
return ResponseEntity.ok(responseMap); |
|||
|
|||
} catch (RazorpayException e) { |
|||
e.printStackTrace(); |
|||
String errorMsg = e.getMessage(); |
|||
System.err.println("Razorpay Error: " + errorMsg); |
|||
|
|||
if (errorMsg.contains("already")) { |
|||
return ResponseEntity.status(400).body("Refund already completed for this payment."); |
|||
} |
|||
return ResponseEntity.status(500).body("Razorpay Error: " + e.getMessage()); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(500).body("Error: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@PostMapping("/confirmBooking") |
|||
public ResponseEntity<?> confirmBooking(@RequestParam int tempid, @RequestParam int pid) { |
|||
try { |
|||
// Check temp data |
|||
Map<String, Object> temp = bookingService.getTempBookingByTempId(tempid); |
|||
if (temp.isEmpty()) { |
|||
return ResponseEntity.badRequest().body("Invalid Temp Booking ID"); |
|||
} |
|||
|
|||
// Extract required fields |
|||
int bid = Integer.parseInt(temp.get("bid").toString()); |
|||
int cid = Integer.parseInt(temp.get("cid").toString()); |
|||
int sid = Integer.parseInt(temp.get("sid").toString()); |
|||
int noOfPerson = Integer.parseInt(temp.get("no_of_person").toString()); |
|||
String[] slotIds = temp.get("slotids").toString().split(","); |
|||
LocalDate from = LocalDate.parse(temp.get("from_date").toString()); |
|||
LocalDate to = LocalDate.parse(temp.get("to_date").toString()); |
|||
|
|||
// Check availability for all slots in date range |
|||
List<LocalDate> dates = BookingService.getDatesBetween(from, to); |
|||
for (String slot : slotIds) { |
|||
int slotId = Integer.parseInt(slot); |
|||
for (LocalDate date : dates) { |
|||
if (bookingService.checkAvailabilityByBdate(bid, cid, date, sid, noOfPerson, slotId)) { |
|||
return ResponseEntity.ok("Slot not available for " + date + " Slot " + slotId); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// If available, insert booking |
|||
int bookingId = bookingService.saveBooking(tempid, pid); |
|||
return ResponseEntity.ok("Booking Confirmed! ID: " + bookingId); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(500).body("Failed to confirm booking"); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/getBookingIdByOrderId") |
|||
public ResponseEntity<Integer> getBookingId(@RequestParam String orderId) { |
|||
String sql = "select booking_id from payment where order_id=?"; |
|||
try { |
|||
Integer bookingId = jdbcTemplate.queryForObject(sql, Integer.class, orderId); |
|||
return ResponseEntity.ok(bookingId); |
|||
} catch (EmptyResultDataAccessException e) { |
|||
return ResponseEntity.ok(0); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getOrderIdByPaymentId") |
|||
public ResponseEntity<String> getOrderIdByPaymentId(@RequestParam("paymentId") int paymentId) { |
|||
try { |
|||
String sql = "SELECT order_id FROM payment WHERE id = ?"; |
|||
String orderId = jdbcTemplate.queryForObject(sql, String.class, paymentId); |
|||
return ResponseEntity.ok(orderId); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(404).body("Order ID not found for payment ID: " + paymentId); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getRefundOrderDetails") |
|||
public ResponseEntity<Map<String, Object>> getRefundOrderDetails(@RequestParam("paymentId") int paymentId) { |
|||
try { |
|||
String sql = "SELECT order_id, tempid FROM payment WHERE id = ?"; |
|||
Map<String, Object> result = jdbcTemplate.queryForMap(sql, paymentId); |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
response.put("orderId", result.get("order_id")); |
|||
response.put("tempid", result.get("tempid")); |
|||
return ResponseEntity.ok(response); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(404).body(Collections.singletonMap("error", "Refund data not found")); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@ -0,0 +1,169 @@ |
|||
package com.gcc.coworkspace.controller; |
|||
|
|||
import com.gcc.coworkspace.service.ReportService; |
|||
import jakarta.servlet.http.HttpSession; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
@RestController |
|||
@RequestMapping("/muthalvarpadaippagam/book/api/reports") |
|||
public class ReportController { |
|||
@Autowired |
|||
private ReportService reportService; |
|||
|
|||
// @GetMapping("/getslotdateReports") |
|||
// public List<Map<String, Object>> getslotdateReports( |
|||
// @RequestParam(required = false) String fromDate, |
|||
// @RequestParam(required = false) String toDate, |
|||
// @RequestParam(required = false) String type, |
|||
// @RequestParam(required = false) String status, |
|||
// @RequestParam(required = false) String type1, |
|||
// @RequestParam(required = false) String filterBy) { // Add filterBy parameter |
|||
// System.out.println(); |
|||
// // If no fromDate and toDate are provided, set a default date range |
|||
// if (fromDate == null && toDate == null) { |
|||
// fromDate = LocalDate.now().toString(); |
|||
// toDate = LocalDate.now().plusDays(30).toString(); |
|||
// } |
|||
// List<Map<String, Object>> ad= reportService.getslotdateReports(fromDate, toDate, type, status, filterBy,type1); |
|||
// System.out.println(ad.size()); |
|||
// return reportService.getslotdateReports(fromDate, toDate, type, status, filterBy ,type1); |
|||
// } |
|||
|
|||
// @GetMapping("/getbookingdateReports") |
|||
// public List<Map<String, Object>> getbookingdateReports( |
|||
// @RequestParam(required = false) String fromDate, |
|||
// @RequestParam(required = false) String toDate, |
|||
// @RequestParam(required = false) String type, |
|||
// @RequestParam(required = false) String status, |
|||
// @RequestParam(required = false) String type1, |
|||
// @RequestParam(required = false) String filterBy) { // Add filterBy parameter |
|||
// System.out.println(); |
|||
// // If no fromDate and toDate are provided, set a default date range |
|||
// if (fromDate == null && toDate == null) { |
|||
// fromDate = LocalDate.now().toString(); |
|||
// toDate = LocalDate.now().plusDays(30).toString(); |
|||
// } |
|||
// List<Map<String, Object>> ad= reportService.getbookingdateReports(fromDate, toDate, type, status, filterBy,type1); |
|||
// System.out.println(ad.size()); |
|||
// return reportService.getbookingdateReports(fromDate, toDate, type, status, filterBy,type1); |
|||
// } |
|||
// /* |
|||
// @GetMapping("/abstractReport") |
|||
// public List<Map<String, Object>> abstractReportPage(){ |
|||
// return reportService.abstractReportPage(); |
|||
// } |
|||
// */ |
|||
// @GetMapping("/abstractReport") |
|||
// public List<Map<String, Object>> abstractReportPage( |
|||
// @RequestParam(required = false) String fromDate, |
|||
// @RequestParam(required = false) String toDate, |
|||
// @RequestParam(required = false) String type, |
|||
// @RequestParam(required = false) String type1 |
|||
// ){ |
|||
// return reportService.abstractReportPage(fromDate, toDate, type,type1); |
|||
|
|||
// } |
|||
|
|||
// @GetMapping("/calendarReport") |
|||
// public List<Map<String, Object>> getCalendarReport( |
|||
// @RequestParam(required = false) String fromDate, |
|||
// @RequestParam(required = false) String toDate |
|||
// ) { |
|||
// if (fromDate == null || fromDate.isEmpty()) { |
|||
// fromDate = java.time.LocalDate.now().toString(); |
|||
// } |
|||
// if (toDate == null || toDate.isEmpty()) { |
|||
// toDate = fromDate; |
|||
// } |
|||
// return reportService.getCalendarReport(fromDate, toDate); |
|||
// } |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@GetMapping("/getslotdateReports") |
|||
public List<Map<String, Object>> getslotdateReports( |
|||
@RequestParam(required = false) String fromDate, |
|||
@RequestParam(required = false) String toDate, |
|||
@RequestParam(required = false) String type, |
|||
@RequestParam(required = false) String status, |
|||
@RequestParam(required = false) String type1, |
|||
@RequestParam(required = false) String filterBy, |
|||
@RequestParam(required = false) Integer bid) { // Add filterBy parameter |
|||
System.out.println(); |
|||
// If no fromDate and toDate are provided, set a default date range |
|||
if (fromDate == null && toDate == null) { |
|||
fromDate = LocalDate.now().toString(); |
|||
toDate = LocalDate.now().plusDays(30).toString(); |
|||
} |
|||
List<Map<String, Object>> ad= reportService.getslotdateReports(fromDate, toDate, type, status, filterBy,type1,bid); |
|||
System.out.println(ad.size()); |
|||
return reportService.getslotdateReports(fromDate, toDate, type, status, filterBy ,type1,bid); |
|||
} |
|||
|
|||
@GetMapping("/getbookingdateReports") |
|||
public List<Map<String, Object>> getbookingdateReports( |
|||
@RequestParam(required = false) String fromDate, |
|||
@RequestParam(required = false) String toDate, |
|||
@RequestParam(required = false) String type, |
|||
@RequestParam(required = false) String status, |
|||
@RequestParam(required = false) String type1, |
|||
@RequestParam(required = false) String filterBy, |
|||
@RequestParam(required = false) Integer bid) { // Add filterBy parameter |
|||
System.out.println(); |
|||
// If no fromDate and toDate are provided, set a default date range |
|||
if (fromDate == null && toDate == null) { |
|||
fromDate = LocalDate.now().toString(); |
|||
toDate = LocalDate.now().plusDays(30).toString(); |
|||
} |
|||
List<Map<String, Object>> ad= reportService.getbookingdateReports(fromDate, toDate, type, status, filterBy,type1,bid); |
|||
System.out.println(ad.size()); |
|||
return reportService.getbookingdateReports(fromDate, toDate, type, status, filterBy,type1,bid); |
|||
} |
|||
/* |
|||
@GetMapping("/abstractReport") |
|||
public List<Map<String, Object>> abstractReportPage(){ |
|||
return reportService.abstractReportPage(); |
|||
} |
|||
*/ |
|||
@GetMapping("/abstractReport") |
|||
public List<Map<String, Object>> abstractReportPage( |
|||
@RequestParam(required = false) String fromDate, |
|||
@RequestParam(required = false) String toDate, |
|||
@RequestParam(required = false) String type, |
|||
@RequestParam(required = false) String type1, |
|||
@RequestParam(required = false) Integer bid |
|||
){ |
|||
return reportService.abstractReportPage(fromDate, toDate, type,type1,bid); |
|||
|
|||
} |
|||
|
|||
@GetMapping("/calendarReport") |
|||
public List<Map<String, Object>> getCalendarReport( |
|||
@RequestParam(required = false) String fromDate, |
|||
@RequestParam(required = false) String toDate, |
|||
@RequestParam(required = false) int bid |
|||
) { |
|||
if (fromDate == null || fromDate.isEmpty()) { |
|||
fromDate = java.time.LocalDate.now().toString(); |
|||
} |
|||
if (toDate == null || toDate.isEmpty()) { |
|||
toDate = fromDate; |
|||
} |
|||
return reportService.getCalendarReport(fromDate, toDate, bid); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,784 @@ |
|||
package com.gcc.coworkspace.controller; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.core.env.Environment; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
|
|||
import com.gcc.coworkspace.component.UserSession; |
|||
import com.gcc.coworkspace.service.BookingService; |
|||
import com.gcc.coworkspace.service.BuildingService; |
|||
import com.gcc.coworkspace.service.ComplaintService; |
|||
import com.gcc.coworkspace.service.HomeService; |
|||
|
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import jakarta.servlet.http.HttpSession; |
|||
|
|||
@Controller |
|||
@RequestMapping(value = {"/","","/muthalvarpadaippagam"}) |
|||
public class controller { |
|||
|
|||
@Autowired |
|||
private BuildingService buildingSer; |
|||
|
|||
@Autowired |
|||
private BookingService bookingService; |
|||
|
|||
@Autowired |
|||
HomeService homeService; |
|||
|
|||
@Autowired |
|||
private ComplaintService complaintService; |
|||
|
|||
@Autowired |
|||
private UserSession userSession; |
|||
|
|||
@Autowired |
|||
private Environment environment; |
|||
|
|||
@Value("${app.full_URL}") |
|||
private String baseUrl; |
|||
|
|||
private void setNoCacheHeaders(HttpServletResponse response) { |
|||
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0"); |
|||
response.setHeader("Pragma", "no-cache"); |
|||
response.setDateHeader("Expires", 0); |
|||
} |
|||
|
|||
/* |
|||
@GetMapping(value = {"/","","/home"}) |
|||
public String viewHome(Model model) { |
|||
List<Map<String, Object>> spaces = homeService.getActiveCoWorkingSpaces(); |
|||
|
|||
List<Map<String, Object>> readingZoneDetails = homeService.getPricingDetailsByCid(1); |
|||
List<Map<String, Object>> deskSpaceDetails = homeService.getPricingDetailsByCid(2); |
|||
List<Map<String, Object>> conferenceHallDetails = homeService.getPricingDetailsByCid(3); |
|||
|
|||
model.addAttribute("readingZoneDetails", readingZoneDetails); |
|||
model.addAttribute("deskSpaceDetails", deskSpaceDetails); |
|||
model.addAttribute("conferenceHallDetails", conferenceHallDetails); |
|||
model.addAttribute("homeImg",homeService.getImgByCid(0)); |
|||
|
|||
model.addAttribute("spaces", spaces); |
|||
return "user/home"; |
|||
} |
|||
|
|||
*/ |
|||
// @GetMapping(value = {"/", "", "/workspacelist"}) |
|||
// public String viewWorkspaclist(@RequestParam(value = "cid", required = false) Integer cidParam, Model model) { |
|||
// List<Map<String, Object>> spaces = homeService.getActiveCoWorkingSpaces(bid); |
|||
// List<Map<String, Object>> readingZoneDetails = homeService.getPricingDetailsByCid(1); |
|||
// List<Map<String, Object>> deskSpaceDetails = homeService.getPricingDetailsByCid(2); |
|||
// List<Map<String, Object>> conferenceHallDetails = homeService.getPricingDetailsByCid(3); |
|||
|
|||
|
|||
// // Default to Learning Centre (cid = 1) |
|||
// Integer cid = (cidParam != null) ? cidParam : 2; |
|||
|
|||
// // Set type |
|||
// for (Map<String, Object> space : spaces) { |
|||
// Integer categoryId = (Integer) space.get("cid"); |
|||
// if (categoryId != null) { |
|||
// switch (categoryId) { |
|||
// case 1 -> space.put("type", "reading"); |
|||
// case 2 -> space.put("type", "desk"); |
|||
// case 3 -> space.put("type", "meeting"); |
|||
// default -> space.put("type", "learning"); |
|||
// } |
|||
// } |
|||
// } |
|||
|
|||
// final Integer finalCid = cid; // ✅ Now this is effectively final |
|||
// Map<String, Object> selectedSpace = spaces.stream() |
|||
// .filter(space -> finalCid.equals(space.get("cid"))) |
|||
// .findFirst() |
|||
// .orElse(null); |
|||
|
|||
// model.addAttribute("cid", cid); |
|||
// model.addAttribute("spaces", spaces); |
|||
// model.addAttribute("selectedSpace", selectedSpace); |
|||
// model.addAttribute("readingZoneDetails", readingZoneDetails); |
|||
// model.addAttribute("deskSpaceDetails", deskSpaceDetails); |
|||
// model.addAttribute("conferenceHallDetails", conferenceHallDetails); |
|||
// model.addAttribute("homeImg",homeService.getImgByCid(0)); |
|||
// return "user/workspacelist"; |
|||
// } |
|||
|
|||
@GetMapping(value = {"/", "", "/workspacelist"}) |
|||
public String viewWorkspaceList(Model model) { |
|||
|
|||
// ✅ Get all active buildings (for workspace list page) |
|||
List<Map<String, Object>> buildingList = buildingSer.getBuildingDetails(); |
|||
|
|||
// ✅ You can also fetch coworking space categories (if needed to show as tabs or filters) |
|||
List<Map<String, Object>> spaces = homeService.getActiveCoWorkingSpaces(); |
|||
|
|||
// ✅ Add to model |
|||
model.addAttribute("buildings", buildingList); |
|||
model.addAttribute("spaces", spaces); |
|||
|
|||
// ✅ Return the list page (user/workspacelist.html) |
|||
return "user/workspacelist"; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
// @GetMapping(value = { "/home"}) |
|||
// public String viewHome(@RequestParam int bid,@RequestParam(value = "cid", required = false) Integer cidParam, Model model) { |
|||
// List<Map<String, Object>> spaces = homeService.getActiveCoWorkingSpaces(); |
|||
// List<Map<String, Object>> readingZoneDetails = homeService.getPricingDetailsByCid(1); |
|||
// List<Map<String, Object>> deskSpaceDetails = homeService.getPricingDetailsByCid(2); |
|||
// List<Map<String, Object>> conferenceHallDetails = homeService.getPricingDetailsByCid(3); |
|||
|
|||
|
|||
// // Default to Learning Centre (cid = 1) |
|||
// Integer cid = (cidParam != null) ? cidParam : 2; |
|||
|
|||
// // Set type |
|||
// for (Map<String, Object> space : spaces) { |
|||
// Integer categoryId = (Integer) space.get("cid"); |
|||
// if (categoryId != null) { |
|||
// switch (categoryId) { |
|||
// case 1 -> space.put("type", "reading"); |
|||
// case 2 -> space.put("type", "desk"); |
|||
// case 3 -> space.put("type", "meeting"); |
|||
// default -> space.put("type", "learning"); |
|||
// } |
|||
// } |
|||
// } |
|||
|
|||
// final Integer finalCid = cid; // ✅ Now this is effectively final |
|||
// Map<String, Object> selectedSpace = spaces.stream() |
|||
// .filter(space -> finalCid.equals(space.get("cid"))) |
|||
// .findFirst() |
|||
// .orElse(null); |
|||
|
|||
// model.addAttribute("cid", cid); |
|||
// model.addAttribute("bid", bid); |
|||
// model.addAttribute("spaces", spaces); |
|||
// model.addAttribute("selectedSpace", selectedSpace); |
|||
// model.addAttribute("readingZoneDetails", readingZoneDetails); |
|||
// model.addAttribute("deskSpaceDetails", deskSpaceDetails); |
|||
// model.addAttribute("conferenceHallDetails", conferenceHallDetails); |
|||
// model.addAttribute("homeImg",homeService.getImgByCid(0)); |
|||
// return "user/home"; |
|||
// } |
|||
|
|||
|
|||
@GetMapping("/home") |
|||
public String viewHome(@RequestParam int bid, |
|||
@RequestParam(value = "cid", required = false) Integer cidParam, |
|||
Model model) { |
|||
|
|||
// ✅ Get coworking spaces for this building |
|||
List<Map<String, Object>> spaces = homeService.getActiveCoWorkingSpacesByBuilding(bid); |
|||
|
|||
|
|||
//System.out.println("home inside:" + spaces); |
|||
|
|||
// Remove duplicate category rows (keep first per cid) |
|||
spaces = spaces.stream() |
|||
.collect(Collectors.toMap( |
|||
m -> (Integer) m.get("cid"), |
|||
m -> m, |
|||
(existing, replacement) -> existing |
|||
)) |
|||
.values() |
|||
.stream() |
|||
.toList(); |
|||
// ✅ Default CID → first space of that building |
|||
Integer cid = (cidParam != null) |
|||
? cidParam |
|||
: (spaces.isEmpty() ? null : (Integer) spaces.get(0).get("cid")); |
|||
|
|||
// ✅ Get subcategory (pricing/capacity) details for this category |
|||
/*List<Map<String, Object>> pricingDetails = (cid != null) |
|||
? homeService.getPricingDetailsByCid(cid) |
|||
: List.of();*/ |
|||
List<Map<String, Object>> readingZoneDetails = homeService.getPricingDetailsByCid(cid); |
|||
List<Map<String, Object>> deskSpaceDetails = homeService.getPricingDetailsByCid(cid); |
|||
List<Map<String, Object>> conferenceHallDetails = homeService.getPricingDetailsByCid(cid); |
|||
|
|||
// ✅ Get category images for this category |
|||
List<Map<String, Object>> homeImg = (cid != null) |
|||
? homeService.getImgByCid(cid) |
|||
: List.of(); |
|||
|
|||
// ✅ Identify the selected space |
|||
Map<String, Object> selectedSpace = spaces.stream() |
|||
.filter(space -> cid != null && cid.equals(space.get("cid"))) |
|||
.findFirst() |
|||
.orElse(null); |
|||
//ak |
|||
|
|||
|
|||
|
|||
// ✅ Add everything to model |
|||
model.addAttribute("bid", bid); |
|||
model.addAttribute("cid", cid); |
|||
model.addAttribute("spaces", spaces); |
|||
System.out.println("spaces:" + spaces); |
|||
model.addAttribute("selectedSpace", selectedSpace); |
|||
//model.addAttribute("pricingDetails", pricingDetails); |
|||
model.addAttribute("readingZoneDetails", readingZoneDetails); |
|||
model.addAttribute("deskSpaceDetails", deskSpaceDetails); |
|||
model.addAttribute("conferenceHallDetails", conferenceHallDetails); |
|||
model.addAttribute("homeImg", homeImg); |
|||
|
|||
|
|||
|
|||
return "user/home"; |
|||
} |
|||
|
|||
//ak |
|||
@GetMapping("/api/pricing") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> getPricingDetails(@RequestParam int cid) { |
|||
return homeService.getPricingDetailsByCid(cid); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
// @GetMapping("/book") |
|||
// public String showCategoryPage(@RequestParam int buildingId,@RequestParam int categoryId, Model model) { |
|||
// List<Map<String, Object>> buildingCategoryDetails = buildingSer.getBuildingCategoryDetailsById(buildingId,categoryId); // Retrieve data |
|||
// model.addAttribute("homeImg",homeService.getImgByCid(categoryId)); |
|||
// |
|||
// if (!buildingCategoryDetails.isEmpty()) { |
|||
// model.addAttribute("details", buildingCategoryDetails.get(0)); // Pass the first item to the model |
|||
// // model.addAttribute("subcategories", buildingCategoryDetails.get(0).get("Subcategories")); // Assuming you have a list of subcategories |
|||
// } |
|||
// return "user/booking"; // Return the view |
|||
// } |
|||
|
|||
// @GetMapping("/book") |
|||
// public String showCategoryPage(@RequestParam int buildingId,@RequestParam int categoryId, Model model) { |
|||
// List<Map<String, Object>> buildingCategoryDetails = buildingSer.getBuildingCategoryDetailsById(buildingId,categoryId); // Retrieve data |
|||
// model.addAttribute("homeImg",homeService.getImgByCid(categoryId)); |
|||
// |
|||
// if (!buildingCategoryDetails.isEmpty()) { |
|||
// model.addAttribute("details", buildingCategoryDetails.get(0)); // Pass the first item to the model |
|||
// // model.addAttribute("subcategories", buildingCategoryDetails.get(0).get("Subcategories")); // Assuming you have a list of subcategories |
|||
// } |
|||
// return "user/booking"; // Return the view |
|||
// } |
|||
|
|||
// Endpoint to fetch space content for AJAX |
|||
// @GetMapping("/home/space") |
|||
// public String getSpaceFragment(@RequestParam("cid") Integer cid, Model model) { |
|||
// List<Map<String, Object>> spaces = homeService.getActiveCoWorkingSpaces(); |
|||
|
|||
// // Filter the selected space |
|||
// Map<String, Object> selectedSpace = spaces.stream() |
|||
// .filter(space -> cid.equals(space.get("cid"))) |
|||
// .findFirst() |
|||
// .orElse(null); |
|||
|
|||
// model.addAttribute("space", selectedSpace); |
|||
// return "fragments/spaceContent :: content"; |
|||
// } |
|||
|
|||
|
|||
|
|||
// @GetMapping("/home/space") |
|||
// public String getSpaceFragment(@RequestParam("cid") Integer cid, |
|||
// @RequestParam("bid") Integer bid, |
|||
// Model model) { |
|||
// List<Map<String, Object>> spaces = homeService.getActiveCoWorkingSpaces(); |
|||
|
|||
// Map<String, Object> selectedSpace = spaces.stream() |
|||
// .filter(space -> cid.equals(space.get("cid"))) |
|||
// .findFirst() |
|||
// .orElse(null); |
|||
|
|||
// model.addAttribute("space", selectedSpace); |
|||
// model.addAttribute("bid", bid); // ✅ Add buildingId |
|||
// model.addAttribute("cid", cid); |
|||
// return "fragments/spaceContent :: content"; |
|||
// } |
|||
|
|||
|
|||
|
|||
@GetMapping("/home/space") |
|||
public String getSpaceFragment(@RequestParam("cid") Integer cid, |
|||
@RequestParam("bid") Integer bid, |
|||
Model model) { |
|||
|
|||
// ✅ Get spaces for this specific building |
|||
List<Map<String, Object>> spaces = homeService.getActiveCoWorkingSpacesByBuilding(bid); |
|||
|
|||
//System.out.println("home spaces inside:" + spaces); |
|||
Map<String, Object> selectedSpace = spaces.stream() |
|||
.filter(space -> cid.equals(space.get("cid"))) |
|||
.findFirst() |
|||
.orElse(null); |
|||
|
|||
// System.out.println("selectedSpace :" + selectedSpace); |
|||
|
|||
model.addAttribute("space", selectedSpace); |
|||
model.addAttribute("bid", bid); |
|||
model.addAttribute("cid", cid); |
|||
|
|||
return "fragments/spaceContent :: content"; |
|||
} |
|||
|
|||
|
|||
// @GetMapping("/home/space") |
|||
// public String getSpaceFragment(@RequestParam("cid") Integer cid, |
|||
// @RequestParam("bid") Integer bid, |
|||
// Model model) { |
|||
|
|||
// List<Map<String, Object>> pricingDetails = homeService.getPricingDetailsByCid(cid); |
|||
// List<Map<String, Object>> images = homeService.getImgByCid(cid); |
|||
|
|||
// model.addAttribute("pricingDetails", pricingDetails); |
|||
// model.addAttribute("homeImg", images); |
|||
|
|||
// return "fragments/spaceContent :: content"; |
|||
// } |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@GetMapping("/registercomplaint") |
|||
public String registercomplaint(Model model, HttpSession session) { |
|||
String userName = (String) session.getAttribute("user_name"); |
|||
return "user/registercomplaint"; |
|||
} |
|||
|
|||
//complaintlist in caretaker side |
|||
@GetMapping("/complaintlist") |
|||
public String complaintlist(Model model, HttpSession session) { |
|||
String userName = (String) session.getAttribute("user_name"); |
|||
|
|||
if (userName != null && !userName.isEmpty()) { |
|||
model.addAttribute("user_name", userName); |
|||
|
|||
List<Map<String, Object>> complaintlist = complaintService.getOpenComplaintList(); |
|||
|
|||
List<Map<String,Object>> closedcomplaintlist = complaintService.getClosedComplaintList(); |
|||
|
|||
// Append base URL to each complaint's upload_photo_url |
|||
for (Map<String, Object> complaint : complaintlist) { |
|||
Object photoUrl = complaint.get("upload_photo_url"); |
|||
if (photoUrl != null && !photoUrl.toString().isEmpty()) { |
|||
// Ensure no double prefix happens |
|||
String fullUrl = baseUrl + "/co-workspaceDocuments" + photoUrl.toString(); |
|||
complaint.put("full_upload_photo_url", fullUrl); |
|||
} else { |
|||
complaint.put("full_upload_photo_url", ""); |
|||
} |
|||
} |
|||
|
|||
// Append base URL to each complaint's upload_photo_url |
|||
for (Map<String, Object> closedcomplaint : closedcomplaintlist) { |
|||
Object photoUrl = closedcomplaint.get("upload_photo_url"); |
|||
if (photoUrl != null && !photoUrl.toString().isEmpty()) { |
|||
// Ensure no double prefix happens |
|||
String fullUrl = baseUrl + "/co-workspaceDocuments" + photoUrl.toString(); |
|||
closedcomplaint.put("full_upload_photo_url", fullUrl); |
|||
} else { |
|||
closedcomplaint.put("full_upload_photo_url", ""); |
|||
} |
|||
} |
|||
|
|||
|
|||
model.addAttribute("complaintlist", complaintlist); |
|||
|
|||
model.addAttribute("closedcomplaintlist",closedcomplaintlist); |
|||
return "caretaker/complaintlist"; |
|||
} else { |
|||
return "redirect:/muthalvarpadaippagam/officiallogin"; |
|||
} |
|||
} |
|||
|
|||
//attendancereport |
|||
@GetMapping("/attendancereport") |
|||
public String attendancereport(Model model, HttpSession session) { |
|||
String userName = (String) session.getAttribute("user_name"); |
|||
Integer bid = (Integer) session.getAttribute("bid"); // ✅ get BID from session |
|||
// Check if the user is logged in |
|||
if (userName != null && !userName.isEmpty()) { |
|||
model.addAttribute("user_name", userName); |
|||
model.addAttribute("bid", bid); |
|||
return "caretaker/attendancereport"; // Render the report page |
|||
} else { |
|||
return "redirect:/muthalvarpadaippagam/officiallogin"; // Redirect to login if not logged in |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/attendance") |
|||
public String attendancePage(Model model, HttpSession session) { |
|||
String userName = (String) session.getAttribute("user_name"); |
|||
Integer bid = (Integer) session.getAttribute("bid"); // ✅ get BID from session |
|||
// Check if the user is logged in |
|||
if (userName != null && !userName.isEmpty()) { |
|||
//Integer bid = bookingService.getBidByUserName(userName); |
|||
|
|||
model.addAttribute("user_name", userName); |
|||
model.addAttribute("bid", bid); |
|||
|
|||
// (optional) store bid in session for later use |
|||
//session.setAttribute("bid", bid); |
|||
//model.addAttribute("user_name", userName); |
|||
return "caretaker/attendance"; // Render the report page |
|||
} else { |
|||
return "redirect:/muthalvarpadaippagam/officiallogin"; // Redirect to login if not logged in |
|||
} |
|||
} |
|||
|
|||
//checklist |
|||
/* |
|||
@GetMapping("/CheckList") |
|||
public String CheckList(Model model, HttpSession session) { |
|||
String userName = (String) session.getAttribute("user_name"); |
|||
|
|||
// Check if the user is logged in |
|||
if (userName != null && !userName.isEmpty()) { |
|||
model.addAttribute("user_name", userName); |
|||
return "caretaker/CheckList"; // Render the report page |
|||
} else { |
|||
return "redirect:/muthalvarpadaippagam/officiallogin"; // Redirect to login if not logged in |
|||
} |
|||
} |
|||
*/ |
|||
@GetMapping("/CheckList") |
|||
public String CheckList(Model model, HttpSession session) { |
|||
String userName = (String) session.getAttribute("user_name"); |
|||
|
|||
// Check if the user is logged in |
|||
if (userName != null && !userName.isEmpty()) { |
|||
model.addAttribute("user_name", userName); |
|||
//model.addAttribute("serverDate", LocalDate.now().toString()); |
|||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|||
String dateTimeNow = LocalDateTime.now().format(formatter); |
|||
model.addAttribute("serverDate", dateTimeNow); |
|||
|
|||
return "caretaker/CheckList"; // Render the report page |
|||
} else { |
|||
return "redirect:/muthalvarpadaippagam/officiallogin"; // Redirect to login if not logged in |
|||
} |
|||
} |
|||
//CheckListReport |
|||
@GetMapping("/CheckListReport") |
|||
public String CheckListReport(Model model, HttpSession session) { |
|||
String userName = (String) session.getAttribute("user_name"); |
|||
|
|||
// Check if the user is logged in |
|||
if (userName != null && !userName.isEmpty()) { |
|||
model.addAttribute("user_name", userName); |
|||
return "caretaker/CheckListReport"; // Render the report page |
|||
} else { |
|||
return "redirect:/muthalvarpadaippagam/officiallogin"; // Redirect to login if not logged in |
|||
} |
|||
} |
|||
|
|||
// @GetMapping("/book") |
|||
// public String showCategoryPage(@RequestParam int buildingId,@RequestParam int categoryId, Model model) { |
|||
// String url=""; |
|||
// List<Map<String, Object>> buildingCategoryDetails = buildingSer.getBuildingCategoryDetailsById(buildingId,categoryId); // Retrieve data |
|||
// model.addAttribute("homeImg",homeService.getImgByCid(categoryId)); |
|||
|
|||
// if (!buildingCategoryDetails.isEmpty()) { |
|||
// model.addAttribute("details", buildingCategoryDetails.get(0)); // Pass the first item to the model |
|||
// } |
|||
// // if(categoryId==1) { // Reading / Leaning Zone |
|||
// // url = "user/book-reading"; // Return the view |
|||
// // } |
|||
// // if(categoryId==2) { // Reading / Leaning Zone |
|||
// // url = "user/book-workdesk"; // Return the view |
|||
// // } |
|||
// // if(categoryId==3) { // Reading / Leaning Zone |
|||
// // url = "user/book-Conferance"; // Return the view |
|||
// // } |
|||
// // return url; |
|||
|
|||
// // ✅ Dynamically determine view name based on categoryId |
|||
|
|||
// switch (categoryId) { |
|||
// case 1 -> url = "user/book-learning"; |
|||
// case 2 -> url = "user/book-workdesk"; |
|||
// case 3 -> url = "user/book-conference"; |
|||
// case 4 -> url = "user/book-learning"; // optional if you add more later |
|||
// default -> throw new IllegalArgumentException("Invalid category ID: " + categoryId); |
|||
// } |
|||
|
|||
// // ✅ Pass IDs for dynamic usage in JavaScript |
|||
// model.addAttribute("buildingId", buildingId); |
|||
// model.addAttribute("categoryId", categoryId); |
|||
|
|||
// return url; |
|||
// } |
|||
|
|||
|
|||
|
|||
@GetMapping("/book") |
|||
public String showCategoryPage(@RequestParam int buildingId, |
|||
@RequestParam int categoryId, |
|||
@RequestParam(required = false) Integer subId, |
|||
Model model) { |
|||
// System.out.println("buildingId:" + buildingId); |
|||
// System.out.println("categoryId:" + categoryId); |
|||
|
|||
List<Map<String, Object>> buildingCategoryDetails = |
|||
buildingSer.getBuildingCategoryDetailsById(buildingId, categoryId); |
|||
//System.out.println("buildingCategoryDetails:" + buildingCategoryDetails); |
|||
|
|||
model.addAttribute("homeImg", homeService.getImgByCid(categoryId)); |
|||
|
|||
if (!buildingCategoryDetails.isEmpty()) { |
|||
Map<String, Object> firstRecord = buildingCategoryDetails.get(0); |
|||
model.addAttribute("details", firstRecord); |
|||
//ak |
|||
Object buildingName = firstRecord.get("Building_Name"); |
|||
Object buildingAddress = firstRecord.get("Address"); |
|||
Object latitude = firstRecord.get("Latitude"); |
|||
Object longitude = firstRecord.get("Longitude"); |
|||
|
|||
model.addAttribute("buildingName", buildingName); |
|||
model.addAttribute("buildingAddress", buildingAddress); |
|||
model.addAttribute("latitude", latitude); |
|||
model.addAttribute("longitude", longitude); |
|||
|
|||
// ✅ Prefer URL parameter subId, else fallback from DB |
|||
if (subId == null) { |
|||
Object scidObj = firstRecord.get("scid"); |
|||
subId = (scidObj != null) ? Integer.parseInt(scidObj.toString()) : 0; |
|||
} |
|||
|
|||
model.addAttribute("subId", subId); |
|||
System.out.println("SubId: " + subId); |
|||
} |
|||
|
|||
model.addAttribute("buildingId", buildingId); |
|||
model.addAttribute("categoryId", categoryId); |
|||
|
|||
String url = switch (categoryId) { |
|||
case 1 -> "user/book-reading"; |
|||
case 2 -> "user/book-workdesk"; |
|||
case 3 -> "user/book-Conferance"; |
|||
case 4 -> "user/book-reading"; |
|||
default -> throw new IllegalArgumentException("Invalid category ID: " + categoryId); |
|||
}; |
|||
|
|||
return url; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
// @GetMapping("/book") |
|||
// public String showCategoryPage( |
|||
// @RequestParam int buildingId, |
|||
// @RequestParam int categoryId, |
|||
// Model model) { |
|||
|
|||
// // Fetch building + category + subcategory + slot info |
|||
// List<Map<String, Object>> buildingCategoryDetails = buildingSer.getBuildingCategoryDetailsById(buildingId, categoryId); |
|||
// model.addAttribute("homeImg", homeService.getImgByCid(categoryId)); |
|||
|
|||
// if (!buildingCategoryDetails.isEmpty()) { |
|||
// model.addAttribute("details", buildingCategoryDetails.get(0)); |
|||
// } |
|||
|
|||
// // Dynamically resolve the view name based on category name or ID |
|||
// String viewName = switch (categoryId) { |
|||
// case 1 -> "user/book-reading"; |
|||
// case 2 -> "user/book-workdesk"; |
|||
// case 3 -> "user/book-Conference"; |
|||
// default -> "user/book-generic"; // fallback if future category added |
|||
// }; |
|||
|
|||
// return viewName; |
|||
// } |
|||
|
|||
|
|||
@GetMapping("/subcategory-display-names") |
|||
public String showSubcategoryDisplayNames(@RequestParam Model model) { |
|||
List<Map<String, Object>> displayNames = buildingSer.getSubcategoryDisplayNames(); |
|||
model.addAttribute("displayNames", displayNames); |
|||
return "user/termsandconditions"; // Ensure this matches your Thymeleaf template file |
|||
} |
|||
|
|||
|
|||
// @GetMapping("/bookingdetails") |
|||
// public String viewBookingDetails (Model model) { |
|||
// return "user/bookingdetails";} |
|||
|
|||
@GetMapping("/bookinghistory") |
|||
public String viewbookinghistory (Model model) { |
|||
if(userSession!=null && userSession.getMobileno()!=0){ |
|||
model.addAttribute("bookinghistorylist",bookingService.getBookingByMobileNo(userSession.getMobileno())); |
|||
} |
|||
return "user/bookinghistory"; |
|||
} |
|||
|
|||
@GetMapping("/bookingQRCode") |
|||
public String getBookingQRCode(HttpServletResponse response,@RequestParam int booking_id, Model model) { |
|||
setNoCacheHeaders(response); |
|||
List<?> bookinghistorylist = bookingService.getQrPageByBookingId(booking_id); |
|||
if (!bookinghistorylist.isEmpty()) { |
|||
model.addAttribute("bookinghistorylist", bookinghistorylist); |
|||
return "user/qrpage"; |
|||
} else { |
|||
model.addAttribute("error", "Booking not found for mobile number: " + booking_id); |
|||
return "error"; // A template to handle errors |
|||
} |
|||
} |
|||
|
|||
|
|||
@GetMapping("/officiallogin") |
|||
public String officiallogin (HttpServletResponse response, Model model) { |
|||
setNoCacheHeaders(response); |
|||
return "caretaker/login"; |
|||
} |
|||
|
|||
@GetMapping("/logout") |
|||
public String logout(HttpServletResponse response,HttpSession session) { |
|||
setNoCacheHeaders(response); |
|||
try { |
|||
session.invalidate(); |
|||
return "redirect:/muthalvarpadaippagam/officiallogin"; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return "redirect:/muthalvarpadaippagam/officiallogin"; |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/bookingdetails") |
|||
public String viewbookingdetails (HttpServletResponse response,Model model, HttpSession httpSession) { |
|||
setNoCacheHeaders(response); |
|||
String userName = (String) httpSession.getAttribute("user_name"); |
|||
|
|||
if (userName != null){ |
|||
//ak |
|||
// Call service to get bid |
|||
Integer bid = bookingService.getBidByUserName(userName); |
|||
|
|||
model.addAttribute("user_name", userName); |
|||
model.addAttribute("bid", bid); |
|||
|
|||
// (optional) store bid in session for later use |
|||
httpSession.setAttribute("bid", bid); |
|||
|
|||
return "caretaker/bookingdetails"; |
|||
} else { |
|||
return "redirect:/muthalvarpadaippagam/officiallogin"; |
|||
} |
|||
} |
|||
|
|||
// @GetMapping("/Dashboard") |
|||
// public String Dashboard ( Model model,HttpSession httpSession, HttpServletResponse response) { |
|||
|
|||
// String userName = (String) httpSession.getAttribute("user_name"); |
|||
// Integer bid = bookingService.getBidByUserName(userName); |
|||
// //System.out.println("username:"+ userName); |
|||
// if (userName != null){ |
|||
// model.addAttribute("user_name",userName); |
|||
// model.addAttribute("bid", bid); |
|||
// setNoCacheHeaders(response); |
|||
// return "caretaker/officer-dashboard"; |
|||
// } else { |
|||
// return "redirect:/muthalvarpadaippagam/officiallogin"; |
|||
// } |
|||
// } |
|||
|
|||
// @GetMapping("/Report") |
|||
// public String showReportPage(Model model, HttpSession session) { |
|||
// String userName = (String) session.getAttribute("user_name"); |
|||
|
|||
// // Check if the user is logged in |
|||
// if (userName != null && !userName.isEmpty()) { |
|||
// model.addAttribute("user_name", userName); |
|||
// return "caretaker/report"; // Render the report page |
|||
// } else { |
|||
// return "redirect:/muthalvarpadaippagam/officiallogin"; // Redirect to login if not logged in |
|||
// } |
|||
// } |
|||
|
|||
// @GetMapping("/Abstract") |
|||
// public String abstractReportPage(Model model, HttpSession session) { |
|||
// String userName = (String) session.getAttribute("user_name"); |
|||
|
|||
// // Check if the user is logged in |
|||
// if (userName != null && !userName.isEmpty()) { |
|||
// model.addAttribute("user_name", userName); |
|||
// return "caretaker/abstract"; // Render the report page |
|||
// } else { |
|||
// return "redirect:/muthalvarpadaippagam/officiallogin"; // Redirect to login if not logged in |
|||
// } |
|||
// } |
|||
|
|||
|
|||
// added by yogi |
|||
@GetMapping("/Dashboard") |
|||
public String Dashboard ( Model model,HttpSession httpSession, HttpServletResponse response) { |
|||
|
|||
String userName = (String) httpSession.getAttribute("user_name"); |
|||
Integer bid = (Integer) httpSession.getAttribute("bid"); // ✅ get BID from session |
|||
//System.out.println("username:"+ userName); |
|||
if (userName != null && bid!= null){ |
|||
model.addAttribute("user_name",userName); |
|||
model.addAttribute("bid",bid); // ✅ pass BID to model |
|||
setNoCacheHeaders(response); |
|||
return "caretaker/officer-dashboard"; |
|||
} else { |
|||
return "redirect:/muthalvarpadaippagam/officiallogin"; |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/Report") |
|||
public String showReportPage(Model model, HttpSession session) { |
|||
String userName = (String) session.getAttribute("user_name"); |
|||
|
|||
Integer bid = (Integer) session.getAttribute("bid"); // ✅ get BID from session |
|||
|
|||
//Integer bid = bookingService.getBidByUserName(userName); |
|||
System.out.println("bid inside controller: "+bid); |
|||
|
|||
// Check if the user is logged in |
|||
if (userName != null && !userName.isEmpty() && bid!=null ) { |
|||
model.addAttribute("user_name", userName); |
|||
model.addAttribute("bid", bid); |
|||
return "caretaker/report"; // Render the report page |
|||
} else { |
|||
return "redirect:/muthalvarpadaippagam/officiallogin"; // Redirect to login if not logged in |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/Abstract") |
|||
public String abstractReportPage(Model model, HttpSession session) { |
|||
String userName = (String) session.getAttribute("user_name"); |
|||
|
|||
//Integer bid = bookingService.getBidByUserName(userName); |
|||
Integer bid = (Integer) session.getAttribute("bid"); |
|||
// Check if the user is logged in |
|||
if (userName != null && !userName.isEmpty()) { |
|||
model.addAttribute("user_name", userName); |
|||
model.addAttribute("bid", bid); |
|||
return "caretaker/abstract"; // Render the report page |
|||
} else { |
|||
return "redirect:/muthalvarpadaippagam/officiallogin"; // Redirect to login if not logged in |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
package com.gcc.coworkspace.exception; |
|||
|
|||
public class ErrorResponse { |
|||
private int statusCode; |
|||
private String message; |
|||
|
|||
// Constructor, getters, and setters |
|||
|
|||
public ErrorResponse(int statusCode, String message) { |
|||
this.statusCode = statusCode; |
|||
this.message = message; |
|||
} |
|||
|
|||
public int getStatusCode() { |
|||
return statusCode; |
|||
} |
|||
|
|||
public void setStatusCode(int statusCode) { |
|||
this.statusCode = statusCode; |
|||
} |
|||
|
|||
public String getMessage() { |
|||
return message; |
|||
} |
|||
|
|||
public void setMessage(String message) { |
|||
this.message = message; |
|||
} |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
package com.gcc.coworkspace.exception; |
|||
|
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.ControllerAdvice; |
|||
import org.springframework.web.bind.annotation.ExceptionHandler; |
|||
import org.springframework.web.servlet.NoHandlerFoundException; |
|||
|
|||
@ControllerAdvice |
|||
public class GlobalExceptionHandler { |
|||
@ExceptionHandler(NoHandlerFoundException.class) |
|||
public ResponseEntity<String> handlePageNotFoundException(NoHandlerFoundException ex) { |
|||
// Log the exception |
|||
ex.printStackTrace(); |
|||
|
|||
// Get the requested URL from the exception |
|||
String requestedUrl = ex.getRequestURL(); |
|||
|
|||
// Create an error message with the requested URL |
|||
String errorMessage = "Page not found: " + requestedUrl; |
|||
|
|||
// Return a ResponseEntity with a 404 Not Found status code and error message |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(errorMessage); |
|||
} |
|||
@ExceptionHandler(Exception.class) |
|||
public ResponseEntity<ErrorResponse> handleException(Exception ex) { |
|||
// Log the exception |
|||
ex.printStackTrace(); |
|||
|
|||
// Create an error response object |
|||
ErrorResponse errorResponse = new ErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "An error occurred: " + ex.getMessage()); |
|||
|
|||
// Return a ResponseEntity with an appropriate HTTP status code and error response object |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse); |
|||
} |
|||
|
|||
@ExceptionHandler(NoSlotAvailable.class) |
|||
public ResponseEntity<ErrorResponse> noSlotAvailable(NoSlotAvailable ex){ |
|||
|
|||
ErrorResponse errorResponse = new ErrorResponse(HttpStatus.NOT_FOUND.value(),ex.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(errorResponse); |
|||
|
|||
|
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,7 @@ |
|||
package com.gcc.coworkspace.exception; |
|||
|
|||
public class NoSlotAvailable extends RuntimeException{ |
|||
public NoSlotAvailable(String msg){ |
|||
super(msg); |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
package com.gcc.coworkspace; |
|||
@ -0,0 +1,33 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class AmountConfigService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
|
|||
public Map<String, Object> getAmountBySlotid(int slotid) { |
|||
String sql = """ |
|||
SELECT * FROM amount_config WHERE slotid = ? |
|||
AND isactive = 1 AND isdelete = 0 |
|||
"""; |
|||
try { |
|||
Map<String, Object> result = jdbcTemplate.queryForMap(sql, slotid); |
|||
return result; |
|||
}catch (Exception e){ |
|||
return null; |
|||
} |
|||
|
|||
// Check if the result is null and return an empty map if so |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,582 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.dao.DataAccessException; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.sql.Date; |
|||
import java.time.LocalDate; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.HashMap; |
|||
|
|||
|
|||
@Service |
|||
public class AttendanceService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
/* |
|||
public List<Map<String, Object>> getAttendance(String type, String typeName, Integer noOfPerson, String fromDate, String toDate) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("SELECT ") |
|||
.append("c.calid, ") |
|||
.append("c.cdate, ") |
|||
.append("c.bid, ") |
|||
.append("c.cid, ") |
|||
.append("c.slotid, ") |
|||
.append("c.bookingid, ") |
|||
.append("c.bdate, ") |
|||
.append("c.bcount, ") |
|||
.append("b.user_name, ") |
|||
.append("b.mobile, ") |
|||
.append("b.from_date, ") |
|||
.append("b.to_date, ") |
|||
.append("b.no_of_person, ") |
|||
.append("b.amount, ") |
|||
.append("a.no_of_person_absent AS NoofAbsent, ") |
|||
.append("sl.name AS slot_name, ") |
|||
.append("SUBSTRING_INDEX(sl.name, ' to ', 1) AS checkin, ") |
|||
.append("SUBSTRING_INDEX(sl.name, ' to ', -1) AS checkout, ") |
|||
.append("cat.name AS type, ") |
|||
.append("cat.display_name AS type_name, ") |
|||
.append("sc.display_name AS subcategory_name ") |
|||
.append("FROM calendar c ") |
|||
.append("JOIN booking b ON c.bookingid = b.booking_id ") |
|||
.append("JOIN slots sl ON c.slotid = sl.slotid ") |
|||
.append("JOIN category cat ON c.cid = cat.cid ") |
|||
.append("JOIN subcategory sc ON c.bid = sc.scid ") |
|||
.append("left JOIN attendance a ON c.bookingid = a.booking_id ") |
|||
.append("WHERE 1=1 ") |
|||
.append("AND cat.display_name = 'Desk Space' "); |
|||
//.append("AND c.bdate = CURDATE() ");; |
|||
|
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
if (type != null && !type.isEmpty()) { |
|||
sql.append("AND cat.name = ? "); |
|||
params.add(type); |
|||
} |
|||
|
|||
if (typeName != null && !typeName.isEmpty()) { |
|||
sql.append("AND cat.display_name = ? "); |
|||
params.add(typeName); |
|||
} |
|||
|
|||
if (noOfPerson != null) { |
|||
sql.append("AND b.no_of_person = ? "); |
|||
params.add(noOfPerson); |
|||
} |
|||
|
|||
// Date filters |
|||
if (fromDate != null && toDate != null) { |
|||
sql.append("AND c.bdate BETWEEN ? AND ? "); |
|||
params.add(fromDate); |
|||
params.add(toDate); |
|||
System.out.println("toDate"); |
|||
System.out.println(toDate); |
|||
System.out.println(fromDate); |
|||
System.out.println("fromDate"); |
|||
|
|||
|
|||
} |
|||
|
|||
/* if (fromDate != null && toDate != null && |
|||
!fromDate.trim().isEmpty() && !toDate.trim().isEmpty() && noOfPerson != null) { |
|||
sql.append("AND a.cdate BETWEEN ? AND ? "); |
|||
params.add(fromDate + " 00:00:00"); |
|||
params.add(toDate + " 23:59:59"); |
|||
} else { |
|||
sql.append("AND DATE(a.cdate) = CURDATE() "); |
|||
}*/ |
|||
|
|||
//boolean check =checkAttendancestatus(); |
|||
//System.out.println(check+"================"); |
|||
/* |
|||
return jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
} |
|||
*/ |
|||
|
|||
|
|||
public List<Map<String, Object>> getAttendance(String type, String typeName, Integer noOfPerson, String fromDate, String toDate, Integer bid) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
sql.append("SELECT ") |
|||
.append("c.bookingid, ") |
|||
.append("MAX(c.calid) AS calid, ") |
|||
.append("MAX(c.cdate) AS cdate, ") |
|||
.append("MAX(c.bid) AS bid, ") |
|||
.append("MAX(c.cid) AS cid, ") |
|||
.append("MAX(c.slotid) AS slotid, ") |
|||
.append("MAX(c.bdate) AS bdate, ") |
|||
.append("SUM(c.bcount) AS bcount, ") |
|||
.append("MAX(b.user_name) AS user_name, ") |
|||
.append("MAX(b.mobile) AS mobile, ") |
|||
.append("MAX(b.from_date) AS from_date, ") |
|||
.append("MAX(b.to_date) AS to_date, ") |
|||
.append("MAX(b.no_of_person) AS no_of_person, ") |
|||
.append("MAX(b.amount) AS amount, ") |
|||
.append("MAX(IFNULL(a.no_of_person_absent, 0)) AS NoofAbsent, ") |
|||
.append("MAX(sl.name) AS slot_name, ") |
|||
.append("MAX(SUBSTRING_INDEX(sl.name, ' to ', 1)) AS checkin, ") |
|||
.append("MAX(SUBSTRING_INDEX(sl.name, ' to ', -1)) AS checkout, ") |
|||
.append("MAX(cat.name) AS type, ") |
|||
.append("MAX(cat.display_name) AS type_name, ") |
|||
.append("MAX(sc.display_name) AS subcategory_name ") |
|||
.append("FROM calendar c ") |
|||
.append("JOIN booking b ON c.bookingid = b.booking_id ") |
|||
.append("JOIN slots sl ON c.slotid = sl.slotid ") |
|||
.append("JOIN category cat ON c.cid = cat.cid ") |
|||
.append("JOIN subcategory sc ON c.bid = sc.scid ") |
|||
.append("JOIN buildings bu ON bu.bid = c.bid ") //ak |
|||
.append("LEFT JOIN attendance a ON c.bookingid = a.booking_id ") |
|||
.append("WHERE cat.display_name = 'Desk Space' ") |
|||
.append("AND sl.name = '09:00 AM to 09:00 PM' "); |
|||
|
|||
// Optional filters |
|||
if (type != null && !type.trim().isEmpty()) { |
|||
sql.append("AND cat.name = ? "); |
|||
params.add(type.trim()); |
|||
} |
|||
|
|||
if (typeName != null && !typeName.trim().isEmpty()) { |
|||
sql.append("AND cat.display_name = ? "); |
|||
params.add(typeName.trim()); |
|||
} |
|||
|
|||
if (noOfPerson != null) { |
|||
sql.append("AND b.no_of_person = ? "); |
|||
params.add(noOfPerson); |
|||
} |
|||
if (bid != null) { |
|||
sql.append("AND c.bid = ? "); |
|||
params.add(bid); |
|||
} |
|||
|
|||
if (fromDate != null && toDate != null && !fromDate.trim().isEmpty() && !toDate.trim().isEmpty()) { |
|||
sql.append("AND c.bdate BETWEEN ? AND ? "); |
|||
params.add(fromDate.trim()); |
|||
params.add(toDate.trim()); |
|||
} |
|||
|
|||
sql.append("GROUP BY c.bookingid ") |
|||
.append("ORDER BY MAX(c.bdate) DESC"); |
|||
|
|||
return jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
} |
|||
|
|||
/* |
|||
public List<Map<String, Object>> getAttendance2(String type, String typeName, Integer noOfPerson, String fromDate, String toDate) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("SELECT ") |
|||
.append("c.calid, ") |
|||
.append("c.cdate, ") |
|||
.append("c.bid, ") |
|||
.append("c.cid, ") |
|||
.append("c.slotid, ") |
|||
.append("c.bookingid, ") |
|||
.append("c.bdate, ") |
|||
.append("c.bcount, ") |
|||
.append("b.user_name, ") |
|||
.append("b.mobile, ") |
|||
.append("b.from_date, ") |
|||
.append("b.to_date, ") |
|||
.append("b.no_of_person, ") |
|||
.append("b.amount, ") |
|||
.append("IFNULL(a.no_of_person_absent, 0) AS NoofAbsent, ") |
|||
.append("sl.name AS slot_name, ") |
|||
.append("SUBSTRING_INDEX(sl.name, ' to ', 1) AS checkin, ") |
|||
.append("SUBSTRING_INDEX(sl.name, ' to ', -1) AS checkout, ") |
|||
.append("cat.name AS type, ") |
|||
.append("cat.display_name AS type_name, ") |
|||
.append("sc.display_name AS subcategory_name ") |
|||
.append("FROM calendar c ") |
|||
.append("JOIN booking b ON c.bookingid = b.booking_id ") |
|||
.append("JOIN slots sl ON c.slotid = sl.slotid ") |
|||
.append("JOIN category cat ON c.cid = cat.cid ") |
|||
.append("JOIN subcategory sc ON c.bid = sc.scid ") |
|||
.append("LEFT JOIN attendance a ON c.bookingid = a.booking_id ") |
|||
.append("WHERE 1=1 ") |
|||
.append("AND cat.display_name = 'Desk Space' "); |
|||
|
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
if (type != null && !type.isEmpty()) { |
|||
sql.append("AND cat.name = ? "); |
|||
params.add(type); |
|||
} |
|||
|
|||
if (typeName != null && !typeName.isEmpty()) { |
|||
sql.append("AND cat.display_name = ? "); |
|||
params.add(typeName); |
|||
} |
|||
|
|||
if (noOfPerson != null) { |
|||
sql.append("AND b.no_of_person = ? "); |
|||
params.add(noOfPerson); |
|||
} |
|||
|
|||
// Apply only exact date match, not range |
|||
if (fromDate != null && !fromDate.isEmpty()) { |
|||
sql.append("AND DATE(c.bdate) = ? "); |
|||
params.add(fromDate); |
|||
} |
|||
|
|||
return jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
} |
|||
*/ |
|||
//prevoius |
|||
/* public List<Map<String, Object>> getAttendance2(String type, String typeName, Integer noOfPerson, String fromDate, String toDate) { |
|||
StringBuilder sql = new StringBuilder("SELECT c.calid, c.cdate, c.bid, c.cid, c.slotid, c.bookingid, c.bdate, c.bcount,cat.display_name AS type_name, " |
|||
+ "b.user_name, b.mobile, b.from_date, b.to_date, " |
|||
+ "b.no_of_person, b.amount, IFNULL(c.absent_count, 0) AS NoofAbsent, " |
|||
+ " SUBSTRING_INDEX(sl.name, ' to ', 1) AS checkin, " |
|||
+ " SUBSTRING_INDEX(sl.name, ' to ', -1) AS checkout " |
|||
+ "FROM booking b " |
|||
+ "left join calendar c on c.bookingid = b.booking_id " |
|||
+ "left JOIN slots sl ON c.slotid = sl.slotid " |
|||
+ "left JOIN category cat ON c.cid = cat.cid " |
|||
+ "left JOIN subcategory sc ON c.bid = sc.scid " |
|||
+ "where cat.display_name = 'Desk Space'"); |
|||
|
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
if (type != null && !type.isEmpty()) { |
|||
sql.append("AND cat.name = ? "); |
|||
params.add(type); |
|||
} |
|||
|
|||
if (typeName != null && !typeName.isEmpty()) { |
|||
sql.append("AND cat.display_name = ? "); |
|||
params.add(typeName); |
|||
} |
|||
|
|||
if (noOfPerson != null) { |
|||
sql.append("AND b.no_of_person = ? "); |
|||
params.add(noOfPerson); |
|||
} |
|||
|
|||
// Apply only exact date match, not range |
|||
if (fromDate != null && !fromDate.isEmpty()) { |
|||
sql.append("AND DATE(c.bdate) = ? "); |
|||
params.add(fromDate); |
|||
} |
|||
return jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
}*/ |
|||
public List<Map<String, Object>> getAttendance2(String type, String typeName, String bid,Integer noOfPerson, String fromDate, String toDate) { |
|||
StringBuilder sql = new StringBuilder("SELECT c.calid, c.cdate, c.bid, c.cid, c.slotid, c.bookingid, c.bdate, c.bcount,cat.display_name AS type_name, " |
|||
+ "b.user_name, b.mobile, b.from_date, b.to_date, " |
|||
+ "b.no_of_person, b.amount, IFNULL(c.absent_count, 0) AS NoofAbsent, " |
|||
+ " SUBSTRING_INDEX(sl.name, ' to ', 1) AS checkin, " |
|||
+ " SUBSTRING_INDEX(sl.name, ' to ', -1) AS checkout " |
|||
+ "FROM coworkingspace.booking b " |
|||
+ "left join calendar c on c.bookingid = b.booking_id " |
|||
+ "left JOIN slots sl ON c.slotid = sl.slotid " |
|||
+ "left JOIN category cat ON c.cid = cat.cid " |
|||
+ "left JOIN subcategory sc ON c.bid = sc.scid " |
|||
+ "where cat.display_name = 'Desk Space'"); |
|||
|
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
if (type != null && !type.isEmpty()) { |
|||
sql.append("AND cat.name = ? "); |
|||
params.add(type); |
|||
} |
|||
|
|||
if (typeName != null && !typeName.isEmpty()) { |
|||
sql.append("AND cat.display_name = ? "); |
|||
params.add(typeName); |
|||
} |
|||
|
|||
if (noOfPerson != null) { |
|||
sql.append("AND b.no_of_person = ? "); |
|||
params.add(noOfPerson); |
|||
} |
|||
|
|||
// Apply only exact date match, not range |
|||
if (fromDate != null && !fromDate.isEmpty()) { |
|||
sql.append("AND DATE(c.bdate) = ? "); |
|||
params.add(fromDate); |
|||
} |
|||
return jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getAttendanceWithSlotDetails( |
|||
String type, String typeName, Integer noOfPerson, String fromDate, String toDate) { |
|||
|
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("SELECT ") |
|||
.append("b.booking_id, ") |
|||
.append("a.id AS attendence_id, ") |
|||
.append("b.user_name, b.mobile, b.from_date, b.to_date, b.cdate, ") |
|||
.append("sl.*, ") |
|||
.append("cat.display_name, ") |
|||
.append("a.no_of_person_absent as seat_available, ") |
|||
.append("b.amount, ") |
|||
.append("SUBSTRING_INDEX(sl.name, ' to ', 1) AS checkin, ") |
|||
.append("SUBSTRING_INDEX(sl.name, ' to ', -1) AS checkout ") |
|||
.append("FROM attendance a ") |
|||
.append("LEFT JOIN booking b ON a.booking_id = b.booking_id ") |
|||
.append("JOIN slots sl ON a.slotid = sl.slotid ") |
|||
.append("JOIN category cat ON a.cid = cat.cid ") |
|||
.append("WHERE 1=1 "); |
|||
|
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
if (type != null && !type.trim().isEmpty()) { |
|||
sql.append("AND LOWER(cat.name) = ? "); |
|||
params.add(type.toLowerCase()); |
|||
} |
|||
|
|||
if (typeName != null && !typeName.trim().isEmpty()) { |
|||
sql.append("AND LOWER(cat.display_name) = ? "); |
|||
params.add(typeName.toLowerCase()); |
|||
} |
|||
|
|||
if (noOfPerson != null) { |
|||
sql.append("AND a.no_of_person_absent = ? "); |
|||
params.add(noOfPerson); |
|||
} |
|||
|
|||
/* if (fromDate != null && toDate != null && |
|||
!fromDate.trim().isEmpty() && !toDate.trim().isEmpty() && noOfPerson != null) { |
|||
sql.append("AND a.cdate BETWEEN ? AND ? "); |
|||
params.add(fromDate + " 00:00:00"); |
|||
params.add(toDate + " 23:59:59"); |
|||
}*/ |
|||
if (fromDate != null && toDate != null && |
|||
!fromDate.trim().isEmpty() && !toDate.trim().isEmpty() && noOfPerson != null) { |
|||
sql.append("AND a.cdate BETWEEN ? AND ? "); |
|||
params.add(fromDate + " 00:00:00"); |
|||
params.add(toDate + " 23:59:59"); |
|||
} else { |
|||
sql.append("AND DATE(a.cdate) = CURDATE() "); |
|||
} |
|||
|
|||
|
|||
// Debug |
|||
System.out.println("Executing SQL: " + sql); |
|||
System.out.println("With params: " + params); |
|||
System.out.println("noOfPerson SQL: " + noOfPerson); |
|||
|
|||
return jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
} |
|||
|
|||
//ak |
|||
public Map<String, Object> getAbsentCountByBookingId(int bookingId) { |
|||
String sql = "SELECT no_of_person_absent as absentCount FROM attendance where booking_id = ? "; |
|||
return jdbcTemplate.queryForMap(sql, bookingId); |
|||
} |
|||
/* public Map<String, Object> updateAbsentCountByBookingId(int noOfAbsent, int bookingId) { |
|||
String sql = "UPDATE attendance SET no_of_person_absent = ? WHERE booking_id = ?"; |
|||
int rowsAffected = jdbcTemplate.update(sql, noOfAbsent, bookingId); |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
response.put("success", rowsAffected > 0); |
|||
response.put("rowsAffected", rowsAffected); |
|||
return response; |
|||
}*/ |
|||
|
|||
public Map<String, Object> updateAbsentCountByBookingId(int noOfAbsent, int bookingId) { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
// Step 1: Check if new_booking_id is NOT NULL |
|||
String getNewBookingIdSql = "SELECT new_booking_id FROM attendance WHERE booking_id = ?"; |
|||
Integer newBookingId = jdbcTemplate.queryForObject(getNewBookingIdSql, Integer.class, bookingId); |
|||
|
|||
// Step 2: If new_booking_id is NOT null, perform validation |
|||
if (newBookingId != null) { |
|||
// Get no_of_person from caretaker_booking for the new_booking_id |
|||
String getNoOfPersonSql = "SELECT no_of_person FROM caretaker_booking WHERE booking_id = ?"; |
|||
Integer noOfPerson = jdbcTemplate.queryForObject(getNoOfPersonSql, Integer.class, newBookingId); |
|||
System.out.println("noOfPersons"); |
|||
System.out.println(noOfPerson); |
|||
|
|||
if (noOfPerson == null) { |
|||
response.put("success", false); |
|||
response.put("message", "No record found in caretaker_booking for new_booking_id."); |
|||
return response; |
|||
} |
|||
|
|||
if (noOfAbsent < noOfPerson) { |
|||
response.put("success", false); |
|||
response.put("message", "Number of absent persons exceeds total number of persons allowed."); |
|||
return response; |
|||
} |
|||
} |
|||
System.out.println("noOfAbsentsss"); |
|||
System.out.println(noOfAbsent); |
|||
|
|||
|
|||
// Step 3: Proceed to update regardless if new_booking_id is null or noOfAbsent is valid |
|||
String updateSql = "UPDATE attendance SET no_of_person_absent = ? WHERE booking_id = ?"; |
|||
int rowsAffected = jdbcTemplate.update(updateSql, noOfAbsent, bookingId); |
|||
|
|||
response.put("success", rowsAffected > 0); |
|||
response.put("rowsAffected", rowsAffected); |
|||
return response; |
|||
} |
|||
|
|||
|
|||
|
|||
/* public void updateAbsentCountByBookingId(int bookingId,int noOfAbsent) { |
|||
String sql = "update attendance set no_of_person_absent=? where booking_id = ?"; |
|||
jdbcTemplate.queryForMap(sql,noOfAbsent, bookingId); |
|||
}*/ |
|||
|
|||
/*public void updateNewBookingIdInAttendance(int newBookingId, |
|||
String attendanceid) { |
|||
String sql = "UPDATE coworkspace.attendance SET new_booking_id = ? " |
|||
+ "WHERE id = ? "; |
|||
jdbcTemplate.update(sql, newBookingId,attendanceid); |
|||
}*/ |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
public int saveAttendanceByBookingId(int bookingId, Map<String, Object> requestData) { |
|||
// Fetch data for booking id |
|||
String fetchSql = "SELECT c.bid, c.cid, c.slotid, c.bcount, b.no_of_person " + |
|||
"FROM calendar c " + |
|||
"JOIN booking b ON c.bookingid = b.booking_id " + |
|||
"WHERE c.bookingid = ? LIMIT 1"; |
|||
|
|||
Map<String, Object> bookingData = jdbcTemplate.queryForMap(fetchSql, bookingId); |
|||
|
|||
if (bookingData == null) { |
|||
throw new RuntimeException("No booking found for bookingId: " + bookingId); |
|||
} |
|||
|
|||
String newbookingId = null; |
|||
|
|||
|
|||
// From request body, get attendance status and no_of_person_absent |
|||
boolean attendanceStatus = Boolean.parseBoolean(requestData.get("attendance_status").toString()); |
|||
int noOfPersonAbsent = Integer.parseInt(requestData.get("no_of_person_absent").toString()); |
|||
|
|||
|
|||
// Insert into attendance table |
|||
String insertSql = "INSERT INTO attendance " + |
|||
"(id, booking_id, bid, cid, slotid, bcount, attendance_status, no_of_person, no_of_person_absent, new_booking_id, cdate) " + |
|||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())"; |
|||
|
|||
// For id, you can pass NULL if AUTO_INCREMENT is enabled, else generate manually |
|||
return jdbcTemplate.update(insertSql, |
|||
null, // id (assuming auto_increment) |
|||
bookingId, |
|||
bookingData.get("bid"), |
|||
bookingData.get("cid"), |
|||
bookingData.get("slotid"), |
|||
bookingData.get("bcount"), |
|||
attendanceStatus, |
|||
bookingData.get("no_of_person"), |
|||
noOfPersonAbsent, |
|||
newbookingId // new_booking_id |
|||
); |
|||
} |
|||
|
|||
// public int updateNewBookingIdInAttendanceById(int attendanceId, int newBookingId) { |
|||
// System.out.println("Updating attendance table: attendance.id = " + attendanceId + ", new_booking_id = " + newBookingId); |
|||
// String updateSql = "UPDATE attendance SET new_booking_id = ? WHERE id = ?"; |
|||
// return jdbcTemplate.update(updateSql, newBookingId, attendanceId); |
|||
// } |
|||
public boolean hasTodayAttendance(int bookingId) { |
|||
String sql = "SELECT COUNT(*) FROM attendance WHERE booking_id = ? AND DATE(cdate) = CURDATE()"; |
|||
Integer count = jdbcTemplate.queryForObject(sql, Integer.class, bookingId); |
|||
return count != null && count > 0; |
|||
} |
|||
|
|||
public boolean saveAndUpdateAttendance(int bookingId, int noOfAbsent) { |
|||
try { |
|||
// 1. Insert into attendance |
|||
String insertAttendance = "INSERT INTO attendance (booking_id, no_of_person_absent, cdate, attendance_status) VALUES (?, ?, NOW(), ?)"; |
|||
jdbcTemplate.update(insertAttendance, bookingId, noOfAbsent, "ABSENT"); |
|||
System.out.println("✅ Step 1: Attendance saved"); |
|||
|
|||
// 2. Just update absent_count (not bcount) |
|||
String updateCalendar = "UPDATE calendar SET absent_count = absent_count + ? WHERE bookingid = ? AND DATE(bdate) = CURDATE()"; |
|||
jdbcTemplate.update(updateCalendar, noOfAbsent, bookingId); |
|||
System.out.println("✅ Step 2: Calendar updated"); |
|||
|
|||
return true; |
|||
} catch (Exception e) { |
|||
System.err.println("❌ Error: " + e.getMessage()); |
|||
e.printStackTrace(); |
|||
throw new RuntimeException("Failed to save and update attendance", e); |
|||
} |
|||
} |
|||
|
|||
public boolean saveAbsent(List<Map<String, Object>> absentList,int bid) |
|||
{ |
|||
try { |
|||
|
|||
for(Map<String, Object> absentLists:absentList){ |
|||
|
|||
int bookingId = Integer.parseInt(absentLists.get("bookingId").toString()); |
|||
int noOfAbsent = Integer.parseInt(absentLists.get("noOfAbsent").toString()); |
|||
|
|||
String insertAttendance = "INSERT INTO attendance (booking_id, no_of_person_absent, cdate, attendance_status, bid) VALUES (?, ?, NOW(), ?,?)"; |
|||
jdbcTemplate.update(insertAttendance, bookingId, noOfAbsent, "ABSENT",bid); |
|||
|
|||
String updateCalendar = "UPDATE calendar SET absent_count = absent_count + ? WHERE bookingid = ? AND DATE(bdate) = CURDATE()"; |
|||
jdbcTemplate.update(updateCalendar, noOfAbsent, bookingId); |
|||
} |
|||
|
|||
|
|||
return true; |
|||
} catch (Exception e) { |
|||
System.err.println("❌ Error: " + e.getMessage()); |
|||
e.printStackTrace(); |
|||
throw new RuntimeException("Failed to save attendance", e); |
|||
} |
|||
} |
|||
|
|||
public int insertAbsentCount(int bid, LocalDate absentDate, int absentCount) { |
|||
final String sql = "INSERT INTO absent_count " |
|||
+ " (absent_date, absent_count, cdate, bid, is_active, is_delete) " |
|||
+ " VALUES (?, ?, ?, ?, 1, 0)"; |
|||
|
|||
Date sqlAbsentDate = Date.valueOf(absentDate); |
|||
Date today = Date.valueOf(LocalDate.now()); |
|||
|
|||
try { |
|||
int rows = jdbcTemplate.update(sql,sqlAbsentDate,absentCount,today,bid); |
|||
return rows; |
|||
} catch (DataAccessException e) { |
|||
// TODO: log the exception (e.g. logger.error(...)) |
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
private boolean checkAttendancestatus() { |
|||
|
|||
String sql="SELECT absent_count " + |
|||
"FROM absent_count " + |
|||
"WHERE DATE(absent_date) = CURDATE() AND is_active = 1 AND is_delete = 0 LIMIT 1"; |
|||
Integer cnt = jdbcTemplate.queryForObject(sql, Integer.class); |
|||
// cnt will be 0 if there are no rows today; >0 otherwise |
|||
return cnt != null && cnt > 0; |
|||
} |
|||
|
|||
|
|||
public int getTodayAbsentCount(int bid) { |
|||
try { |
|||
String sql = "SELECT IFNULL(SUM(absent_count), 0) FROM calendar WHERE bdate = CURDATE() AND bid = ?"; |
|||
Integer result = jdbcTemplate.queryForObject(sql, Integer.class, bid); |
|||
return result != null ? result : 0; |
|||
} catch (Exception e) { |
|||
System.out.println("Error: " + e.getMessage()); |
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
} |
|||
1111
src/main/java/com/gcc/coworkspace/service/BookingService.java
File diff suppressed because it is too large
View File
@ -0,0 +1,198 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
//import conferencehall.conferencehall.Repository.CoworkSpaceRepository; |
|||
import com.gcc.coworkspace.exception.NoSlotAvailable; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.jdbc.core.simple.SimpleJdbcInsert; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class BookingServiceCopy { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
private AmountConfigService amountConfigService; |
|||
// @Autowired |
|||
//private CoworkSpaceRepository coworkSpaceRepository; |
|||
|
|||
public int saveTempBooking(String userName, long userMobile, List<Integer> slots, LocalDate fromDate, LocalDate toDate, int noOfPeople, int catId, int buildId, int subId) { |
|||
|
|||
double amount =0; |
|||
List<LocalDate> btnDates = getDatesBetween(fromDate, toDate); |
|||
if(!btnDates.isEmpty()) { |
|||
for (Integer slot : slots) { |
|||
Map<String,Object> amt = amountConfigService.getAmountBySlotid(slot); |
|||
if(amt!=null) { |
|||
for (LocalDate date : btnDates) { |
|||
if (checkAvailabilityByBdate(buildId, catId, date, subId, noOfPeople, slot)) { |
|||
return 0; |
|||
} |
|||
} |
|||
} |
|||
else { |
|||
throw new NoSlotAvailable("Amount is not configured"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
// Join the slots with commas |
|||
String Tslot = slots.stream().map(String::valueOf).collect(Collectors.joining(",")); |
|||
System.out.println(Tslot); |
|||
|
|||
// Define the SimpleJdbcInsert with the expected table and key |
|||
SimpleJdbcInsert insert = new SimpleJdbcInsert(jdbcTemplate) |
|||
.withTableName("temp_booking") |
|||
.usingGeneratedKeyColumns("tempbookid"); |
|||
|
|||
// Map the parameters to the column names |
|||
Map<String, Object> parameters = new HashMap<>(); |
|||
parameters.put("user_name", userName); |
|||
parameters.put("mobile", userMobile); |
|||
parameters.put("slotids", Tslot); |
|||
parameters.put("from_date", fromDate); |
|||
parameters.put("to_date", toDate); |
|||
parameters.put("no_of_person", noOfPeople); |
|||
parameters.put("cdate", LocalDateTime.now()); |
|||
|
|||
parameters.put("cid", catId); |
|||
parameters.put("bid", buildId); |
|||
parameters.put("sid", subId); |
|||
|
|||
try { |
|||
// Execute the insert and return the generated key |
|||
Number generatedId = insert.executeAndReturnKey(parameters); |
|||
return generatedId.intValue(); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
public Map<String, Object> getTempBookingByTempId(int tempbookid) { |
|||
String sql = "SELECT * FROM temp_booking where tempbookid = ?"; |
|||
return jdbcTemplate.queryForMap(sql, tempbookid); |
|||
} |
|||
|
|||
|
|||
// public int saveBooking(int tempbookid) { |
|||
// System.out.println("==========central====save " + tempbookid); |
|||
// |
|||
// // Retrieve data from temp_booking based on tempbookid |
|||
// Map<String, Object> tempBooking = getTempBookingByTempId(tempbookid); |
|||
// System.out.println(tempBooking); |
|||
// |
|||
// // SQL INSERT query with placeholders and RETURNING clause |
|||
// String sql = "INSERT INTO booking (user_name, mobile, slotids, from_date, to_date, no_of_person, amount, payment_status, cdate, cid, bid, sid) " |
|||
// + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING booking_id"; // Assuming 'bid' is the booking ID |
|||
// |
|||
// try { |
|||
// // Execute the insert query and retrieve the generated booking ID |
|||
// int bookingId = jdbcTemplate.update(sql, |
|||
// new Object[]{ |
|||
// tempBooking.get("user_name"), // user_name |
|||
// tempBooking.get("mobile"), // mobile |
|||
// tempBooking.get("slotIds"), // slotids |
|||
// tempBooking.get("from_date").toString(), // from_date |
|||
// tempBooking.get("to_date").toString(), // to_date |
|||
// tempBooking.get("no_of_person"), // no_of_person |
|||
// tempBooking.get("amount"), // amount (ensure this exists in tempBooking) |
|||
// tempBooking.get("payment_status"), // payment_status (set a default if needed) |
|||
// LocalDateTime.now(), // cdate (current timestamp) |
|||
// tempBooking.get("cid"), // cid |
|||
// tempBooking.get("bid"), // bid |
|||
// tempBooking.get("sid") // sid |
|||
// }, |
|||
// Integer.class); // Expecting an Integer return type for booking ID |
|||
// |
|||
// System.out.println("Booking successfully created with ID: " + bookingId); |
|||
// return bookingId; // Return the generated booking ID |
|||
// } catch (Exception e) { |
|||
// System.err.println("Error while saving booking: " + e.getMessage()); |
|||
// e.printStackTrace(); |
|||
// return 0; // Return 0 in case of an error |
|||
// } |
|||
// } |
|||
|
|||
|
|||
public static List<LocalDate> getDatesBetween(LocalDate fromDate, LocalDate toDate) { |
|||
List<LocalDate> dates = new ArrayList<>(); |
|||
|
|||
LocalDate currentDate = fromDate; |
|||
while (!currentDate.isAfter(toDate)) { |
|||
dates.add(currentDate); |
|||
currentDate = currentDate.plusDays(1); |
|||
} |
|||
|
|||
return dates; |
|||
} |
|||
|
|||
|
|||
public Map<String, Object> getCalendarBySlotId(int bid, int cid, LocalDate Bdate, int slotId) { |
|||
String sql = """ |
|||
select slotid, sum(bcount) as filed, bdate |
|||
from calendar |
|||
where bdate = ? |
|||
and cid = ? and bid = ? and slotId = ? |
|||
group by slotid, bdate |
|||
"""; |
|||
|
|||
// Using query() instead of queryForMap to handle no results |
|||
List<Map<String, Object>> result = jdbcTemplate.query(sql, (rs, rowNum) -> { |
|||
Map<String, Object> map = new HashMap<>(); |
|||
map.put("slotid", rs.getInt("slotid")); |
|||
map.put("filed", rs.getInt("filed")); // Adjust type accordingly |
|||
map.put("bdate", rs.getDate("bdate").toLocalDate()); |
|||
return map; |
|||
}, Bdate, cid, bid, slotId); |
|||
|
|||
// Check if result is empty and handle it |
|||
if (result.isEmpty()) { |
|||
return Collections.emptyMap(); // Return an empty map if no rows found |
|||
} |
|||
return result.get(0); // Return the first (and expected only) result |
|||
} |
|||
|
|||
|
|||
public Map<String, Object> getCapacity(int sId, int catId) { |
|||
String sql = "select limits, capacity from subcategory where scid = ? and cid = ?"; |
|||
try { |
|||
return jdbcTemplate.queryForMap(sql, sId, catId); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return Collections.singletonMap("error", "An error occurred while getting capacity."); |
|||
} |
|||
} |
|||
public Boolean checkAvailabilityByBdate(int bid,int cid,LocalDate Bdate,int scid,int noOfPerson,int slotId){ |
|||
System.out.println("=================checkAvailabilityByBdate==========================="); |
|||
Map<String,Object> getcalendar = getCalendarBySlotId(bid,cid,Bdate,slotId); |
|||
Map<String,Object> capacity= getCapacity( scid, cid); |
|||
|
|||
int capsint = Integer.parseInt(capacity.get("limits").toString()); |
|||
int capacityint = Integer.parseInt(capacity.get("capacity").toString()); |
|||
System.out.println("=====condition====="); |
|||
if(!getcalendar.isEmpty()){ |
|||
int count= Integer.parseInt(getcalendar.get("filed")+"")+ noOfPerson; |
|||
if(count > capacityint ){ |
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
System.out.println("======end=============="); |
|||
return false; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,170 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class BuildingService { |
|||
|
|||
private final JdbcTemplate jdbcTemplate; |
|||
|
|||
public BuildingService(JdbcTemplate jdbcTemplate) { |
|||
this.jdbcTemplate = jdbcTemplate; |
|||
} |
|||
|
|||
// public List<Map<String, Object>> getBuildingDetails() { |
|||
// String sql = "SELECT b.building_id, b.building_name, b.latitude, b.longitude, b.building_address, " + |
|||
// "b.dictrict, b.pincode, b.contact_1, b.contact_2, b.contact_name, " + |
|||
// "c.cat_name, c.cat_flag, c.display_name, bc.bc_id, " + |
|||
// "bc.capacity, bc.price, bc.gst, bc.days, bc.timing, bc.limits, bc.bc_desc, bc.floor " + |
|||
// "FROM coworkspacedata.buildings b " + |
|||
// "LEFT JOIN coworkspacedata.building_caterogy bc ON b.building_id = bc.building_id_bc_fk " + |
|||
// "LEFT JOIN coworkspacedata.slots sl ON bc.bc_id = sl.bc_id_slot_fk " + |
|||
// "LEFT JOIN coworkspacedata.category c ON bc.cat_id_bc_fk = c.cat_id"; |
|||
|
|||
// return jdbcTemplate.queryForList(sql); |
|||
// } |
|||
|
|||
|
|||
// public List<Map<String, Object>> getBuildingDetails() { |
|||
// String sql = "SELECT bid, name, address, latitude, longitude, orderby, cdate, " + |
|||
// "isactive, isdelete, pincode, district, contact_1, contact_2, area, contact_person " + |
|||
// "FROM buildings WHERE isdelete = 0 ORDER BY orderby ASC"; |
|||
// return jdbcTemplate.queryForList(sql); |
|||
// } |
|||
|
|||
public List<Map<String, Object>> getBuildingDetails() { |
|||
String sql = """ |
|||
SELECT |
|||
b.bid, |
|||
b.name AS name, |
|||
b.address, |
|||
b.latitude, |
|||
b.longitude, |
|||
b.orderby, |
|||
b.cdate, |
|||
b.isactive, |
|||
b.isdelete, |
|||
b.pincode, |
|||
b.district, |
|||
b.contact_1, |
|||
b.contact_2, |
|||
b.area, |
|||
b.contact_person, |
|||
b.building_image_url, |
|||
c.cid, |
|||
c.display_name, |
|||
c.description, |
|||
c.timing, |
|||
c.days, |
|||
c.icon, |
|||
c.list1, |
|||
c.list2, |
|||
c.list3, |
|||
c.list4, |
|||
s.capacity |
|||
FROM buildings b |
|||
LEFT JOIN category c |
|||
ON b.bid = c.bid AND c.isdelete = 0 |
|||
LEFT JOIN subcategory s |
|||
ON c.cid = s.cid |
|||
WHERE b.isdelete = 0 |
|||
ORDER BY b.orderby ASC, c.orderby ASC |
|||
"""; |
|||
|
|||
return jdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getBuildingDetailsbyId(String bid) { |
|||
String sql = "SELECT bid, name, address, latitude, longitude, orderby, cdate, " + |
|||
"isactive, isdelete, pincode, district, contact_1, contact_2, area, contact_person " + |
|||
"FROM buildings WHERE isdelete = 0 and bid = ? ORDER BY orderby ASC"; |
|||
return jdbcTemplate.queryForList(sql,bid); |
|||
} |
|||
// public List<Map<String, Object>> getBuildingCategoryDetailsById(int bcId) { |
|||
// String sql = "SELECT b.building_id, b.building_name, b.latitude, b.longitude, b.building_address, " + |
|||
// "b.dictrict, b.pincode, b.contact_1, b.contact_2, b.contact_name, " + |
|||
// "c.cat_name, c.cat_flag, c.display_name, " + |
|||
// "bc.bc_id, bc.capacity, bc.price, bc.gst, bc.days, bc.timing, bc.limits, bc.bc_desc, bc.floor, sl.slot_timing, sl.c_date " + |
|||
// "FROM buildings b " + |
|||
// "LEFT JOIN building_caterogy bc ON b.building_id = bc.building_id_bc_fk " + |
|||
// "LEFT JOIN slots sl ON bc.bc_id = sl.bc_id_slot_fk " + |
|||
// "LEFT JOIN category c ON bc.cat_id_bc_fk = c.cat_id " + |
|||
// "WHERE bc.bc_id = ?"; |
|||
// |
|||
// // Return a list of maps to handle multiple rows |
|||
// return jdbcTemplate.queryForList(sql, bcId); |
|||
// } |
|||
|
|||
public List<Map<String, Object>> getBuildingCategoryDetailsById(int bid,int cid) { |
|||
String sql = "SELECT b.bid AS Building_ID, " + |
|||
"b.name AS Building_Name, " + |
|||
"b.address AS Address, " + |
|||
"b.latitude AS Latitude, " + |
|||
"b.longitude AS Longitude, " + |
|||
"b.pincode AS Pincode, " + |
|||
"b.district AS District, " + |
|||
"b.contact_1 AS Contact1, " + |
|||
"b.contact_2 AS Contact2, " + |
|||
"b.area AS Area, " + |
|||
"b.contact_person AS Contact_Person, " + |
|||
"c.cid AS Category_ID, " + |
|||
"c.name AS Category_Name, " + |
|||
"c.display_name AS Category_Display_Name, " + |
|||
"c.description AS Category_Description, " + |
|||
" c.timing AS Timing, " + |
|||
" c.days AS days, " + |
|||
"sc.scid AS scid, " + |
|||
"sc.name AS Subcategory_Name, " + |
|||
"sc.display_name AS Subcategory_Display_Name, " + |
|||
"sc.limits AS Subcategory_Limits, " + |
|||
"sc.capacity AS Subcategory_Capacity, " + |
|||
"s.slotid AS Slot_ID, " + |
|||
"s.name AS Slot_Name " + |
|||
|
|||
"FROM buildings b " + |
|||
"JOIN category c ON b.bid = c.bid " + |
|||
"JOIN subcategory sc ON c.cid = sc.cid " + |
|||
"JOIN slots s ON sc.scid = s.scid " + |
|||
|
|||
"WHERE c.bid=? and c.cid = ? " + // Keep the placeholder |
|||
"ORDER BY b.name, c.name, sc.name, s.name"; |
|||
|
|||
return jdbcTemplate.queryForList(sql, bid,cid); // Pass the actual parameter here |
|||
} |
|||
|
|||
public List<Map<String, Object>> getSubcategoryDisplayNames() { |
|||
String sql = "SELECT * FROM subcategory"; |
|||
|
|||
// Return a list of maps to hold the result rows |
|||
return jdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getamenities() { |
|||
String sql = "SELECT * FROM amenities" |
|||
; |
|||
|
|||
// Return a list of maps to hold the result rows |
|||
return jdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getSubCategoryDetailsById(int categoryId) { |
|||
String sql = "SELECT * FROM subcategory WHERE cid = ?"; |
|||
return jdbcTemplate.queryForList(sql,categoryId); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getslotsbySubcategoryId(Integer subcategoryId) { |
|||
String sql = "SELECT * FROM slots WHERE scid = ?"; |
|||
return jdbcTemplate.queryForList(sql,subcategoryId); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getAmenitiesById(int categoryId) { |
|||
String sql = "SELECT * FROM amenities WHERE cid = ?"; |
|||
return jdbcTemplate.queryForList(sql,categoryId); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class CalendarService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
public List<Map<String, Object>> getCalendarBasedOnSubCatId(int scid) { |
|||
String sql = "select * from slots where scid = ? AND (`isactive`=1 AND `isdelete`=0)"; |
|||
System.err.println(sql+scid); |
|||
return jdbcTemplate.queryForList(sql, scid); |
|||
|
|||
} |
|||
|
|||
public String getSlotText(String slotID) { |
|||
String sql = "SELECT name FROM slots WHERE slotid = ? AND isactive = 1 AND isdelete = 0"; |
|||
return jdbcTemplate.queryForObject(sql, new Object[]{slotID}, String.class); |
|||
} |
|||
} |
|||
@ -0,0 +1,229 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.HashSet; |
|||
import java.util.LinkedHashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Set; |
|||
import java.util.StringJoiner; |
|||
import java.util.TreeMap; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class CheckListService { |
|||
|
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
|
|||
public List<Map<String, Object>> getQuestionsWithOptions(int shiftId) { |
|||
/* int today = LocalDate.now().getDayOfMonth(); |
|||
|
|||
// Skip deep cleaning if not 15 or 29 |
|||
if (shiftId == 3 && today != 15 && today != 29) { |
|||
return new ArrayList<>(); |
|||
}*/ |
|||
int today = LocalDate.now().getDayOfMonth(); |
|||
LocalDate now = LocalDate.now(); |
|||
int lastDayOfMonth = now.lengthOfMonth(); // Gets 28, 29, 30, or 31 depending on the month |
|||
|
|||
// Skip deep cleaning if not 15 or last day of the month |
|||
if (shiftId == 3 && today != 15 && today != lastDayOfMonth) { |
|||
return new ArrayList<>(); |
|||
} |
|||
|
|||
|
|||
// Fetch questions |
|||
String questionsSql = "SELECT id, questions, field_name FROM question_master " + |
|||
"WHERE shift_id = ? AND is_active = 1 AND is_delete = 0 ORDER BY order_by"; |
|||
List<Map<String, Object>> questions = jdbcTemplate.queryForList(questionsSql, shiftId); |
|||
|
|||
// Fetch options |
|||
String optionsSql = "SELECT id, options FROM options_values " + |
|||
"WHERE is_active = 1 AND is_delete = 0 ORDER BY order_by"; |
|||
List<Map<String, Object>> allOptions = jdbcTemplate.queryForList(optionsSql); |
|||
|
|||
// Fetch feedback if exists |
|||
String feedbackSql = "SELECT * FROM checklist_feedback " + |
|||
"WHERE shift_id = ? AND DATE(cdate) = CURDATE() " + |
|||
"ORDER BY id DESC LIMIT 1"; |
|||
List<Map<String, Object>> feedbackList = jdbcTemplate.queryForList(feedbackSql, shiftId); |
|||
|
|||
boolean submitted = !feedbackList.isEmpty(); // 🔥 whether feedback is present for today |
|||
|
|||
Map<String, Object> feedback = submitted ? feedbackList.get(0) : new HashMap<>(); |
|||
|
|||
// Attach options and selected flag to each question |
|||
for (Map<String, Object> question : questions) { |
|||
String fieldName = (String) question.get("field_name"); |
|||
|
|||
// Mark options with "selected": true/false |
|||
List<Map<String, Object>> enrichedOptions = new ArrayList<>(); |
|||
|
|||
for (Map<String, Object> opt : allOptions) { |
|||
Map<String, Object> enrichedOpt = new HashMap<>(opt); |
|||
Object selectedVal = feedback.get(fieldName); |
|||
|
|||
if (selectedVal != null && selectedVal.toString().equals(opt.get("id").toString())) { |
|||
enrichedOpt.put("selected", true); |
|||
} else { |
|||
enrichedOpt.put("selected", false); |
|||
} |
|||
|
|||
enrichedOptions.add(enrichedOpt); |
|||
} |
|||
|
|||
question.put("options", enrichedOptions); |
|||
question.put("submitted", submitted); // 🔥 inject the submitted flag for frontend |
|||
} |
|||
|
|||
return questions; |
|||
} |
|||
|
|||
|
|||
//initial |
|||
|
|||
/*public void saveFeedback(Map<String, String> answers, Integer shiftId) { |
|||
StringJoiner columns = new StringJoiner(", "); |
|||
StringJoiner placeholders = new StringJoiner(", "); |
|||
|
|||
Object[] values = new Object[answers.size() + 1]; // +1 for shiftId |
|||
int index = 0; |
|||
|
|||
// Add shift_id column |
|||
columns.add("shift_id"); |
|||
placeholders.add("?"); |
|||
values[index++] = shiftId; |
|||
|
|||
// Add answers |
|||
for (Map.Entry<String, String> entry : answers.entrySet()) { |
|||
columns.add(entry.getKey()); |
|||
placeholders.add("?"); |
|||
values[index++] = entry.getValue(); |
|||
} |
|||
System.out.println("test"); |
|||
|
|||
String sql = "INSERT INTO checklist_feedback (" + columns + ") VALUES (" + placeholders + ")"; |
|||
jdbcTemplate.update(sql, values); |
|||
}*/ |
|||
public void saveFeedback(Map<String, String> answers, Integer shiftId, String date) { |
|||
StringJoiner columns = new StringJoiner(", "); |
|||
StringJoiner placeholders = new StringJoiner(", "); |
|||
|
|||
Object[] values = new Object[answers.size() + 2]; // +1 for shiftId, +1 for cdate |
|||
int index = 0; |
|||
|
|||
// Add shift_id column |
|||
columns.add("shift_id"); |
|||
placeholders.add("?"); |
|||
values[index++] = shiftId; |
|||
|
|||
// Add cdate column |
|||
columns.add("cdate"); |
|||
placeholders.add("?"); |
|||
values[index++] = date; // Assuming `cdate` is of type DATE or VARCHAR(10) in `yyyy-MM-dd` |
|||
|
|||
// Add answers |
|||
for (Map.Entry<String, String> entry : answers.entrySet()) { |
|||
columns.add(entry.getKey()); |
|||
placeholders.add("?"); |
|||
values[index++] = entry.getValue(); |
|||
} |
|||
|
|||
String sql = "INSERT INTO checklist_feedback (" + columns + ") VALUES (" + placeholders + ")"; |
|||
jdbcTemplate.update(sql, values); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getFeedbackSummary(String fromDate, String toDate) { |
|||
String sql = "SELECT DATE(cdate) AS cdate, shift_id " + |
|||
"FROM checklist_feedback " + |
|||
"WHERE DATE(cdate) BETWEEN ? AND ? " + |
|||
"GROUP BY DATE(cdate), shift_id"; |
|||
|
|||
List<Map<String, Object>> raw = jdbcTemplate.queryForList(sql, fromDate, toDate); |
|||
|
|||
Map<String, Set<Integer>> dateShiftMap = new TreeMap<>(); |
|||
|
|||
for (Map<String, Object> row : raw) { |
|||
String date = row.get("cdate").toString(); |
|||
int shift = (int) row.get("shift_id"); |
|||
dateShiftMap.computeIfAbsent(date, k -> new HashSet<>()).add(shift); |
|||
} |
|||
|
|||
List<Map<String, Object>> result = new ArrayList<>(); |
|||
|
|||
for (String date : dateShiftMap.keySet()) { |
|||
Set<Integer> shifts = dateShiftMap.get(date); |
|||
Map<String, Object> record = new LinkedHashMap<>(); |
|||
record.put("date", date); |
|||
record.put("shift1", shifts.contains(1)); |
|||
record.put("shift2", shifts.contains(2)); |
|||
record.put("shift3", shifts.contains(3)); |
|||
result.add(record); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
// |
|||
|
|||
public List<Map<String, Object>> getFeedbackQuestions(int shiftId, LocalDate date) { |
|||
int day = date.getDayOfMonth(); |
|||
int lastDay = date.lengthOfMonth(); |
|||
|
|||
// Only allow Deep Cleaning on 15 or last day |
|||
if (shiftId == 3 && day != 15 && day != lastDay) { |
|||
return new ArrayList<>(); |
|||
} |
|||
|
|||
// Get Questions |
|||
String questionsSql = "SELECT id, questions, field_name FROM question_master " + |
|||
"WHERE shift_id = ? AND is_active = 1 AND is_delete = 0 ORDER BY order_by"; |
|||
List<Map<String, Object>> questions = jdbcTemplate.queryForList(questionsSql, shiftId); |
|||
|
|||
// Get Options |
|||
String optionsSql = "SELECT id, options FROM options_values " + |
|||
"WHERE is_active = 1 AND is_delete = 0 ORDER BY order_by"; |
|||
List<Map<String, Object>> allOptions = jdbcTemplate.queryForList(optionsSql); |
|||
|
|||
// Get Feedback for the selected date |
|||
String feedbackSql = "SELECT * FROM checklist_feedback " + |
|||
"WHERE shift_id = ? AND DATE(cdate) = ? ORDER BY id DESC LIMIT 1"; |
|||
List<Map<String, Object>> feedbackList = jdbcTemplate.queryForList(feedbackSql, shiftId, date); |
|||
|
|||
boolean submitted = !feedbackList.isEmpty(); |
|||
Map<String, Object> feedback = submitted ? feedbackList.get(0) : new HashMap<>(); |
|||
|
|||
for (Map<String, Object> question : questions) { |
|||
String fieldName = (String) question.get("field_name"); |
|||
|
|||
List<Map<String, Object>> enrichedOptions = new ArrayList<>(); |
|||
for (Map<String, Object> opt : allOptions) { |
|||
Map<String, Object> enrichedOpt = new HashMap<>(opt); |
|||
Object selectedVal = feedback.get(fieldName); |
|||
enrichedOpt.put("selected", selectedVal != null && selectedVal.toString().equals(opt.get("id").toString())); |
|||
enrichedOptions.add(enrichedOpt); |
|||
} |
|||
|
|||
question.put("options", enrichedOptions); |
|||
question.put("submitted", submitted); |
|||
} |
|||
|
|||
return questions; |
|||
} |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,348 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
import java.io.IOException; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.security.SecureRandom; |
|||
import java.sql.Timestamp; |
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Random; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.core.env.Environment; |
|||
import org.springframework.dao.EmptyResultDataAccessException; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import com.gcc.coworkspace.controller.DateTimeUtil; |
|||
|
|||
@Service |
|||
public class ComplaintService { |
|||
|
|||
|
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
private Environment environment; |
|||
|
|||
|
|||
@Value("${app.full_URL}") |
|||
private String baseUrl; |
|||
|
|||
|
|||
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
|||
private static final int STRING_LENGTH = 15; |
|||
private static final Random RANDOM = new SecureRandom(); |
|||
|
|||
|
|||
public int complaintDetails(String userName, String remarks, String mobileNumber, MultipartFile uploadPhotoFile) throws IOException { |
|||
String uploadPhotoUrl = null; |
|||
String status = "OPEN"; |
|||
|
|||
if (uploadPhotoFile != null && !uploadPhotoFile.isEmpty()) { |
|||
uploadPhotoUrl = saveFile(uploadPhotoFile); |
|||
} |
|||
|
|||
// Generate complaint_no |
|||
String datePrefix = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
|||
int randomSuffix = new Random().nextInt(90000) + 10000; |
|||
String complaintNo = "CMP" + datePrefix + randomSuffix; |
|||
|
|||
// Insert into complaint_details |
|||
String sql = "INSERT INTO complaint_details (complaint_no, status, user_name, remarks, mobile_number, upload_photo_url) " + |
|||
"VALUES (?, ?, ?, ?, ?, ?)"; |
|||
int rows = jdbcTemplate.update(sql, complaintNo, status, userName, remarks, mobileNumber, uploadPhotoUrl); |
|||
|
|||
// Insert into complaint_details_history |
|||
String historySql = "INSERT INTO complaint_details_history (complaint_no, status, user_name, remarks, mobile_number, upload_photo_url) " + |
|||
"VALUES (?, ?, ?, ?, ?, ?)"; |
|||
jdbcTemplate.update(historySql, complaintNo, status, userName, remarks, mobileNumber, uploadPhotoUrl); |
|||
|
|||
return rows; |
|||
} |
|||
|
|||
|
|||
|
|||
//complaint user reply |
|||
public int updateComplaintWithReply(String complaintNo, String userName, String remarks, |
|||
String mobileNumber, MultipartFile uploadPhotoFile) throws IOException { |
|||
|
|||
String uploadPhotoUrl = null; |
|||
String status = "PENDING"; |
|||
|
|||
if (uploadPhotoFile != null && !uploadPhotoFile.isEmpty()) { |
|||
uploadPhotoUrl = saveFile(uploadPhotoFile); // Your existing file-saving logic |
|||
} |
|||
|
|||
// ✅ 1. Update main complaint table |
|||
String updateSql = "UPDATE complaint_details SET status = ?, user_name = ?, remarks = ?, mobile_number = ?, upload_photo_url = ?, caretaker_updated_date = CURRENT_TIMESTAMP WHERE complaint_no = ?"; |
|||
int updated = jdbcTemplate.update(updateSql, status, userName, remarks, mobileNumber, uploadPhotoUrl, complaintNo); |
|||
|
|||
// ✅ 2. Insert history |
|||
String insertHistorySql = "INSERT INTO complaint_details_history (complaint_no, status, user_name, remarks, mobile_number, upload_photo_url) VALUES (?, ?, ?, ?, ?, ?)"; |
|||
jdbcTemplate.update(insertHistorySql, complaintNo, status, userName, remarks, mobileNumber, uploadPhotoUrl); |
|||
|
|||
return updated; |
|||
} |
|||
|
|||
|
|||
|
|||
//ak |
|||
public void closeComplaint(String complaintNo) { |
|||
String sql = "UPDATE complaint_details SET status = 'CLOSED' WHERE complaint_no = ?"; |
|||
jdbcTemplate.update(sql, complaintNo); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getComplaintHistory(String complaintNo) { |
|||
String sql = "SELECT complaint_no, cdate, caretaker_updated_date, user_name, remarks, upload_photo_url, " + |
|||
"caretaker_remarks, caretaker_photo_url " + |
|||
"FROM complaint_details_history WHERE complaint_no = ? "; |
|||
|
|||
List<Map<String, Object>> historyList = jdbcTemplate.queryForList(sql, complaintNo); |
|||
System.out.println("historyList"); |
|||
System.out.println(historyList); |
|||
|
|||
String baseUrl = "/co-workspaceDocuments"; |
|||
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"); |
|||
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy, hh:mm:ss a"); |
|||
|
|||
for (Map<String, Object> record : historyList) { |
|||
// Photo paths |
|||
Object photo = record.get("upload_photo_url"); |
|||
Object caretakerPhoto = record.get("caretaker_photo_url"); |
|||
|
|||
record.put("upload_photo_url", |
|||
(photo != null && !photo.toString().isEmpty()) ? baseUrl + photo.toString() : ""); |
|||
|
|||
record.put("caretaker_photo_url", |
|||
(caretakerPhoto != null && !caretakerPhoto.toString().isEmpty()) ? baseUrl + caretakerPhoto.toString() : ""); |
|||
|
|||
// Format date fields |
|||
try { |
|||
Object cdateObj = record.get("cdate"); |
|||
if (cdateObj != null) { |
|||
/*LocalDateTime cdate = LocalDateTime.parse(cdateObj.toString(), inputFormatter); |
|||
record.put("cdate", outputFormatter.format(cdate));*/ |
|||
Timestamp ts = (Timestamp) cdateObj; |
|||
LocalDateTime cdate = ts.toLocalDateTime(); |
|||
record.put("cdate", outputFormatter.format(cdate)); |
|||
} |
|||
|
|||
Object caretakerDateObj = record.get("caretaker_updated_date"); |
|||
if (caretakerDateObj != null) { |
|||
// For some JDBC drivers this might already include milliseconds or timezone, handle carefully |
|||
String dateStr = caretakerDateObj.toString(); |
|||
if (dateStr.length() > 19) dateStr = dateStr.substring(0, 19); // truncate if needed |
|||
LocalDateTime caretakerDate = LocalDateTime.parse(dateStr, inputFormatter); |
|||
record.put("caretaker_updated_date", outputFormatter.format(caretakerDate)); |
|||
} |
|||
|
|||
} catch (Exception e) { |
|||
System.err.println("Date parse error: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
return historyList; |
|||
} |
|||
|
|||
|
|||
|
|||
//ak |
|||
public Map<String, Object> getUserDetailsByComplaintNo(String complaintNo) { |
|||
String sql = "SELECT user_name, mobile_number FROM complaint_details WHERE complaint_no = ?"; |
|||
|
|||
try { |
|||
return jdbcTemplate.queryForMap(sql, complaintNo); |
|||
} catch (EmptyResultDataAccessException e) { |
|||
// No result found |
|||
return Collections.emptyMap(); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
throw e; |
|||
} |
|||
} |
|||
|
|||
|
|||
public void updateCaretakerDetails(String complaint_no, String remarks, MultipartFile photoUrl) throws IOException { |
|||
String uploadPhotoUrlCaretaker = null; |
|||
String status = "CLOSED"; |
|||
|
|||
|
|||
// Check if new photo is uploaded |
|||
if (photoUrl != null && !photoUrl.isEmpty()) { |
|||
uploadPhotoUrlCaretaker = saveFileCaretaker(photoUrl); |
|||
} |
|||
|
|||
String updateSql; |
|||
if ((uploadPhotoUrlCaretaker != null) || (remarks != null && !remarks.trim().isEmpty())) { |
|||
updateSql = "UPDATE complaint_details SET caretaker_remarks = ?, caretaker_photo_url = ?, status = ?, caretaker_updated_date = CURRENT_TIMESTAMP WHERE complaint_no = ?"; |
|||
jdbcTemplate.update(updateSql, remarks, uploadPhotoUrlCaretaker, status, complaint_no); |
|||
} else { |
|||
updateSql = "UPDATE complaint_details SET caretaker_remarks = ?, caretaker_photo_url = ? WHERE complaint_no = ?"; |
|||
jdbcTemplate.update(updateSql, remarks, uploadPhotoUrlCaretaker, complaint_no); |
|||
} |
|||
|
|||
|
|||
// Fetch full complaint details for history insert |
|||
String fetchSql = "SELECT complaint_no, status, user_name, remarks, upload_photo_url, mobile_number FROM complaint_details WHERE complaint_no = ?"; |
|||
Map<String, Object> data = jdbcTemplate.queryForMap(fetchSql, complaint_no); |
|||
|
|||
// Always insert a new row into complaint_details_history (versioned log) |
|||
String insertSql = "INSERT INTO complaint_details_history " + |
|||
"(complaint_no, status, user_name, remarks, upload_photo_url, mobile_number, caretaker_remarks, caretaker_photo_url, caretaker_updated_date) " + |
|||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)"; |
|||
|
|||
jdbcTemplate.update(insertSql, |
|||
data.get("complaint_no"), |
|||
data.get("status"), |
|||
data.get("user_name"), |
|||
data.get("remarks"), |
|||
data.get("upload_photo_url"), |
|||
data.get("mobile_number"), |
|||
remarks, |
|||
uploadPhotoUrlCaretaker |
|||
); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public String saveFile(MultipartFile file) throws IOException { |
|||
|
|||
String order_copy_url = ""; |
|||
// type_folder = "works/"+type_folder; |
|||
// Handle file upload if a file is provided |
|||
if (file == null || file.isEmpty()) { |
|||
return order_copy_url; |
|||
} |
|||
|
|||
// Set the file path where you want to save it |
|||
String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
String serviceFolderName = environment.getProperty("complaintfile_directory"); |
|||
var year =DateTimeUtil.getCurrentYear(); |
|||
var month =DateTimeUtil.getCurrentMonth(); |
|||
//var date =DateTimeUtil.getCurrentDay(); |
|||
|
|||
uploadDirectory = uploadDirectory + "/"+ serviceFolderName + "/" + year + "/" + month; |
|||
|
|||
Path directoryPath = Paths.get(uploadDirectory); |
|||
if (!Files.exists(directoryPath)) { |
|||
Files.createDirectories(directoryPath); |
|||
} |
|||
|
|||
String datetimetxt = DateTimeUtil.getCurrentDateTime(); |
|||
|
|||
String fileName = datetimetxt +""+generateRandomStringForFile(10) +"_" + file.getOriginalFilename(); |
|||
// Construct the file path |
|||
String filepath = uploadDirectory + "/" + fileName; |
|||
String filepath_txt = "/" + serviceFolderName + "/" + year + "/" + month + "/" + fileName; |
|||
Path path = Paths.get(filepath); |
|||
|
|||
// Ensure the directory exists |
|||
Files.createDirectories(path.getParent()); |
|||
|
|||
// Write the file to the specified path |
|||
Files.write(path, file.getBytes()); |
|||
|
|||
// Set the order_copy_url to the relative file path for storing in DB |
|||
order_copy_url = filepath_txt; |
|||
|
|||
return order_copy_url; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
public String saveFileCaretaker(MultipartFile file) throws IOException { |
|||
|
|||
String order_copy_url = ""; |
|||
// type_folder = "works/"+type_folder; |
|||
// Handle file upload if a file is provided |
|||
if (file == null || file.isEmpty()) { |
|||
return order_copy_url; |
|||
} |
|||
|
|||
// Set the file path where you want to save it |
|||
String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
String serviceFolderName = environment.getProperty("caretakerfileuploads_directory"); |
|||
var year =DateTimeUtil.getCurrentYear(); |
|||
var month =DateTimeUtil.getCurrentMonth(); |
|||
//var date =DateTimeUtil.getCurrentDay(); |
|||
|
|||
uploadDirectory = uploadDirectory + "/"+ serviceFolderName + "/" + year + "/" + month; |
|||
|
|||
Path directoryPath = Paths.get(uploadDirectory); |
|||
if (!Files.exists(directoryPath)) { |
|||
Files.createDirectories(directoryPath); |
|||
} |
|||
|
|||
String datetimetxt = DateTimeUtil.getCurrentDateTime(); |
|||
|
|||
String fileName = datetimetxt +""+generateRandomStringForFile(10) +"_" + file.getOriginalFilename(); |
|||
// Construct the file path |
|||
String filepath = uploadDirectory + "/" + fileName; |
|||
String filepath_txt = "/" + serviceFolderName + "/" + year + "/" + month + "/" + fileName; |
|||
Path path = Paths.get(filepath); |
|||
|
|||
// Ensure the directory exists |
|||
Files.createDirectories(path.getParent()); |
|||
|
|||
// Write the file to the specified path |
|||
Files.write(path, file.getBytes()); |
|||
|
|||
// Set the order_copy_url to the relative file path for storing in DB |
|||
order_copy_url = filepath_txt; |
|||
|
|||
return order_copy_url; |
|||
} |
|||
|
|||
|
|||
|
|||
public static String generateRandomStringForFile(int String_Lenth) { |
|||
StringBuilder result = new StringBuilder(String_Lenth); |
|||
for (int i = 0; i < STRING_LENGTH; i++) { |
|||
result.append(CHARACTERS.charAt(RANDOM.nextInt(CHARACTERS.length()))); |
|||
} |
|||
return result.toString(); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
public List<Map<String,Object>> getOpenComplaintList() { |
|||
|
|||
|
|||
String sql = "SELECT complaint_no,user_name,remarks,mobile_number,upload_photo_url,cdate,status FROM complaint_details where status = 'OPEN' "; |
|||
return jdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public List<Map<String,Object>> getClosedComplaintList(){ |
|||
|
|||
String sql = "SELECT complaint_no,user_name,remarks,mobile_number,upload_photo_url,cdate,status FROM complaint_details where status ='CLOSED' "; |
|||
return jdbcTemplate.queryForList(sql); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
import org.springframework.web.util.UriComponentsBuilder; |
|||
|
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class GoogleReviewService { |
|||
|
|||
@Value("${google.api.key}") |
|||
private String apiKey; |
|||
|
|||
@Value("${google.place.id}") |
|||
private String placeId; |
|||
|
|||
@Autowired |
|||
JdbcTemplate jdbcTemplate; |
|||
|
|||
private final String GOOGLE_PLACE_URL = "https://maps.googleapis.com/maps/api/place/details/json"; |
|||
|
|||
public Map<String, Object> getGoogleReviews() { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
|
|||
String url = UriComponentsBuilder.fromHttpUrl(GOOGLE_PLACE_URL) |
|||
.queryParam("place_id", placeId) |
|||
.queryParam("fields", "name,rating,reviews") |
|||
.queryParam("key", apiKey) |
|||
.toUriString(); |
|||
|
|||
return restTemplate.getForObject(url, Map.class); |
|||
} |
|||
|
|||
|
|||
public Map<String, Object> getmarquee() { |
|||
String sql = "SELECT * FROM marquee where is_active = 1"; |
|||
return jdbcTemplate.queryForMap(sql); |
|||
} |
|||
} |
|||
@ -0,0 +1,161 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class HomeService { |
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
/* |
|||
public List<Map<String, Object>> getActiveCoWorkingSpaces() { |
|||
String sql = "SELECT c.cid AS cid, c.name, c.display_name, c.bid,c.orderby,c.cdate,c.isactive,c.isdelete, \n" + |
|||
" c.description, ci.imageurl as imageurl\n" + |
|||
"FROM category c INNER JOIN category_images ci ON c.cid = ci.cid AND ci.orderby = 1\n" + |
|||
"WHERE c.isactive = 1 AND c.isdelete = 0"; |
|||
|
|||
return jdbcTemplate.queryForList(sql); // Use queryForList to get List<Map<String, Object>> |
|||
} |
|||
*/ |
|||
// public List<Map<String, Object>> getActiveCoWorkingSpaces() { |
|||
// String sql = " SELECT c.cid AS cid, c.name, c.display_name, c.bid,c.orderby,c.cdate,c.isactive,c.isdelete, \n" + |
|||
// " c.description, c.icon, \r\n" + |
|||
// " c.list1, c.list2, c.list3, c.list4, ci.imageurl as imageurl\n" + |
|||
// " FROM category c INNER JOIN category_images ci ON c.cid = ci.cid AND ci.orderby = 1\n" + |
|||
// " WHERE c.isactive = 1 AND c.isdelete = 0"; |
|||
|
|||
// return jdbcTemplate.queryForList(sql); // Use queryForList to get List<Map<String,Object>> |
|||
// } |
|||
|
|||
|
|||
|
|||
|
|||
// public List<Map<String, Object>> getActiveCoWorkingSpaces() { |
|||
// String sql = " SELECT c.cid AS cid, c.name, c.display_name, c.bid,c.orderby,c.cdate,c.isactive,c.isdelete, \n" + |
|||
// " c.description, c.icon, \r\n" + |
|||
// " c.list1, c.list2, c.list3, c.list4, ci.imageurl as imageurl\n" + |
|||
// " FROM category c INNER JOIN category_images ci ON c.cid = ci.cid AND ci.orderby = 1\n" + |
|||
// " WHERE c.isactive = 1 AND c.isdelete = 0"; |
|||
|
|||
// return jdbcTemplate.queryForList(sql); // Use queryForList to get List<Map<String,Object>> |
|||
// } |
|||
|
|||
|
|||
public List<Map<String, Object>> getActiveCoWorkingSpaces() { |
|||
String sql = """ |
|||
SELECT |
|||
c.cid AS cid, |
|||
c.name AS category_name, |
|||
c.display_name AS display_name, |
|||
c.bid AS bid, |
|||
c.description AS description, |
|||
c.icon AS icon, |
|||
c.list1 AS list1, |
|||
c.list2 AS list2, |
|||
c.list3 AS list3, |
|||
c.list4 AS list4, |
|||
ci.imageurl AS imageurl, |
|||
sc.scid AS scid, |
|||
sc.name AS subcategory_name, |
|||
sc.display_name AS subcategory_display_name, |
|||
sc.limits AS limits, |
|||
sc.capacity AS capacity |
|||
FROM category c |
|||
INNER JOIN category_images ci |
|||
ON c.cid = ci.cid AND ci.orderby = 1 |
|||
LEFT JOIN subcategory sc |
|||
ON c.cid = sc.cid AND sc.isactive = 1 AND sc.isdelete = 0 |
|||
WHERE c.isactive = 1 AND c.isdelete = 0 |
|||
ORDER BY c.bid, c.orderby, sc.orderby |
|||
"""; |
|||
|
|||
return jdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
|
|||
// public List<Map<String, Object>> getActiveCoWorkingSpacesByBuilding(int bid) { |
|||
// String sql = """ |
|||
// SELECT |
|||
// c.cid AS cid, |
|||
// c.name, |
|||
// c.display_name, |
|||
// c.bid, |
|||
// c.description, |
|||
// c.icon, |
|||
// c.list1, |
|||
// c.list2, |
|||
// c.list3, |
|||
// c.list4, |
|||
// ci.imageurl AS imageurl |
|||
// FROM category c |
|||
// INNER JOIN category_images ci |
|||
// ON c.cid = ci.cid |
|||
// AND ci.orderby = 1 |
|||
// WHERE c.isactive = 1 |
|||
// AND c.isdelete = 0 |
|||
// AND c.bid = ? |
|||
// ORDER BY c.orderby ASC |
|||
// """; |
|||
// return jdbcTemplate.queryForList(sql, bid); |
|||
// } |
|||
|
|||
public List<Map<String, Object>> getActiveCoWorkingSpacesByBuilding(int bid) { |
|||
String sql = """ |
|||
SELECT |
|||
c.cid AS cid, |
|||
c.name AS category_name, |
|||
c.display_name AS display_name, |
|||
c.bid AS bid, |
|||
c.description AS description, |
|||
c.icon AS icon, |
|||
c.list1 AS list1, |
|||
c.list2 AS list2, |
|||
c.list3 AS list3, |
|||
c.list4 AS list4, |
|||
ci.imageurl AS imageurl, |
|||
sc.scid AS scid, |
|||
sc.name AS subcategory_name, |
|||
sc.display_name AS subcategory_display_name, |
|||
sc.limits AS limits, |
|||
sc.capacity AS capacity |
|||
FROM category c |
|||
INNER JOIN category_images ci |
|||
ON c.cid = ci.cid AND ci.orderby = 1 |
|||
LEFT JOIN subcategory sc |
|||
ON c.cid = sc.cid AND sc.isactive = 1 AND sc.isdelete = 0 |
|||
WHERE c.isactive = 1 |
|||
AND c.isdelete = 0 |
|||
AND c.bid = ? |
|||
ORDER BY c.orderby ASC, sc.orderby ASC |
|||
"""; |
|||
|
|||
return jdbcTemplate.queryForList(sql, bid); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getPricingDetailsByCid(int cid) { |
|||
String sql = """ |
|||
SELECT sc.scid, sc.name, sc.display_name, sc.cid, sc.orderby, sc.cdate, sc.isactive, |
|||
sc.isdelete, sc.limits, sc.capacity, c.description |
|||
FROM subcategory sc |
|||
JOIN category c ON sc.cid = c.cid |
|||
WHERE sc.cid = ? AND sc.isactive = 1 AND sc.isdelete = 0 |
|||
"""; |
|||
return jdbcTemplate.queryForList(sql, cid); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getImgByCid(int cid) { |
|||
String sql = """ |
|||
SELECT * FROM category_images where cid = ? |
|||
AND isactive = 1 AND isdelete = 0 |
|||
"""; |
|||
return jdbcTemplate.queryForList(sql, cid); |
|||
} |
|||
} |
|||
@ -0,0 +1,96 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
import com.gcc.coworkspace.configuration.AppConfig; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class NormalSMS { |
|||
|
|||
@Autowired |
|||
private AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
private SMSService whatsappMsgService; |
|||
|
|||
private final String key = "pfTEYN6H"; |
|||
|
|||
public String sendOTPNsms(String MobileNo, String msg) { |
|||
String generatedToken = "Welcome to Muthalvar Padaippagam, The OTP for your booking is " + msg + " - GCC"; |
|||
String urlString = appConfig.getGetOtpUrl() + "from=GCCCRP&key=" + key + "&sender=GCCCRP&to=" + MobileNo + "&body=" + generatedToken + "&entityid=1401572690000011081&templateid=1407173027593091895"; |
|||
return whatsappMsgService.sendSMS(urlString); |
|||
} |
|||
|
|||
public String sendELearnNsms(String MobileNo, String noOfPerson, String bdate, String slot, String amount) { |
|||
String generatedToken = "Dear Patron, \n" + |
|||
"Welcome to Muthalvar Padaippagam. \n" + |
|||
"You have booked our Learning Centre for " + noOfPerson + " number of persons on " + bdate + " at time slot " + slot + ". Payment for the booking is Rs." + amount + " received. Please show your QR Code at Reception Desk for accessing Muthalvar Padaippagam. Have a Nice Day - GCC"; |
|||
String urlString = appConfig.getGetOtpUrl() + "from=GCCCRP&key=" + key + "&sender=GCCCRP&to=" + MobileNo + "&body=" + generatedToken + "&entityid=1401572690000011081&templateid=1407173027552104564"; |
|||
return whatsappMsgService.sendSMS(urlString); |
|||
} |
|||
|
|||
public String sendTLearnNsms(String MobileNo, String noOfPerson, String bdate, String slot, String amount) { |
|||
String generatedToken = "அன்பான வாடிக்கையாளரே,\n" + |
|||
"முதல்வர் படைப்பகம் தங்களை அன்புடன் வரவேற்கின்றது. தாங்கள் எங்களின் கற்றல் மையத்தை "+ noOfPerson +" எண்ணிக்கை நபர்களுக்கு "+bdate+" அன்று நேர இடைவெளி "+bdate+" ல் பயன்படுத்திக்கொள்ள முன்பதிவு செய்துள்ளீர்கள். இதற்கான கட்டணம் ரூ. "+amount+" பெறப்பட்டுள்ளது. முதல்வர் படைப்பகம் பயன்படுத்த உங்கள் QR குறியீட்டை வரவேற்பறையில் காட்டுங்கள் இந்நாள் இனிய நாளாய் அமையட்டும் - பெ.செ.மா"; |
|||
String urlString = appConfig.getGetOtpUrl() + "from=GCCCRP&key=" + key + "&sender=GCCCRP&to=" + MobileNo + "&body=" + generatedToken + "&entityid=1401572690000011081&templateid=1407173027534475535"; |
|||
return whatsappMsgService.sendSMS(urlString); |
|||
} |
|||
|
|||
public String sendEDeskspaceNsms(String MobileNo, String noOfPerson, String bdate, String slot, String amount) { |
|||
|
|||
String generatedToken ="Welcome to Muthalvar Padaippagam. \n" + |
|||
"You have booked our Desk space for "+noOfPerson+" number of persons on "+bdate+" at time slot "+slot+". Payment for the booking is Rs. "+amount+" received. Please show your QR Code at Reception Desk for accessing Muthalvar Padaippagam. Have a Nice Day - GCC"; |
|||
String urlString = appConfig.getGetOtpUrl() + "from=GCCCRP&key=" + key + "&sender=GCCCRP&to=" + MobileNo + "&body=" + generatedToken + "&entityid=1401572690000011081&templateid=1407173027483767802"; |
|||
return whatsappMsgService.sendSMS(urlString); |
|||
} |
|||
|
|||
public String sendTDeskspaceNsms(String MobileNo, String noOfPerson, String bdate, String slot, String amount) { |
|||
|
|||
String generatedToken ="அன்பான வாடிக்கையாளரே, முதல்வர் படைப்பகம் தங்களை அன்புடன் வரவேற்கின்றது. தாங்கள் எங்களின் மேசை இடத்தினை "+noOfPerson+" எண்ணிக்கை நபர்களுக்கு "+bdate+" அன்று நேர இடைவெளி "+slot+" ல் பயன்படுத்திக்கொள்ள முன்பதிவு செய்துள்ளீர்கள். இதற்கான கட்டணம் ரூ "+amount+" பெறப்பட்டுள்ளது. முதல்வர் படைப்பகம் பயன்படுத்த உங்கள் QR குறியீட்டை வரவேற்பறையில் காட்டுங்கள் இந்நாள் இனிய நாளாய் அமையட்டும் - பெ.செ.மா"; |
|||
|
|||
String urlString = appConfig.getGetOtpUrl() + "from=GCCCRP&key=" + key + "&sender=GCCCRP&to=" + MobileNo + "&body=" + generatedToken + "&entityid=1401572690000011081&templateid=1407173027432906761"; |
|||
return whatsappMsgService.sendSMS(urlString); |
|||
} |
|||
|
|||
public String sendEMonthDeskspaceNsms(String MobileNo, String noOfPerson, String bdate, String slot, String amount) { |
|||
|
|||
String generatedToken ="Dear Patron,\n" + |
|||
"Welcome to Muthalvar Padaippagam. You have booked our Desk space for "+noOfPerson+" number of persons for 30 days from "+bdate+" at time slot "+slot+". Payment for the booking is Rs. "+amount+" received. Please show your QR Code at Reception Desk for accessing Muthalvar Padaippagam. Have a Nice Day - GCC" ; |
|||
|
|||
String urlString = appConfig.getGetOtpUrl() + "from=GCCCRP&key=" + key + "&sender=GCCCRP&to=" + MobileNo + "&body=" + generatedToken + "&entityid=1401572690000011081&templateid=1407173027375118705"; |
|||
return whatsappMsgService.sendSMS(urlString); |
|||
} |
|||
|
|||
public String sendTMonthDeskspaceNsms(String MobileNo, String noOfPerson, String bdate, String slot, String amount) { |
|||
|
|||
String generatedToken = "அன்பான வாடிக்கையாளரே, \n" + |
|||
"முதல்வர் படைப்பகம் தங்களை அன்புடன் வரவேற்கின்றது. \n" + |
|||
"தாங்கள் எங்களின் மேசை இடத்தை "+noOfPerson+" எண்ணிக்கை நபர்களுக்கு 30 நாட்கள் "+bdate+" முதல் "+slot+" வரை நேர இடைவெளி {#var#} ல் பயன்படுத்திக்கொள்ள முன்பதிவு செய்துள்ளீர்கள். இதற்கான கட்டணம் ரூ "+amount+" பெறப்பட்டுள்ளது. முதல்வர் படைப்பகம் பயன்படுத்த உங்கள் QR குறியீட்டை வரவேற்பறையில் காட்டுங்கள் இந்நாள் இனிய நாளாய் அமையட்டும் - பெ.செ.மா"; |
|||
|
|||
String urlString = appConfig.getGetOtpUrl() + "from=GCCCRP&key=" + key + "&sender=GCCCRP&to=" + MobileNo + "&body=" + generatedToken + "&entityid=1401572690000011081&templateid=1407173027375118705"; |
|||
return whatsappMsgService.sendSMS(urlString); |
|||
|
|||
} |
|||
|
|||
public String sendEConfeNsms(String MobileNo, String bdate, String slot, String amount) { |
|||
String generatedToken ="Dear Patron, \n" + |
|||
"Welcome to Muthalvar Padaippagam.\n" + |
|||
"You have booked our Conference Hall on "+bdate+" at time slot "+slot+". Payment for the booking is Rs. "+amount+" received. Please show your QR Code at Reception Desk for accessing Muthalvar Padaippagam. Have a Nice Day - GCC"; |
|||
String urlString = appConfig.getGetOtpUrl() + "from=GCCCRP&key=" + key + "&sender=GCCCRP&to=" + MobileNo + "&body=" + generatedToken + "&entityid=1401572690000011081&templateid=1407173027286475722"; |
|||
return whatsappMsgService.sendSMS(urlString); |
|||
|
|||
} |
|||
|
|||
public String sendTConfeNsms(String MobileNo, String bdate, String slot, String amount) { |
|||
|
|||
String generatedToken ="அன்பான வாடிக்கையாளரே, \n" + |
|||
"முதல்வர் படைப்பகம் தங்களை அன்புடன் வரவேற்கின்றது.\n" + |
|||
"தாங்கள் எங்களின் கலந்தாய்வு அரங்கத்தினை "+bdate+" அன்று நேர இடைவெளி "+slot+" ல் பயன்படுத்திக்கொள்ள முன்பதிவு செய்துள்ளீர்கள். \n" + |
|||
"இதற்கான கட்டணம் ரூ. "+amount+" பெறப்பட்டுள்ளது. முதல்வர் படைப்பகம் பயன்படுத்த உங்கள் QR குறியீட்டை வரவேற்பறையில் காட்டுங்கள் இந்நாள் இனிய நாளாய் அமையட்டும்- பெ.செ.மா"; |
|||
String urlString = appConfig.getGetOtpUrl() + "from=GCCCRP&key=" + key + "&sender=GCCCRP&to=" + MobileNo + "&body=" + generatedToken + "&entityid=1401572690000011081&templateid=1407173027263977351"; |
|||
return whatsappMsgService.sendSMS(urlString); |
|||
|
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,173 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.dao.DataAccessException; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.jdbc.core.PreparedStatementCreator; |
|||
import org.springframework.jdbc.support.GeneratedKeyHolder; |
|||
import org.springframework.jdbc.support.KeyHolder; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.sql.Connection; |
|||
import java.sql.PreparedStatement; |
|||
import java.sql.SQLException; |
|||
import java.time.LocalDateTime; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class PaymentService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
@Transactional |
|||
public int savePayment( String totalAmount, |
|||
String payment_id, |
|||
String payment_orderid, |
|||
String payment_status, |
|||
String bookingId, |
|||
String mobile_no |
|||
){ |
|||
|
|||
|
|||
int lastInsertId = 0; |
|||
|
|||
String sqlQuery = "INSERT INTO `payment`(`amount`, `mobno`, `order_id`, `payment_id`, `payment_status`, `paymentdate`, `booking_id`) " |
|||
+ "VALUES (?,?,?,?,?,?,?)"; |
|||
|
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
|
|||
try { |
|||
int affectedRows = jdbcTemplate.update(new PreparedStatementCreator() { |
|||
@Override |
|||
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
|||
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); |
|||
ps.setString(1, totalAmount); |
|||
ps.setString(2, mobile_no); |
|||
ps.setString(3, payment_orderid); |
|||
ps.setString(4, payment_id); |
|||
ps.setString(5, payment_status); |
|||
ps.setString(6, LocalDateTime.now().toString()); |
|||
ps.setString(7, bookingId); |
|||
return ps; |
|||
} |
|||
}, keyHolder); |
|||
|
|||
if (affectedRows > 0) { |
|||
Number generatedId = keyHolder.getKey(); |
|||
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
|||
return lastInsertId; |
|||
} else { |
|||
System.out.println("Error on temp save!"); |
|||
return 0; |
|||
} |
|||
} catch (DataAccessException e) { |
|||
System.out.println("Data Access Exception:"); |
|||
Throwable rootCause = e.getMostSpecificCause(); |
|||
if (rootCause instanceof SQLException) { |
|||
SQLException sqlException = (SQLException) rootCause; |
|||
System.out.println("SQL State: " + sqlException.getSQLState()); |
|||
System.out.println("Error Code: " + sqlException.getErrorCode()); |
|||
System.out.println("Message: " + sqlException.getMessage()); |
|||
} else { |
|||
System.out.println("Message: " + rootCause.getMessage()); |
|||
} |
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public int saveorderLog( |
|||
String order_id, |
|||
String order_info, |
|||
String temp_booking_id |
|||
|
|||
) { |
|||
|
|||
|
|||
int lastInsertId = 0; |
|||
|
|||
String sqlQuery = "INSERT INTO `order_log`(`order_id`, `order_info`, `temp_booking_id`) " |
|||
+ "VALUES (?,?,?)"; |
|||
|
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
|
|||
try { |
|||
int affectedRows = jdbcTemplate.update(new PreparedStatementCreator() { |
|||
@Override |
|||
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
|||
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); |
|||
ps.setString(1, order_id); |
|||
ps.setString(2, order_info); |
|||
ps.setString(3, temp_booking_id); |
|||
|
|||
return ps; |
|||
} |
|||
}, keyHolder); |
|||
|
|||
if (affectedRows > 0) { |
|||
Number generatedId = keyHolder.getKey(); |
|||
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
|||
return lastInsertId; |
|||
} else { |
|||
System.out.println("Error on temp save!"); |
|||
} |
|||
} catch (DataAccessException e) { |
|||
System.out.println("Data Access Exception:"); |
|||
Throwable rootCause = e.getMostSpecificCause(); |
|||
if (rootCause instanceof SQLException) { |
|||
SQLException sqlException = (SQLException) rootCause; |
|||
System.out.println("SQL State: " + sqlException.getSQLState()); |
|||
System.out.println("Error Code: " + sqlException.getErrorCode()); |
|||
System.out.println("Message: " + sqlException.getMessage()); |
|||
} else { |
|||
System.out.println("Message: " + rootCause.getMessage()); |
|||
} |
|||
} |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public int updateBookingIdInPayment(String mobile_no,String bookingId,String payment_id) { |
|||
String sqlQuery = "UPDATE `payment` SET `mobno` = ?, `booking_id` = ? WHERE `id` = ?"; |
|||
|
|||
try { |
|||
int affectedRows = jdbcTemplate.update(new PreparedStatementCreator() { |
|||
@Override |
|||
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
|||
PreparedStatement ps = connection.prepareStatement(sqlQuery); |
|||
ps.setString(1, mobile_no); // Set the new mobile number |
|||
ps.setString(2, bookingId); // Set the new booking ID |
|||
ps.setString(3, payment_id); // Use the payment ID to locate the record to update |
|||
return ps; |
|||
} |
|||
}); |
|||
|
|||
if (affectedRows > 0) { |
|||
System.out.println("Record updated successfully!"); |
|||
return 1; // Or return some relevant status |
|||
} else { |
|||
System.out.println("Error on updating record!"); |
|||
return 0; |
|||
} |
|||
} catch (DataAccessException e) { |
|||
System.out.println("Data Access Exception:"); |
|||
Throwable rootCause = e.getMostSpecificCause(); |
|||
if (rootCause instanceof SQLException) { |
|||
SQLException sqlException = (SQLException) rootCause; |
|||
System.out.println("SQL State: " + sqlException.getSQLState()); |
|||
System.out.println("Error Code: " + sqlException.getErrorCode()); |
|||
System.out.println("Message: " + sqlException.getMessage()); |
|||
} else { |
|||
System.out.println("Message: " + rootCause.getMessage()); |
|||
} |
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
public Map<String, Object > getPaymentById(int pid){ |
|||
String sqlQuery="select * from payment where id = ?"; |
|||
return jdbcTemplate.queryForMap(sqlQuery,pid); |
|||
} |
|||
} |
|||
@ -0,0 +1,288 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
import java.sql.Connection; |
|||
import java.sql.PreparedStatement; |
|||
import java.sql.SQLException; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import com.gcc.coworkspace.constants.AppConstants; |
|||
import com.razorpay.RazorpayClient; |
|||
import com.razorpay.RazorpayException; |
|||
import org.json.JSONObject; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.dao.DataAccessException; |
|||
import org.springframework.dao.EmptyResultDataAccessException; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.jdbc.core.PreparedStatementCreator; |
|||
import org.springframework.jdbc.support.GeneratedKeyHolder; |
|||
import org.springframework.jdbc.support.KeyHolder; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class RefundService { |
|||
|
|||
@Autowired |
|||
PaymentService paymentService; |
|||
|
|||
@Autowired |
|||
BookingService bookingService; |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
public List<Map<String, Object>> refund(int refund_id) { |
|||
String refundsql = "select * from refund_info where refund_id=?"; |
|||
|
|||
return jdbcTemplate.queryForList(refundsql.toString(), refund_id); |
|||
|
|||
} |
|||
|
|||
public List<Map<String, Object>> getbyrefundstatus(String refundstatus) { |
|||
String refundsql1 = "select * from refund_info where refund_status=? and cdate < NOW() - INTERVAL 1 DAY"; |
|||
return jdbcTemplate.queryForList(refundsql1.toString(), refundstatus); ///nededd to updated |
|||
} |
|||
|
|||
|
|||
public void updateRefundRrnStatus(int id, String refund_id, String rrn, String rrn_status) { |
|||
String sql = "UPDATE refund_info SET refund_status = ?, rrn = ? WHERE refund_id = ? AND id = ?"; |
|||
jdbcTemplate.update(sql, rrn_status, rrn, refund_id, id); |
|||
} |
|||
|
|||
public void updateOrderStatus(String orderId, String orderStatus) { |
|||
String sql = "UPDATE order_log SET order_status = ? WHERE order_id = ? and id=? "; |
|||
int rowsAffected = jdbcTemplate.update(sql, orderStatus, orderId); |
|||
System.out.println("Updated Order ID: " + orderId + " with status: " + orderStatus); |
|||
System.out.println("Rows affected: " + rowsAffected); // Add this line |
|||
} |
|||
|
|||
|
|||
public List<Map<String , Object>> checkPaymentStatusByMobile(long mobileno) { |
|||
String sqlQuery = "SELECT " + |
|||
"DATE_FORMAT(tbd.from_date, '%d-%m-%Y') AS from_date, " + |
|||
"DATE_FORMAT(tbd.to_date, '%d-%m-%Y') AS to_date, " + |
|||
"DATE_FORMAT(tbd.cdate, '%d-%m-%Y') AS cdate, " + |
|||
"tbd.tempbookid, " + |
|||
"tbd.amount, " + |
|||
"tbd.no_of_person, " + |
|||
"tbd.slotids, " + |
|||
"bu.name AS buildingname, " + |
|||
"st.name AS duration, " + |
|||
"c.name AS type, " + |
|||
"c.display_name AS type_name, " + |
|||
"SUBSTRING_INDEX(st.name, ' to ', 1) AS checkin, " + |
|||
"SUBSTRING_INDEX(st.name, ' to ', -1) AS checkout, " + |
|||
"TIMESTAMPDIFF( " + |
|||
" HOUR, " + |
|||
" STR_TO_DATE(SUBSTRING_INDEX(st.name, ' to ', 1), '%h:%i %p'), " + |
|||
" STR_TO_DATE(SUBSTRING_INDEX(st.name, ' to ', -1), '%h:%i %p') " + |
|||
") AS duration_hours, " + |
|||
"CASE " + |
|||
" WHEN tbd.to_date < CURDATE() THEN 'Completed' " + |
|||
" WHEN (tbd.from_date > CURDATE() OR tbd.to_date > CURDATE()) THEN 'Upcoming' " + |
|||
" ELSE 'Ongoing' " + |
|||
"END AS status " + |
|||
"FROM temp_booking tbd " + |
|||
"JOIN slots st ON tbd.slotids = st.slotid " + |
|||
"JOIN buildings bu ON tbd.bid = bu.bid " + |
|||
"JOIN category c ON tbd.cid = c.cid " + |
|||
"join order_log ol on ol.temp_booking_id=tbd.tempbookid and (ol.order_status is null or ol.order_status = '')"+ |
|||
"WHERE tbd.mobile = ?"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery, mobileno); |
|||
} |
|||
|
|||
public ResponseEntity<?> refundProcess(String msg, int bookingId, int pid) throws RazorpayException { |
|||
Map<String,Object> pay = paymentService.getPaymentById(pid); |
|||
String paymentId = pay.get("payment_id").toString(); |
|||
double amount = Double.parseDouble(pay.get("amount")+""); |
|||
RazorpayClient razorpay = new RazorpayClient(AppConstants.key_id, AppConstants.key_secret); |
|||
|
|||
|
|||
JSONObject refundRequest = new JSONObject(); |
|||
refundRequest.put("amount",amount*100); |
|||
refundRequest.put("speed","normal"); |
|||
JSONObject notes = new JSONObject(); |
|||
notes.put("notes_key_1",msg); |
|||
refundRequest.put("notes",notes); |
|||
|
|||
com.razorpay.Refund payment = razorpay.payments.refund(paymentId,refundRequest); |
|||
JSONObject pj = payment.toJson(); |
|||
System.out.println( payment.toJson()); |
|||
if(pj.get("id")!=null){ |
|||
double amt = 0; |
|||
if(pj.get("amount")!=null){ |
|||
amt = (Double.parseDouble(pj.get("amount")+"")/100); |
|||
} |
|||
saveRefund(bookingId,pid,amt,pj.get("id").toString(),"REFUND_PROCESSED", payment.toJson().toString()); |
|||
bookingService.updateBookingStatus(bookingId,"refunded"); |
|||
} |
|||
else{ |
|||
saveRefund(bookingId,pid,0,"","REJECTED", payment.toJson().toString()); |
|||
} |
|||
|
|||
return ResponseEntity.ok(payment.toJson().toString()); |
|||
|
|||
} |
|||
|
|||
public int saveRefund(int bookingId,int pid,double refundAmount,String refundId,String refundStatus,String desc){ |
|||
|
|||
|
|||
List<Map<String, Object>> result=null; |
|||
Map<String, Object> response = new HashMap<>(); |
|||
int calendarId = 0; |
|||
|
|||
String sqlQuery = "INSERT INTO refund_info (bookingId, refund_amt, balance_amt, pid, refund_id, refund_status, r_desc) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?)"; |
|||
|
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
|
|||
System.out.println("Inserting Refund Info:"); |
|||
System.out.println(" bookingId = " + bookingId); |
|||
System.out.println(" refundAmount = " + refundAmount); |
|||
System.out.println(" pid = " + pid); |
|||
System.out.println(" refundId = " + refundId); |
|||
System.out.println(" refundStatus = " + refundStatus); |
|||
System.out.println(" desc = " + desc); |
|||
|
|||
try { |
|||
int affectedRows = jdbcTemplate.update(new PreparedStatementCreator() { |
|||
@Override |
|||
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
|||
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); |
|||
ps.setInt(1, bookingId); // Fix: Use setInt for bookingId |
|||
ps.setDouble(2, refundAmount); // Fix: Use setDouble for refund_amt |
|||
ps.setDouble(3, 0.0); // Fix: Add balance_amt (defaulting to 0) |
|||
ps.setInt(4, pid); // Fix: Use setInt for pid |
|||
ps.setString(5, refundId); |
|||
ps.setString(6, refundStatus); |
|||
ps.setString(7, desc); |
|||
|
|||
return ps; |
|||
} |
|||
}, keyHolder); |
|||
|
|||
if (affectedRows > 0) { |
|||
Number generatedId = keyHolder.getKey(); |
|||
calendarId = (generatedId != null) ? generatedId.intValue() : 0; |
|||
return calendarId; |
|||
} else { |
|||
return 10; |
|||
} |
|||
} catch (DataAccessException e) { |
|||
System.out.println("Data Access Exception:"); |
|||
Throwable rootCause = e.getMostSpecificCause(); |
|||
if (rootCause instanceof SQLException) { |
|||
SQLException sqlException = (SQLException) rootCause; |
|||
System.out.println("SQL State: " + sqlException.getSQLState()); |
|||
System.out.println("Error Code: " + sqlException.getErrorCode()); |
|||
System.out.println("Message: " + sqlException.getMessage()); |
|||
return 0; |
|||
} else { |
|||
System.out.println("Message: " + rootCause.getMessage()); |
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
public ResponseEntity<?> refundProcessOrder(String msg, int bookingId, int pid) { |
|||
try { |
|||
Map<String, Object> pay = paymentService.getPaymentById(pid); |
|||
if (pay == null || pay.isEmpty()) { |
|||
return ResponseEntity.badRequest().body("No payment found for given id"); |
|||
} |
|||
|
|||
String paymentId = pay.get("payment_id").toString(); |
|||
double amount = Double.parseDouble(pay.get("amount") + ""); |
|||
|
|||
RazorpayClient razorpay = new RazorpayClient(AppConstants.key_id, AppConstants.key_secret); |
|||
|
|||
JSONObject refundRequest = new JSONObject(); |
|||
refundRequest.put("amount", amount * 100); |
|||
refundRequest.put("speed", "normal"); |
|||
|
|||
JSONObject notes = new JSONObject(); |
|||
notes.put("notes_key_1", msg); |
|||
refundRequest.put("notes", notes); |
|||
|
|||
com.razorpay.Refund payment = razorpay.payments.refund(paymentId, refundRequest); |
|||
JSONObject pj = payment.toJson(); |
|||
//new update |
|||
System.err.println("Refund Process Order:line 216"); |
|||
System.err.println(pj); |
|||
System.err.println("refundProcessOrder ->"+pj.get("id")+"bookingId:-"+bookingId +"pid:-"+pid); |
|||
if (pj.get("id") != null) { |
|||
double amt = (pj.get("amount") != null) ? (Double.parseDouble(pj.get("amount") + "") / 100) : 0; |
|||
saveRefundOrder(bookingId, pid, amt, pj.get("id").toString(), "REFUND_PROCESSED", pj.toString()); |
|||
if(bookingId != 0) { |
|||
bookingService.updateBookingStatus(bookingId, "refunded"); |
|||
} |
|||
} else { |
|||
saveRefundOrder(bookingId, pid, 0, "", "REJECTED", pj.toString()); |
|||
} |
|||
|
|||
return ResponseEntity.ok(pj.toString()); |
|||
|
|||
} catch (RazorpayException e) { |
|||
|
|||
if (e.getMessage().contains("fully refunded")) { |
|||
System.err.println("Already refunded: " + e.getMessage()); |
|||
saveRefundOrder(bookingId, pid, 0, "", "ALREADY_REFUNDED", e.getMessage()); |
|||
if(bookingId != 0) { |
|||
bookingService.updateBookingStatus(bookingId, "refunded"); |
|||
} |
|||
return ResponseEntity.ok("Already refunded"); |
|||
} |
|||
return ResponseEntity.status(500).body("Refund failed: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
public int saveRefundOrder(int bookingId, int pid, double refundAmount, String refundId, String refundStatus, String desc) { |
|||
try { |
|||
updateRefundStatusInOrderLog(pid, true); |
|||
// Insert new refund record |
|||
String sqlQuery = "INSERT INTO refund_info (bookingId, refund_amt, balance_amt, pid, refund_id, refund_status, r_desc) VALUES (?, ?, ?, ?, ?, ?, ?)"; |
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
|
|||
int affectedRows = jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); |
|||
ps.setInt(1, bookingId); |
|||
ps.setDouble(2, refundAmount); |
|||
ps.setDouble(3, 0.0); |
|||
ps.setInt(4, pid); |
|||
ps.setString(5, refundId); |
|||
ps.setString(6, refundStatus); |
|||
ps.setString(7, desc != null ? desc : ""); |
|||
return ps; |
|||
}, keyHolder); |
|||
|
|||
if (affectedRows > 0) { |
|||
Number generatedId = keyHolder.getKey(); |
|||
return (generatedId != null) ? generatedId.intValue() : -1; |
|||
} else { |
|||
return -1; // Indicate failure |
|||
} |
|||
|
|||
} catch (EmptyResultDataAccessException e) { |
|||
System.err.println("No existing refund record found, proceeding with insert."); |
|||
} catch (DataAccessException e) { |
|||
System.err.println("saveRefundOrder Database error: " + e.getMessage()); |
|||
} |
|||
|
|||
return -1; |
|||
} |
|||
|
|||
public void updateRefundStatusInOrderLog(int pid, boolean isRefundedProcessed) { |
|||
|
|||
|
|||
String sql = "UPDATE order_log od inner join payment pay on od.order_id = pay.order_id SET od.sch_refund_status = ? WHERE pay.id = ?"; |
|||
|
|||
jdbcTemplate.update(sql, isRefundedProcessed, pid); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,265 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
import java.sql.Connection; |
|||
import java.sql.PreparedStatement; |
|||
import java.sql.SQLException; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import com.gcc.coworkspace.constants.AppConstants; |
|||
import com.razorpay.RazorpayClient; |
|||
import com.razorpay.RazorpayException; |
|||
import org.json.JSONObject; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.dao.DataAccessException; |
|||
import org.springframework.dao.EmptyResultDataAccessException; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.jdbc.core.PreparedStatementCreator; |
|||
import org.springframework.jdbc.support.GeneratedKeyHolder; |
|||
import org.springframework.jdbc.support.KeyHolder; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class RefundService_old { |
|||
|
|||
@Autowired |
|||
PaymentService paymentService; |
|||
|
|||
@Autowired |
|||
BookingService bookingService; |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
public List<Map<String, Object>> refund(int refund_id) { |
|||
String refundsql = "select * from refund_info where where refund_id=?"; |
|||
|
|||
return jdbcTemplate.queryForList(refundsql.toString(), refund_id); |
|||
|
|||
} |
|||
|
|||
public List<Map<String, Object>> getbyrefundstatus(String refundstatus) { |
|||
String refundsql1 = "select * from refund_info where refund_status=? and cdate < NOW() - INTERVAL 1 DAY"; |
|||
return jdbcTemplate.queryForList(refundsql1.toString(), refundstatus); ///nededd to updated |
|||
} |
|||
|
|||
|
|||
public void updateRefundRrnStatus(int id, String refund_id, String rrn, String rrn_status) { |
|||
String sql = "UPDATE refund_info SET refund_status = ?, rrn = ? WHERE refund_id = ? AND id = ?"; |
|||
jdbcTemplate.update(sql, rrn_status, rrn, refund_id, id); |
|||
} |
|||
|
|||
public void updateOrderStatus(String orderId, String orderStatus) { |
|||
String sql = "UPDATE order_log SET order_status = ? WHERE order_id = ? and id=? "; |
|||
int rowsAffected = jdbcTemplate.update(sql, orderStatus, orderId); |
|||
System.out.println("Updated Order ID: " + orderId + " with status: " + orderStatus); |
|||
System.out.println("Rows affected: " + rowsAffected); // Add this line |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> checkPaymentStatusByMobile(long mobileno) { |
|||
String sqlQuery = "SELECT " + |
|||
"DATE_FORMAT(tbd.from_date, '%d-%m-%Y') AS from_date, " + |
|||
"DATE_FORMAT(tbd.to_date, '%d-%m-%Y') AS to_date, " + |
|||
"DATE_FORMAT(tbd.cdate, '%d-%m-%Y') AS cdate, " + |
|||
"tbd.tempbookid, " + |
|||
"tbd.amount, " + |
|||
"tbd.no_of_person, " + |
|||
"tbd.slotids, " + |
|||
"bu.name AS buildingname, " + |
|||
"st.name AS duration, " + |
|||
"c.name AS type, " + |
|||
"c.display_name AS type_name, " + |
|||
"SUBSTRING_INDEX(st.name, ' to ', 1) AS checkin, " + |
|||
"SUBSTRING_INDEX(st.name, ' to ', -1) AS checkout, " + |
|||
"TIMESTAMPDIFF( " + |
|||
" HOUR, " + |
|||
" STR_TO_DATE(SUBSTRING_INDEX(st.name, ' to ', 1), '%h:%i %p'), " + |
|||
" STR_TO_DATE(SUBSTRING_INDEX(st.name, ' to ', -1), '%h:%i %p') " + |
|||
") AS duration_hours, " + |
|||
"CASE " + |
|||
" WHEN tbd.to_date < CURDATE() THEN 'Completed' " + |
|||
" WHEN (tbd.from_date > CURDATE() OR tbd.to_date > CURDATE()) THEN 'Upcoming' " + |
|||
" ELSE 'Ongoing' " + |
|||
"END AS status " + |
|||
"FROM temp_booking tbd " + |
|||
"JOIN slots st ON tbd.slotids = st.slotid " + |
|||
"JOIN buildings bu ON tbd.bid = bu.bid " + |
|||
"JOIN category c ON tbd.cid = c.cid " + |
|||
"join order_log ol on ol.temp_booking_id=tbd.tempbookid and (ol.order_status is null or ol.order_status = '')"+ |
|||
"WHERE tbd.mobile = ?"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery, mobileno); |
|||
} |
|||
|
|||
public ResponseEntity<?> refundProcess(String msg, int bookingId, int pid) throws RazorpayException { |
|||
Map<String,Object> pay = paymentService.getPaymentById(pid); |
|||
String paymentId = pay.get("payment_id").toString(); |
|||
double amount = Double.parseDouble(pay.get("amount")+""); |
|||
RazorpayClient razorpay = new RazorpayClient(AppConstants.key_id, AppConstants.key_secret); |
|||
|
|||
|
|||
JSONObject refundRequest = new JSONObject(); |
|||
refundRequest.put("amount",amount*100); |
|||
refundRequest.put("speed","normal"); |
|||
JSONObject notes = new JSONObject(); |
|||
notes.put("notes_key_1",msg); |
|||
refundRequest.put("notes",notes); |
|||
|
|||
com.razorpay.Refund payment = razorpay.payments.refund(paymentId,refundRequest); |
|||
JSONObject pj = payment.toJson(); |
|||
System.out.println( payment.toJson()); |
|||
if(pj.get("id")!=null){ |
|||
double amt = 0; |
|||
if(pj.get("amount")!=null){ |
|||
amt = (Double.parseDouble(pj.get("amount")+"")/100); |
|||
} |
|||
saveRefund(bookingId,pid,amt,pj.get("id").toString(),"REFUND_PROCESSED", payment.toJson().toString()); |
|||
bookingService.updateBookingStatus(bookingId,"refunded"); |
|||
} |
|||
else{ |
|||
saveRefund(bookingId,pid,0,"","REJECTED", payment.toJson().toString()); |
|||
} |
|||
|
|||
return ResponseEntity.ok(payment.toJson().toString()); |
|||
|
|||
} |
|||
|
|||
public int saveRefund(int bookingId,int pid,double refundAmount,String refundId,String refundStatus,String desc){ |
|||
List<Map<String, Object>> result=null; |
|||
Map<String, Object> response = new HashMap<>(); |
|||
int calendarId = 0; |
|||
|
|||
String sqlQuery = "INSERT INTO refund_info (bookingId, refund_amt, pid, refund_id, refund_status, r_desc) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?)"; |
|||
|
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
|
|||
try { |
|||
int affectedRows = jdbcTemplate.update(new PreparedStatementCreator() { |
|||
@Override |
|||
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
|||
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); |
|||
ps.setString(1, bookingId+""); |
|||
ps.setString(2, refundAmount+""); |
|||
ps.setString(3, pid+""); |
|||
ps.setString(4, refundId); |
|||
ps.setString(5, refundStatus); |
|||
ps.setString(6, desc); |
|||
|
|||
return ps; |
|||
} |
|||
}, keyHolder); |
|||
|
|||
if (affectedRows > 0) { |
|||
Number generatedId = keyHolder.getKey(); |
|||
calendarId = (generatedId != null) ? generatedId.intValue() : 0; |
|||
return calendarId; |
|||
} else { |
|||
return 10; |
|||
} |
|||
} catch (DataAccessException e) { |
|||
System.out.println("Data Access Exception:"); |
|||
Throwable rootCause = e.getMostSpecificCause(); |
|||
if (rootCause instanceof SQLException) { |
|||
SQLException sqlException = (SQLException) rootCause; |
|||
System.out.println("SQL State: " + sqlException.getSQLState()); |
|||
System.out.println("Error Code: " + sqlException.getErrorCode()); |
|||
System.out.println("Message: " + sqlException.getMessage()); |
|||
return 0; |
|||
} else { |
|||
System.out.println("Message: " + rootCause.getMessage()); |
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
public ResponseEntity<?> refundProcessOrder(String msg, int bookingId, int pid) { |
|||
try { |
|||
Map<String, Object> pay = paymentService.getPaymentById(pid); |
|||
if (pay == null || pay.isEmpty()) { |
|||
return ResponseEntity.badRequest().body("No payment found for given id"); |
|||
} |
|||
|
|||
String paymentId = pay.get("payment_id").toString(); |
|||
double amount = Double.parseDouble(pay.get("amount") + ""); |
|||
|
|||
RazorpayClient razorpay = new RazorpayClient(AppConstants.key_id, AppConstants.key_secret); |
|||
|
|||
JSONObject refundRequest = new JSONObject(); |
|||
refundRequest.put("amount", amount * 100); |
|||
refundRequest.put("speed", "normal"); |
|||
|
|||
JSONObject notes = new JSONObject(); |
|||
notes.put("notes_key_1", msg); |
|||
refundRequest.put("notes", notes); |
|||
|
|||
com.razorpay.Refund payment = razorpay.payments.refund(paymentId, refundRequest); |
|||
JSONObject pj = payment.toJson(); |
|||
|
|||
if (pj.get("id") != null) { |
|||
double amt = (pj.get("amount") != null) ? (Double.parseDouble(pj.get("amount") + "") / 100) : 0; |
|||
saveRefundOrder(bookingId, pid, amt, pj.get("id").toString(), "REFUND_PROCESSED", pj.toString()); |
|||
if(bookingId != 0) { |
|||
bookingService.updateBookingStatus(bookingId, "refunded"); |
|||
} |
|||
} else { |
|||
saveRefundOrder(bookingId, pid, 0, "", "REJECTED", pj.toString()); |
|||
} |
|||
|
|||
return ResponseEntity.ok(pj.toString()); |
|||
|
|||
} catch (RazorpayException e) { |
|||
// ✅ This handles the already refunded case and still logs it |
|||
if (e.getMessage().contains("fully refunded")) { |
|||
System.err.println("Already refunded: " + e.getMessage()); |
|||
saveRefundOrder(bookingId, pid, 0, "", "ALREADY_REFUNDED", e.getMessage()); |
|||
if(bookingId != 0) { |
|||
bookingService.updateBookingStatus(bookingId, "refunded"); |
|||
} |
|||
return ResponseEntity.ok("Already refunded"); |
|||
} |
|||
return ResponseEntity.status(500).body("Refund failed: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
public int saveRefundOrder(int bookingId, int pid, double refundAmount, String refundId, String refundStatus, String desc) { |
|||
try { |
|||
|
|||
// Insert new refund record |
|||
String sqlQuery = "INSERT INTO refund_info (bookingId, refund_amt, pid, refund_id, refund_status, r_desc) VALUES (?, ?, ?, ?, ?, ?)"; |
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
|
|||
int affectedRows = jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); |
|||
ps.setInt(1, bookingId); |
|||
ps.setDouble(2, refundAmount); |
|||
ps.setInt(3, pid); |
|||
ps.setString(4, refundId); |
|||
ps.setString(5, refundStatus); |
|||
ps.setString(6, desc); |
|||
return ps; |
|||
}, keyHolder); |
|||
|
|||
if (affectedRows > 0) { |
|||
Number generatedId = keyHolder.getKey(); |
|||
return (generatedId != null) ? generatedId.intValue() : -1; // Return new ID if available, otherwise return -1 |
|||
} else { |
|||
return -1; // Indicate failure |
|||
} |
|||
|
|||
} catch (EmptyResultDataAccessException e) { |
|||
System.err.println("No existing refund record found, proceeding with insert."); |
|||
} catch (DataAccessException e) { |
|||
System.err.println("Database error: " + e.getMessage()); |
|||
} |
|||
|
|||
return -1; // Return -1 to indicate failure |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,512 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class ReportService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
|
|||
|
|||
// public List<Map<String, Object>> getslotdateReports(String fromDate, String toDate, String type, String status, String filterBy, String type1) { |
|||
// StringBuilder sql = new StringBuilder( |
|||
// "SELECT " + |
|||
// "b.`booking_id`, b.`user_name`, b.`mobile`, b.`slotids`, b.`from_date`, b.`to_date`, " + |
|||
// "b.`no_of_person`, b.`amount`, b.`payment_status`, b.`cdate` AS bdate, sc.display_name, cl.bdate, " + |
|||
// "SUBSTRING_INDEX(sl.name, ' to ', 1) AS checkin, " + |
|||
// "SUBSTRING_INDEX(sl.name, ' to ', -1) AS checkout, " + |
|||
// "CASE " + |
|||
// " WHEN CURDATE() BETWEEN b.from_date AND b.to_date THEN 'Ongoing' " + |
|||
// " WHEN b.to_date < CURDATE() THEN 'Completed' " + |
|||
// " WHEN b.from_date > CURDATE() THEN 'Upcoming' " + |
|||
// " ELSE 'Ongoing' " + |
|||
// "END AS status, " + |
|||
// "cat.name AS type, cat.display_name AS type_name, sc.display_name AS subcategory_name " + |
|||
// "FROM `booking` b " + |
|||
// "JOIN `slots` sl ON b.`slotids` = sl.`slotid` " + |
|||
// "JOIN `category` cat ON b.`cid` = cat.`cid` " + |
|||
// "JOIN `subcategory` sc ON b.`sid` = sc.`scid` " + |
|||
// "JOIN `calendar` cl ON b.`booking_id` = cl.`bookingid` " |
|||
// ); |
|||
|
|||
// List<Object> params = new ArrayList<>(); |
|||
|
|||
// // Apply filters based on `filterBy` |
|||
// if ("slot_date".equals(filterBy)) { |
|||
// sql.append("WHERE cl.bdate >= STR_TO_DATE(?, '%Y-%m-%d') AND cl.bdate <= STR_TO_DATE(?, '%Y-%m-%d') "); |
|||
// params.add(fromDate); |
|||
// params.add(toDate); |
|||
// } else if ("current_date".equals(filterBy)) { |
|||
// sql.append("WHERE DATE(b.`cdate`) >= ? AND DATE(b.`cdate`) <= ? "); |
|||
// params.add(fromDate); |
|||
// params.add(toDate); |
|||
// } else { |
|||
// sql.append("WHERE 1=1 "); // For cases where no filter is applied |
|||
// } |
|||
|
|||
// // Additional filters |
|||
// if (type != null && !type.isEmpty()) { |
|||
// sql.append("AND cat.display_name = ? "); |
|||
// params.add(type); |
|||
// } |
|||
|
|||
// if (type1 != null && !type1.isEmpty()) { |
|||
// sql.append("AND sc.display_name = ? "); |
|||
// params.add(type1); |
|||
// } |
|||
|
|||
// if (status != null && !status.isEmpty()) { |
|||
// if ("Ongoing".equals(status)) { |
|||
// sql.append("AND CURDATE() BETWEEN b.`from_date` AND b.`to_date` "); |
|||
// } else if ("Completed".equals(status)) { |
|||
// sql.append("AND b.`to_date` < CURDATE() "); |
|||
// } else if ("Upcoming".equals(status)) { |
|||
// sql.append("AND b.`from_date` > CURDATE() "); |
|||
// } |
|||
// } |
|||
|
|||
// sql.append("ORDER BY b.`cdate` DESC"); |
|||
|
|||
// // Debugging for SQL and Parameters |
|||
// System.out.println("Generated SQL: " + sql); |
|||
// System.out.println("Parameters: " + params); |
|||
|
|||
// // Execute the query |
|||
// return jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
// } |
|||
|
|||
|
|||
// public List<Map<String, Object>> getbookingdateReports(String fromDate, String toDate, String type, String status, String filterBy, String type1) { |
|||
// StringBuilder sql = new StringBuilder( |
|||
// "SELECT " + |
|||
// "b.from_date, " + |
|||
// "b.to_date, " + |
|||
// "b.booking_id, " + |
|||
// "b.user_name, " + |
|||
// "b.mobile, " + |
|||
// "b.amount, " + |
|||
// "b.payment_status, " + |
|||
// "b.no_of_person, " + |
|||
// "b.slotids, " + |
|||
// "bu.name AS buildingname, " + |
|||
// "st.name AS duration, " + |
|||
// "ca.name AS type, " + |
|||
// "ca.display_name AS type_name, " + |
|||
// "b.from_date AS bdate, " + |
|||
// "b.cdate, " + |
|||
// "sc.display_name, " + |
|||
// "SUBSTRING_INDEX(st.name, ' to ', 1) AS checkin, " + |
|||
// "SUBSTRING_INDEX(st.name, ' to ', -1) AS checkout, " + |
|||
// "CASE " + |
|||
// " WHEN CURDATE() BETWEEN DATE(b.from_date) AND DATE(b.to_date) THEN 'Ongoing' " + |
|||
// " WHEN DATE(b.to_date) < CURDATE() THEN 'Completed' " + |
|||
// " WHEN DATE(b.from_date) > CURDATE() THEN 'Upcoming' " + |
|||
// "END AS status " + |
|||
// "FROM calendar c " + |
|||
// "INNER JOIN booking b ON c.bookingid = b.booking_id " + |
|||
// "JOIN buildings bu ON b.bid = bu.bid " + |
|||
// "JOIN slots st ON b.slotids = st.slotid " + |
|||
// "JOIN `subcategory` sc ON b.sid = sc.scid " + |
|||
// "JOIN category ca ON b.cid = ca.cid " + |
|||
// "WHERE DATE(c.cdate) BETWEEN ? AND ? " |
|||
// ); |
|||
|
|||
// List<Object> params = new ArrayList<>(); |
|||
// params.add(fromDate); |
|||
// params.add(toDate); |
|||
|
|||
// // Apply filter for subcategory |
|||
// if (type1 != null && !type1.isEmpty()) { |
|||
// sql.append("AND sc.display_name = ? "); |
|||
// params.add(type1); |
|||
// } |
|||
|
|||
// // Apply filter for category type |
|||
// if (type != null && !type.isEmpty()) { |
|||
// sql.append("AND ca.display_name = ? "); |
|||
// params.add(type); |
|||
// } |
|||
|
|||
// // Apply filter for booking status |
|||
// if (status != null && !status.isEmpty()) { |
|||
// sql.append( |
|||
// "AND ( " + |
|||
// " (CURDATE() BETWEEN DATE(b.from_date) AND DATE(b.to_date) AND ? = 'Ongoing') OR " + |
|||
// " (DATE(b.to_date) < CURDATE() AND ? = 'Completed') OR " + |
|||
// " (DATE(b.from_date) > CURDATE() AND ? = 'Upcoming') " + |
|||
// ") " |
|||
// ); |
|||
// params.add(status); |
|||
// params.add(status); |
|||
// params.add(status); |
|||
// } |
|||
|
|||
// // Group and order the results |
|||
// sql.append("GROUP BY b.from_date, b.to_date, b.booking_id, b.cdate "); |
|||
// sql.append("ORDER BY b.cdate DESC "); |
|||
|
|||
// System.out.println("Generated SQL: " + sql); |
|||
|
|||
// // Execute the query and return results |
|||
// return jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
// } |
|||
|
|||
// /* |
|||
// public List<Map<String, Object>> abstractReportPage() { |
|||
// String sql2 = "SELECT category.display_name, subcategory.display_name, slots.name, " + |
|||
// "SUM(booking.amount) AS total_amount, SUM(booking.no_of_person) AS total_persons " + |
|||
// "FROM booking " + |
|||
// "JOIN category ON category.cid = subcategory.cid " + |
|||
// "JOIN subcategory ON booking.cid = category.cid " + |
|||
// "JOIN slots ON booking.slotids = slots.slotid " + |
|||
// "WHERE DATE(booking.cdate) = CURDATE() " + |
|||
// "GROUP BY category.display_name, subcategory.display_name, slots.name"; |
|||
|
|||
// return jdbcTemplate.queryForList(sql2); |
|||
// } |
|||
// */ |
|||
// public List<Map<String, Object>> abstractReportPage(String fromDate, String toDate, String type, String type1) { |
|||
// // Base SQL query |
|||
// StringBuilder sql2 = new StringBuilder( |
|||
// "SELECT DATE(booking.cdate) AS created_date, " + |
|||
// "category.display_name AS category, " + |
|||
// "subcategory.display_name AS type, " + |
|||
// "slots.name AS slots, " + |
|||
// "SUM(booking.amount) AS amount, " + |
|||
// "SUM(booking.no_of_person) AS NO_of_person " + |
|||
// "FROM booking " + |
|||
// "JOIN subcategory ON booking.sid = subcategory.scid " + |
|||
// "JOIN category ON category.cid = subcategory.cid " + |
|||
// "JOIN slots ON booking.slotids = slots.slotid " + |
|||
// "WHERE booking.booking_status = 'success' " |
|||
// ); |
|||
|
|||
// // Parameters for the query |
|||
// List<Object> params = new ArrayList<>(); |
|||
|
|||
// // Handle default date to current date if no range is provided |
|||
// if ((fromDate == null || fromDate.isEmpty()) && (toDate == null || toDate.isEmpty())) { |
|||
// sql2.append("AND DATE(booking.cdate) = CURDATE() "); |
|||
// } else { |
|||
// // Use provided date range |
|||
// if (fromDate != null && !fromDate.isEmpty() && toDate != null && !toDate.isEmpty()) { |
|||
// sql2.append("AND DATE(booking.cdate) BETWEEN ? AND ? "); |
|||
// params.add(fromDate); |
|||
// params.add(toDate); |
|||
// } |
|||
// } |
|||
|
|||
// // Add subcategory filter if provided |
|||
// if (type1 != null && !type1.isEmpty()) { |
|||
// sql2.append("AND subcategory.display_name = ? "); |
|||
// params.add(type1); |
|||
// } |
|||
|
|||
// // Add category filter if provided |
|||
// if (type != null && !type.isEmpty()) { |
|||
// sql2.append("AND category.display_name = ? "); |
|||
// params.add(type); |
|||
// } |
|||
|
|||
// // Grouping |
|||
// sql2.append("GROUP BY booking_status, category.display_name, subcategory.display_name, slots.name, DATE(booking.cdate)"); |
|||
|
|||
// // Execute query and return results |
|||
// return jdbcTemplate.queryForList(sql2.toString(), params.toArray()); |
|||
// } |
|||
|
|||
|
|||
// public List<Map<String, Object>> getCalendarReport(String fromDate, String toDate) { |
|||
// StringBuilder sql = new StringBuilder(); |
|||
// sql.append("SELECT ") |
|||
// .append("DATE(c.bdate) AS booking_date, ") |
|||
// .append("cat.display_name AS type, ") |
|||
// .append("SUM(b.no_of_person) AS total_booked_count, ") |
|||
// .append("SUM(c.absent_count) AS total_absent_count ") |
|||
// .append("FROM calendar c ") |
|||
// .append("LEFT JOIN booking b ON c.bookingid = b.booking_id ") |
|||
// .append("JOIN category cat ON c.cid = cat.cid ") |
|||
// .append("WHERE c.is_active = 1 AND c.is_delete = 0 ") |
|||
// .append("AND cat.display_name = 'Desk Space' ") |
|||
// .append("AND DATE(c.bdate) BETWEEN ? AND ? ") |
|||
// .append("GROUP BY DATE(c.bdate), cat.display_name ") |
|||
// .append("ORDER BY DATE(c.bdate)"); |
|||
|
|||
// List<Object> params = new ArrayList<>(); |
|||
// params.add(fromDate); |
|||
// params.add(toDate); |
|||
|
|||
// return jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
// } |
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getslotdateReports( |
|||
String fromDate, String toDate, |
|||
String type, String status, |
|||
String filterBy, String type1, |
|||
Integer bid) { |
|||
|
|||
StringBuilder sql = new StringBuilder( |
|||
"SELECT " + |
|||
"b.booking_id, bu.name as building_name,b.user_name,b.bid ,b.mobile, b.slotids, b.from_date, b.to_date, " + |
|||
"b.no_of_person, b.amount, b.payment_status, b.cdate AS bdate, " + |
|||
"b.bid, " + |
|||
"sc.display_name, cl.bdate, " + |
|||
"SUBSTRING_INDEX(sl.name, ' to ', 1) AS checkin, " + |
|||
"SUBSTRING_INDEX(sl.name, ' to ', -1) AS checkout, " + |
|||
"CASE " + |
|||
" WHEN CURDATE() BETWEEN b.from_date AND b.to_date THEN 'Ongoing' " + |
|||
" WHEN b.to_date < CURDATE() THEN 'Completed' " + |
|||
" WHEN b.from_date > CURDATE() THEN 'Upcoming' " + |
|||
" ELSE 'Ongoing' " + |
|||
"END AS status, " + |
|||
"cat.name AS type, cat.display_name AS type_name, sc.display_name AS subcategory_name " + |
|||
"FROM booking b " + |
|||
"JOIN buildings bu ON b.bid = bu.bid " + |
|||
"JOIN slots sl ON b.slotids = sl.slotid " + |
|||
"JOIN category cat ON b.cid = cat.cid " + |
|||
"JOIN subcategory sc ON b.sid = sc.scid " + |
|||
"JOIN calendar cl ON b.booking_id = cl.bookingid " |
|||
); |
|||
|
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
// Main filters |
|||
if ("slot_date".equals(filterBy)) { |
|||
sql.append("WHERE cl.bdate >= STR_TO_DATE(?, '%Y-%m-%d') AND cl.bdate <= STR_TO_DATE(?, '%Y-%m-%d') "); |
|||
params.add(fromDate); |
|||
params.add(toDate); |
|||
} else if ("current_date".equals(filterBy)) { |
|||
sql.append("WHERE DATE(b.cdate) >= ? AND DATE(b.cdate) <= ? "); |
|||
params.add(fromDate); |
|||
params.add(toDate); |
|||
} else { |
|||
sql.append("WHERE 1=1 "); |
|||
} |
|||
|
|||
// Additional filters |
|||
if (type != null && !type.isEmpty()) { |
|||
sql.append("AND cat.display_name = ? "); |
|||
params.add(type); |
|||
} |
|||
|
|||
if (type1 != null && !type1.isEmpty()) { |
|||
sql.append("AND sc.display_name = ? "); |
|||
params.add(type1); |
|||
} |
|||
|
|||
if (status != null && !status.isEmpty()) { |
|||
if ("Ongoing".equals(status)) { |
|||
sql.append("AND CURDATE() BETWEEN b.from_date AND b.to_date "); |
|||
} else if ("Completed".equals(status)) { |
|||
sql.append("AND b.to_date < CURDATE() "); |
|||
} else if ("Upcoming".equals(status)) { |
|||
sql.append("AND b.from_date > CURDATE() "); |
|||
} |
|||
} |
|||
|
|||
|
|||
if (bid != null) { |
|||
sql.append("AND b.bid = ? "); |
|||
params.add(bid); |
|||
} |
|||
|
|||
sql.append("ORDER BY b.cdate DESC"); |
|||
|
|||
System.out.println("Generated SQL: " + sql); |
|||
System.out.println("Parameters: " + params); |
|||
|
|||
return jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
// added by yogi |
|||
|
|||
public List<Map<String, Object>> getbookingdateReports( |
|||
String fromDate, String toDate, String type, String status, |
|||
String filterBy, String type1, Integer bid) { |
|||
|
|||
StringBuilder sql = new StringBuilder( |
|||
"SELECT " + |
|||
"b.from_date, " + |
|||
"b.to_date, " + |
|||
"b.booking_id, " + |
|||
"b.bid," + |
|||
"b.user_name, " + |
|||
"b.mobile, " + |
|||
"b.amount, " + |
|||
"b.payment_status, " + |
|||
"b.no_of_person, " + |
|||
"b.slotids, " + |
|||
"bu.name AS building_name, " + |
|||
"st.name AS duration, " + |
|||
"ca.name AS type, " + |
|||
"ca.display_name AS type_name, " + |
|||
"b.from_date AS bdate, " + |
|||
"b.cdate, " + |
|||
"sc.display_name, " + |
|||
"SUBSTRING_INDEX(st.name, ' to ', 1) AS checkin, " + |
|||
"SUBSTRING_INDEX(st.name, ' to ', -1) AS checkout, " + |
|||
"CASE " + |
|||
" WHEN CURDATE() BETWEEN DATE(b.from_date) AND DATE(b.to_date) THEN 'Ongoing' " + |
|||
" WHEN DATE(b.to_date) < CURDATE() THEN 'Completed' " + |
|||
" WHEN DATE(b.from_date) > CURDATE() THEN 'Upcoming' " + |
|||
"END AS status " + |
|||
"FROM calendar c " + |
|||
"INNER JOIN booking b ON c.bookingid = b.booking_id " + |
|||
"JOIN buildings bu ON b.bid = bu.bid " + |
|||
"JOIN slots st ON b.slotids = st.slotid " + |
|||
"JOIN subcategory sc ON b.sid = sc.scid " + |
|||
"JOIN category ca ON b.cid = ca.cid " + |
|||
"WHERE DATE(c.cdate) BETWEEN ? AND ? " |
|||
); |
|||
|
|||
List<Object> params = new ArrayList<>(); |
|||
params.add(fromDate); |
|||
params.add(toDate); |
|||
|
|||
|
|||
if (bid != null) { |
|||
sql.append("AND b.bid = ? "); |
|||
params.add(bid); |
|||
} |
|||
|
|||
// Filter subcategory |
|||
if (type1 != null && !type1.isEmpty()) { |
|||
sql.append("AND sc.display_name = ? "); |
|||
params.add(type1); |
|||
} |
|||
|
|||
// Filter category |
|||
if (type != null && !type.isEmpty()) { |
|||
sql.append("AND ca.display_name = ? "); |
|||
params.add(type); |
|||
} |
|||
|
|||
// Filter status |
|||
if (status != null && !status.isEmpty()) { |
|||
sql.append( |
|||
"AND ( " + |
|||
"(CURDATE() BETWEEN DATE(b.from_date) AND DATE(b.to_date) AND ? = 'Ongoing') OR " + |
|||
"(DATE(b.to_date) < CURDATE() AND ? = 'Completed') OR " + |
|||
"(DATE(b.from_date) > CURDATE() AND ? = 'Upcoming') " + |
|||
") " |
|||
); |
|||
params.add(status); |
|||
params.add(status); |
|||
params.add(status); |
|||
} |
|||
|
|||
sql.append("GROUP BY b.from_date, b.to_date, b.booking_id, b.cdate "); |
|||
sql.append("ORDER BY b.cdate DESC "); |
|||
|
|||
System.out.println("Generated SQL: " + sql); |
|||
System.out.println("Params: " + params); |
|||
|
|||
return jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
} |
|||
|
|||
|
|||
|
|||
// added by yogi |
|||
public List<Map<String, Object>> abstractReportPage( |
|||
String fromDate, String toDate, String type, String type1, Integer bid) { |
|||
|
|||
StringBuilder sql2 = new StringBuilder( |
|||
"SELECT DATE(booking.cdate) AS created_date, " + |
|||
"booking.bid AS building_id, " + |
|||
"buildings.name AS building_name, " + |
|||
"category.display_name AS category, " + |
|||
"subcategory.display_name AS type, " + |
|||
"slots.name AS slots, " + |
|||
"SUM(booking.amount) AS amount, " + |
|||
"SUM(booking.no_of_person) AS NO_of_person " + |
|||
"FROM booking " + |
|||
"JOIN buildings ON booking.bid = buildings.bid " + |
|||
"JOIN subcategory ON booking.sid = subcategory.scid " + |
|||
"JOIN category ON category.cid = subcategory.cid " + |
|||
"JOIN slots ON booking.slotids = slots.slotid " + |
|||
"WHERE booking.booking_status = 'success' " |
|||
); |
|||
|
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
// Date filter (default to today) |
|||
if ((fromDate == null || fromDate.isEmpty()) && |
|||
(toDate == null || toDate.isEmpty())) { |
|||
|
|||
sql2.append("AND DATE(booking.cdate) = CURDATE() "); |
|||
|
|||
} else if (fromDate != null && !fromDate.isEmpty() && |
|||
toDate != null && !toDate.isEmpty()) { |
|||
|
|||
sql2.append("AND DATE(booking.cdate) BETWEEN ? AND ? "); |
|||
params.add(fromDate); |
|||
params.add(toDate); |
|||
} |
|||
|
|||
// Sub-category filter |
|||
if (type1 != null && !type1.isEmpty()) { |
|||
sql2.append("AND subcategory.display_name = ? "); |
|||
params.add(type1); |
|||
} |
|||
|
|||
// Category filter |
|||
if (type != null && !type.isEmpty()) { |
|||
sql2.append("AND category.display_name = ? "); |
|||
params.add(type); |
|||
} |
|||
|
|||
// ✅ Building (bid) filter |
|||
if (bid != null && bid > 0) { |
|||
sql2.append("AND booking.bid = ? "); |
|||
params.add(bid); |
|||
} |
|||
|
|||
// Grouping |
|||
sql2.append("GROUP BY booking.bid, category.display_name, subcategory.display_name, slots.name, DATE(booking.cdate)"); |
|||
|
|||
return jdbcTemplate.queryForList(sql2.toString(), params.toArray()); |
|||
} |
|||
|
|||
|
|||
|
|||
// added by yogi |
|||
public List<Map<String, Object>> getCalendarReport(String fromDate, String toDate, int bid) { |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("SELECT ") |
|||
.append("DATE(c.bdate) AS booking_date, ") |
|||
.append("cat.display_name AS type, ") |
|||
.append("SUM(b.no_of_person) AS total_booked_count, ") |
|||
.append("SUM(c.absent_count) AS total_absent_count ") |
|||
.append("FROM calendar c ") |
|||
.append("LEFT JOIN booking b ON c.bookingid = b.booking_id ") |
|||
.append("JOIN category cat ON c.cid = cat.cid ") |
|||
.append("WHERE c.is_active = 1 AND c.is_delete = 0 ") |
|||
.append("AND cat.display_name = 'Desk Space' ") |
|||
.append("AND b.bid = ? ") // ✅ Filter by building ID |
|||
.append("AND DATE(c.bdate) BETWEEN ? AND ? ") |
|||
.append("GROUP BY DATE(c.bdate), cat.display_name ") |
|||
.append("ORDER BY DATE(c.bdate)"); |
|||
|
|||
List<Object> params = new ArrayList<>(); |
|||
params.add(bid); // add bid first |
|||
params.add(fromDate); // then date start |
|||
params.add(toDate); // then date end |
|||
|
|||
return jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
|
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
|
|||
@Service |
|||
public class SMSService { |
|||
public String sendMsg(String msgUrl) { |
|||
System.out.println("Whatsapp URL :-"+msgUrl); |
|||
|
|||
String response =""; |
|||
try{ |
|||
HttpURLConnection connection =null; |
|||
|
|||
URL url = new URL(msgUrl); |
|||
connection = (HttpURLConnection) url.openConnection(); |
|||
connection.setRequestMethod("GET"); |
|||
|
|||
int responseCode = connection.getResponseCode(); |
|||
response=responseCode+""; |
|||
System.out.println("Response Code: " + responseCode); |
|||
|
|||
}catch (Exception e){ |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
public String sendSMS(String SMS_Url) { |
|||
System.out.println("SMS URL:- "+ SMS_Url); |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String response =restTemplate.getForObject(SMS_Url,String.class); |
|||
return response; |
|||
} |
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
package com.gcc.coworkspace.service; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class WhatsAppService { |
|||
|
|||
@Autowired |
|||
private SMSService whatsappMsgService; |
|||
|
|||
String password = "h2YjFNcJ"; |
|||
|
|||
public String sendOTP(String mobileNo, String msg) { |
|||
String msgContent ="https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password="+password+"&send_to="+mobileNo+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Welcome+to+Mudhalvar+Padaipagam%2C+%0A%0AThe+OTP+for+your+booking+is+"+msg+"%2A"; |
|||
System.out.println(msgContent); |
|||
return whatsappMsgService.sendMsg(msgContent); |
|||
} |
|||
|
|||
public String sendELearnNmsg(String MobileNo, String noOfPerson, String bdate, String slot, String amount, String bookingId) { |
|||
String msgContent = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password="+password+"&send_to="+MobileNo+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Dear+Patron%2C%0AWelcome+to+Muthalvar+Padaippagam%F0%9F%99%8F++%0A%0AYou+have+booked+our+Learning+Centre+for+%2A"+noOfPerson+"%2A+number+of+persons+on+%2A"+bdate+"%2A+at+%0Atime+slot+%2A"+slot+"%2A+.%0A%0APayment+for+the+booking+is+%2ARs.+"+amount+"%2A+received.+%0A%0APlease+show+your+QR+Code+at+Reception+Desk+for+accessing+Muthalvar+Padaippagam.%0A%0AHave+a+Nice+Day%F0%9F%98%8A&isTemplate=true&buttonUrlParam=muthalvarpadaippagam%2FbookingQRCode%3Fbooking_id%3D"+bookingId; |
|||
System.out.println(msgContent); |
|||
return whatsappMsgService.sendMsg(msgContent); |
|||
} |
|||
|
|||
public String sendTLearnNmsg(String MobileNo, String noOfPerson, String bdate, String slot, String amount, String bookingId) { |
|||
String msgContent = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password="+password+"&send_to="+MobileNo+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=%E0%AE%85%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%BE%E0%AE%A9+%E0%AE%B5%E0%AE%BE%E0%AE%9F%E0%AE%BF%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%88%E0%AE%AF%E0%AE%BE%E0%AE%B3%E0%AE%B0%E0%AF%87%2C+%0A%E0%AE%AE%E0%AF%81%E0%AE%A4%E0%AE%B2%E0%AF%8D%E0%AE%B5%E0%AE%B0%E0%AF%8D+%E0%AE%AA%E0%AE%9F%E0%AF%88%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%95%E0%AE%AE%E0%AF%8D+%E0%AE%A4%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%88+%E0%AE%85%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AF%81%E0%AE%9F%E0%AE%A9%E0%AF%8D+%E0%AE%B5%E0%AE%B0%E0%AE%B5%E0%AF%87%E0%AE%B1%E0%AF%8D%E0%AE%95%E0%AE%BF%E0%AE%A9%E0%AF%8D%E0%AE%B1%E0%AE%A4%E0%AF%81+%F0%9F%99%8F++%0A%0A%E0%AE%A4%E0%AE%BE%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D+%E0%AE%8E%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AE%BF%E0%AE%A9%E0%AF%8D+%E0%AE%95%E0%AE%B1%E0%AF%8D%E0%AE%B1%E0%AE%B2%E0%AF%8D+%E0%AE%AE%E0%AF%88%E0%AE%AF%E0%AE%A4%E0%AF%8D%E0%AE%A4%E0%AF%88++%2A"+noOfPerson+"%2A+%E0%AE%8E%E0%AE%A3%E0%AF%8D%E0%AE%A3%E0%AE%BF%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%88+%E0%AE%A8%E0%AE%AA%E0%AE%B0%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%81%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%81++%2A"+bdate+"%2A+%E0%AE%85%E0%AE%A9%E0%AF%8D%E0%AE%B1%E0%AF%81++%E0%AE%A8%E0%AF%87%E0%AE%B0+%E0%AE%87%E0%AE%9F%E0%AF%88%E0%AE%B5%E0%AF%86%E0%AE%B3%E0%AE%BF+%2A"+slot+"%2A+%E0%AE%B2%E0%AF%8D+%E0%AE%AA%E0%AE%AF%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%81%E0%AE%A4%E0%AF%8D%E0%AE%A4%E0%AE%BF%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%8A%E0%AE%B3%E0%AF%8D%E0%AE%B3+%E0%AE%AE%E0%AF%81%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%A4%E0%AE%BF%E0%AE%B5%E0%AF%81+%E0%AE%9A%E0%AF%86%E0%AE%AF%E0%AF%8D%E0%AE%A4%E0%AF%81%E0%AE%B3%E0%AF%8D%E0%AE%B3%E0%AF%80%E0%AE%B0%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D.+.%0A%0A%E0%AE%87%E0%AE%A4%E0%AE%B1%E0%AF%8D%E0%AE%95%E0%AE%BE%E0%AE%A9++%E0%AE%95%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AE%A3%E0%AE%AE%E0%AF%8D+%2A%E0%AE%B0%E0%AF%82.+"+amount+"%2A+%E0%AE%AA%E0%AF%86%E0%AE%B1%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%B3%E0%AF%8D%E0%AE%B3%E0%AE%A4%E0%AF%81.%0A%0A%E0%AE%AE%E0%AF%81%E0%AE%A4%E0%AE%B2%E0%AF%8D%E0%AE%B5%E0%AE%B0%E0%AF%8D+%E0%AE%AA%E0%AE%9F%E0%AF%88%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%95%E0%AE%AE%E0%AF%8D+%E0%AE%AA%E0%AE%AF%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%81%E0%AE%A4%E0%AF%8D%E0%AE%A4+%E0%AE%89%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D+QR+%E0%AE%95%E0%AF%81%E0%AE%B1%E0%AE%BF%E0%AE%AF%E0%AF%80%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%88+%E0%AE%B5%E0%AE%B0%E0%AE%B5%E0%AF%87%E0%AE%B1%E0%AF%8D%E0%AE%AA%E0%AE%B1%E0%AF%88%E0%AE%AF%E0%AE%BF%E0%AE%B2%E0%AF%8D+%E0%AE%95%E0%AE%BE%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D.%0A%0A%E0%AE%87%E0%AE%A8%E0%AF%8D%E0%AE%A8%E0%AE%BE%E0%AE%B3%E0%AF%8D+%E0%AE%87%E0%AE%A9%E0%AE%BF%E0%AE%AF+%E0%AE%A8%E0%AE%BE%E0%AE%B3%E0%AE%BE%E0%AE%AF%E0%AF%8D+%E0%AE%85%E0%AE%AE%E0%AF%88%E0%AE%AF%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%AE%E0%AF%8D%F0%9F%98%8A&isTemplate=true&buttonUrlParam=muthalvarpadaippagam%2FbookingQRCode%3Fbooking_id%3D"+bookingId; |
|||
System.out.println(msgContent); |
|||
return whatsappMsgService.sendMsg(msgContent); |
|||
} |
|||
|
|||
public String sendEDeskspaceNmsg(String MobileNo, String noOfPerson, String bdate, String slot, String amount, String bookingId) { |
|||
String msgContent = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password="+password+"&send_to="+MobileNo+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Dear+Patron%2C%0AWelcome+to+Muthalvar+Padaippagam%F0%9F%99%8F++%0A%0AYou+have+booked+our+Desk+space+for+%2A"+noOfPerson+"%2A+number+of+persons+on+%2A"+bdate+"%2A+at+time+slot+%2A"+slot+"%2A+.%0A%0APayment+for+the+booking+is+%2ARs.+"+amount+"%2A+received.+%0A%0APlease+show+your+QR+Code+at+Reception+Desk+for+accessing+Muthalvar+Padaippagam.%0A%0AHave+a+Nice+Day%F0%9F%98%8A&isTemplate=true&buttonUrlParam=muthalvarpadaippagam%2FbookingQRCode%3Fbooking_id%3D"+bookingId; |
|||
System.out.println(msgContent); |
|||
return whatsappMsgService.sendMsg(msgContent); |
|||
} |
|||
|
|||
public String sendTDeskspaceNmsg(String MobileNo, String noOfPerson, String bdate, String slot, String amount, String bookingId) { |
|||
String msgContent = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password="+password+"&send_to="+MobileNo+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=%E0%AE%85%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%BE%E0%AE%A9+%E0%AE%B5%E0%AE%BE%E0%AE%9F%E0%AE%BF%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%88%E0%AE%AF%E0%AE%BE%E0%AE%B3%E0%AE%B0%E0%AF%87%2C+%0A%E0%AE%AE%E0%AF%81%E0%AE%A4%E0%AE%B2%E0%AF%8D%E0%AE%B5%E0%AE%B0%E0%AF%8D+%E0%AE%AA%E0%AE%9F%E0%AF%88%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%95%E0%AE%AE%E0%AF%8D+%E0%AE%A4%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%88+%E0%AE%85%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AF%81%E0%AE%9F%E0%AE%A9%E0%AF%8D+%E0%AE%B5%E0%AE%B0%E0%AE%B5%E0%AF%87%E0%AE%B1%E0%AF%8D%E0%AE%95%E0%AE%BF%E0%AE%A9%E0%AF%8D%E0%AE%B1%E0%AE%A4%E0%AF%81%F0%9F%99%8F++%0A%0A%E0%AE%A4%E0%AE%BE%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D+%E0%AE%8E%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AE%BF%E0%AE%A9%E0%AF%8D+%E0%AE%AE%E0%AF%87%E0%AE%9A%E0%AF%88+%E0%AE%87%E0%AE%9F%E0%AE%A4%E0%AF%8D%E0%AE%A4%E0%AE%BF%E0%AE%A9%E0%AF%88+%2A"+noOfPerson+"%2A+%E0%AE%8E%E0%AE%A3%E0%AF%8D%E0%AE%A3%E0%AE%BF%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%88+%E0%AE%A8%E0%AE%AA%E0%AE%B0%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%81%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%81+%2A"+bdate+"%2A+%E0%AE%85%E0%AE%A9%E0%AF%8D%E0%AE%B1%E0%AF%81+%E0%AE%A8%E0%AF%87%E0%AE%B0+%E0%AE%87%E0%AE%9F%E0%AF%88%E0%AE%B5%E0%AF%86%E0%AE%B3%E0%AE%BF+%2A"+slot+"%2A+%E0%AE%B2%E0%AF%8D+%E0%AE%AA%E0%AE%AF%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%81%E0%AE%A4%E0%AF%8D%E0%AE%A4%E0%AE%BF%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%8A%E0%AE%B3%E0%AF%8D%E0%AE%B3+%E0%AE%AE%E0%AF%81%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%A4%E0%AE%BF%E0%AE%B5%E0%AF%81+%E0%AE%9A%E0%AF%86%E0%AE%AF%E0%AF%8D%E0%AE%A4%E0%AF%81%E0%AE%B3%E0%AF%8D%E0%AE%B3%E0%AF%80%E0%AE%B0%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D.%0A%0A%E0%AE%87%E0%AE%A4%E0%AE%B1%E0%AF%8D%E0%AE%95%E0%AE%BE%E0%AE%A9++%E0%AE%95%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AE%A3%E0%AE%AE%E0%AF%8D+%2A%E0%AE%B0%E0%AF%82.+"+amount+"%2A+%E0%AE%AA%E0%AF%86%E0%AE%B1%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%B3%E0%AF%8D%E0%AE%B3%E0%AE%A4%E0%AF%81.+%0A%0A%E0%AE%AE%E0%AF%81%E0%AE%A4%E0%AE%B2%E0%AF%8D%E0%AE%B5%E0%AE%B0%E0%AF%8D+%E0%AE%AA%E0%AE%9F%E0%AF%88%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%95%E0%AE%AE%E0%AF%8D+%E0%AE%AA%E0%AE%AF%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%81%E0%AE%A4%E0%AF%8D%E0%AE%A4+%E0%AE%89%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D+QR+%E0%AE%95%E0%AF%81%E0%AE%B1%E0%AE%BF%E0%AE%AF%E0%AF%80%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%88+%E0%AE%B5%E0%AE%B0%E0%AE%B5%E0%AF%87%E0%AE%B1%E0%AF%8D%E0%AE%AA%E0%AE%B1%E0%AF%88%E0%AE%AF%E0%AE%BF%E0%AE%B2%E0%AF%8D+%E0%AE%95%E0%AE%BE%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D%0A%0A%E0%AE%87%E0%AE%A8%E0%AF%8D%E0%AE%A8%E0%AE%BE%E0%AE%B3%E0%AF%8D+%E0%AE%87%E0%AE%A9%E0%AE%BF%E0%AE%AF+%E0%AE%A8%E0%AE%BE%E0%AE%B3%E0%AE%BE%E0%AE%AF%E0%AF%8D+%E0%AE%85%E0%AE%AE%E0%AF%88%E0%AE%AF%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%AE%E0%AF%8D%F0%9F%98%8A&isTemplate=true&buttonUrlParam=muthalvarpadaippagam%2FbookingQRCode%3Fbooking_id%3D"+bookingId; |
|||
System.out.println(msgContent); |
|||
return whatsappMsgService.sendMsg(msgContent); |
|||
} |
|||
|
|||
public String sendEMonthDeskspaceNmsg(String MobileNo, String noOfPerson, String bFromdate,String bTodate, String slot, String amount, String bookingId) { |
|||
String msgContent = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password="+password+"&send_to="+MobileNo+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Dear+Patron%2C%0AWelcome+to+Muthalvar+Padaippagam%F0%9F%99%8F++%0A%0AYou+have+booked+our+Desk+space+for+%2A"+noOfPerson+"%2A+number+of+persons+for+30+days+from+%2A"+bFromdate+"+to+"+bTodate+"%2A+at+time+slot+%2A"+slot+"%2A.%0A%0APayment+for+the+booking+is+%2ARs.+"+amount+"%2A+received.+%0A%0APlease+show+your+QR+Code+at+Reception+Desk+for+accessing+Muthalvar+Padaippagam.%0A%0AHave+a+Nice+Day%F0%9F%98%8A&isTemplate=true&buttonUrlParam=muthalvarpadaippagam%2FbookingQRCode%3Fbooking_id%3D"+bookingId; |
|||
System.out.println(msgContent); |
|||
return whatsappMsgService.sendMsg(msgContent); |
|||
} |
|||
|
|||
public String sendTMonthDeskspaceNmsg(String MobileNo, String noOfPerson, String bfromDate,String btoDate, String slot, String amount, String bookingId) { |
|||
String msgContent = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="+MobileNo+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=%E0%AE%85%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%BE%E0%AE%A9+%E0%AE%B5%E0%AE%BE%E0%AE%9F%E0%AE%BF%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%88%E0%AE%AF%E0%AE%BE%E0%AE%B3%E0%AE%B0%E0%AF%87%2C+%0A%E0%AE%AE%E0%AF%81%E0%AE%A4%E0%AE%B2%E0%AF%8D%E0%AE%B5%E0%AE%B0%E0%AF%8D+%E0%AE%AA%E0%AE%9F%E0%AF%88%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%95%E0%AE%AE%E0%AF%8D+%E0%AE%A4%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%88+%E0%AE%85%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AF%81%E0%AE%9F%E0%AE%A9%E0%AF%8D+%E0%AE%B5%E0%AE%B0%E0%AE%B5%E0%AF%87%E0%AE%B1%E0%AF%8D%E0%AE%95%E0%AE%BF%E0%AE%A9%E0%AF%8D%E0%AE%B1%E0%AE%A4%E0%AF%81+%F0%9F%99%8F++%0A%0A%E0%AE%A4%E0%AE%BE%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D+%E0%AE%8E%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AE%BF%E0%AE%A9%E0%AF%8D+%E0%AE%AE%E0%AF%87%E0%AE%9A%E0%AF%88+%E0%AE%87%E0%AE%9F%E0%AE%A4%E0%AF%8D%E0%AE%A4%E0%AF%88+%2A"+noOfPerson+"%2A+%E0%AE%8E%E0%AE%A3%E0%AF%8D%E0%AE%A3%E0%AE%BF%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%88+%E0%AE%A8%E0%AE%AA%E0%AE%B0%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%81%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%81+30+%E0%AE%A8%E0%AE%BE%E0%AE%9F%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D+%2A"+bfromDate+"+%E0%AE%AE%E0%AF%81%E0%AE%A4%E0%AE%B2%E0%AF%8D+"+btoDate+"%2A+%E0%AE%B5%E0%AE%B0%E0%AF%88+%E0%AE%A8%E0%AF%87%E0%AE%B0+%E0%AE%87%E0%AE%9F%E0%AF%88%E0%AE%B5%E0%AF%86%E0%AE%B3%E0%AE%BF+%2A"+slot+"%2A+%E0%AE%B2%E0%AF%8D+%E0%AE%AA%E0%AE%AF%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%81%E0%AE%A4%E0%AF%8D%E0%AE%A4%E0%AE%BF%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%8A%E0%AE%B3%E0%AF%8D%E0%AE%B3+%E0%AE%AE%E0%AF%81%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%A4%E0%AE%BF%E0%AE%B5%E0%AF%81+%E0%AE%9A%E0%AF%86%E0%AE%AF%E0%AF%8D%E0%AE%A4%E0%AF%81%E0%AE%B3%E0%AF%8D%E0%AE%B3%E0%AF%80%E0%AE%B0%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D.%0A%0A%E0%AE%87%E0%AE%A4%E0%AE%B1%E0%AF%8D%E0%AE%95%E0%AE%BE%E0%AE%A9++%E0%AE%95%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AE%A3%E0%AE%AE%E0%AF%8D+%2A%E0%AE%B0%E0%AF%82.+"+amount+"%2A+%E0%AE%AA%E0%AF%86%E0%AE%B1%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%B3%E0%AF%8D%E0%AE%B3%E0%AE%A4%E0%AF%81.%0A%0A%E0%AE%AE%E0%AF%81%E0%AE%A4%E0%AE%B2%E0%AF%8D%E0%AE%B5%E0%AE%B0%E0%AF%8D+%E0%AE%AA%E0%AE%9F%E0%AF%88%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%95%E0%AE%AE%E0%AF%8D+%E0%AE%AA%E0%AE%AF%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%81%E0%AE%A4%E0%AF%8D%E0%AE%A4+%E0%AE%89%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D+QR+%E0%AE%95%E0%AF%81%E0%AE%B1%E0%AE%BF%E0%AE%AF%E0%AF%80%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%88+%E0%AE%B5%E0%AE%B0%E0%AE%B5%E0%AF%87%E0%AE%B1%E0%AF%8D%E0%AE%AA%E0%AE%B1%E0%AF%88%E0%AE%AF%E0%AE%BF%E0%AE%B2%E0%AF%8D+%E0%AE%95%E0%AE%BE%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D%0A%0A%E0%AE%87%E0%AE%A8%E0%AF%8D%E0%AE%A8%E0%AE%BE%E0%AE%B3%E0%AF%8D+%E0%AE%87%E0%AE%A9%E0%AE%BF%E0%AE%AF+%E0%AE%A8%E0%AE%BE%E0%AE%B3%E0%AE%BE%E0%AE%AF%E0%AF%8D+%E0%AE%85%E0%AE%AE%E0%AF%88%E0%AE%AF%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%AE%E0%AF%8D%F0%9F%98%8A&isTemplate=true&buttonUrlParam=muthalvarpadaippagam%2FbookingQRCode%3Fbooking_id%3D"+bookingId; |
|||
System.out.println(msgContent); |
|||
return whatsappMsgService.sendMsg(msgContent); |
|||
} |
|||
|
|||
public String sendEConfeNmsg(String mobileNo, String bdate, String slot, String amount,String bookingId) { |
|||
String msgContent= "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="+mobileNo+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Dear+Patron%2C%0AWelcome+to+Muthalvar+Padaippagam%F0%9F%99%8F++%0A%0AYou+have+booked+our+Conference+Hall+on+%2A"+bdate+"%2A+at+time+slot+%2A"+slot+"%2A+.%0A%0APayment+for+the+booking+is+%2ARs.+"+amount+"%2A+received.+%0A%0APlease+show+your+QR+Code+at+Reception+Desk+for+accessing+Muthalvar+Padaippagam.%0A%0AHave+a+Nice+Day%F0%9F%98%8A&isTemplate=true&buttonUrlParam=muthalvarpadaippagam%2FbookingQRCode%3Fbooking_id%3D"+bookingId; |
|||
System.out.println(msgContent); |
|||
return whatsappMsgService.sendMsg(msgContent); |
|||
} |
|||
|
|||
public String sendTConfeNmsg(String mobileNo, String bdate, String slot, String amount,String bookingId) { |
|||
String msgContent = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="+mobileNo+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=%E0%AE%85%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%BE%E0%AE%A9+%E0%AE%B5%E0%AE%BE%E0%AE%9F%E0%AE%BF%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%88%E0%AE%AF%E0%AE%BE%E0%AE%B3%E0%AE%B0%E0%AF%87%2C+%0A%E0%AE%AE%E0%AF%81%E0%AE%A4%E0%AE%B2%E0%AF%8D%E0%AE%B5%E0%AE%B0%E0%AF%8D+%E0%AE%AA%E0%AE%9F%E0%AF%88%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%95%E0%AE%AE%E0%AF%8D+%E0%AE%A4%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%88+%E0%AE%85%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AF%81%E0%AE%9F%E0%AE%A9%E0%AF%8D+%E0%AE%B5%E0%AE%B0%E0%AE%B5%E0%AF%87%E0%AE%B1%E0%AF%8D%E0%AE%95%E0%AE%BF%E0%AE%A9%E0%AF%8D%E0%AE%B1%E0%AE%A4%E0%AF%81+%F0%9F%99%8F++%0A%0A%E0%AE%A4%E0%AE%BE%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D+%E0%AE%8E%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AE%BF%E0%AE%A9%E0%AF%8D+%E0%AE%95%E0%AE%B2%E0%AE%A8%E0%AF%8D%E0%AE%A4%E0%AE%BE%E0%AE%AF%E0%AF%8D%E0%AE%B5%E0%AF%81+%E0%AE%85%E0%AE%B0%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%A4%E0%AF%8D%E0%AE%A4%E0%AE%BF%E0%AE%A9%E0%AF%88+%2A"+bdate+"%2A+%E0%AE%85%E0%AE%A9%E0%AF%8D%E0%AE%B1%E0%AF%81++%E0%AE%A8%E0%AF%87%E0%AE%B0+%E0%AE%87%E0%AE%9F%E0%AF%88%E0%AE%B5%E0%AF%86%E0%AE%B3%E0%AE%BF+%2A"+slot+"%2A+%E0%AE%B2%E0%AF%8D+%E0%AE%AA%E0%AE%AF%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%81%E0%AE%A4%E0%AF%8D%E0%AE%A4%E0%AE%BF%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%8A%E0%AE%B3%E0%AF%8D%E0%AE%B3+%E0%AE%AE%E0%AF%81%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%A4%E0%AE%BF%E0%AE%B5%E0%AF%81+%E0%AE%9A%E0%AF%86%E0%AE%AF%E0%AF%8D%E0%AE%A4%E0%AF%81%E0%AE%B3%E0%AF%8D%E0%AE%B3%E0%AF%80%E0%AE%B0%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D.+%0A%0A%E0%AE%87%E0%AE%A4%E0%AE%B1%E0%AF%8D%E0%AE%95%E0%AE%BE%E0%AE%A9++%E0%AE%95%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AE%A3%E0%AE%AE%E0%AF%8D+%2A%E0%AE%B0%E0%AF%82.+"+amount+"%2A+%E0%AE%AA%E0%AF%86%E0%AE%B1%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%B3%E0%AF%8D%E0%AE%B3%E0%AE%A4%E0%AF%81.+%0A%0A%E0%AE%AE%E0%AF%81%E0%AE%A4%E0%AE%B2%E0%AF%8D%E0%AE%B5%E0%AE%B0%E0%AF%8D+%E0%AE%AA%E0%AE%9F%E0%AF%88%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%95%E0%AE%AE%E0%AF%8D+%E0%AE%AA%E0%AE%AF%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%81%E0%AE%A4%E0%AF%8D%E0%AE%A4+%E0%AE%89%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D+QR+%E0%AE%95%E0%AF%81%E0%AE%B1%E0%AE%BF%E0%AE%AF%E0%AF%80%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%88+%E0%AE%B5%E0%AE%B0%E0%AE%B5%E0%AF%87%E0%AE%B1%E0%AF%8D%E0%AE%AA%E0%AE%B1%E0%AF%88%E0%AE%AF%E0%AE%BF%E0%AE%B2%E0%AF%8D+%E0%AE%95%E0%AE%BE%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D%0A%0A%E0%AE%87%E0%AE%A8%E0%AF%8D%E0%AE%A8%E0%AE%BE%E0%AE%B3%E0%AF%8D+%E0%AE%87%E0%AE%A9%E0%AE%BF%E0%AE%AF+%E0%AE%A8%E0%AE%BE%E0%AE%B3%E0%AE%BE%E0%AE%AF%E0%AF%8D+%E0%AE%85%E0%AE%AE%E0%AF%88%E0%AE%AF%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%AE%E0%AF%8D%F0%9F%98%8A&isTemplate=true&buttonUrlParam=muthalvarpadaippagam%2FbookingQRCode%3Fbooking_id%3D"+bookingId; |
|||
return whatsappMsgService.sendMsg(msgContent); |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
spring.application.name=muthalvarpadaippagam |
|||
|
|||
|
|||
file.upload.directory=${user.dir}/co-workspaceDocuments |
|||
app.baseUrl=/ |
|||
app.getOtpUrl=https://tmegov.onex-aura.com/api/sms? |
|||
|
|||
payment.razorpay.my_key_id=rzp_test_tDkHFEqWXmuEi8 |
|||
|
|||
app.full_URL=http://localhost:8074 |
|||
|
|||