+ Hyperviseur and Superviseur history
This commit is contained in:
parent
848d9428c7
commit
3b330e1595
|
@ -141,8 +141,8 @@ class NanoCreditController extends Controller
|
||||||
$walletHyper = Wallet::findOrFail($walletHyper->wallet_id);
|
$walletHyper = Wallet::findOrFail($walletHyper->wallet_id);
|
||||||
$walletUser = WalletsUser::where('idUser', $request->id_user)->firstOrFail();
|
$walletUser = WalletsUser::where('idUser', $request->id_user)->firstOrFail();
|
||||||
|
|
||||||
$demande_credit->date_demande = new \DateTime();
|
$demande_credit->date_validation = new \DateTime();
|
||||||
$demande_credit->date_remboursement_prevu = $demande_credit->date_demande->modify('+' . $request->duree_mois . ' month');
|
$demande_credit->date_remboursement_prevu = $demande_credit->date_validation->modify('+' . $request->duree_mois . ' month');
|
||||||
$demande_credit->etat = 'VALIDE';
|
$demande_credit->etat = 'VALIDE';
|
||||||
|
|
||||||
$montant_total = $demande_credit->montant + $demande_credit->interet + $demande_credit->taxe;
|
$montant_total = $demande_credit->montant + $demande_credit->interet + $demande_credit->taxe;
|
||||||
|
@ -186,10 +186,6 @@ class NanoCreditController extends Controller
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortFunction($a, $b)
|
|
||||||
{
|
|
||||||
return strtotime($b->date_creation) - strtotime($a->date_creation);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Demandes de nano credit et d'epargnes
|
// Demandes de nano credit et d'epargnes
|
||||||
public function getAllNanoCreditsDemands($id_user, Request $request)
|
public function getAllNanoCreditsDemands($id_user, Request $request)
|
||||||
|
@ -197,45 +193,69 @@ class NanoCreditController extends Controller
|
||||||
$demandes = DB::select("SELECT 'N' as type_historique , i.* FROM infos_users_demandes_credits i WHERE id_user = :id ;", ['id' => $id_user]);
|
$demandes = DB::select("SELECT 'N' as type_historique , i.* FROM infos_users_demandes_credits i WHERE id_user = :id ;", ['id' => $id_user]);
|
||||||
$savings = DB::select("SELECT 'E' as type_historique , i.* FROM infos_users_epargnes i WHERE id_user = :id;", ['id' => $id_user]);
|
$savings = DB::select("SELECT 'E' as type_historique , i.* FROM infos_users_epargnes i WHERE id_user = :id;", ['id' => $id_user]);
|
||||||
|
|
||||||
$merge = array_merge($demandes, $savings);
|
// Supprimer les underscore sur les etats
|
||||||
usort($merge, array($this, 'sortFunction'));
|
$merge = array_map(function ($demand) {
|
||||||
|
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||||
|
return $demand;
|
||||||
|
}, array_merge($demandes, $savings));
|
||||||
|
|
||||||
// return $this->successResponse($this->arrayPaginator($merge,$request));
|
usort($merge, array($this, 'sortFunction')); // Trier le tout par date
|
||||||
|
|
||||||
return $this->successResponse($merge);
|
return $this->successResponse($this->arrayPaginator($merge, $request));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNanoCreditsDemands($id_user)
|
public function getNanoCreditsDemands($id_user)
|
||||||
{
|
{
|
||||||
$demandes = DB::select('SELECT * FROM infos_users_demandes_credits WHERE id_user = :id ORDER BY date_creation DESC;', ['id' => $id_user]);
|
$demandes = DB::select('SELECT * FROM infos_users_demandes_credits WHERE id_user = :id ORDER BY date_creation DESC;', ['id' => $id_user]);
|
||||||
return $this->successResponse($demandes);
|
|
||||||
|
$result = array_map(function ($demand) {
|
||||||
|
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||||
|
return $demand;
|
||||||
|
}, $demandes);
|
||||||
|
return $this->successResponse($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Demandes de credits en cours pour le remboursement
|
// Demandes de credits en cours pour le remboursement
|
||||||
public function getNanoCreditsDemandsInProgress($id_user)
|
public function getNanoCreditsDemandsInProgress($id_user)
|
||||||
{
|
{
|
||||||
$demandes = DB::select("SELECT * FROM infos_users_demandes_credits WHERE id_user = :id AND etat = 'VALIDE' ORDER BY date_creation DESC;", ['id' => $id_user]);
|
$demandes = DB::select("SELECT * FROM infos_users_demandes_credits WHERE id_user = :id AND etat = 'VALIDE' ORDER BY date_creation DESC;", ['id' => $id_user]);
|
||||||
return $this->successResponse($demandes);
|
$result = array_map(function ($demand) {
|
||||||
|
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||||
|
return $demand;
|
||||||
|
}, $demandes);
|
||||||
|
return $this->successResponse($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGuaranteeNanoCreditsDemands($id_wallet_agent)
|
public function getGuaranteeNanoCreditsDemands($id_wallet_agent)
|
||||||
{
|
{
|
||||||
$demandes = DB::select('SELECT * FROM infos_users_demandes_credits WHERE id_wallet_agent = :id ORDER BY date_creation DESC;'
|
$demandes = DB::select('SELECT * FROM infos_users_demandes_credits WHERE id_wallet_agent = :id ORDER BY date_creation DESC;'
|
||||||
, ['id' => $id_wallet_agent]);
|
, ['id' => $id_wallet_agent]);
|
||||||
return $this->successResponse($demandes);
|
$result = array_map(function ($demand) {
|
||||||
|
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||||
|
return $demand;
|
||||||
|
}, $demandes);
|
||||||
|
return $this->successResponse($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSavingsDemands($id_user)
|
public function getSavingsDemands($id_user)
|
||||||
{
|
{
|
||||||
$savings = DB::select('SELECT * FROM infos_users_epargnes WHERE id_user = :id ORDER BY date_creation DESC;', ['id' => $id_user]);
|
$savings = DB::select('SELECT * FROM infos_users_epargnes WHERE id_user = :id ORDER BY date_creation DESC;', ['id' => $id_user]);
|
||||||
return $this->successResponse($savings);
|
$result = array_map(function ($demand) {
|
||||||
|
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||||
|
return $demand;
|
||||||
|
}, $savings);
|
||||||
|
return $this->successResponse($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Demandes d'epargnes pour la cassation
|
// Demandes d'epargnes pour la cassation
|
||||||
public function getSavingsDemandsInProgress($id_user)
|
public function getSavingsDemandsInProgress($id_user)
|
||||||
{
|
{
|
||||||
$savings = DB::select("SELECT * FROM infos_users_epargnes WHERE id_user = :id AND etat = 'EN_COURS' ORDER BY date_creation DESC;", ['id' => $id_user]);
|
$savings = DB::select("SELECT * FROM infos_users_epargnes WHERE id_user = :id AND etat = 'EN_COURS' ORDER BY date_creation DESC;", ['id' => $id_user]);
|
||||||
return $this->successResponse($savings);
|
$result = array_map(function ($demand) {
|
||||||
|
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||||
|
return $demand;
|
||||||
|
}, $savings);
|
||||||
|
return $this->successResponse($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cautionner une demande de credit
|
// Cautionner une demande de credit
|
||||||
|
@ -280,8 +300,8 @@ class NanoCreditController extends Controller
|
||||||
return $this->errorResponse(trans('errors.insufficient_balance'));
|
return $this->errorResponse(trans('errors.insufficient_balance'));
|
||||||
|
|
||||||
|
|
||||||
$demande_credit->date_demande = new \DateTime();
|
$demande_credit->date_validation = new \DateTime();
|
||||||
$demande_credit->date_remboursement_prevu = $demande_credit->date_demande->modify('+' . $demande_credit->duree_mois . ' month');
|
$demande_credit->date_remboursement_prevu = $demande_credit->date_validation->modify('+' . $demande_credit->duree_mois . ' month');
|
||||||
$demande_credit->etat = 'VALIDE';
|
$demande_credit->etat = 'VALIDE';
|
||||||
$demande_credit->id_wallet_agent = $walletAgent->id;
|
$demande_credit->id_wallet_agent = $walletAgent->id;
|
||||||
$user->balance_credit += $montant_total;
|
$user->balance_credit += $montant_total;
|
||||||
|
@ -528,6 +548,7 @@ class NanoCreditController extends Controller
|
||||||
{
|
{
|
||||||
$demand = UsersDemandesCredit::where('id_demande', $id_demand)->first();
|
$demand = UsersDemandesCredit::where('id_demande', $id_demand)->first();
|
||||||
if ($demand) {
|
if ($demand) {
|
||||||
|
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||||
return $this->successResponse($demand);
|
return $this->successResponse($demand);
|
||||||
} else {
|
} else {
|
||||||
return $this->errorResponse(trans('errors.nano_credit_not_found'));
|
return $this->errorResponse(trans('errors.nano_credit_not_found'));
|
||||||
|
@ -538,6 +559,7 @@ class NanoCreditController extends Controller
|
||||||
{
|
{
|
||||||
$demand = UsersEpargne::where('id_epargne', $id_saving)->first();
|
$demand = UsersEpargne::where('id_epargne', $id_saving)->first();
|
||||||
if ($demand) {
|
if ($demand) {
|
||||||
|
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||||
return $this->successResponse($demand);
|
return $this->successResponse($demand);
|
||||||
} else {
|
} else {
|
||||||
return $this->errorResponse(trans('errors.savings_not_found'));
|
return $this->errorResponse(trans('errors.savings_not_found'));
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\ConfigWallet;
|
use App\Models\ConfigWallet;
|
||||||
use App\Models\Identification;
|
use App\Models\Identification;
|
||||||
|
use App\Models\User;
|
||||||
use App\Models\UsersDemandesCredit;
|
use App\Models\UsersDemandesCredit;
|
||||||
use App\Models\UsersGroup;
|
use App\Models\UsersGroup;
|
||||||
use App\Models\UsersGroupsDemandesValidation;
|
use App\Models\UsersGroupsDemandesValidation;
|
||||||
|
@ -13,7 +14,6 @@ use App\Models\WalletsUser;
|
||||||
use App\Traits\ApiResponser;
|
use App\Traits\ApiResponser;
|
||||||
use App\Traits\Helper;
|
use App\Traits\Helper;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
@ -593,8 +593,8 @@ ug.date_creation , ug.createur , ug.sponsor1 , ug.sponsor2 , ug.sponsor3, ug.cou
|
||||||
|
|
||||||
$montant_total = $demande_credit->montant + $demande_credit->frais + $demande_credit->taxe;
|
$montant_total = $demande_credit->montant + $demande_credit->frais + $demande_credit->taxe;
|
||||||
|
|
||||||
$demande_credit->date_demande = new \DateTime();
|
$demande_credit->date_validation = new \DateTime();
|
||||||
$demande_credit->date_remboursement_prevu = $demande_credit->date_demande->modify('+' . $demande_credit->duree_mois . ' month');
|
$demande_credit->date_remboursement_prevu = $demande_credit->date_validation->modify('+' . $demande_credit->duree_mois . ' month');
|
||||||
$demande_credit->etat = 'VALIDE';
|
$demande_credit->etat = 'VALIDE';
|
||||||
|
|
||||||
$user->balance_credit += $montant_total;
|
$user->balance_credit += $montant_total;
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\WalletAgent;
|
||||||
use App\Models\WalletsUser;
|
use App\Models\WalletsUser;
|
||||||
use App\Traits\ApiResponser;
|
use App\Traits\ApiResponser;
|
||||||
use App\Traits\Helper;
|
use App\Traits\Helper;
|
||||||
|
@ -113,4 +115,106 @@ class WalletController extends Controller
|
||||||
return $this->errorResponse(trans('errors.model_not_found', ['model' => 'wallet']), Response::HTTP_BAD_REQUEST);
|
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)
|
||||||
|
{
|
||||||
|
|
||||||
|
$demandes = DB::select("SELECT 'N' as type_historique , i.* FROM infos_users_demandes_credits i WHERE id_network = :id ;", ['id' => $id_network]);
|
||||||
|
$savings = DB::select("SELECT 'E' as type_historique , i.* FROM infos_users_epargnes i WHERE id_network = :id;", ['id' => $id_network]);
|
||||||
|
|
||||||
|
$transactions = DB::select("SELECT 'T' as type_historique, wit.id_transaction, tit.nom as operation , wit.montant ,wit.nom_emetteur, wit.prenom_emetteur, wit.id_wallet_user,wit.frais,wit.taxe,wit.id_destinataire,
|
||||||
|
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) {
|
||||||
|
|
||||||
|
$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;
|
||||||
|
$data->montant = $this->toMoney($data->montant, $data->init_country);
|
||||||
|
$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;
|
||||||
|
|
||||||
|
unset($data->type, $data->id_wallet_user, $data->network_destinataire, $data->nom_destinataire, $data->prenom_destinataire, $data->taxe, $data->numero_carte,
|
||||||
|
$data->montant_net_final_country, $data->montant_net, $data->nom_emetteur, $data->prenom_emetteur, $data->id_destinataire);
|
||||||
|
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($this->arrayPaginator($result,$request));
|
||||||
|
return $this->successResponse($result);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function superHistory($id_wallet, Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$walletSup = WalletAgent::where('wallet_id', $id_wallet)->firstOrFail();
|
||||||
|
|
||||||
|
$demandes = DB::select("SELECT 'N' as type_historique , i.* FROM infos_users_demandes_credits i WHERE id_network = :id ;", ['id' => $walletSup->codeMembre]);
|
||||||
|
|
||||||
|
|
||||||
|
$transactions = DB::select("SELECT 'T' as type_historique, wit.id_transaction, tit.nom as operation , wit.montant ,wit.nom_emetteur, wit.prenom_emetteur, wit.id_wallet_user,wit.frais,wit.taxe,wit.id_destinataire,
|
||||||
|
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) {
|
||||||
|
|
||||||
|
$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;
|
||||||
|
$data->montant = $this->toMoney($data->montant, $data->init_country);
|
||||||
|
$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;
|
||||||
|
|
||||||
|
unset($data->type, $data->id_wallet_user, $data->network_destinataire, $data->nom_destinataire, $data->prenom_destinataire, $data->taxe, $data->numero_carte,
|
||||||
|
$data->montant_net_final_country, $data->montant_net, $data->nom_emetteur, $data->prenom_emetteur, $data->id_destinataire);
|
||||||
|
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($this->arrayPaginator($result,$request));
|
||||||
|
return $this->successResponse($result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ class iLinkTransactionController extends Controller
|
||||||
return $this->errorResponse(trans('errors.insufficient_balance'));
|
return $this->errorResponse(trans('errors.insufficient_balance'));
|
||||||
} else {
|
} else {
|
||||||
//Verification des limites reglementaires
|
//Verification des limites reglementaires
|
||||||
$rep = $this->checkReguationsLimits($walletUser->id, $init_country, $transaction->montant);
|
$rep = $this->checkReguationsLimits($walletUser->id, $init_country, $request->final_country, $transaction->montant);
|
||||||
if ($rep instanceof JsonResponse)
|
if ($rep instanceof JsonResponse)
|
||||||
return $rep;
|
return $rep;
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ class iLinkTransactionController extends Controller
|
||||||
return $this->errorResponse(trans('errors.insufficient_balance'));
|
return $this->errorResponse(trans('errors.insufficient_balance'));
|
||||||
} else {
|
} else {
|
||||||
//Verification des limites reglementaires
|
//Verification des limites reglementaires
|
||||||
$rep = $this->checkReguationsLimits($walletUser->id, $init_country, $transaction->montant);
|
$rep = $this->checkReguationsLimits($walletUser->id, $init_country, $request->final_country, $transaction->montant);
|
||||||
if ($rep instanceof JsonResponse)
|
if ($rep instanceof JsonResponse)
|
||||||
return $rep;
|
return $rep;
|
||||||
|
|
||||||
|
@ -712,7 +712,7 @@ class iLinkTransactionController extends Controller
|
||||||
$transaction->final_country = $final_country = $user->network->country->id;
|
$transaction->final_country = $final_country = $user->network->country->id;
|
||||||
|
|
||||||
//Verification des limites reglementaires
|
//Verification des limites reglementaires
|
||||||
$rep = $this->checkReguationsLimits($walletUser->id, $init_country, $transaction->montant);
|
$rep = $this->checkReguationsLimits($walletUser->id, $init_country, $final_country, $transaction->montant);
|
||||||
if ($rep instanceof JsonResponse)
|
if ($rep instanceof JsonResponse)
|
||||||
return $rep;
|
return $rep;
|
||||||
|
|
||||||
|
@ -765,7 +765,7 @@ class iLinkTransactionController extends Controller
|
||||||
return $this->errorResponse(trans('errors.insufficient_balance'));
|
return $this->errorResponse(trans('errors.insufficient_balance'));
|
||||||
|
|
||||||
//Verification des limites reglementaires
|
//Verification des limites reglementaires
|
||||||
$rep = $this->checkReguationsLimits($request->id_document_emetteur, $init_country, $transaction->montant, true);
|
$rep = $this->checkReguationsLimits($request->id_document_emetteur, $init_country, $request->final_country, $transaction->montant, true);
|
||||||
if ($rep instanceof JsonResponse)
|
if ($rep instanceof JsonResponse)
|
||||||
return $rep;
|
return $rep;
|
||||||
|
|
||||||
|
@ -901,7 +901,7 @@ class iLinkTransactionController extends Controller
|
||||||
return $this->errorResponse(trans('errors.insufficient_balance'));
|
return $this->errorResponse(trans('errors.insufficient_balance'));
|
||||||
|
|
||||||
//Verification des limites reglementaires
|
//Verification des limites reglementaires
|
||||||
$rep = $this->checkReguationsLimits($request->id_document_emetteur, $init_country, $transaction->montant, true);
|
$rep = $this->checkReguationsLimits($request->id_document_emetteur, $init_country, $request->final_country, $transaction->montant, true);
|
||||||
if ($rep instanceof JsonResponse)
|
if ($rep instanceof JsonResponse)
|
||||||
return $rep;
|
return $rep;
|
||||||
|
|
||||||
|
@ -1062,7 +1062,7 @@ class iLinkTransactionController extends Controller
|
||||||
$data->montant_net_final = $data->montant_net_final_country ? $this->toMoney($data->montant_net_final_country, $data->final_country) : $data->montant_net_init ;
|
$data->montant_net_final = $data->montant_net_final_country ? $this->toMoney($data->montant_net_final_country, $data->final_country) : $data->montant_net_init ;
|
||||||
$data->montant = $this->toMoney($data->montant, $data->init_country);
|
$data->montant = $this->toMoney($data->montant, $data->init_country);
|
||||||
$data->init_country = $this->getCountryName($data->init_country);
|
$data->init_country = $this->getCountryName($data->init_country);
|
||||||
$data->final_country = $this->getCountryName($data->final_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;
|
$data->reseau_payeur = isset($data->network_destinataire) ? $this->getNetworkName($data->network_destinataire) . ' ' . $data->final_country : null;
|
||||||
$data->date = $date;
|
$data->date = $date;
|
||||||
unset($data->type, $data->id_wallet_user, $data->network_destinataire,$data->nom_destinataire, $data->prenom_destinataire ,$data->taxe,$data->numero_carte,
|
unset($data->type, $data->id_wallet_user, $data->network_destinataire,$data->nom_destinataire, $data->prenom_destinataire ,$data->taxe,$data->numero_carte,
|
||||||
|
@ -1411,7 +1411,7 @@ class iLinkTransactionController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
//Verfier les limites reglementaires
|
//Verfier les limites reglementaires
|
||||||
public function checkReguationsLimits($identifiant, $init_country, $montant_transaction, $is_id_document_emetteur = false)
|
public function checkReguationsLimits($identifiant, $init_country, $final_country, $montant_transaction, $is_id_document_emetteur = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
$regulation = Regulation::where('id_country', $init_country)->first();
|
$regulation = Regulation::where('id_country', $init_country)->first();
|
||||||
|
@ -1421,34 +1421,36 @@ class iLinkTransactionController extends Controller
|
||||||
|
|
||||||
// Total montants journalier
|
// Total montants journalier
|
||||||
if ($is_id_document_emetteur)
|
if ($is_id_document_emetteur)
|
||||||
$daily_sum = WalletIlinkTransaction::where('id_document_emetteur', $identifiant)->whereDate('date', Carbon::today())->sum('montant');
|
$daily_sum = WalletIlinkTransaction::where('id_document_emetteur', $identifiant)->where('final_country', $final_country)->whereDate('date', Carbon::today())->sum('montant');
|
||||||
else
|
else
|
||||||
$daily_sum = WalletIlinkTransaction::where('id_wallet_user', $identifiant)->whereDate('date', Carbon::today())->sum('montant');
|
$daily_sum = WalletIlinkTransaction::where('id_wallet_user', $identifiant)->where('final_country', $final_country)->whereDate('date', Carbon::today())->sum('montant');
|
||||||
$amount_admitted = $regulation->montant_max_jour - $daily_sum;
|
$max_jour = ($init_country == $final_country) ? $regulation->montant_max_jour_national : $regulation->montant_max_jour_international;
|
||||||
// dd(($daily_sum + $montant_transaction) > $regulation->montant_max_jour);
|
$amount_admitted = $max_jour - $daily_sum;
|
||||||
if (($daily_sum + $montant_transaction) > $regulation->montant_max_jour)
|
if (($daily_sum + $montant_transaction) > $max_jour)
|
||||||
return $this->errorResponse(trans('errors.daily_regulations_limits_reached') . ' '
|
return $this->errorResponse(($init_country == $final_country) ? trans('errors.national_daily_regulations_limits_reached') : trans('errors.international_daily_regulations_limits_reached') . ' '
|
||||||
. ($amount_admitted > 0 ? trans('errors.regulations_limits_amount_transaction', ['amount' => $this->toMoney($amount_admitted, $init_country)]) : ''));
|
. ($amount_admitted > 0 ? trans('errors.regulations_limits_amount_transaction', ['amount' => $this->toMoney($amount_admitted, $init_country)]) : ''));
|
||||||
|
|
||||||
// Total montants hebdomadaire
|
// Total montants hebdomadaire
|
||||||
if ($is_id_document_emetteur)
|
if ($is_id_document_emetteur)
|
||||||
$weekly_sum = WalletIlinkTransaction::where('id_document_emetteur', $identifiant)->whereBetween('date', [Carbon::today()->subDay(7), Carbon::today()])->sum('montant');
|
$weekly_sum = WalletIlinkTransaction::where('id_document_emetteur', $identifiant)->where('final_country', $final_country)->whereBetween('date', [Carbon::today()->subDay(7), Carbon::today()])->sum('montant');
|
||||||
else
|
else
|
||||||
$weekly_sum = WalletIlinkTransaction::where('id_wallet_user', $identifiant)->whereBetween('date', [Carbon::today()->subDay(7), Carbon::today()])->sum('montant');
|
$weekly_sum = WalletIlinkTransaction::where('id_wallet_user', $identifiant)->where('final_country', $final_country)->whereBetween('date', [Carbon::today()->subDay(7), Carbon::today()])->sum('montant');
|
||||||
$amount_admitted = $regulation->montant_max_hedbo - $weekly_sum;
|
$max_hebdo = ($init_country == $final_country) ? $regulation->montant_max_hedbo_national : $regulation->montant_max_hedbo_international;
|
||||||
if (($weekly_sum + $montant_transaction) > $regulation->montant_max_hebdo)
|
$amount_admitted = $max_hebdo - $weekly_sum;
|
||||||
return $this->errorResponse(trans('errors.weekly_regulations_limits_reached') . ' '
|
if (($weekly_sum + $montant_transaction) > $max_hebdo)
|
||||||
|
return $this->errorResponse(($init_country == $final_country) ? trans('errors.national_weekly_regulations_limits_reached') : trans('errors.international_weekly_regulations_limits_reached') . ' '
|
||||||
. ($amount_admitted > 0 ? trans('errors.regulations_limits_amount_transaction', ['amount' => $this->toMoney($amount_admitted, $init_country)]) : ''));
|
. ($amount_admitted > 0 ? trans('errors.regulations_limits_amount_transaction', ['amount' => $this->toMoney($amount_admitted, $init_country)]) : ''));
|
||||||
|
|
||||||
|
|
||||||
// Total montants mensuel
|
// Total montants mensuel
|
||||||
if ($is_id_document_emetteur)
|
if ($is_id_document_emetteur)
|
||||||
$monthly_sum = WalletIlinkTransaction::where('id_document_emetteur', $identifiant)->whereBetween('date', [Carbon::today()->subDay(30), Carbon::today()])->sum('montant');
|
$monthly_sum = WalletIlinkTransaction::where('id_document_emetteur', $identifiant)->where('final_country', $final_country)->whereBetween('date', [Carbon::today()->subDay(30), Carbon::today()])->sum('montant');
|
||||||
else
|
else
|
||||||
$monthly_sum = WalletIlinkTransaction::where('id_wallet_user', $identifiant)->whereBetween('date', [Carbon::today()->subDay(30), Carbon::today()])->sum('montant');
|
$monthly_sum = WalletIlinkTransaction::where('id_wallet_user', $identifiant)->where('final_country', $final_country)->whereBetween('date', [Carbon::today()->subDay(30), Carbon::today()])->sum('montant');
|
||||||
$amount_admitted = $regulation->montant_max_mensuel - $monthly_sum;
|
$max_mensuel = ($init_country == $final_country) ? $regulation->montant_max_mensuel_national : $regulation->montant_max_mensuel_international;
|
||||||
if (($monthly_sum + $montant_transaction) > $regulation->montant_max_mensuel)
|
$amount_admitted = $max_mensuel - $monthly_sum;
|
||||||
return $this->errorResponse(trans('errors.monthly_regulations_limits_reached') . ' '
|
if (($monthly_sum + $montant_transaction) > $max_mensuel)
|
||||||
|
return $this->errorResponse(($init_country == $final_country) ? trans('errors.national_monthly_regulations_limits_reached') : trans('errors.international_monthly_regulations_limits_reached') . ' '
|
||||||
. ($amount_admitted > 0 ? trans('errors.regulations_limits_amount_transaction', ['amount' => $this->toMoney($amount_admitted, $init_country)]) : ''));
|
. ($amount_admitted > 0 ? trans('errors.regulations_limits_amount_transaction', ['amount' => $this->toMoney($amount_admitted, $init_country)]) : ''));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,12 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property int $id_country
|
* @property int $id_country
|
||||||
* @property float $montant_max_jour
|
* @property float $montant_max_jour_national
|
||||||
* @property float $montant_max_hebdo
|
* @property float $montant_max_hebdo_national
|
||||||
* @property float $montant_max_mensuel
|
* @property float $montant_max_mensuel_national
|
||||||
|
* @property float $montant_max_jour_international
|
||||||
|
* @property float $montant_max_hebdo_international
|
||||||
|
* @property float $montant_max_mensuel_international
|
||||||
*
|
*
|
||||||
* @package App\Models
|
* @package App\Models
|
||||||
*/
|
*/
|
||||||
|
@ -26,15 +29,21 @@ class Regulation extends Model
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'id_country' => 'int',
|
'id_country' => 'int',
|
||||||
'montant_max_jour' => 'float',
|
'montant_max_jour_national' => 'float',
|
||||||
'montant_max_hebdo' => 'float',
|
'montant_max_hebdo_national' => 'float',
|
||||||
'montant_max_mensuel' => 'float'
|
'montant_max_mensuel_national' => 'float',
|
||||||
|
'montant_max_jour_international' => 'float',
|
||||||
|
'montant_max_hebdo_international' => 'float',
|
||||||
|
'montant_max_mensuel_international' => 'float'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'id_country',
|
'id_country',
|
||||||
'montant_max_jour',
|
'montant_max_jour_national',
|
||||||
'montant_max_hebdo',
|
'montant_max_hebdo_national',
|
||||||
'montant_max_mensuel'
|
'montant_max_mensuel_national',
|
||||||
|
'montant_max_jour_international',
|
||||||
|
'montant_max_hebdo_international',
|
||||||
|
'montant_max_mensuel_international'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
* @property string $etat
|
* @property string $etat
|
||||||
* @property float $interet
|
* @property float $interet
|
||||||
* @property float $taxe
|
* @property float $taxe
|
||||||
* @property Carbon $date_demande
|
* @property Carbon $date_validation
|
||||||
* @property Carbon $date_remboursement_prevu
|
* @property Carbon $date_remboursement_prevu
|
||||||
* @property Carbon $date_remboursement
|
* @property Carbon $date_remboursement
|
||||||
* @property int $id_user
|
* @property int $id_user
|
||||||
|
@ -52,7 +52,7 @@ class UsersDemandesCredit extends Model
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $dates = [
|
protected $dates = [
|
||||||
'date_demande',
|
'date_validation',
|
||||||
'date_remboursement_prevu',
|
'date_remboursement_prevu',
|
||||||
'date_remboursement',
|
'date_remboursement',
|
||||||
'date_creation'
|
'date_creation'
|
||||||
|
@ -68,7 +68,7 @@ class UsersDemandesCredit extends Model
|
||||||
'etat',
|
'etat',
|
||||||
'interet',
|
'interet',
|
||||||
'taxe',
|
'taxe',
|
||||||
'date_demande',
|
'date_validation',
|
||||||
'date_remboursement_prevu',
|
'date_remboursement_prevu',
|
||||||
'date_remboursement',
|
'date_remboursement',
|
||||||
'id_user',
|
'id_user',
|
||||||
|
|
|
@ -269,6 +269,12 @@ trait Helper
|
||||||
return $randomString;
|
return $randomString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fonction de tri par date
|
||||||
|
public function sortFunction($a, $b)
|
||||||
|
{
|
||||||
|
return strtotime($b->date_creation) - strtotime($a->date_creation);
|
||||||
|
}
|
||||||
|
|
||||||
public function refundAllNanoCredit()
|
public function refundAllNanoCredit()
|
||||||
{
|
{
|
||||||
// \Log::info('cron refund credit --');
|
// \Log::info('cron refund credit --');
|
||||||
|
@ -364,9 +370,9 @@ trait Helper
|
||||||
|
|
||||||
$message = trans('messages.successful_nano_credit_demand_refunded',
|
$message = trans('messages.successful_nano_credit_demand_refunded',
|
||||||
['id_demand' => $demande_credit->id_demande, 'amount' => $this->toMoney($montantARembourser, $init_country), 'duration' => $demande_credit->duree_mois,
|
['id_demand' => $demande_credit->id_demande, 'amount' => $this->toMoney($montantARembourser, $init_country), 'duration' => $demande_credit->duree_mois,
|
||||||
'net' => $this->toMoney($montantARembourser * $quota, $init_country), 'fees' => $this->toMoney($demande_credit->interet * $quota, $init_country),
|
'net' => $this->toMoney($montantARembourser - $demande_credit->interet * $quota - $demande_credit->taxe * $quota, $init_country),
|
||||||
'tax' => $this->toMoney($demande_credit->taxe * $quota, $init_country),
|
'fees' => $this->toMoney($demande_credit->interet * $quota, $init_country),
|
||||||
'caution' => $demande_credit->type_caution == 'groupe' ? 'Groupe' : 'Individuel']);
|
'tax' => $this->toMoney($demande_credit->taxe * $quota, $init_country)]);
|
||||||
|
|
||||||
$title = (!$partialRefund) ? trans('messages.successful_nano_credit_refunded') :
|
$title = (!$partialRefund) ? trans('messages.successful_nano_credit_refunded') :
|
||||||
trans('messages.successful_nano_credit_partially_refunded');
|
trans('messages.successful_nano_credit_partially_refunded');
|
||||||
|
|
|
@ -60,7 +60,10 @@ Paying network : :network :country',
|
||||||
"borrowing_capacity_exceeded" => "The borrowing capacity is exceeded",
|
"borrowing_capacity_exceeded" => "The borrowing capacity is exceeded",
|
||||||
"savings_not_found" => "This savings does not exist",
|
"savings_not_found" => "This savings does not exist",
|
||||||
"regulations_limits_amount_transaction" => "You can make a transaction of :amount .",
|
"regulations_limits_amount_transaction" => "You can make a transaction of :amount .",
|
||||||
"daily_regulations_limits_reached" => "You have reached your daily limit.",
|
"national_daily_regulations_limits_reached" => "You have reached your national daily limit.",
|
||||||
"weekly_regulations_limits_reached" => "You have reached your weekly limit.",
|
"national_weekly_regulations_limits_reached" => "You have reached your national weekly limit.",
|
||||||
"monthly_regulations_limits_reached" => "You have reached your monthly limit.",
|
"national_monthly_regulations_limits_reached" => "You have reached your national monthly limit.",
|
||||||
|
"international_daily_regulations_limits_reached" => "You have reached your international daily limit.",
|
||||||
|
"international_weekly_regulations_limits_reached" => "You have reached your international weekly limit.",
|
||||||
|
"international_monthly_regulations_limits_reached" => "You have reached your international monthly limit.",
|
||||||
];
|
];
|
||||||
|
|
|
@ -214,11 +214,10 @@ NB: The reimbursement process is automatic on the due date if the reimbursement
|
||||||
'successful_nano_credit_demand_refunded' => "Nano credit refunded
|
'successful_nano_credit_demand_refunded' => "Nano credit refunded
|
||||||
Request Information:
|
Request Information:
|
||||||
- Request number: :id_demand
|
- Request number: :id_demand
|
||||||
- Type of deposit: :deposit
|
- Amount of credit repaid : :amount
|
||||||
- Credit amount: :amount
|
|
||||||
- Interests : :fees
|
- Interests : :fees
|
||||||
- Taxes : :tax
|
- Taxes : :tax
|
||||||
- Net amount received: :net",
|
- Capital : :net",
|
||||||
'successful_accepted_group_membership_request' => "Membership request accepted",
|
'successful_accepted_group_membership_request' => "Membership request accepted",
|
||||||
'successful_canceled_group_membership_request' => "Membership request refused",
|
'successful_canceled_group_membership_request' => "Membership request refused",
|
||||||
'successful_nano_credit_sent_to_hypervisor' => "Your request has been sent to your network hypervisor. You will receive the credit only after validation",
|
'successful_nano_credit_sent_to_hypervisor' => "Your request has been sent to your network hypervisor. You will receive the credit only after validation",
|
||||||
|
@ -244,5 +243,5 @@ Savings Information :
|
||||||
- Taxes : :tax
|
- Taxes : :tax
|
||||||
- Net amount saved : :net",
|
- Net amount saved : :net",
|
||||||
"successful_broken_saving" => "Broken savings",
|
"successful_broken_saving" => "Broken savings",
|
||||||
"reload_your_account" => "Reload your account",
|
"reload_your_account" => "The repayment of nano credit failed for insufficient balance, please recharge your account",
|
||||||
];
|
];
|
||||||
|
|
|
@ -60,7 +60,10 @@ Réseau payeur : :network :country',
|
||||||
"borrowing_capacity_exceeded" => "La capacité d'emprunt est dépassée",
|
"borrowing_capacity_exceeded" => "La capacité d'emprunt est dépassée",
|
||||||
"savings_not_found" => "Cette épargne n'existe pas",
|
"savings_not_found" => "Cette épargne n'existe pas",
|
||||||
"regulations_limits_amount_transaction" => "Vous pouvez effectuer une transaction de :amount .",
|
"regulations_limits_amount_transaction" => "Vous pouvez effectuer une transaction de :amount .",
|
||||||
"daily_regulations_limits_reached" => "Vous avez atteint votre limite journalière.",
|
"national_daily_regulations_limits_reached" => "Vous avez atteint votre limite journalière nationale.",
|
||||||
"weekly_regulations_limits_reached" => "Vous avez atteint votre limite hebdomadaire.",
|
"national_weekly_regulations_limits_reached" => "Vous avez atteint votre limite hebdomadaire nationale.",
|
||||||
"monthly_regulations_limits_reached" => "Vous avez atteint votre limite mensuelle.",
|
"national_monthly_regulations_limits_reached" => "Vous avez atteint votre limite mensuelle nationale.",
|
||||||
|
"international_daily_regulations_limits_reached" => "Vous avez atteint votre limite journalière internationale.",
|
||||||
|
"international_weekly_regulations_limits_reached" => "Vous avez atteint votre limite hebdomadaire internationale.",
|
||||||
|
"international_monthly_regulations_limits_reached" => "Vous avez atteint votre limite mensuelle internationale.",
|
||||||
];
|
];
|
||||||
|
|
|
@ -212,13 +212,12 @@ NB: Le processus de remboursement est automatique à la date d'échéance si le
|
||||||
'successful_nano_credit_partially_refunded' => 'Remboursement de nano crédit partiellement effectué',
|
'successful_nano_credit_partially_refunded' => 'Remboursement de nano crédit partiellement effectué',
|
||||||
'failed_nano_credit_refunded' => 'Remboursement de nano crédit échoué',
|
'failed_nano_credit_refunded' => 'Remboursement de nano crédit échoué',
|
||||||
'successful_nano_credit_demand_refunded' => "Nano crédit remboursé
|
'successful_nano_credit_demand_refunded' => "Nano crédit remboursé
|
||||||
Informations de la demande :
|
Informations sur la demande :
|
||||||
- Numéro de la demande : :id_demand
|
- Numéro de la demande : :id_demand
|
||||||
- Type de caution : :caution
|
- Montant du crédit remboursé : :amount
|
||||||
- Montant du crédit : :amount
|
|
||||||
- Intérêts : :fees
|
- Intérêts : :fees
|
||||||
- Taxes : :tax
|
- Taxes : :tax
|
||||||
- Montant net percu : :net",
|
- Capital : :net",
|
||||||
'successful_accepted_group_membership_request' => "Demande d'adhésion acceptée",
|
'successful_accepted_group_membership_request' => "Demande d'adhésion acceptée",
|
||||||
'successful_canceled_group_membership_request' => "Demande d'adhésion refusée",
|
'successful_canceled_group_membership_request' => "Demande d'adhésion refusée",
|
||||||
'successful_nano_credit_sent_to_hypervisor' => "Votre demande a été envoyé à l'hyperviseur de votre reseau. Vous recevrez le credit seulement après validation",
|
'successful_nano_credit_sent_to_hypervisor' => "Votre demande a été envoyé à l'hyperviseur de votre reseau. Vous recevrez le credit seulement après validation",
|
||||||
|
@ -246,5 +245,5 @@ Informations sur l'epargne :
|
||||||
- Montant net epargné : :net
|
- Montant net epargné : :net
|
||||||
",
|
",
|
||||||
"successful_broken_saving" => "Epargne cassée",
|
"successful_broken_saving" => "Epargne cassée",
|
||||||
"reload_your_account" => "Rechargez votre compte",
|
"reload_your_account" => "Le remboursement de nano credit a echoué pour solde insuffisant, veuillez recharger votre compte.",
|
||||||
];
|
];
|
||||||
|
|
|
@ -53,6 +53,10 @@ $router->group(['prefix' => '/wallets'] , function () use ($router){
|
||||||
$router->get('{id_wallet}', 'WalletController@show');
|
$router->get('{id_wallet}', 'WalletController@show');
|
||||||
$router->post('', 'WalletController@create');
|
$router->post('', 'WalletController@create');
|
||||||
|
|
||||||
|
//Les historiques globals des hyperviseur et superviseur
|
||||||
|
$router->get('hyper_history/{id_network}', 'WalletController@hyperHistory');
|
||||||
|
$router->get('super_history/{id_wallet}', 'WalletController@superHistory');
|
||||||
|
|
||||||
// Wallets users iLink
|
// Wallets users iLink
|
||||||
$router->group(['prefix' => '/users'], function () use ($router) {
|
$router->group(['prefix' => '/users'], function () use ($router) {
|
||||||
$router->get('{id_user}', 'WalletController@showWalletUser');
|
$router->get('{id_user}', 'WalletController@showWalletUser');
|
||||||
|
|
Loading…
Reference in New Issue