+ Send notification and substract commission accounts when deleting wallet transactions
This commit is contained in:
parent
75f13c8af0
commit
b5f82b9694
|
@ -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_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_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
|
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');
|
||||||
|
|
|
@ -79,9 +79,6 @@ $db['default'] = array(
|
||||||
'username' => 'root',
|
'username' => 'root',
|
||||||
'password' => 'vps@2017GA',
|
'password' => 'vps@2017GA',
|
||||||
'database' => 'iLink_preprod',
|
'database' => 'iLink_preprod',
|
||||||
'wallet_service_url' => 'http://localhost:8081',
|
|
||||||
'wallet_service_externe_url' => 'http://localhost:8085',
|
|
||||||
'notification_service_url' => 'http://localhost:8083',
|
|
||||||
'dbdriver' => 'mysqli',
|
'dbdriver' => 'mysqli',
|
||||||
'dbprefix' => '',
|
'dbprefix' => '',
|
||||||
'pconnect' => FALSE,
|
'pconnect' => FALSE,
|
||||||
|
|
|
@ -144,10 +144,10 @@ class Admin_dash extends CI_Controller
|
||||||
if ($this->input->get('view')) {
|
if ($this->input->get('view')) {
|
||||||
switch ($this->input->get('view')){
|
switch ($this->input->get('view')){
|
||||||
case 'walletServiceInterne' :
|
case 'walletServiceInterne' :
|
||||||
$data['link'] = $this->db->wallet_service_url.'/api/documentation';
|
$data['link'] = WALLET_SERVICE_URL.'/api/documentation';
|
||||||
break;
|
break;
|
||||||
case 'walletServiceExterne' :
|
case 'walletServiceExterne' :
|
||||||
$data['link'] = $this->db->wallet_service_externe_url.'/api/documentation';
|
$data['link'] = WALLET_SERVICE_EXTERNE_URL.'/api/documentation';
|
||||||
break;
|
break;
|
||||||
case 'backoffice':
|
case 'backoffice':
|
||||||
$data['link'] = base_url('docs/html/index.html');
|
$data['link'] = base_url('docs/html/index.html');
|
||||||
|
|
|
@ -1997,7 +1997,7 @@ class Gestion extends CI_Controller
|
||||||
$id_transacton = $_POST['id_transaction'];
|
$id_transacton = $_POST['id_transaction'];
|
||||||
|
|
||||||
/* API URL */
|
/* API URL */
|
||||||
$url = $this->db->wallet_service_url.'/transactions/'.$id_transacton;
|
$url = WALLET_SERVICE_URL.'/transactions/'.$id_transacton;
|
||||||
|
|
||||||
/* Init cURL resource */
|
/* Init cURL resource */
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
|
@ -2007,7 +2007,7 @@ class Gestion extends CI_Controller
|
||||||
/* set the content type json */
|
/* set the content type json */
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||||
'Content-Type:application/json',
|
'Content-Type:application/json',
|
||||||
'Authorization: yhSTSSqIO1uSE1icu09edPOeSFGxIDjo'
|
'Authorization:'.WALLET_SERVICE_TOKEN
|
||||||
));
|
));
|
||||||
|
|
||||||
/* set return type json */
|
/* set return type json */
|
||||||
|
@ -2035,7 +2035,7 @@ class Gestion extends CI_Controller
|
||||||
$id_transacton = $_POST['id_transaction'];
|
$id_transacton = $_POST['id_transaction'];
|
||||||
|
|
||||||
/* API URL */
|
/* API URL */
|
||||||
$url = $this->db->wallet_service_url . '/transactions/ilink/' . $id_transacton;
|
$url = WALLET_SERVICE_URL . '/transactions/ilink/' . $id_transacton;
|
||||||
|
|
||||||
/* Init cURL resource */
|
/* Init cURL resource */
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
|
@ -2045,7 +2045,7 @@ class Gestion extends CI_Controller
|
||||||
/* set the content type json */
|
/* set the content type json */
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||||
'Content-Type:application/json',
|
'Content-Type:application/json',
|
||||||
'Authorization: yhSTSSqIO1uSE1icu09edPOeSFGxIDjo'
|
'Authorization:'.WALLET_SERVICE_TOKEN
|
||||||
));
|
));
|
||||||
|
|
||||||
/* set return type json */
|
/* set return type json */
|
||||||
|
|
|
@ -268,16 +268,16 @@ class Hyperviseur_dash extends CI_Controller
|
||||||
try {
|
try {
|
||||||
$message = line_with_arguments($this->lang->line('credit_request_canceled_by_hypervisor_message'), array($id,$demand->montant));
|
$message = line_with_arguments($this->lang->line('credit_request_canceled_by_hypervisor_message'), array($id,$demand->montant));
|
||||||
//Send email
|
//Send email
|
||||||
$this->load->library('email');
|
// $this->load->library('email');
|
||||||
$this->email->from('noreply@ilink-app.com', 'iLink World');
|
// $this->email->from('noreply@ilink-app.com', 'iLink World');
|
||||||
$this->email->to(array($demand->email_agent,$demand->email_parrain));
|
// $this->email->to(array($demand->email_agent,$demand->email_parrain));
|
||||||
|
//
|
||||||
$this->email->subject($this->lang->line('credit_request_canceled_by_hypervisor'));
|
// $this->email->subject($this->lang->line('credit_request_canceled_by_hypervisor'));
|
||||||
$this->email->message($message);
|
// $this->email->message($message);
|
||||||
$this->email->send() ;
|
// $this->email->send() ;
|
||||||
|
|
||||||
/* API URL */
|
/* API URL */
|
||||||
$url = $this->db->notification_service_url . '/onesignal/pushToAgent' ;
|
$url = NOTIFICATION_SERVICE_URL . '/onesignal/pushToAgent' ;
|
||||||
|
|
||||||
/* Init cURL resource */
|
/* Init cURL resource */
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
|
@ -287,7 +287,7 @@ class Hyperviseur_dash extends CI_Controller
|
||||||
/* set the content type json */
|
/* set the content type json */
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||||
'Content-Type:application/json',
|
'Content-Type:application/json',
|
||||||
'Authorization: RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg'
|
'Authorization:'.NOTIFICATION_SERVICE_TOKEN
|
||||||
));
|
));
|
||||||
|
|
||||||
$data = new \stdClass();
|
$data = new \stdClass();
|
||||||
|
@ -578,20 +578,88 @@ class Hyperviseur_dash extends CI_Controller
|
||||||
if ($this->isLogged()) {
|
if ($this->isLogged()) {
|
||||||
$datetime = $this->user_model->getCurrentTimeByNetworkID($this->session->userdata('network_id'));
|
$datetime = $this->user_model->getCurrentTimeByNetworkID($this->session->userdata('network_id'));
|
||||||
$id = $this->input->post('id_transaction');
|
$id = $this->input->post('id_transaction');
|
||||||
|
$query = $this->db->get_where('wallet_transaction', ['id' => $id]);
|
||||||
|
if($query->num_rows()>0) {
|
||||||
|
$transaction = $query->first_row();
|
||||||
|
|
||||||
|
// 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');
|
||||||
|
|
||||||
|
// 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');
|
||||||
|
|
||||||
|
// 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(
|
$data = array(
|
||||||
'deleted' => 1 ,
|
'deleted' => 1 ,
|
||||||
'deleted_at' => $datetime
|
'deleted_at' => $datetime
|
||||||
);
|
);
|
||||||
|
// Changer l'etat de la transaction
|
||||||
$this->db->where('id',$id);
|
$this->db->where('id',$id);
|
||||||
$query = $this->db->update('wallet_transaction',$data);
|
$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) {
|
if ($query) {
|
||||||
echo json_encode("200");
|
echo json_encode("200");
|
||||||
} else {
|
} else {
|
||||||
echo json_encode("500");
|
echo json_encode("500");
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
echo json_encode("404");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1789,7 +1857,7 @@ class Hyperviseur_dash extends CI_Controller
|
||||||
if ($view) {
|
if ($view) {
|
||||||
switch ($view){
|
switch ($view){
|
||||||
case 'walletServiceExterne' :
|
case 'walletServiceExterne' :
|
||||||
$data['link'] = $this->db->wallet_service_externe_url.'/api/documentation';
|
$data['link'] = WALLET_SERVICE_EXTERNE_URL.'/api/documentation';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$data['link'] = '#';
|
$data['link'] = '#';
|
||||||
|
|
|
@ -101,7 +101,7 @@
|
||||||
</span><!--//icon-holder-->
|
</span><!--//icon-holder-->
|
||||||
Note
|
Note
|
||||||
</h4>
|
</h4>
|
||||||
<p>Utilisez ce jeton d'autorisation : <code class="callout-title">JeJMx6KNW1qo2h01rCVOLfX3f1nmcF2I</code> afin de pouvoir tester les routes qui y figurent.</p>
|
<p>Utilisez ce jeton d'autorisation : <code class="callout-title"><?=WALLET_SERVICE_EXTERNE_TOKEN ?></code> afin de pouvoir tester les routes qui y figurent.</p>
|
||||||
</div><!--//content-->
|
</div><!--//content-->
|
||||||
</div><!--//callout-block-->
|
</div><!--//callout-block-->
|
||||||
</section><!--//section-->
|
</section><!--//section-->
|
||||||
|
|
|
@ -105,7 +105,7 @@
|
||||||
</span><!--//icon-holder-->
|
</span><!--//icon-holder-->
|
||||||
Note
|
Note
|
||||||
</h4>
|
</h4>
|
||||||
<p>Utilisez ce jeton d'autorisation : <code class="callout-title">fywRtXSwEhHncwXaqn10wa9bJU9a63r2</code> afin de pouvoir tester les routes qui y figurent.</p>
|
<p>Utilisez ce jeton d'autorisation : <code class="callout-title"><?= WALLET_SERVICE_TOKEN ?></code> afin de pouvoir tester les routes qui y figurent.</p>
|
||||||
</div><!--//content-->
|
</div><!--//content-->
|
||||||
</div><!--//callout-block-->
|
</div><!--//callout-block-->
|
||||||
</section><!--//section-->
|
</section><!--//section-->
|
||||||
|
@ -124,7 +124,7 @@
|
||||||
</span><!--//icon-holder-->
|
</span><!--//icon-holder-->
|
||||||
Note
|
Note
|
||||||
</h4>
|
</h4>
|
||||||
<p>Utilisez ce jeton d'autorisation : <code class="callout-title">JeJMx6KNW1qo2h01rCVOLfX3f1nmcF2I</code> afin de pouvoir tester les routes qui y figurent.</p>
|
<p>Utilisez ce jeton d'autorisation : <code class="callout-title"><?=WALLET_SERVICE_EXTERNE_TOKEN ?></code> afin de pouvoir tester les routes qui y figurent.</p>
|
||||||
</div><!--//content-->
|
</div><!--//content-->
|
||||||
</div><!--//callout-block-->
|
</div><!--//callout-block-->
|
||||||
</section><!--//section-->
|
</section><!--//section-->
|
||||||
|
|
|
@ -401,13 +401,13 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if ($row->status) {
|
<?php if ($row->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');
|
$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_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');
|
$document_back_file = @fopen($document_back ,'r');
|
||||||
?>
|
?>
|
||||||
<label class="text-center text-muted" style="padding: 10px"> Identification </label>
|
<label class="text-center text-muted" style="padding: 10px"> Identification </label>
|
||||||
|
@ -604,13 +604,13 @@
|
||||||
value="<?php echo $row->phone ?>">
|
value="<?php echo $row->phone ?>">
|
||||||
</div>
|
</div>
|
||||||
<?php if ($row->status) {
|
<?php if ($row->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');
|
$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_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');
|
$document_back_file = @fopen($document_back ,'r');
|
||||||
?>
|
?>
|
||||||
<label class="text-center text-muted" style="padding: 10px"> Identification </label>
|
<label class="text-center text-muted" style="padding: 10px"> Identification </label>
|
||||||
|
|
Loading…
Reference in New Issue