2020-04-15 23:08:09 +00:00
< ? php
namespace App\Http\Controllers ;
2020-10-05 16:32:31 +00:00
use App\Models\User ;
use App\Models\WalletAgent ;
2020-06-01 18:31:25 +00:00
use App\Models\WalletsUser ;
2020-04-15 23:08:09 +00:00
use App\Traits\ApiResponser ;
2020-06-25 08:01:59 +00:00
use App\Traits\Helper ;
2020-04-17 15:26:12 +00:00
use Illuminate\Http\Request ;
use Illuminate\Http\Response ;
2020-04-15 23:08:09 +00:00
use Illuminate\Support\Facades\DB ;
class WalletController extends Controller
{
use ApiResponser ;
2020-06-25 08:01:59 +00:00
use Helper ;
2020-04-17 15:26:12 +00:00
2020-04-15 23:08:09 +00:00
/**
* Create a new controller instance .
*
* @ return void
*/
public function __construct ()
{
//
}
2020-04-17 15:26:12 +00:00
public function activated ( $id_agent )
{
2020-09-28 09:43:39 +00:00
$networks = DB :: select ( ' SELECT ne . name as network , cc . name AS country , cc . currency_code , w . id , w . balance_princ , w . balance_com , w . created_date , cw . type ,
2020-07-07 19:15:30 +00:00
na . id AS id_networkAgent , cw . taux_com_client_depot , na . id AS id_networkAgent , cg . category FROM agents ag
2020-04-21 14:07:57 +00:00
INNER JOIN networks_agents na ON ag . id = na . agent_id INNER JOIN codeGenerer cg ON cg . id = na . codeGenerer_id INNER JOIN networks ne ON ne . id = na . network_id INNER JOIN configWallet cw ON ne . id = cw . id_network
2020-09-28 09:43:39 +00:00
INNER JOIN countries_currencies cc ON ne . country_id = cc . id LEFT JOIN wallets w ON na . id = w . id_networkAgent WHERE ag . id = : id AND network_id IN (
2020-04-17 15:26:12 +00:00
SELECT networks . id FROM networks LEFT JOIN configWallet ON configWallet . id_network = networks . id WHERE status = 1 AND id_network IS NOT NULL ) ', [' id ' => $id_agent ]);
2020-04-15 23:08:09 +00:00
2020-05-05 08:27:08 +00:00
// Create wallet if is not exist
2020-05-05 20:42:57 +00:00
$category = null ;
2020-05-05 08:27:08 +00:00
if ( $networks ){
$reload = false ;
$id = $id_agent ;
foreach ( $networks as $network ){
2020-05-05 20:42:57 +00:00
$category = $network -> category ;
// Create wallet if is not exist
2020-05-05 08:27:08 +00:00
if ( ! $network -> id ){
DB :: insert ( 'INSERT INTO wallets (id_networkAgent) VALUES (?);' , [ $network -> id_networkAgent ]);
$reload = true ;
}
}
if ( $reload )
return $this -> activated ( $id );
}
2020-05-05 20:42:57 +00:00
2020-05-05 22:29:26 +00:00
2020-05-05 20:42:57 +00:00
// Return only single wallet if it is hypervisor or supervisor
2020-05-05 22:29:26 +00:00
if ( in_array ( $category , [ 'hyper' , 'super' ])){
// Remove unnecessary fields
$networks = $this -> array_except ( $networks ,[ 'id_networkAgent' , 'category' ]);
2020-05-05 20:42:57 +00:00
return $this -> successResponse ( collect ( $networks ) -> first ());
2020-05-05 22:29:26 +00:00
} else {
// Remove unnecessary fields
$networks = $this -> array_except ( $networks ,[ 'id_networkAgent' , 'category' , 'balance_princ' , 'balance_com' , 'created_date' , 'taux_com_client_depot' ]);
2020-05-05 20:42:57 +00:00
return $this -> successResponse ( $networks );
2020-05-05 22:29:26 +00:00
}
}
2020-10-05 16:32:31 +00:00
private function array_except ( $array , $keys ){
2020-05-05 22:29:26 +00:00
foreach ( $array as $row ){
foreach ( $keys as $key ){
unset ( $row -> $key );
}
}
return $array ;
2020-04-15 23:08:09 +00:00
}
2020-04-17 15:26:12 +00:00
public function show ( $id_wallet )
{
2020-05-05 19:18:08 +00:00
// $wallet = Wallet::findOrFail($id_wallet);
2020-07-07 19:15:30 +00:00
$wallet = collect ( DB :: select ( ' SELECT wa . wallet_id AS id , wa . balance_princ , wa . balance_com , wa . created_date , wa . network , cw . taux_com_client_depot , c . name AS country , cw . type ,
2020-11-03 07:38:12 +00:00
c . currency_code , cw . id_network FROM wallet_agent wa INNER JOIN configWallet cw ON wa . network_id = cw . id_network INNER JOIN networks n ON n . id = wa . network_id
2020-07-04 17:03:59 +00:00
INNER JOIN countries_currencies c ON c . id = n . country_id
2020-05-05 19:18:08 +00:00
WHERE wa . wallet_id = : id ',[' id ' => $id_wallet ])) -> first ();
if ( $wallet )
return $this -> successResponse ( $wallet );
else
return $this -> errorResponse ( trans ( 'errors.model_not_found' ,[ 'model' => 'wallet' ]), Response :: HTTP_BAD_REQUEST );
2020-04-17 15:26:12 +00:00
}
2020-04-21 14:07:57 +00:00
public function create ( Request $request )
{
$rules = [
'id_networkAgent' => 'required|integer|min:1'
];
$this -> validate ( $request , $rules );
DB :: insert ( 'INSERT INTO wallets (id_networkAgent) VALUES (?);' , [ $request -> id_networkAgent ]);
2020-04-28 16:12:05 +00:00
return $this -> successResponse ( trans ( 'messages.new_wallet_added' ));
2020-04-21 14:07:57 +00:00
}
2020-06-01 18:31:25 +00:00
// Wallets users iLink
public function showWalletUser ( $id_user ){
2020-10-27 10:52:37 +00:00
$wallet = collect ( DB :: select ( ' SELECT wu .* , u . user_code , u . numero_carte , u . expiration_date , n2 . id as id_wallet_network , n2 . name as network , cc . name as country , cc . currency_code from wallets_users wu
2020-07-25 18:02:54 +00:00
INNER JOIN users u ON u . id = wu . idUser
INNER JOIN networks n1 ON n1 . id = u . network_id
INNER JOIN networks n2 ON n2 . country_id = n1 . country_id
INNER JOIN configWallet cw ON cw . id_network = n2 . id
INNER JOIN countries_currencies cc ON cc . id = n2 . country_id
2020-10-05 16:32:31 +00:00
WHERE wu . idUser = : id_user AND cw . type = \ 'ilink\' LIMIT 1' , [ 'id_user' => $id_user ])) -> first ();
if ( $wallet ) {
2020-06-02 08:35:37 +00:00
return $this -> successResponse ( $wallet );
2020-06-16 05:49:49 +00:00
} else
2020-10-05 16:32:31 +00:00
return $this -> errorResponse ( trans ( 'errors.model_not_found' , [ 'model' => 'wallet' ]), Response :: HTTP_BAD_REQUEST );
}
//Les historiques globals des hyperviseur et superviseur
public function hyperHistory ( $id_network , Request $request )
{
2020-10-16 18:43:44 +00:00
$demandes = DB :: select ( " SELECT 'N' as type_historique, i.montant , i.user as destinataire , i.* FROM infos_users_demandes_credits i WHERE id_network = :id ; " , [ 'id' => $id_network ]);
$savings = DB :: select ( " SELECT 'E' as type_historique , i.montant , i.user as destinataire , i.* FROM infos_users_epargnes i WHERE id_network = :id; " , [ 'id' => $id_network ]);
2020-10-05 16:32:31 +00:00
2020-10-27 10:52:37 +00:00
$transactions = DB :: select ( " SELECT 'T' as type_historique, wit.id_transaction, tit.nom as operation_fr , tit.name as operation_en , wit.montant ,wit.nom_emetteur, wit.prenom_emetteur, wit.id_wallet_user,wit.frais,wit.taxe,wit.id_destinataire,
2020-10-05 16:32:31 +00:00
wit . nom_destinataire , wit . prenom_destinataire , wit . type , wit . id_wallet_user , wit . init_country , wit . final_country , wit . network_destinataire , wit . montant_net_final_country ,
wit . date as date_creation , wit . id , wit . numero_carte , wit . montant_net FROM wallet_ilink_transaction wit
INNER JOIN type_ilink_transaction tit ON wit . type = tit . id WHERE wit . network_emetteur = : id ; " , ['id' => $id_network ]);
$transactions_mapped = array_map ( function ( $data ) {
2020-10-27 10:52:37 +00:00
$data -> operation = app () -> isLocale ( 'en' ) ? $data -> operation_en : $data -> operation_fr ;
2020-10-16 16:21:27 +00:00
$date = $data -> date_creation ;
unset ( $data -> date_creation );
2020-10-05 16:32:31 +00:00
$wallet_user = isset ( $data -> id_wallet_user ) ? WalletsUser :: findOrFail ( $data -> id_wallet_user ) : null ;
$user_destinataire = isset ( $data -> id_destinataire ) ? User :: where ( 'user_code' , $data -> id_destinataire ) -> first () : null ;
$emetteur = $wallet_user ? $wallet_user -> user -> lastname . ' ' . $wallet_user -> user -> firstname : $data -> prenom_emetteur . ' ' . $data -> nom_emetteur ;
if ( ! $wallet_user && ! $data -> nom_emetteur )
$emetteur = $data -> numero_carte ;
$destinataire = in_array ( $data -> type , [ 12 , 16 ]) ? $emetteur : ( $user_destinataire ? $user_destinataire -> lastname . ' ' . $user_destinataire -> firstname :
$data -> prenom_destinataire . ' ' . $data -> nom_destinataire );
$data -> emetteur = $emetteur ;
$data -> destinataire = $destinataire ;
$data -> frais = $this -> toMoney ( $data -> frais + $data -> taxe , $data -> init_country );
$data -> montant_net_init = $this -> toMoney ( $data -> montant_net , $data -> init_country );
$data -> montant_net_final = $data -> montant_net_final_country ? $this -> toMoney ( $data -> montant_net_final_country , $data -> final_country ) : $data -> montant_net_init ;
2020-10-16 19:30:27 +00:00
$data -> montant2 = $this -> toMoney ( $data -> montant , $data -> init_country );
2020-10-05 16:32:31 +00:00
$data -> init_country = $this -> getCountryName ( $data -> init_country );
$data -> final_country = $data -> montant_net_final_country ? $this -> getCountryName ( $data -> final_country ) : '' ;
$data -> reseau_payeur = isset ( $data -> network_destinataire ) ? $this -> getNetworkName ( $data -> network_destinataire ) . ' ' . $data -> final_country : null ;
2020-10-16 18:13:56 +00:00
if ( $data -> type == 13 )
$data -> destinataire = $data -> numero_carte ;
2020-10-16 19:30:27 +00:00
if ( ctype_space ( $data -> destinataire )) {
$data -> destinataire = $data -> emetteur ;
}
2020-10-16 16:21:27 +00:00
$data -> date_creation = $date ;
2020-10-05 16:32:31 +00:00
unset ( $data -> type , $data -> id_wallet_user , $data -> network_destinataire , $data -> nom_destinataire , $data -> prenom_destinataire , $data -> taxe , $data -> numero_carte ,
2020-10-27 10:52:37 +00:00
$data -> montant_net_final_country , $data -> montant_net , $data -> nom_emetteur , $data -> prenom_emetteur , $data -> id_destinataire , $data -> operation_fr , $data -> operation_en );
2020-10-05 16:32:31 +00:00
return $data ;
}, $transactions );
// Supprimer les underscore sur les etats
$merge = array_map ( function ( $demand ) {
$demand -> etat = str_replace ( '_' , ' ' , $demand -> etat );
return $demand ;
}, array_merge ( $demandes , $savings ));
$result = array_merge ( $transactions_mapped , $merge );
usort ( $result , array ( $this , 'sortFunction' )); // Trier le tout par date
2020-10-07 09:07:11 +00:00
return $this -> successResponse ( $this -> arrayPaginator ( $result , $request ));
2020-10-05 16:32:31 +00:00
}
public function superHistory ( $id_wallet , Request $request )
{
$walletSup = WalletAgent :: where ( 'wallet_id' , $id_wallet ) -> firstOrFail ();
2020-10-16 18:43:44 +00:00
$demandes = DB :: select ( " SELECT 'N' as type_historique , i.montant ,i.user as destinataire , i.* FROM infos_users_demandes_credits i WHERE codeParrain = :code ; " , [ 'code' => $walletSup -> codeMembre ]);
2020-10-05 16:32:31 +00:00
2020-10-27 10:52:37 +00:00
$transactions = DB :: select ( " SELECT 'T' as type_historique, wit.id_transaction, tit.nom as operation_fr , tit.name as operation_en , wit.montant ,wit.nom_emetteur, wit.prenom_emetteur, wit.id_wallet_user,wit.frais,wit.taxe,wit.id_destinataire,
2020-10-05 16:32:31 +00:00
wit . nom_destinataire , wit . prenom_destinataire , wit . type , wit . id_wallet_user , wit . init_country , wit . final_country , wit . network_destinataire , wit . montant_net_final_country ,
wit . date as date_creation , wit . id , wit . numero_carte , wit . montant_net FROM wallet_ilink_transaction wit
INNER JOIN type_ilink_transaction tit ON wit . type = tit . id WHERE wit . id_wallet_sup = : id ; " , ['id' => $id_wallet ]);
$transactions_mapped = array_map ( function ( $data ) {
2020-10-27 10:52:37 +00:00
$data -> operation = app () -> isLocale ( 'en' ) ? $data -> operation_en : $data -> operation_fr ;
2020-10-16 16:21:27 +00:00
$date = $data -> date_creation ;
unset ( $data -> date_creation );
2020-10-05 16:32:31 +00:00
$wallet_user = isset ( $data -> id_wallet_user ) ? WalletsUser :: findOrFail ( $data -> id_wallet_user ) : null ;
$user_destinataire = isset ( $data -> id_destinataire ) ? User :: where ( 'user_code' , $data -> id_destinataire ) -> first () : null ;
$emetteur = $wallet_user ? $wallet_user -> user -> lastname . ' ' . $wallet_user -> user -> firstname : $data -> prenom_emetteur . ' ' . $data -> nom_emetteur ;
if ( ! $wallet_user && ! $data -> nom_emetteur )
$emetteur = $data -> numero_carte ;
$destinataire = in_array ( $data -> type , [ 12 , 16 ]) ? $emetteur : ( $user_destinataire ? $user_destinataire -> lastname . ' ' . $user_destinataire -> firstname :
$data -> prenom_destinataire . ' ' . $data -> nom_destinataire );
$data -> emetteur = $emetteur ;
$data -> destinataire = $destinataire ;
$data -> frais = $this -> toMoney ( $data -> frais + $data -> taxe , $data -> init_country );
$data -> montant_net_init = $this -> toMoney ( $data -> montant_net , $data -> init_country );
$data -> montant_net_final = $data -> montant_net_final_country ? $this -> toMoney ( $data -> montant_net_final_country , $data -> final_country ) : $data -> montant_net_init ;
2020-10-16 19:30:27 +00:00
$data -> montant2 = $this -> toMoney ( $data -> montant , $data -> init_country );
2020-10-05 16:32:31 +00:00
$data -> init_country = $this -> getCountryName ( $data -> init_country );
$data -> final_country = $data -> montant_net_final_country ? $this -> getCountryName ( $data -> final_country ) : '' ;
$data -> reseau_payeur = isset ( $data -> network_destinataire ) ? $this -> getNetworkName ( $data -> network_destinataire ) . ' ' . $data -> final_country : null ;
2020-10-16 18:13:56 +00:00
if ( $data -> type == 13 )
$data -> destinataire = $data -> numero_carte ;
2020-10-16 16:21:27 +00:00
$data -> date_creation = $date ;
2020-10-05 16:32:31 +00:00
unset ( $data -> type , $data -> id_wallet_user , $data -> network_destinataire , $data -> nom_destinataire , $data -> prenom_destinataire , $data -> taxe , $data -> numero_carte ,
2020-10-27 10:52:37 +00:00
$data -> montant_net_final_country , $data -> montant_net , $data -> nom_emetteur , $data -> prenom_emetteur , $data -> id_destinataire , $data -> operation_fr , $data -> operation_en );
2020-10-05 16:32:31 +00:00
return $data ;
}, $transactions );
// Supprimer les underscore sur les etats
$demandes_mapped = array_map ( function ( $demand ) {
$demand -> etat = str_replace ( '_' , ' ' , $demand -> etat );
return $demand ;
}, $demandes );
$result = array_merge ( $transactions_mapped , $demandes_mapped );
usort ( $result , array ( $this , 'sortFunction' )); // Trier le tout par date
2020-10-07 09:07:11 +00:00
return $this -> successResponse ( $this -> arrayPaginator ( $result , $request ));
2020-06-01 18:31:25 +00:00
}
2020-10-16 07:40:10 +00:00
// Routes sans pagination
public function allHyperHistory ( $id_network )
{
2020-10-16 18:43:44 +00:00
$demandes = DB :: select ( " SELECT 'N' as type_historique, i.montant , i.user as destinataire , i.* FROM infos_users_demandes_credits i WHERE id_network = :id ; " , [ 'id' => $id_network ]);
$savings = DB :: select ( " SELECT 'E' as type_historique , i.montant , i.user as destinataire , i.* FROM infos_users_epargnes i WHERE id_network = :id; " , [ 'id' => $id_network ]);
2020-10-16 07:40:10 +00:00
2020-10-27 10:52:37 +00:00
$transactions = DB :: select ( " SELECT 'T' as type_historique, wit.id_transaction, tit.nom as operation_fr , tit.name as operation_en , wit.montant ,wit.nom_emetteur, wit.prenom_emetteur, wit.id_wallet_user,wit.frais,wit.taxe,wit.id_destinataire,
2020-10-16 07:40:10 +00:00
wit . nom_destinataire , wit . prenom_destinataire , wit . type , wit . id_wallet_user , wit . init_country , wit . final_country , wit . network_destinataire , wit . montant_net_final_country ,
wit . date as date_creation , wit . id , wit . numero_carte , wit . montant_net FROM wallet_ilink_transaction wit
INNER JOIN type_ilink_transaction tit ON wit . type = tit . id WHERE wit . network_emetteur = : id ; " , ['id' => $id_network ]);
$transactions_mapped = array_map ( function ( $data ) {
2020-10-27 10:52:37 +00:00
$data -> operation = app () -> isLocale ( 'en' ) ? $data -> operation_en : $data -> operation_fr ;
2020-10-16 16:21:27 +00:00
$date = $data -> date_creation ;
unset ( $data -> date_creation );
2020-10-16 07:40:10 +00:00
$wallet_user = isset ( $data -> id_wallet_user ) ? WalletsUser :: findOrFail ( $data -> id_wallet_user ) : null ;
$user_destinataire = isset ( $data -> id_destinataire ) ? User :: where ( 'user_code' , $data -> id_destinataire ) -> first () : null ;
$emetteur = $wallet_user ? $wallet_user -> user -> lastname . ' ' . $wallet_user -> user -> firstname : $data -> prenom_emetteur . ' ' . $data -> nom_emetteur ;
if ( ! $wallet_user && ! $data -> nom_emetteur )
$emetteur = $data -> numero_carte ;
$destinataire = in_array ( $data -> type , [ 12 , 16 ]) ? $emetteur : ( $user_destinataire ? $user_destinataire -> lastname . ' ' . $user_destinataire -> firstname :
$data -> prenom_destinataire . ' ' . $data -> nom_destinataire );
$data -> emetteur = $emetteur ;
$data -> destinataire = $destinataire ;
$data -> frais = $this -> toMoney ( $data -> frais + $data -> taxe , $data -> init_country );
$data -> montant_net_init = $this -> toMoney ( $data -> montant_net , $data -> init_country );
$data -> montant_net_final = $data -> montant_net_final_country ? $this -> toMoney ( $data -> montant_net_final_country , $data -> final_country ) : $data -> montant_net_init ;
2020-10-16 19:30:27 +00:00
$data -> montant2 = $this -> toMoney ( $data -> montant , $data -> init_country );
2020-10-16 07:40:10 +00:00
$data -> init_country = $this -> getCountryName ( $data -> init_country );
$data -> final_country = $data -> montant_net_final_country ? $this -> getCountryName ( $data -> final_country ) : '' ;
$data -> reseau_payeur = isset ( $data -> network_destinataire ) ? $this -> getNetworkName ( $data -> network_destinataire ) . ' ' . $data -> final_country : null ;
2020-10-16 18:13:56 +00:00
if ( $data -> type == 13 )
$data -> destinataire = $data -> numero_carte ;
2020-10-16 19:30:27 +00:00
if ( ctype_space ( $data -> destinataire )) {
$data -> destinataire = $data -> emetteur ;
}
2020-10-16 16:21:27 +00:00
$data -> date_creation = $date ;
2020-10-16 07:40:10 +00:00
unset ( $data -> type , $data -> id_wallet_user , $data -> network_destinataire , $data -> nom_destinataire , $data -> prenom_destinataire , $data -> taxe , $data -> numero_carte ,
2020-10-27 10:52:37 +00:00
$data -> montant_net_final_country , $data -> montant_net , $data -> nom_emetteur , $data -> prenom_emetteur , $data -> id_destinataire , $data -> operation_fr , $data -> operation_en );
2020-10-16 07:40:10 +00:00
return $data ;
}, $transactions );
// Supprimer les underscore sur les etats
$merge = array_map ( function ( $demand ) {
$demand -> etat = str_replace ( '_' , ' ' , $demand -> etat );
return $demand ;
}, array_merge ( $demandes , $savings ));
$result = array_merge ( $transactions_mapped , $merge );
usort ( $result , array ( $this , 'sortFunction' )); // Trier le tout par date
return $this -> successResponse ( $result );
}
public function allSuperHistory ( $id_wallet )
{
$walletSup = WalletAgent :: where ( 'wallet_id' , $id_wallet ) -> firstOrFail ();
2020-10-16 18:43:44 +00:00
$demandes = DB :: select ( " SELECT 'N' as type_historique, i.montant , i.user as destinataire , i.* FROM infos_users_demandes_credits i WHERE codeParrain = :code ; " , [ 'code' => $walletSup -> codeMembre ]);
2020-10-16 07:40:10 +00:00
2020-10-27 10:52:37 +00:00
$transactions = DB :: select ( " SELECT 'T' as type_historique, wit.id_transaction, tit.nom as operation_fr , tit.name as operation_en , wit.montant ,wit.nom_emetteur, wit.prenom_emetteur, wit.id_wallet_user,wit.frais,wit.taxe,wit.id_destinataire,
2020-10-16 07:40:10 +00:00
wit . nom_destinataire , wit . prenom_destinataire , wit . type , wit . id_wallet_user , wit . init_country , wit . final_country , wit . network_destinataire , wit . montant_net_final_country ,
wit . date as date_creation , wit . id , wit . numero_carte , wit . montant_net FROM wallet_ilink_transaction wit
INNER JOIN type_ilink_transaction tit ON wit . type = tit . id WHERE wit . id_wallet_sup = : id ; " , ['id' => $id_wallet ]);
$transactions_mapped = array_map ( function ( $data ) {
2020-10-27 10:52:37 +00:00
$data -> operation = app () -> isLocale ( 'en' ) ? $data -> operation_en : $data -> operation_fr ;
2020-10-16 16:21:27 +00:00
$date = $data -> date_creation ;
unset ( $data -> date_creation );
2020-10-16 07:40:10 +00:00
$wallet_user = isset ( $data -> id_wallet_user ) ? WalletsUser :: findOrFail ( $data -> id_wallet_user ) : null ;
$user_destinataire = isset ( $data -> id_destinataire ) ? User :: where ( 'user_code' , $data -> id_destinataire ) -> first () : null ;
$emetteur = $wallet_user ? $wallet_user -> user -> lastname . ' ' . $wallet_user -> user -> firstname : $data -> prenom_emetteur . ' ' . $data -> nom_emetteur ;
if ( ! $wallet_user && ! $data -> nom_emetteur )
$emetteur = $data -> numero_carte ;
$destinataire = in_array ( $data -> type , [ 12 , 16 ]) ? $emetteur : ( $user_destinataire ? $user_destinataire -> lastname . ' ' . $user_destinataire -> firstname :
$data -> prenom_destinataire . ' ' . $data -> nom_destinataire );
$data -> emetteur = $emetteur ;
$data -> destinataire = $destinataire ;
$data -> frais = $this -> toMoney ( $data -> frais + $data -> taxe , $data -> init_country );
$data -> montant_net_init = $this -> toMoney ( $data -> montant_net , $data -> init_country );
$data -> montant_net_final = $data -> montant_net_final_country ? $this -> toMoney ( $data -> montant_net_final_country , $data -> final_country ) : $data -> montant_net_init ;
2020-10-16 19:30:27 +00:00
$data -> montant2 = $this -> toMoney ( $data -> montant , $data -> init_country );
2020-10-16 07:40:10 +00:00
$data -> init_country = $this -> getCountryName ( $data -> init_country );
$data -> final_country = $data -> montant_net_final_country ? $this -> getCountryName ( $data -> final_country ) : '' ;
$data -> reseau_payeur = isset ( $data -> network_destinataire ) ? $this -> getNetworkName ( $data -> network_destinataire ) . ' ' . $data -> final_country : null ;
2020-10-16 18:13:56 +00:00
if ( $data -> type == 13 )
$data -> destinataire = $data -> numero_carte ;
2020-10-16 19:30:27 +00:00
if ( ctype_space ( $data -> destinataire )) {
$data -> destinataire = $data -> emetteur ;
}
2020-10-16 16:21:27 +00:00
$data -> date_creation = $date ;
2020-10-16 07:40:10 +00:00
unset ( $data -> type , $data -> id_wallet_user , $data -> network_destinataire , $data -> nom_destinataire , $data -> prenom_destinataire , $data -> taxe , $data -> numero_carte ,
2020-10-27 10:52:37 +00:00
$data -> montant_net_final_country , $data -> montant_net , $data -> nom_emetteur , $data -> prenom_emetteur , $data -> id_destinataire , $data -> operation_fr , $data -> operation_en );
2020-10-16 07:40:10 +00:00
return $data ;
}, $transactions );
// Supprimer les underscore sur les etats
$demandes_mapped = array_map ( function ( $demand ) {
$demand -> etat = str_replace ( '_' , ' ' , $demand -> etat );
return $demand ;
}, $demandes );
$result = array_merge ( $transactions_mapped , $demandes_mapped );
usort ( $result , array ( $this , 'sortFunction' )); // Trier le tout par date
return $this -> successResponse ( $result );
}
2020-10-27 10:52:37 +00:00
public function getWalletBanks ( $id_wallet_network )
{
2020-11-05 17:12:55 +00:00
$banks = DB :: select ( " SELECT bc.id as id_bank, b.nom as bank_name , bc.adresse as bank_address, c.name as country FROM networks_banks nb INNER JOIN banks_countries bc on bc.id = nb.id_bank_country INNER JOIN banks b ON b.id = bc.id_bank
2020-10-27 10:52:37 +00:00
INNER JOIN countries c ON bc . id_country = c . id WHERE nb . id_network = : id_network ; " , ['id_network' => $id_wallet_network ]);
return $this -> successResponse ( $banks );
}
2020-04-15 23:08:09 +00:00
}