Commit 242870c3 by Jansa Jose

Merge branch 'master' of https://gitlab.techware.co.in/timeout/timeOut into jansa

parents 8757fda6 734de007
......@@ -329,6 +329,10 @@ class Api extends CI_Controller {
switch($txnType){
case 'WALLET':
return $this->Api_model->updateWalletTxn($txnData);
case 'HOTEL_BOOK':
if(isset($txnData['bookData']) && !empty($txnData['bookData'])){
return $this->Api_model->hotelBooking($txnData);
}
}
}
......@@ -345,12 +349,13 @@ class Api extends CI_Controller {
if(empty($reqData) || empty($reqData = json_decode($reqData,true)) ||
!isset($reqData['amount']) || empty($amount = $reqData['amount']) ||
!isset($reqData['auth_token']) || empty($auth_token = $reqData['auth_token'])){
redirect($redUrl.'failure');
redirect($redUrl.'failure');
}
if(isset($reqData['txnType']) && !empty($reqData['txnType'])){
$params = array('mode'=>'1','status'=>'0','auth_token'=>$reqData['auth_token'],
'amount'=>$reqData['amount']);
$params = array('mode'=>'1','status'=>'0',
'auth_token'=>$reqData['auth_token'],'amount'=>$reqData['amount'],
'bookData'=>(isset($reqData['bookData']))?$reqData['bookData']:'');
$customData = $this->txnManager($reqData['txnType'],$params);
if(empty($customData)){
......@@ -577,7 +582,7 @@ class Api extends CI_Controller {
$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'));
$customData = $this->txnManager($eventid,array('tnx_id'=>$booking_id,'status'=>'2'));
$sql = "SELECT BOK.event_id FROM transaction AS TX
INNER JOIN booking AS BOK ON (BOK.bookId=TX.booking_id)
......
......@@ -25,5 +25,8 @@
WHERE transaction.datetime<'$date_time'";
mysqli_query($conn, $sql);
$sql = "UPDATE wallet_transactions SET status='2' WHERE status='0' && created_date<'$date_time'";
mysqli_query($conn, $sql);
$conn->close();
?>
......@@ -627,6 +627,7 @@ class Api_model extends CI_Model {
'created_date'=>date('Y-m-d H:i:s'),'status'=>$promoStatus);
}
$auth_token = $post_data['auth_token'];
$card_data = (isset($post_data['cardData']))?$post_data['cardData']:array();
unset($post_data['auth_token'],$post_data['has_payment'],$post_data['cardData'],
$post_data['promocode_id'],$post_data['redeem_amount']);
......@@ -636,13 +637,11 @@ class Api_model extends CI_Model {
$this->db->insert('promocode_used',$promocodeData);
}
$cardDetails = array();
if(isset($post_data['cardData']) && !empty($card_data = $post_data['cardData'])){
// (CC)-Credit ,(DC)-Debit ,(DD)-Direct Debit,(PAYPAL)-PayPal,(NB)-Net Banking
if(!empty($card_data)){
switch($card_data->card_type) {
case '1': $cardDetails['cardMode'] = 'CC'; break;
case '2': $cardDetails['cardMode'] = 'DC'; break;
case '3': $cardDetails['cardMode'] = 'DD'; break;
default : $cardDetails['cardMode'] = 'DD'; break;
case '1': $cardDetails['cardMode'] = 'DD'; break;
case '2': $cardDetails['cardMode'] = 'CC'; break;
default : $cardDetails['cardMode'] = 'CC'; break;
}
switch(substr($card_data->card_number,0,1)) {
......@@ -1397,8 +1396,8 @@ class Api_model extends CI_Model {
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();
$lastTxn = $this->db->get_where('wallet_transactions',$cond)->row_array();
$amount = $lastTxn['amount'];
$customer_id = $lastTxn['customer_id'];
$sql = "UPDATE wallet SET balance_amount=balance_amount+$amount
......@@ -1791,5 +1790,32 @@ class Api_model extends CI_Model {
$res = array('status'=>0,'message'=>'Invalid user','code'=>'ER19');
}
}
public function hotelBooking($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']) ||
!isset($txnData['bookData']) || empty($bookData = $txnData['bookData'])){
return;
}
$user_id = $this->auth_token_get($txnData['auth_token']);
if(empty($user_id)){
return;
}
$bookId = 'HTL'.date('ymd').str_pad(rand(1111,9999),4,0,STR_PAD_LEFT);
$insert = array('hotel_book_id'=>$bookId,'hotel_name'=>$bookData['hotelName'],
'hotel_image'=>$bookData['hotelImage'],'checkin'=>$bookData['checkin'],
'checkout'=>$bookData['checkout'],'price'=>$bookData['amount'],
'request_data'=>json_encode($bookData['requestData']));
$this->db->insert('hotel_booking',$insert);
return array('status'=>1,'transaction_id'=>$bookId);
}
}catch(Exception $e){}
}
}
?>
\ No newline at end of file
......@@ -1862,6 +1862,7 @@ class Webservice_model extends CI_Model {
if(empty($data)){
return array('status'=>0,'code'=>'918','message'=>'Data Missing');
}
$phNumbers = '';
foreach($data['contacts'] AS $key => $number) {
$number = preg_replace('/\D/', '', $number);
......@@ -1874,40 +1875,63 @@ class Webservice_model extends CI_Model {
$phNumbers .= " (CUST.phone LIKE '%".$number."' ".$eCond;
}
}
if(empty($phNumbers)){
return array('status'=>0,'code'=>'919','message'=>'Invalid Data');
}
if(empty($phNumbers)){ return array('status'=>0,'code'=>'919','message'=>'Invalid Data'); }
$sql = "SELECT CUST.customer_id FROM customer AS CUST
INNER JOIN users AS USR ON (USR.id=CUST.customer_id)
WHERE $phNumbers AND CUST.customer_id!=$user_id";
WHERE CUST.enable_chat='1' AND CUST.customer_id!=$user_id AND $phNumbers";
$custIds = $this->db->query($sql)->result_array();
if(empty($custIds)){
return array('status'=>0,'code'=>'919','message'=>'No Data Found');
if(empty($custIds)){
return array('status'=>0,'code'=>'919','message'=>'No Data Found');
}
$user_ids = '';
foreach ($custIds AS $id) {
$user_ids = $id['customer_id'].',';
foreach ($custIds AS $id) {
if(!empty($user_ids) && in_array($id,$user_ids)){
continue;
}
$user_ids[] = $id['customer_id'];
}
$user_ids = trim($user_ids,',');
$result = $this->db->query("SELECT CUST.customer_id,CUST.name,CUST.phone,CUST.profile_image,
CUST.profile_image_qr,CHT.type AS friend_status
FROM customer AS CUST
LEFT JOIN chats AS CHT ON ((CUST.customer_id=CHT.from_user OR CUST.customer_id=CHT.to_user) AND CHT.type IN (0,1))
WHERE CUST.customer_id IN ($user_ids) AND
customer_id NOT IN
(SELECT from_user FROM chats
WHERE (from_user=$user_id AND type='2') OR
(to_user=$user_id AND type='2'))
AND
customer_id NOT IN
(SELECT to_user FROM chats
WHERE (from_user=$user_id AND type='2') OR
(to_user=$user_id AND type='2'))
GROUP BY CUST.customer_id");
$respArr['status'] = 1;
$respArr['data'] = (!empty($result) && !empty($result=$result->result_array()))?$result:[];
$sql = "SELECT from_user FROM chats
WHERE (from_user=$user_id AND type='2') OR (to_user=$user_id AND type='2')";
$blocked = $this->db->query($sql)->result_array();
if(!empty($blocked)){
foreach ($blocked AS $id) {
$user_ids = array_diff($user_ids,$id);
}
}
$sql = "SELECT to_user FROM chats
WHERE (from_user=$user_id AND type='2') OR (to_user=$user_id AND type='2')";
$blocked = $this->db->query($sql)->result_array();
if(!empty($blocked)){
foreach ($blocked AS $id) {
$user_ids = array_diff($user_ids,$id);
}
}
if(empty($user_ids)){
return array('status'=>0,'code'=>'920','message'=>'No User Found');
}
$chatUsers = array();
foreach($user_ids AS $user) {
$sql = "SELECT CUST.customer_id,CUST.name,CUST.phone,CUST.profile_image,
CUST.profile_image_qr,CHT.type AS friend_status
FROM customer AS CUST
LEFT JOIN chats AS CHT ON (
((CHT.from_user=$user AND to_user=$user_id) OR
(CHT.to_user=$user AND from_user=$user_id)) AND
CHT.type IN (0,1))
WHERE CUST.customer_id IN ($user)
GROUP BY CUST.customer_id";
$result = $this->db->query($sql)->row_array();
if(!empty($result)){
$chatUsers[] = $result;
}
}
$respArr = array('status'=>1,'data'=>$chatUsers);
return $respArr;
}
......@@ -1977,16 +2001,10 @@ class Webservice_model extends CI_Model {
public function recent_chats($data){
$respArr = array('status'=>0,'code'=>'918','message'=>'No Request for you');
$user_id = $this->auth_token_get($data['auth_token']);
$result = $this->db->query("SELECT from_user,to_user,type
FROM chats
WHERE (from_user=$user_id OR to_user=$user_id) AND
type IN ('0','1')")->result_array();
$result = $this->db->query("SELECT from_user,to_user,type FROM chats WHERE (from_user=$user_id OR to_user=$user_id) AND type IN ('1')")->result_array();
$custData = array();
if(!empty($result)){
foreach ($result as $key => $value) {
if($value['type'] == 0){
continue;
}
$fromUsrId = '';
if($value['to_user'] == $user_id) {
$fromUsrId = $value['from_user'];
......
......@@ -68,9 +68,9 @@
case 3: echo 'Pending'; break;
case 4: echo 'Deleted'; break;
case 5: echo 'Payment Failed'; break;
case 6: if($booking->has_payment == 0){ echo 'Waiting for Aproval'; break; }
case 6: if($booking->has_payment == 0){ echo 'Waiting for Approval'; break; }
else {
if ($booking->trans_status == '1') { echo 'Waiting for Aproval'; break; }
if ($booking->trans_status == '1') { echo 'Waiting for Approval';break; }
else { echo 'Pending'; break; }
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment