adjusting all fields of the request create process bank account
This commit is contained in:
parent
76647c7c4f
commit
bb4c9aa804
|
|
@ -2,7 +2,7 @@ APP_NAME=WalletService
|
|||
APP_ENV=production
|
||||
APP_KEY=NhSitM0Iv4HmNTRVJRiQPm0x20tgz7zE
|
||||
APP_DEBUG=false
|
||||
APP_URL=https://test.ilink-app.com
|
||||
APP_URL=https://test.ilink-app.com:8082
|
||||
APP_TIMEZONE=UTC
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
|
|
|
|||
|
|
@ -652,19 +652,16 @@ INNER JOIN countries c ON oc.id_country = c.id INNER JOIN type_operators top ON
|
|||
'firstname' => 'required|string',
|
||||
'nationality' => 'required|string',
|
||||
'birth_date' => 'required|date',
|
||||
'birth_country' => 'required|string',
|
||||
'birth_country' => 'required|string|max:3',
|
||||
'birth_city' => 'required|string',
|
||||
'father_firstname' => 'required|string',
|
||||
'father_lastname' => 'required|string',
|
||||
'mother_firstname' => 'required|string',
|
||||
'mother_lastname' => 'required|string',
|
||||
'identification_number' => 'required|string',
|
||||
'spouse_name' => 'required|string',
|
||||
'phone_number' => 'required|string|max:15|min:9',
|
||||
'marital_name' => 'nullable|string',
|
||||
'marital_status' => 'nullable|string',
|
||||
'profession' => 'required|string',
|
||||
'sector_activity' => 'required|string',
|
||||
'subsector_activity' => 'nullable|string',
|
||||
'tax_number' => 'required|string',
|
||||
'employee_number' => 'nullable|string',
|
||||
'niu' => 'nullable|string',
|
||||
'employer_city' => 'nullable|string',
|
||||
'position' => 'nullable|string',
|
||||
'employer_name' => 'nullable|string',
|
||||
'employer_address' => 'nullable|string',
|
||||
|
|
@ -726,10 +723,11 @@ INNER JOIN countries c ON oc.id_country = c.id INNER JOIN type_operators top ON
|
|||
$bankAccount->mother_lastname = $request->mother_lastname;
|
||||
$bankAccount->marital_status = $request->marital_status ?? 'celibataire';
|
||||
$bankAccount->profession = $request->profession;
|
||||
$bankAccount->sector_activity = $request->sector_activity;
|
||||
$bankAccount->subsector_activity = $request->subsector_activity ?? 'null';
|
||||
$bankAccount->tax_number = $request->tax_number;
|
||||
$bankAccount->employee_number = $request->employee_number;
|
||||
$bankAccount->identification_number = $request->identification_number;
|
||||
$bankAccount->phone_number = $request->phone_number ?? 'null';
|
||||
$bankAccount->spouse_name = $request->spouse_name;
|
||||
$bankAccount->niu = $request->niu ?? 'null';
|
||||
$bankAccount->employer_city = $request->employer_city ?? 'null';
|
||||
$bankAccount->position = $request->position;
|
||||
$bankAccount->employer_name = $request->employer_name ?? 'null';
|
||||
$bankAccount->employer_address = $request->employer_address ?? 'null';
|
||||
|
|
@ -739,49 +737,21 @@ INNER JOIN countries c ON oc.id_country = c.id INNER JOIN type_operators top ON
|
|||
$bankAccount->updated_at = date('Y-m-d H:i:s');
|
||||
$bankAccount->save();
|
||||
|
||||
// Envoi des informations à la banque partenaire (via API)
|
||||
// $payload = [
|
||||
// 'account_number' => $bankAccount->account_number,
|
||||
// 'iban' => $bankAccount->iban,
|
||||
// 'swift_code' => $bankAccount->swift_code,
|
||||
// 'lastname' => $bankAccount->lastname,
|
||||
// 'firstname' => $bankAccount->firstname,
|
||||
// 'birth_date' => $bankAccount->birth_date,
|
||||
// 'nationality' => $bankAccount->nationality,
|
||||
// 'birth_country' => $bankAccount->birth_country,
|
||||
// 'network_code' => $network_bank->network->code ?? null,
|
||||
// ];
|
||||
|
||||
Log::info('--- Envoi création compte bancaire à la banque partenaire ---');
|
||||
// Log::info(json_encode($payload));
|
||||
|
||||
try {
|
||||
// // Envoi à une API bancaire
|
||||
// $response = Http::withHeaders([
|
||||
// 'Accept' => 'application/json',
|
||||
// 'Authorization' => 'Bearer ' . env('BANK_API_TOKEN'),
|
||||
// ])->post(env('BANK_API_URL') . '/accounts/create', $payload);
|
||||
|
||||
// if ($response->failed()) {
|
||||
// $bankAccount->status = 'rejected';
|
||||
// $bankAccount->reason = $response->json('message') ?? 'Erreur API bancaire';
|
||||
// $bankAccount->save();
|
||||
// return $this->errorResponse(trans('errors.bank_api_failed'));
|
||||
// }
|
||||
|
||||
// $bankAccount->status = 'active';
|
||||
$bankAccount->reason = 'Demande de compte bancaire envoyée via API en attente de validation';
|
||||
$bankAccount->reason = 'Demande de creation de compte bancaire soumise. En attente de verification par un administrateur.';
|
||||
$bankAccount->save();
|
||||
Log::info('Réponse API Banque: Compte bancaire créé avec succès');
|
||||
Log::info('Demande de creation de compte bancaire enregistree avec succes');
|
||||
|
||||
// Envoi de notification par email
|
||||
Mail::to($user->email)->send(new BankAccountCreatedMail($bankAccount, $bank_name, $user));
|
||||
Log::info('Mail envoyé à l’utilisateur : ' . $user->email);
|
||||
Log::info('Mail envoye a l’utilisateur : ' . $user->email);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$bankAccount->status = 'rejected';
|
||||
$bankAccount->reason = $e->getMessage();
|
||||
$bankAccount->save();
|
||||
Log::error('Erreur API Banque: ' . $e->getMessage());
|
||||
Log::error('Erreur lors de la demande de creation de compte bancaire ' . $e->getMessage());
|
||||
return $this->errorResponse(trans('errors.bank_api_exception'));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,31 +16,26 @@ class UserBankAccount extends Model
|
|||
'id_operator',
|
||||
'account_number',
|
||||
'iban',
|
||||
'swift_code',
|
||||
'identification_number',
|
||||
'account_type',
|
||||
'balance',
|
||||
'status',
|
||||
'reason',
|
||||
'lastname',
|
||||
'firstname',
|
||||
'marital_name',
|
||||
'phone_number',
|
||||
'nationality',
|
||||
'birth_date',
|
||||
'birth_country',
|
||||
'birth_city',
|
||||
'father_firstname',
|
||||
'father_lastname',
|
||||
'mother_firstname',
|
||||
'mother_lastname',
|
||||
'spouse_name',
|
||||
'niu',
|
||||
'marital_status',
|
||||
'profession',
|
||||
'sector_activity',
|
||||
'subsector_activity',
|
||||
'tax_number',
|
||||
'employee_number',
|
||||
'position',
|
||||
'employer_name',
|
||||
'employer_address',
|
||||
'employer_city',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -14,10 +14,12 @@ class CreateUserBankAccountsTable extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::dropIfExists('user_bank_accounts');
|
||||
|
||||
Schema::create('user_bank_accounts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// Référence utilisateur
|
||||
// Référence utilisateur (BigInteger pour correspondre au type id() par défaut)
|
||||
$table->unsignedInteger('id_user');
|
||||
$table->unsignedInteger('id_operator_country');
|
||||
|
||||
|
|
@ -26,47 +28,41 @@ class CreateUserBankAccountsTable extends Migration
|
|||
->nullable()
|
||||
->comment('Numéro de compte bancaire attribué par la banque');
|
||||
$table->string('iban')->nullable()->comment('Numéro IBAN du compte si disponible');
|
||||
$table->string('swift_code')->nullable()->comment('Code SWIFT/BIC de la banque');
|
||||
$table->string('account_type')->nullable()->comment('Type de compte : courant, épargne, etc.');
|
||||
$table->decimal('balance', 20, 2)->default(0);
|
||||
$table->string('status')->default('pending')->comment('Statut du compte : pending, active, rejected, closed');
|
||||
$table->string('status')->default('pending')->comment('Statut du compte : pending, validated, active, rejected, closed');
|
||||
$table->string('reason')->nullable()->comment('Raison ou message en cas de rejet ou erreur API');
|
||||
|
||||
// Informations personnelles
|
||||
$table->string('lastname')->comment('Nom de famille');
|
||||
$table->string('firstname')->comment('Prénom');
|
||||
$table->string('marital_name')->nullable()->comment('Nom marital si applicable');
|
||||
$table->string('nationality');
|
||||
$table->date('birth_date');
|
||||
$table->string('birth_country')->comment('Pays de naissance');
|
||||
$table->string('birth_city')->nullable()->comment('Ville de naissance');
|
||||
|
||||
// Parents
|
||||
$table->string('father_firstname')->nullable()->comment('Prénom du père');
|
||||
$table->string('father_lastname')->nullable()->comment('Nom du père');
|
||||
$table->string('mother_firstname')->nullable()->comment('Prénom de la mère');
|
||||
$table->string('mother_lastname')->nullable()->comment('Nom de la mère');
|
||||
|
||||
// Situation sociale et professionnelle
|
||||
$table->enum('marital_status', ['celibataire', 'marie', 'veuf', 'divorce'])
|
||||
->default('celibataire');
|
||||
$table->string('spouse_name')->nullable()->comment('Nom du conjoint si marié');
|
||||
|
||||
$table->string('profession')->nullable();
|
||||
$table->string('sector_activity')->nullable();
|
||||
$table->string('subsector_activity')->nullable();
|
||||
$table->string('tax_number')->nullable()->comment('Numéro fiscal');
|
||||
$table->string('employee_number')->nullable()->comment('Matricule employé');
|
||||
$table->string('position')->nullable()->comment('Fonction ou poste occupé');
|
||||
$table->string('identification_number')->nullable()->comment('Piece d\'identité nationale ou passeport');
|
||||
|
||||
// Correction ici : la taille est le 2ème argument de string()
|
||||
$table->string('niu', 14)->nullable()->comment('Numéro d’identification unique');
|
||||
$table->string('phone_number', 15)->nullable()->comment('numero de téléphone');
|
||||
|
||||
$table->string('profession')->nullable()->comment('Profession ou métier');
|
||||
$table->string('employer_name')->nullable()->comment('Nom de l’employeur');
|
||||
$table->string('employer_address')->nullable()->comment('Adresse de l’employeur');
|
||||
$table->timestamps();
|
||||
});
|
||||
$table->string('employer_city')->nullable()->comment('Ville de l’employeur');
|
||||
|
||||
Schema::table('user_bank_accounts', function (Blueprint $table) {
|
||||
$table->timestamps();
|
||||
|
||||
// Ajout des clés étrangères directement dans le create (plus propre)
|
||||
$table->foreign('id_user')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreign('id_operator_country')->references('id')->on('operators_countries')->onDelete('cascade');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ReInitializeDB extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Liste de toutes vos tables
|
||||
$tables = [
|
||||
'agents',
|
||||
'codeGenerer',
|
||||
'demandeAdhesion',
|
||||
'demandeCredits',
|
||||
'identifications',
|
||||
'networks_agents',
|
||||
'networks_operators',
|
||||
'nh_acts',
|
||||
'nh_authorization_of_care_requests',
|
||||
'nh_drugs_and_devices',
|
||||
'nh_exams',
|
||||
'nh_having_rights',
|
||||
'nh_health_care_sheets',
|
||||
'nh_health_care_sheets_exams',
|
||||
'nh_health_care_sheets_history',
|
||||
'nh_health_care_sheets_performances',
|
||||
'nh_health_care_sheets_prescriptions',
|
||||
'nh_insurances',
|
||||
'nh_insurances_having_rights',
|
||||
'nh_insurances_invoices',
|
||||
'nh_insurances_payments',
|
||||
'nh_insurances_subscriptions',
|
||||
'nh_insurances_subscriptions_history',
|
||||
'nh_medical_prescriptions',
|
||||
'nh_months_prices_grid',
|
||||
'nh_networks_configs',
|
||||
'nh_performances',
|
||||
'nh_provider_classes',
|
||||
'nh_tmp_health_care_sheets',
|
||||
'nh_validating_agents',
|
||||
'nh_years_prices_grid',
|
||||
'oauth_access_tokens',
|
||||
'oauth_refresh_tokens',
|
||||
'operators',
|
||||
'operators_countries',
|
||||
'paliers',
|
||||
'paliersConfigNanoCredit',
|
||||
'paliersConfigWallet',
|
||||
'paliers_commissions_wallet',
|
||||
'paying_networks',
|
||||
'payment_transactions',
|
||||
'regulations',
|
||||
'transfert_commission_transaction',
|
||||
'transmitting_networks',
|
||||
'type_operators',
|
||||
'users',
|
||||
'users_banking_account_verification',
|
||||
'users_demandes_credits',
|
||||
'users_epargnes',
|
||||
'users_groups',
|
||||
'users_groups_demandes_validations',
|
||||
'user_bank_accounts',
|
||||
'wallets',
|
||||
'walletsPassword',
|
||||
'wallets_users',
|
||||
'wallet_ilink_transaction',
|
||||
'wallet_recharge',
|
||||
'wallet_transaction'
|
||||
];
|
||||
|
||||
$this->command->info('Désactivation des contraintes de clés étrangères...');
|
||||
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
|
||||
|
||||
foreach ($tables as $tableName) {
|
||||
if (Schema::hasTable($tableName)) {
|
||||
$this->command->info("Tronquage de la table : {$tableName}");
|
||||
DB::table($tableName)->truncate();
|
||||
} else {
|
||||
$this->command->warn("La table {$tableName} n'existe pas, elle a été sautée.");
|
||||
}
|
||||
}
|
||||
|
||||
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
|
||||
$this->command->info('Réinitialisation terminée avec succès !');
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue