Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TimeOutAdmin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TimeOut
TimeOutAdmin
Commits
4b364cd8
Commit
4b364cd8
authored
5 years ago
by
Tobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dc
parent
ef439d5b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
181 additions
and
1 deletion
+181
-1
Api.php
application/controllers/Api.php
+23
-0
Api_model.php
application/models/Api_model.php
+129
-0
Validation_model.php
application/models/Validation_model.php
+29
-1
No files found.
application/controllers/Api.php
View file @
4b364cd8
...
...
@@ -541,5 +541,28 @@ class Api extends CI_Controller {
$this
->
errorResponse
(
$res
[
'code'
],
$res
[
'message'
]);
}
}
public
function
validate_promo_code
(){
$data
=
(
array
)
json_decode
(
file_get_contents
(
'php://input'
));
$data
[
'auth_token'
]
=
$this
->
auth_token
;
$res
=
$this
->
Api_model
->
validate_promo_code
(
$data
);
if
(
$res
[
'status'
]
!=
0
){
$this
->
response
(
$res
[
'data'
]);
}
else
{
$this
->
errorResponse
(
$res
[
'code'
],
$res
[
'message'
]);
}
}
public
function
getCheckerBookList
(){
$data
=
(
array
)
json_decode
(
file_get_contents
(
'php://input'
));
$res
=
$this
->
Api_model
->
getCheckerBookList
(
$data
);
if
(
$res
[
'status'
]
!=
0
){
$this
->
response
(
$res
[
'data'
]);
}
else
{
$this
->
errorResponse
(
$res
[
'code'
],
$res
[
'message'
]);
}
}
}
?>
This diff is collapsed.
Click to expand it.
application/models/Api_model.php
View file @
4b364cd8
...
...
@@ -1684,5 +1684,134 @@ class Api_model extends CI_Model {
$curlresponse
=
curl_exec
(
$ch
);
}
}
public
function
validate_promo_code
(
$data
=
array
()){
$user_id
=
$this
->
auth_token_get
(
$data
[
'auth_token'
]);
if
(
$user_id
>
0
){
$date
=
date
(
'Y-m-d'
);
$promoCode
=
$data
[
'promo_code'
];
$tot_cost
=
$data
[
'tot_cost'
];
$promoData
=
$this
->
db
->
query
(
"SELECT PROM.*
FROM promocode_management AS PROM
WHERE PROM.promocode_name='
$promoCode
' AND PROM.status='1' AND
PROM.start_date<='
$date
' AND PROM.end_date>='
$date
' AND
PROM.use_limit>(SELECT count(id) FROM promocode_used AS PU
WHERE PU.promocode_id=PROM.promocode_id AND
PU.status=1)"
);
if
(
empty
(
$promoData
)
||
empty
(
$promoData
=
$promoData
->
row_array
())){
$respArr
[
'status'
]
=
0
;
$respArr
[
'code'
]
=
980
;
$respArr
[
'message'
]
=
'Invalid Promocode'
;
return
$respArr
;
}
$eventData
=
$this
->
db
->
query
(
"SELECT VEN.region_id,EVT.category_id FROM events AS EVT
INNER JOIN venue AS VEN ON (VEN.id = EVT.venue_id)
WHERE EVT.event_id='"
.
$promoData
[
'event_id'
]
.
"' AND EVT.status='1'"
);
if
(
empty
(
$eventData
)
||
empty
(
$eventData
=
$eventData
->
row_array
())){
$respArr
[
'status'
]
=
0
;
$respArr
[
'code'
]
=
980
;
$respArr
[
'message'
]
=
'Promocode Invalid or Expired'
;
return
$respArr
;
}
if
(
!
empty
(
$promoData
[
'event_id'
])
&&
$promoData
[
'event_id'
]
!=
$data
[
'event_id'
]){
$respArr
[
'status'
]
=
0
;
$respArr
[
'code'
]
=
981
;
$respArr
[
'message'
]
=
'Promocode is not Valid for this Event'
;
return
$respArr
;
}
if
(
!
empty
(
$promoData
[
'category_id'
])
&&
$promoData
[
'category_id'
]
!=
$eventData
[
'category_id'
]){
$respArr
[
'status'
]
=
0
;
$respArr
[
'code'
]
=
982
;
$respArr
[
'message'
]
=
'Promocode is not Valid for this Category'
;
return
$respArr
;
}
if
(
!
empty
(
$promoData
[
'city_id'
])
&&
$promoData
[
'city_id'
]
!=
$eventData
[
'region_id'
]){
$respArr
[
'status'
]
=
0
;
$respArr
[
'code'
]
=
983
;
$respArr
[
'message'
]
=
'Promocode is not Valid for this City'
;
return
$respArr
;
}
if
(
!
empty
(
$promoData
[
'min_order_amount'
])
&&
$promoData
[
'min_order_amount'
]
>
$tot_cost
){
$respArr
[
'status'
]
=
1
;
$respArr
[
'code'
]
=
984
;
$respArr
[
'data'
]
=
array
(
'message'
=>
'Minimum amount is not satisfied'
,
'minimum_amount'
=>
$promoData
[
'min_order_amount'
]);
return
$respArr
;
}
$discAmt
=
0
;
if
(
$promoData
[
'discount_type'
]
==
1
){
$discAmt
=
(
$tot_cost
*
$promoData
[
'discount_percentage'
])
/
100
;
}
else
{
$discAmt
=
(
$tot_cost
<=
$promoData
[
'discount_percentage'
])
?
$tot_cost
:
$promoData
[
'discount_percentage'
];
}
$discAmt
=
(
!
empty
(
$maxReedem
=
$promoData
[
'max_redeem'
])
&&
$maxReedem
<
$discAmt
)
?
$maxReedem
:
$discAmt
;
$tot_cost
=
$tot_cost
-
$discAmt
;
$tot_cost
=
(
$tot_cost
<=
0
)
?
0
:
$tot_cost
;
$countryData
=
$this
->
getCountryData
(
$user_id
);
$lang
=
$countryData
[
'language_code'
];
$promDetails
=
langTranslator
(
$promoData
[
'promocode_id'
],
'PROMO'
,
$lang
);
$datas
[
'discounted_price'
]
=
$tot_cost
;
$datas
[
'terms_and_conditions'
]
=
$promDetails
[
'promocode_tc'
];
$datas
[
'description'
]
=
$promDetails
[
'promocode_desc'
];
$respArr
[
'status'
]
=
1
;
$respArr
[
'data'
]
=
$datas
;
return
$respArr
;
}
else
{
$res
=
array
(
'status'
=>
0
,
'message'
=>
'Invalid user'
,
'code'
=>
'ER19'
);
}
}
function
getCheckerBookList
(
$data
)
{
try
{
$checker_id
=
$data
[
'checker_id'
];
$count
=
$this
->
db
->
get_where
(
'checker'
,
array
(
'id'
=>
$checker_id
,
'status'
=>
'1'
))
->
num_rows
();
if
(
$count
>
0
){
$sql
=
"SELECT BOOK.bookId AS booking_id
FROM checker_bookings AS CBOOK
INNER JOIN booking AS BOOK ON (BOOK.bookId=CBOOK.booking_id)
WHERE CBOOK.checker_id='
$checker_id
' AND BOOK.status='1'"
;
$count
=
$this
->
db
->
query
(
$sql
)
->
num_rows
();
if
(
$count
>
0
)
{
$perPage
=
10
;
$page
=
(
isset
(
$data
[
'page'
]))
?
$data
[
'page'
]
:
1
;
$limit
=
(
$page
-
1
)
*
$perPage
;
$meta
=
array
(
'total_pages'
=>
ceil
(
$count
/
$perPage
),
'total'
=>
$count
,
'current_page'
=>
$page
,
'per_page'
=>
$perPage
);
if
(
$count
>
$limit
)
{
$sql
=
"SELECT TEVT.event_name,TCAT.category_name,CUST.name,EDATE.date,
EDATE.time,BOOK.amount,BOOK.bookId AS booking_id
FROM checker_bookings AS CBOOK
INNER JOIN booking AS BOOK ON (BOOK.bookId=CBOOK.booking_id)
INNER JOIN events AS EVT ON (EVT.event_id=BOOK.event_id)
INNER JOIN event_date_time AS EDATE ON (EDATE.event_id=EVT.event_id)
INNER JOIN event_category AS CAT ON (CAT.cat_id=EVT.category_id)
INNER JOIN customer AS CUST ON (CUST.customer_id=BOOK.customer_id)
INNER JOIN translator_event AS TEVT ON (TEVT.event_id=EVT.event_id)
INNER JOIN translator_category AS TCAT ON (TCAT.category_id=CAT.cat_id)
WHERE CBOOK.checker_id='
$checker_id
' AND TEVT.language_code='EN' AND
TCAT.language_code='EN' AND BOOK.status='1'"
;
$result
=
$this
->
db
->
query
(
$sql
)
->
result
();
$resp
=
array
(
'data'
=>
$result
,
'meta'
=>
$meta
);
$res
=
array
(
'status'
=>
1
,
'message'
=>
'Successfully'
,
'data'
=>
$resp
);
}
else
{
$resp
=
array
(
'data'
=>
[],
'meta'
=>
$meta
);
$res
=
array
(
'status'
=>
1
,
'message'
=>
'No More Data Found'
,
'data'
=>
$resp
);
}
}
else
{
$res
=
array
(
'status'
=>
0
,
'message'
=>
'No Record Found'
,
'code'
=>
'ER24'
);
}
}
else
{
$res
=
array
(
'status'
=>
0
,
'message'
=>
'Checker Doesnot Exist'
,
'code'
=>
'ER25'
);
}
}
catch
(
Exception
$e
)
{
$res
=
array
(
'status'
=>
0
,
'message'
=>
'Ohh No!! Something went South!!'
,
'code'
=>
'ER06'
);
}
return
$res
;
}
}
?>
This diff is collapsed.
Click to expand it.
application/models/Validation_model.php
View file @
4b364cd8
...
...
@@ -355,7 +355,35 @@ class Validation_model extends CI_Model {
)
)
,
'payNow'
=>
array
(),
'searchEvent'
=>
array
()
'searchEvent'
=>
array
(),
'validate_promo_code'
=>
array
(
'promo_code'
=>
array
(
'required'
=>
array
(
'code'
=>
'ER16'
,
'message'
=>
'Promocode is null or empty'
)
),
'tot_cost'
=>
array
(
'required'
=>
array
(
'code'
=>
'ER17'
,
'message'
=>
'Total Cost is null or empty'
)
),
'auth_token'
=>
array
(
'required'
=>
array
(
'code'
=>
'ER18'
,
'message'
=>
'User Id is null or empty'
)
)
),
'getCheckerBookList'
=>
array
(
'checker_id'
=>
array
(
'required'
=>
array
(
'code'
=>
'ER04'
,
'message'
=>
'checker ID is null or empty'
)
)
)
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment