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
c732910a
Commit
c732910a
authored
Dec 04, 2019
by
Jansa Jose
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 'dev_production'
Master See merge request
!226
parents
9284fa68
46487d0d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
127 additions
and
41 deletions
+127
-41
Api.php
application/controllers/Api.php
+31
-5
Api_model.php
application/models/Api_model.php
+59
-16
Webservice_model.php
application/models/Webservice_model.php
+37
-20
No files found.
application/controllers/Api.php
View file @
c732910a
...
...
@@ -325,6 +325,13 @@ class Api extends CI_Controller {
}
}
public
function
txnManager
(
$txnType
=
''
,
$txnData
=
array
()){
switch
(
$txnType
){
case
'WALLET'
:
return
$this
->
Api_model
->
updateWalletTxn
(
$txnData
);
}
}
public
function
payNow
(
$reqData
=
''
){
$settings
=
getSettings
();
$redUrl
=
$settings
[
'web_base_url'
];
...
...
@@ -337,9 +344,24 @@ class Api extends CI_Controller {
if
(
empty
(
$reqData
)
||
empty
(
$reqData
=
json_decode
(
$reqData
,
true
))
||
!
isset
(
$reqData
[
'amount'
])
||
empty
(
$amount
=
$reqData
[
'amount'
])
||
!
isset
(
$reqData
[
'event_id'
])
||
empty
(
$event_id
=
$reqData
[
'event_id'
])
||
!
isset
(
$reqData
[
'auth_token'
])
||
empty
(
$auth_token
=
$reqData
[
'auth_token'
])){
redirect
(
$redUrl
.
'failure'
);
}
if
(
isset
(
$reqData
[
'txnType'
])
&&
!
empty
(
$reqData
[
'txnType'
])){
$params
=
array
(
'mode'
=>
'1'
,
'status'
=>
'0'
,
'auth_token'
=>
$reqData
[
'auth_token'
],
'amount'
=>
$reqData
[
'amount'
]);
$customData
=
$this
->
txnManager
(
$reqData
[
'txnType'
],
$params
);
if
(
empty
(
$customData
)){
redirect
(
$redUrl
.
'failure'
);
}
$reqData
[
'event_id'
]
=
$reqData
[
'txnType'
];
$reqData
[
'booking_id'
]
=
$customData
[
'transaction_id'
];
}
if
(
!
isset
(
$reqData
[
'event_id'
])
||
empty
(
$event_id
=
$reqData
[
'event_id'
])
||
!
isset
(
$reqData
[
'cardData'
])
||
empty
(
$cardData
=
$reqData
[
'cardData'
])
||
!
isset
(
$reqData
[
'auth_token'
])
||
empty
(
$auth_token
=
$reqData
[
'auth_token'
])
||
!
isset
(
$reqData
[
'booking_id'
])
||
empty
(
$booking_id
=
$reqData
[
'booking_id'
])){
redirect
(
$redUrl
.
'failure'
);
}
...
...
@@ -506,7 +528,8 @@ class Api extends CI_Controller {
}
if
(
!
empty
(
$transaction_id
)
&&
!
empty
(
$last_id
)){
$this
->
Api_model
->
update_payment
(
$response
,
$transaction_id
,
$last_id
,
'1'
);
$this
->
Api_model
->
update_payment
(
$response
,
$transaction_id
,
$last_id
,
'1'
,
$eventid
);
$customData
=
$this
->
txnManager
(
$eventid
,
array
(
'tnx_id'
=>
$booking_id
,
'status'
=>
'1'
));
}
if
(
!
empty
(
$booking_id
)){
...
...
@@ -551,7 +574,10 @@ class Api extends CI_Controller {
if
(
isset
(
$response
[
1
])
&&
!
empty
(
$response
[
1
])
&&
!
empty
(
$data
=
explode
(
'|'
,
$response
[
1
]))
&&
isset
(
$data
[
1
])
&&
!
empty
(
$data
[
1
])){
$last_id
=
$data
[
1
];
$this
->
Api_model
->
update_payment
(
$response
,
''
,
$last_id
,
'0'
);
$eventid
=
$data
[
2
];
$booking_id
=
$data
[
3
];
$this
->
Api_model
->
update_payment
(
$response
,
''
,
$last_id
,
'0'
,
$eventid
);
$customData
=
$this
->
txnManager
(
$eventid
,
array
(
'tnx_id'
=>
$booking_id
,
'status'
=>
'0'
));
$sql
=
"SELECT BOK.event_id FROM transaction AS TX
INNER JOIN booking AS BOK ON (BOK.bookId=TX.booking_id)
...
...
@@ -719,7 +745,7 @@ class Api extends CI_Controller {
$res
=
$this
->
Api_model
->
payNow
(
$payData
);
if
(
$res
[
'status'
]
==
1
){
$params
=
array
(
'amount'
=>
1
,
'last_id'
=>
$res
[
'transaction_id'
],
'event_id'
=>
'
test
'
,
$params
=
array
(
'amount'
=>
1
,
'last_id'
=>
$res
[
'transaction_id'
],
'event_id'
=>
'
ADD_CARD
'
,
'booking_id'
=>
'ADD_CARD'
,
'custData'
=>
$res
[
'custData'
],
'cardData'
=>
$reqData
);
$reqData
=
$this
->
encrypt
(
json_encode
(
$params
),
$this
->
local_key
,
$this
->
local_iv
);
...
...
application/models/Api_model.php
View file @
c732910a
...
...
@@ -1336,6 +1336,20 @@ class Api_model extends CI_Model {
return
$res
;
}
function
getUserData
(
$cust_id
=
''
){
if
(
empty
(
$cust_id
)){
return
0
;
}
$this
->
db
->
select
(
'customer.name,customer.dob,customer.phone,customer.email,customer.gender,
customer.profile_image AS image,users.id AS userId,customer.profile_city AS city,customer.dob,
customer.email_verified'
);
$this
->
db
->
where
(
'users.status'
,
1
);
$this
->
db
->
where
(
'customer.customer_id'
,
$cust_id
);
$this
->
db
->
from
(
'users'
);
$this
->
db
->
join
(
'customer'
,
'customer.customer_id = users.id'
);
return
$this
->
db
->
get
()
->
row
();
}
function
payNow
(
$data
){
try
{
$user_id
=
$this
->
auth_token_get
(
$data
[
'auth_token'
]);
...
...
@@ -1354,29 +1368,58 @@ class Api_model extends CI_Model {
return
$res
;
}
function
getUserData
(
$cust_id
=
''
){
if
(
empty
(
$cust_id
)){
return
0
;
}
$this
->
db
->
select
(
'customer.name,customer.dob,customer.phone,customer.email,customer.gender,
customer.profile_image AS image,users.id AS userId,customer.profile_city AS city,customer.dob,
customer.email_verified'
);
$this
->
db
->
where
(
'users.status'
,
1
);
$this
->
db
->
where
(
'customer.customer_id'
,
$cust_id
);
$this
->
db
->
from
(
'users'
);
$this
->
db
->
join
(
'customer'
,
'customer.customer_id = users.id'
);
return
$this
->
db
->
get
()
->
row
();
function
updateWalletTxn
(
$txnData
=
array
()){
try
{
if
(
empty
(
$txnData
)){
return
;
}
if
(
$txnData
[
'status'
]
==
'0'
){
if
(
!
isset
(
$txnData
[
'mode'
])
||
empty
(
$txnData
[
'mode'
])
||
!
isset
(
$txnData
[
'amount'
])
||
empty
(
$txnData
[
'amount'
])
||
!
isset
(
$txnData
[
'auth_token'
])
||
empty
(
$txnData
[
'auth_token'
])){
return
;
}
$user_id
=
$this
->
auth_token_get
(
$txnData
[
'auth_token'
]);
if
(
empty
(
$user_id
)){
return
;
}
$txnCode
=
'TXN'
.
date
(
'ymd'
)
.
str_pad
(
rand
(
1111
,
9999
),
4
,
0
,
STR_PAD_LEFT
);
$insertData
=
array
(
'customer_id'
=>
$user_id
,
'transaction_type'
=>
$txnData
[
'mode'
],
'created_date'
=>
date
(
'Y-m-d h:i:s'
),
'amount'
=>
$txnData
[
'amount'
],
'transaction_code'
=>
$txnCode
,
'status'
=>
0
);
$this
->
db
->
insert
(
'wallet_transactions'
,
$insertData
);
return
array
(
'status'
=>
1
,
'transaction_id'
=>
$txnCode
);
}
else
{
if
(
!
isset
(
$txnData
[
'tnx_id'
])
||
empty
(
$txnData
[
'tnx_id'
])){
return
;
}
$this
->
db
->
update
(
'wallet_transactions'
,
array
(
'status'
=>
$txnData
[
'status'
]),
array
(
'transaction_code'
=>
$txnData
[
'tnx_id'
]));
if
(
$txnData
[
'status'
]
==
1
){
$cond
=
array
(
'transaction_code'
=>
$txnData
[
'tnx_id'
],
'status'
=>
'1'
);
$lastTxn
=
$this
->
db
->
get_where
(
'wallet_transactions'
,
$cond
)
->
result_array
();
$amount
=
$lastTxn
[
'amount'
];
$customer_id
=
$lastTxn
[
'customer_id'
];
$sql
=
"UPDATE wallet SET balance_amount=balance_amount+
$amount
WHERE customer_id=
$customer_id
"
;
$this
->
db
->
query
(
$sql
);
}
}
}
catch
(
Exception
$e
){}
}
function
update_payment
(
$response
=
''
,
$transactionid
=
''
,
$last_id
,
$status
){
function
update_payment
(
$response
=
''
,
$transactionid
=
''
,
$last_id
,
$status
,
$eventid
=
''
){
try
{
if
(
empty
(
$last_id
)){
return
;
}
$this
->
db
->
update
(
'transaction'
,
array
(
'transaction_id'
=>
$transactionid
,
'transaction_response'
=>
json_encode
(
$response
),
'status'
=>
$status
),
$this
->
db
->
update
(
'transaction'
,
array
(
'transaction_id'
=>
$transactionid
,
'status'
=>
$status
,
'transaction_response'
=>
json_encode
(
$response
)),
array
(
'id'
=>
$last_id
));
if
(
!
empty
(
$eventid
)){
}
if
(
$status
==
1
){
$trBook
=
$this
->
db
->
get_where
(
'transaction'
,
array
(
'id'
=>
$last_id
))
->
row_array
();
$book_id
=
$trBook
[
'booking_id'
];
...
...
application/models/Webservice_model.php
View file @
c732910a
...
...
@@ -1264,7 +1264,7 @@ class Webservice_model extends CI_Model {
$this
->
db
->
query
(
"SET SESSION group_concat_max_len = 200000"
);
$result
=
$this
->
db
->
query
(
"
SELECT (SELECT COUNT(booking.id) FROM booking WHERE booking.event_id=events.event_id) AS
attendees, events.event_id, event_gallery.media_url,event_category.cat_id,
attendees, events.event_id,
events.has_payment,
event_gallery.media_url,event_category.cat_id,
CAST(AVG (review.rate) AS DECIMAL (12, 1)) AS rating,
venue.location, IF(favourite.is_favorite = 0, 'false', 'true') AS is_favorite,
IF(events.provider_id = 0, 'false', 'true') AS is_editors_choice,
...
...
@@ -1337,7 +1337,8 @@ class Webservice_model extends CI_Model {
'location'
=>
$rs
->
location
,
'is_favorite'
=>
$rs
->
is_favorite
===
'true'
?
true
:
false
,
'is_editors_choice'
=>
$rs
->
is_editors_choice
===
'true'
?
true
:
false
,
'currency_symbol'
=>
$countryData
[
'currency_symbol'
]
'currency_symbol'
=>
$countryData
[
'currency_symbol'
],
'has_payment'
=>
$rs
->
has_payment
);
array_push
(
$response
,
$resData
);
}
...
...
@@ -1737,7 +1738,7 @@ class Webservice_model extends CI_Model {
LEFT JOIN event_gallery AS IMG ON (IMG.event_id=EVT.event_id AND
IMG.media_type=0 AND IMG.status='1')
WHERE EDATE.date>=DATE_FORMAT(NOW(),'%Y-%m-%d') AND EVT.status='1' AND
VEN.status='1' AND EDATE.status='1' AND
VEN.status='1' AND EDATE.status='1' AND
TEVT.language_code='
$lang
' AND
EVT.event_id IN (SELECT event_id FROM translator_event
WHERE (event_name LIKE '%
$str
%' OR
event_description LIKE '%
$str
%')
...
...
@@ -1880,7 +1881,7 @@ class Webservice_model extends CI_Model {
$sql
=
"SELECT CUST.customer_id FROM customer AS CUST
INNER JOIN users AS USR ON (USR.id=CUST.customer_id)
WHERE
$phNumbers
"
;
WHERE
$phNumbers
AND CUST.customer_id!=
$user_id
"
;
$custIds
=
$this
->
db
->
query
(
$sql
)
->
result_array
();
if
(
empty
(
$custIds
)){
return
array
(
'status'
=>
0
,
'code'
=>
'919'
,
'message'
=>
'No Data Found'
);
...
...
@@ -2200,10 +2201,10 @@ class Webservice_model extends CI_Model {
if
(
!
empty
(
$result
)
&&
!
empty
(
$result
=
$result
->
result_array
())){
$res
=
array
(
'status'
=>
'success'
,
'data'
=>
$result
);
}
else
{
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'No
Data
Found'
,
'code'
=>
'ER12'
);
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'No
Users
Found'
,
'code'
=>
'ER12'
);
}
}
else
{
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'
Invalid Use
r'
,
'code'
=>
'ER10'
);
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'
User Authentication Erro
r'
,
'code'
=>
'ER10'
);
}
}
catch
(
Exception
$e
){
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'Ohh No!! Something Went South'
,
'code'
=>
'ER08'
);
...
...
@@ -2219,8 +2220,8 @@ class Webservice_model extends CI_Model {
$sql
=
"SELECT balance_amount AS amount FROM wallet WHERE customer_id ='
$user_id
'"
;
$query
=
$this
->
db
->
query
(
$sql
);
if
(
empty
(
$query
)
||
empty
(
$walletBalance
=
$query
->
row_array
())){
$
res
=
array
(
'status'
=>
'error'
,
'message'
=>
'No Data Found'
,
'code'
=>
'ER12'
)
;
return
$res
;
$
walletBalance
[
'amount'
]
=
0
;
$this
->
db
->
insert
(
'wallet'
,
array
(
'customer_id'
=>
$user_id
,
'balance_amount'
=>
0
))
;
}
$walletBalance
[
'currency_symbol'
]
=
$countryData
[
'currency_symbol'
];
$res
=
array
(
'status'
=>
'success'
,
'data'
=>
$walletBalance
);
...
...
@@ -2228,7 +2229,7 @@ class Webservice_model extends CI_Model {
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'User Authentication Error'
,
'code'
=>
'ER10'
);
}
}
catch
(
Exception
$e
){
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'Ohh No!! Something Went South'
,
'code'
=>
'ER08'
);
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'Ohh No!! Something Went South
!!
'
,
'code'
=>
'ER08'
);
}
return
$res
;
}
...
...
@@ -2238,21 +2239,37 @@ class Webservice_model extends CI_Model {
$user_id
=
$this
->
auth_token_get
(
$data
[
'auth_token'
]);
if
(
$user_id
>
0
){
$countryData
=
$this
->
getCountryData
(
$user_id
);
$sql
=
"SELECT wallet_trans_id,amount,transaction_type,created_date,status FROM wallet_transactions WHERE customer_id='
$user_id
'"
;
$query
=
$this
->
db
->
query
(
$sql
);
if
(
empty
(
$query
)
||
empty
(
$walletHistory
=
$query
->
result_array
())){
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'No History Found'
,
'code'
=>
'ER13'
);
return
$res
;
$sql
=
"SELECT id FROM wallet_transactions WHERE customer_id='
$user_id
'"
;
$count
=
$this
->
db
->
query
(
$sql
)
->
num_rows
();
if
(
$count
>
0
){
$perPage
=
10
;
$page
=
(
isset
(
$data
[
'page'
])
&&
$data
[
'page'
]
!=
0
)
?
$data
[
'page'
]
:
1
;
$limit
=
(
$page
-
1
)
*
$perPage
;
$meta
=
array
(
'total_pages'
=>
ceil
(
$count
/
$perPage
),
'total_items'
=>
$count
,
'current_page'
=>
$page
,
'items_per_page'
=>
$perPage
);
$sql
=
"SELECT transaction_code AS transaction_number,amount,transaction_type,created_date,status
FROM wallet_transactions
WHERE customer_id='
$user_id
'
ORDER BY id DESC
LIMIT
$limit
,
$perPage
"
;
$query
=
$this
->
db
->
query
(
$sql
);
if
(
empty
(
$query
)
||
empty
(
$walletHistory
=
$query
->
result_array
())){
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'No Transaction History Found'
,
'code'
=>
'ER13'
);
return
$res
;
}
foreach
(
$walletHistory
AS
$walletKey
=>
$walletValue
){
$walletHistory
[
$walletKey
][
'currency_symbol'
]
=
$countryData
[
'currency_symbol'
];
}
$res
=
array
(
'status'
=>
'success'
,
'data'
=>
array
(
'wallet'
=>
$walletHistory
,
'meta'
=>
$meta
));
}
else
{
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'No Transaction History Found'
,
'code'
=>
'ER10'
);
}
foreach
(
$walletHistory
AS
$walletKey
=>
$walletValue
){
$walletHistory
[
$walletKey
][
'currency_symbol'
]
=
$countryData
[
'currency_symbol'
];
}
$res
=
array
(
'status'
=>
'success'
,
'data'
=>
$walletHistory
);
}
else
{
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'User
a
uthentication Error'
,
'code'
=>
'ER10'
);
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'User
A
uthentication Error'
,
'code'
=>
'ER10'
);
}
}
catch
(
Exception
$e
){
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'Ohh No!! Something Went South'
,
'code'
=>
'ER08'
);
$res
=
array
(
'status'
=>
'error'
,
'message'
=>
'Ohh No!! Something Went South
!!
'
,
'code'
=>
'ER08'
);
}
return
$res
;
}
...
...
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