diff --git a/application/config/constants.php b/application/config/constants.php index 18d3b4b7..aa60be3b 100755 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -83,3 +83,13 @@ defined('EXIT_USER_INPUT') OR define('EXIT_USER_INPUT', 7); // invalid user defined('EXIT_DATABASE') OR define('EXIT_DATABASE', 8); // database error defined('EXIT__AUTO_MIN') OR define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code + +/* + * Microservices constants + */ +define('WALLET_SERVICE_URL','http://localhost:8081'); +define('WALLET_SERVICE_TOKEN','fywRtXSwEhHncwXaqn10wa9bJU9a63r2'); +define('WALLET_SERVICE_EXTERNE_URL','http://localhost:8085'); +define('WALLET_SERVICE_EXTERNE_TOKEN','JeJMx6KNW1qo2h01rCVOLfX3f1nmcF2I'); +define('NOTIFICATION_SERVICE_URL','http://localhost:8083'); +define('NOTIFICATION_SERVICE_TOKEN','RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg'); diff --git a/application/config/database.php b/application/config/database.php index 7ac94ffe..f17c9b7c 100755 --- a/application/config/database.php +++ b/application/config/database.php @@ -79,9 +79,6 @@ $db['default'] = array( 'username' => 'root', 'password' => 'vps@2017GA', 'database' => 'iLink_preprod', - 'wallet_service_url' => 'http://localhost:8081', - 'wallet_service_externe_url' => 'http://localhost:8085', - 'notification_service_url' => 'http://localhost:8083', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, diff --git a/application/controllers/Admin_dash.php b/application/controllers/Admin_dash.php index f3d1c259..f11da926 100755 --- a/application/controllers/Admin_dash.php +++ b/application/controllers/Admin_dash.php @@ -144,10 +144,10 @@ class Admin_dash extends CI_Controller if ($this->input->get('view')) { switch ($this->input->get('view')){ case 'walletServiceInterne' : - $data['link'] = $this->db->wallet_service_url.'/api/documentation'; + $data['link'] = WALLET_SERVICE_URL.'/api/documentation'; break; case 'walletServiceExterne' : - $data['link'] = $this->db->wallet_service_externe_url.'/api/documentation'; + $data['link'] = WALLET_SERVICE_EXTERNE_URL.'/api/documentation'; break; case 'backoffice': $data['link'] = base_url('docs/html/index.html'); diff --git a/application/controllers/Gestion.php b/application/controllers/Gestion.php index 5b2adb82..11d09466 100755 --- a/application/controllers/Gestion.php +++ b/application/controllers/Gestion.php @@ -1997,7 +1997,7 @@ class Gestion extends CI_Controller $id_transacton = $_POST['id_transaction']; /* API URL */ - $url = $this->db->wallet_service_url.'/transactions/'.$id_transacton; + $url = WALLET_SERVICE_URL.'/transactions/'.$id_transacton; /* Init cURL resource */ $ch = curl_init($url); @@ -2007,7 +2007,7 @@ class Gestion extends CI_Controller /* set the content type json */ curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type:application/json', - 'Authorization: yhSTSSqIO1uSE1icu09edPOeSFGxIDjo' + 'Authorization:'.WALLET_SERVICE_TOKEN )); /* set return type json */ @@ -2035,7 +2035,7 @@ class Gestion extends CI_Controller $id_transacton = $_POST['id_transaction']; /* API URL */ - $url = $this->db->wallet_service_url . '/transactions/ilink/' . $id_transacton; + $url = WALLET_SERVICE_URL . '/transactions/ilink/' . $id_transacton; /* Init cURL resource */ $ch = curl_init($url); @@ -2045,7 +2045,7 @@ class Gestion extends CI_Controller /* set the content type json */ curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type:application/json', - 'Authorization: yhSTSSqIO1uSE1icu09edPOeSFGxIDjo' + 'Authorization:'.WALLET_SERVICE_TOKEN )); /* set return type json */ diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index 61867889..7c3ef671 100755 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -268,16 +268,16 @@ class Hyperviseur_dash extends CI_Controller try { $message = line_with_arguments($this->lang->line('credit_request_canceled_by_hypervisor_message'), array($id,$demand->montant)); //Send email - $this->load->library('email'); - $this->email->from('noreply@ilink-app.com', 'iLink World'); - $this->email->to(array($demand->email_agent,$demand->email_parrain)); - - $this->email->subject($this->lang->line('credit_request_canceled_by_hypervisor')); - $this->email->message($message); - $this->email->send() ; +// $this->load->library('email'); +// $this->email->from('noreply@ilink-app.com', 'iLink World'); +// $this->email->to(array($demand->email_agent,$demand->email_parrain)); +// +// $this->email->subject($this->lang->line('credit_request_canceled_by_hypervisor')); +// $this->email->message($message); +// $this->email->send() ; /* API URL */ - $url = $this->db->notification_service_url . '/onesignal/pushToAgent' ; + $url = NOTIFICATION_SERVICE_URL . '/onesignal/pushToAgent' ; /* Init cURL resource */ $ch = curl_init($url); @@ -287,7 +287,7 @@ class Hyperviseur_dash extends CI_Controller /* set the content type json */ curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type:application/json', - 'Authorization: RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg' + 'Authorization:'.NOTIFICATION_SERVICE_TOKEN )); $data = new \stdClass(); @@ -578,19 +578,87 @@ class Hyperviseur_dash extends CI_Controller if ($this->isLogged()) { $datetime = $this->user_model->getCurrentTimeByNetworkID($this->session->userdata('network_id')); $id = $this->input->post('id_transaction'); + $query = $this->db->get_where('wallet_transaction', ['id' => $id]); + if($query->num_rows()>0) { + $transaction = $query->first_row(); - $data = array( - 'deleted' => 1 , - 'deleted_at' => $datetime - ); + // Debiter le compte de l'agent de sa commission + $this->db->set('balance_com', 'balance_com-'.$transaction->commission_ag,false); + $this->db->where('id',$transaction->id_wallet); + $this->db->update('wallets'); - $this->db->where('id',$id); - $query = $this->db->update('wallet_transaction',$data); + // Debiter le compte du superviseur de sa commission + $this->db->set('balance_com', 'balance_com-'.$transaction->commission_sup,false); + $this->db->where('id',$transaction->id_wallet_sup); + $this->db->update('wallets'); - if ($query) { - echo json_encode("200"); - } else { - echo json_encode("500"); + // Debiter le compte de l'hyperviseur de sa commission + $this->db->set('balance_com', 'balance_com-'.$transaction->commission_hyp,false); + $this->db->where('id',$transaction->id_wallet_hyp); + $this->db->update('wallets'); + + $data = array( + 'deleted' => 1 , + 'deleted_at' => $datetime + ); + // Changer l'etat de la transaction + $this->db->where('id',$id); + $query = $this->db->update('wallet_transaction',$data); + + try { + $message = line_with_arguments($this->lang->line('credit_request_canceled_by_hypervisor_message'), array($id,$demand->montant)); + + $url = NOTIFICATION_SERVICE_URL . '/onesignal/pushToAgent' ; + + /* Init cURL resource */ + $ch = curl_init($url); + + curl_setopt($ch, CURLOPT_POST, 1); + + /* set the content type json */ + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type:application/json', + 'Authorization:'.NOTIFICATION_SERVICE_TOKEN + )); + + $data = new \stdClass(); + $data->screen = "Historique"; + $data->data = new \stdClass(); + $data->data->id = $id; + + $body = new \stdClass(); + $body->agent_code = $demand->codeMembre; + $body->message = $message; + $body->data = $data; + $body->date = $datetime; + + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); + + /* set return type json */ + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + /* execute request */ + curl_exec($ch); + + $body->agent_code = $demand->codeParrain; + + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); + + curl_exec($ch); + /* close cURL resource */ + curl_close($ch); + + }catch (\Throwable $e){ + + } + + if ($query) { + echo json_encode("200"); + } else { + echo json_encode("500"); + } + }else{ + echo json_encode("404"); } } } @@ -1789,7 +1857,7 @@ class Hyperviseur_dash extends CI_Controller if ($view) { switch ($view){ case 'walletServiceExterne' : - $data['link'] = $this->db->wallet_service_externe_url.'/api/documentation'; + $data['link'] = WALLET_SERVICE_EXTERNE_URL.'/api/documentation'; break; default: $data['link'] = '#'; diff --git a/application/views/documentation/docs-page-hyp.php b/application/views/documentation/docs-page-hyp.php index d06d5fc4..e558ddf8 100755 --- a/application/views/documentation/docs-page-hyp.php +++ b/application/views/documentation/docs-page-hyp.php @@ -101,7 +101,7 @@ Note -

Utilisez ce jeton d'autorisation : JeJMx6KNW1qo2h01rCVOLfX3f1nmcF2I afin de pouvoir tester les routes qui y figurent.

+

Utilisez ce jeton d'autorisation : afin de pouvoir tester les routes qui y figurent.

diff --git a/application/views/documentation/docs-page.php b/application/views/documentation/docs-page.php index 48016b01..edac099a 100755 --- a/application/views/documentation/docs-page.php +++ b/application/views/documentation/docs-page.php @@ -105,7 +105,7 @@ Note -

Utilisez ce jeton d'autorisation : fywRtXSwEhHncwXaqn10wa9bJU9a63r2 afin de pouvoir tester les routes qui y figurent.

+

Utilisez ce jeton d'autorisation : afin de pouvoir tester les routes qui y figurent.

@@ -124,7 +124,7 @@ Note -

Utilisez ce jeton d'autorisation : JeJMx6KNW1qo2h01rCVOLfX3f1nmcF2I afin de pouvoir tester les routes qui y figurent.

+

Utilisez ce jeton d'autorisation : afin de pouvoir tester les routes qui y figurent.

diff --git a/application/views/gestion_recherche.php b/application/views/gestion_recherche.php index cfa18abf..907035c2 100755 --- a/application/views/gestion_recherche.php +++ b/application/views/gestion_recherche.php @@ -401,13 +401,13 @@ status) { - $user_image = $this->db->wallet_service_url . '/photos/'.$row->user_image; + $user_image = WALLET_SERVICE_URL . '/photos/'.$row->user_image; $user_image_file = @fopen($user_image ,'r'); - $document_front = $this->db->wallet_service_url . '/documents/'.$row->document_image_front; + $document_front = WALLET_SERVICE_URL . '/documents/'.$row->document_image_front; $document_front_file = @fopen($document_front ,'r'); - $document_back = $this->db->wallet_service_url . '/documents/'.$row->document_image_back; + $document_back = WALLET_SERVICE_URL . '/documents/'.$row->document_image_back; $document_back_file = @fopen($document_back ,'r'); ?> @@ -604,13 +604,13 @@ value="phone ?>"> status) { - $user_image = $this->db->wallet_service_url . '/photos/'.$row->user_image; + $user_image = WALLET_SERVICE_URL . '/photos/'.$row->user_image; $user_image_file = @fopen($user_image ,'r'); - $document_front = $this->db->wallet_service_url . '/documents/'.$row->document_image_front; + $document_front = WALLET_SERVICE_URL . '/documents/'.$row->document_image_front; $document_front_file = @fopen($document_front ,'r'); - $document_back = $this->db->wallet_service_url . '/documents/'.$row->document_image_back; + $document_back = WALLET_SERVICE_URL . '/documents/'.$row->document_image_back; $document_back_file = @fopen($document_back ,'r'); ?>