From 39981f3d1cc764a985a01164c36d8605436d46dd Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Thu, 9 Jul 2020 19:26:05 +0100 Subject: [PATCH] + Update agent transactions history --- .../iLinkTransactionController.php | 37 +++++++++++++------ resources/lang/en/errors.php | 1 + resources/lang/fr/errors.php | 2 +- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/iLinkTransactionController.php b/app/Http/Controllers/iLinkTransactionController.php index ee608e8..f6f1224 100755 --- a/app/Http/Controllers/iLinkTransactionController.php +++ b/app/Http/Controllers/iLinkTransactionController.php @@ -491,6 +491,10 @@ class iLinkTransactionController extends Controller if ($this->checkPassword($request->password, $agent->encrypted_password, $agent->salt)) { $transaction = WalletIlinkTransaction::where('id_transaction', $request->id_transaction)->first(); if ($transaction) { + //Verifier si l'agent qui a effectué l'envoi de cash à cash ne puisse pas retirer l'argent + if($transaction->type == 17) + if($transaction->id_wallet_ag == $walletAgent->id) + return $this->errorResponse(trans('errors.agent_unauthorized')); //Verifier que le reseau payeur est de type iLink if (in_array($transaction->type, [3, 17])) { $configPayeur = ConfigWallet::where('id_network', $transaction->network_destinataire)->firstOrFail(); @@ -894,7 +898,7 @@ class iLinkTransactionController extends Controller public function lastUserTransactions($id_wallet_user) { - $transactions = DB::select('SELECT tit.nom as operation , tit.type ,tit.acteur as source , wit.montant , + $transactions = DB::select('SELECT tit.nom as operation , wit.montant , CASE WHEN u.lastname IS NOT NULL THEN u.lastname ELSE @@ -910,17 +914,28 @@ class iLinkTransactionController extends Controller public function lastAgentTransactions($id_wallet_agent) { - $transactions = DB::select('SELECT tit.nom as operation , tit.type ,tit.acteur as source , wit.montant , - CASE - WHEN u.lastname IS NOT NULL THEN u.lastname - ELSE - CASE - WHEN wit.id_destinataire IS NULL THEN wit.nom_destinataire - ELSE wit.id_destinataire - END - END AS destinataire , wit.date , wit.id FROM wallet_ilink_transaction wit - INNER JOIN type_ilink_transaction tit ON wit.type = tit.id LEFT JOIN users u ON u.user_code = wit.id_destinataire WHERE wit.id_wallet_ag = :id_wallet + $transactions = DB::select('SELECT wit.id_transaction, tit.nom as operation , wit.montant ,wit.nom_emetteur, wit.prenom_emetteur, wit.id_wallet_user,wit.frais,wit.taxe, + 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 , wit.id , wit.montant_net FROM wallet_ilink_transaction wit + INNER JOIN type_ilink_transaction tit ON wit.type = tit.id WHERE wit.id_wallet_ag = :id_wallet ORDER BY wit.date DESC LIMIT 10;', ['id_wallet' => $id_wallet_agent]); + + foreach ($transactions as $data){ + $wallet_user = isset($data->id_wallet_user) ? WalletsUser::findOrFail($data->id_wallet_user) : null ; + $emetteur = $wallet_user ? $wallet_user->user->lastname.' '.$wallet_user->user->firstname : $data->prenom_emetteur . ' ' . $data->nom_emetteur; + $destinataire = in_array($data->type,[12]) ? $emetteur : $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_final = $this->toMoney($data->montant_net_final_country, $data->final_country); + $data->montant_net_init = $this->toMoney($data->montant_net, $data->init_country); + $data->montant = $this->toMoney($data->montant, $data->init_country); + $data->init_country = $this->getCountryName($data->init_country); + $data->final_country = $this->getCountryName($data->final_country); + $data->reseau_payeur = isset($data->network_destinataire) ? $this->getNetworkName($data->network_destinataire) : null; + unset($data->type, $data->id_wallet_user, $data->network_destinataire,$data->nom_destinataire, $data->prenom_destinataire ,$data->taxe, + $data->montant_net_final_country, $data->montant_net,$data->nom_emetteur, $data->prenom_emetteur); + } return $this->successResponse($transactions); } diff --git a/resources/lang/en/errors.php b/resources/lang/en/errors.php index 4613e59..a0407cd 100755 --- a/resources/lang/en/errors.php +++ b/resources/lang/en/errors.php @@ -24,4 +24,5 @@ Paying network : :network :country', 'user_identification_required' => 'User identification is required to continue the operation', 'validation_user_identification_required' => 'Validation of user identification is required to continue the operation', 'incorrect_net_amount' => 'Net amount is less than zero', + 'agent_unauthorized'=> 'This agent cannot make this withdrawal' ]; diff --git a/resources/lang/fr/errors.php b/resources/lang/fr/errors.php index 388c221..f7482e3 100755 --- a/resources/lang/fr/errors.php +++ b/resources/lang/fr/errors.php @@ -24,5 +24,5 @@ Réseau payeur : :network :country', 'user_identification_required' => 'L\'identification de l\'utilisateur est requise pour continuer l\'operation', 'validation_user_identification_required' => 'La validation de l\'identification de l\'utilisateur est requise pour continuer l\'operation', 'incorrect_net_amount' => 'Le montant net est inférieur à zéro', - + 'agent_unauthorized'=> 'Cet agent ne peut pas effectuer ce retrait', ];