+ Adding payment operators
This commit is contained in:
parent
a587c69c51
commit
80ccf453c4
|
@ -348,12 +348,12 @@ class WalletController extends Controller
|
|||
return $this->successResponse($result);
|
||||
}
|
||||
|
||||
public function getWalletBanks($id_wallet_network)
|
||||
public function getWalletOperators($id_wallet_network, $type_operator)
|
||||
{
|
||||
$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
|
||||
INNER JOIN countries c ON bc.id_country = c.id WHERE nb.id_network = :id_network ;", ['id_network' => $id_wallet_network]);
|
||||
$operators = DB::select("SELECT oc.id as id_operator, o.nom as operator_name , oc.adresse as operator_address, c.name as country FROM networks_operators nop INNER JOIN operators_countries oc ON oc.id = nop.id_operator_country INNER JOIN operators o ON o.id = oc.id_operator
|
||||
INNER JOIN countries c ON oc.id_country = c.id INNER JOIN type_operators top ON o.type = top.code WHERE nop.id_network = :id_network AND o.type = :type_operator ;", ['id_network' => $id_wallet_network, 'type_operator' => $type_operator]);
|
||||
|
||||
return $this->successResponse($banks);
|
||||
return $this->successResponse($operators);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use App\Models\ConfigWallet;
|
|||
use App\Models\Country;
|
||||
use App\Models\Identification;
|
||||
use App\Models\NetworksAgent;
|
||||
use App\Models\NetworksBank;
|
||||
use App\Models\NetworksOperator;
|
||||
use App\Models\PayingNetwork;
|
||||
use App\Models\Regulation;
|
||||
use App\Models\TypeIlinkTransaction;
|
||||
|
@ -397,13 +397,16 @@ class iLinkTransactionController extends Controller
|
|||
// return $rep;
|
||||
|
||||
//Verifier si la banque est associée au reseau
|
||||
$network_bank = NetworksBank::where('id_network', $request->id_wallet_network)->where('id_bank_country', $request->id_bank)->first();
|
||||
$network_bank = NetworksOperator::where('id_network', $request->id_wallet_network)->where('id_operator_country', $request->id_bank)->first();
|
||||
if (!$network_bank)
|
||||
return $this->errorResponse(trans('errors.bank_not_associated_with_network'));
|
||||
|
||||
if ($network_bank->operators_country->operator->type != 'bank')
|
||||
return $this->errorResponse(trans('errors.not_banking_operator'));
|
||||
|
||||
//Verifier le code IBAN
|
||||
$country_code = $network_bank->network->country->code_country;
|
||||
$bank_code = $network_bank->banks_country->code_banque;
|
||||
$bank_code = $network_bank->operators_country->code;
|
||||
switch ($this->checkIBAN($request->iban, $country_code, $bank_code)) {
|
||||
case 0:
|
||||
return $this->errorResponse(trans('errors.invalid_iban'));
|
||||
|
@ -424,7 +427,7 @@ class iLinkTransactionController extends Controller
|
|||
$transaction->id_wallet_hyp = $walletHyperviseur->id;
|
||||
$transaction->frais = $frais;
|
||||
$transaction->date = new \DateTime();
|
||||
$transaction->bank = $network_bank->banks_country->bank->nom;
|
||||
$transaction->bank = $network_bank->operators_country->operator->nom;
|
||||
$transaction->country = $network_bank->network->country->name;
|
||||
$transaction->id_bank = $request->id_bank;
|
||||
$transaction->iban = $request->iban;
|
||||
|
@ -1090,13 +1093,16 @@ class iLinkTransactionController extends Controller
|
|||
return $this->errorResponse(trans('errors.insufficient_balance'));
|
||||
|
||||
//Verifier si la banque est associée au reseau
|
||||
$network_bank = NetworksBank::where('id_network', $request->id_wallet_network)->where('id_bank_country', $request->id_bank)->first();
|
||||
$network_bank = NetworksOperator::where('id_network', $request->id_wallet_network)->where('id_operator_country', $request->id_bank)->first();
|
||||
if (!$network_bank)
|
||||
return $this->errorResponse(trans('errors.bank_not_associated_with_network'));
|
||||
|
||||
if ($network_bank->operators_country->operator->type != 'bank')
|
||||
return $this->errorResponse(trans('errors.not_banking_operator'));
|
||||
|
||||
//Verifier le code IBAN
|
||||
$country_code = $network_bank->network->country->code_country;
|
||||
$bank_code = $network_bank->banks_country->code_banque;
|
||||
$bank_code = $network_bank->operators_country->code;
|
||||
switch ($this->checkIBAN($request->iban, $country_code, $bank_code)) {
|
||||
case 0:
|
||||
return $this->errorResponse(trans('errors.invalid_iban'));
|
||||
|
@ -1119,7 +1125,7 @@ class iLinkTransactionController extends Controller
|
|||
$transaction->id_wallet_sup = $walletSuperviseur->id;
|
||||
$transaction->frais = $frais;
|
||||
$transaction->date = new \DateTime();
|
||||
$transaction->bank = $network_bank->banks_country->bank->nom;
|
||||
$transaction->bank = $network_bank->operators_country->operator->nom;
|
||||
$transaction->country = $network_bank->network->country->name;
|
||||
$transaction->id_bank = $request->id_bank;
|
||||
$transaction->iban = $request->iban;
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Bank
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $nom
|
||||
*
|
||||
* @property Collection|BanksCountry[] $banks_countries
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Bank extends Model
|
||||
{
|
||||
protected $table = 'banks';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'nom'
|
||||
];
|
||||
|
||||
public function banks_countries()
|
||||
{
|
||||
return $this->hasMany(BanksCountry::class, 'id_bank');
|
||||
}
|
||||
}
|
|
@ -9,35 +9,35 @@ namespace App\Models;
|
|||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class NetworksBank
|
||||
* Class NetworksOperator
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $id_bank_country
|
||||
* @property int $id_operator_country
|
||||
* @property int $id_network
|
||||
*
|
||||
* @property BanksCountry $banks_country
|
||||
* @property OperatorsCountry $operators_country
|
||||
* @property Network $network
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class NetworksBank extends Model
|
||||
class NetworksOperator extends Model
|
||||
{
|
||||
protected $table = 'networks_banks';
|
||||
protected $table = 'networks_operators';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $casts = [
|
||||
'id_bank_country' => 'int',
|
||||
'id_operator_country' => 'int',
|
||||
'id_network' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'id_bank_country',
|
||||
'id_operator_country',
|
||||
'id_network'
|
||||
];
|
||||
|
||||
public function banks_country()
|
||||
public function operators_country()
|
||||
{
|
||||
return $this->belongsTo(BanksCountry::class, 'id_bank_country');
|
||||
return $this->belongsTo(OperatorsCountry::class, 'id_operator_country');
|
||||
}
|
||||
|
||||
public function network()
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Operator
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $nom
|
||||
* @property string|null $type
|
||||
*
|
||||
* @property TypeOperator $type_operator
|
||||
* @property Collection|OperatorsCountry[] $operators_countries
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Operator extends Model
|
||||
{
|
||||
protected $table = 'operators';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'nom',
|
||||
'type'
|
||||
];
|
||||
|
||||
public function type_operator()
|
||||
{
|
||||
return $this->belongsTo(TypeOperator::class, 'type', 'code');
|
||||
}
|
||||
|
||||
public function operators_countries()
|
||||
{
|
||||
return $this->hasMany(OperatorsCountry::class, 'id_operator');
|
||||
}
|
||||
}
|
|
@ -10,43 +10,43 @@ use Illuminate\Database\Eloquent\Collection;
|
|||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class BanksCountry
|
||||
* Class OperatorsCountry
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $id_bank
|
||||
* @property int $id_operator
|
||||
* @property int $id_country
|
||||
* @property string|null $adresse
|
||||
* @property string|null $code_banque
|
||||
* @property string|null $code
|
||||
* @property bool $status
|
||||
*
|
||||
* @property Bank $bank
|
||||
* @property Operator $operator
|
||||
* @property Country $country
|
||||
* @property Collection|NetworksBank[] $networks_banks
|
||||
* @property Collection|NetworksOperator[] $networks_operators
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class BanksCountry extends Model
|
||||
class OperatorsCountry extends Model
|
||||
{
|
||||
protected $table = 'banks_countries';
|
||||
protected $table = 'operators_countries';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $casts = [
|
||||
'id_bank' => 'int',
|
||||
'id_operator' => 'int',
|
||||
'id_country' => 'int',
|
||||
'status' => 'bool'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'id_bank',
|
||||
'id_operator',
|
||||
'id_country',
|
||||
'adresse',
|
||||
'code_banque',
|
||||
'code',
|
||||
'status'
|
||||
];
|
||||
|
||||
public function bank()
|
||||
public function operator()
|
||||
{
|
||||
return $this->belongsTo(Bank::class, 'id_bank');
|
||||
return $this->belongsTo(Operator::class, 'id_operator');
|
||||
}
|
||||
|
||||
public function country()
|
||||
|
@ -54,8 +54,8 @@ class BanksCountry extends Model
|
|||
return $this->belongsTo(Country::class, 'id_country');
|
||||
}
|
||||
|
||||
public function networks_banks()
|
||||
public function networks_operators()
|
||||
{
|
||||
return $this->hasMany(NetworksBank::class, 'id_bank_country');
|
||||
return $this->hasMany(NetworksOperator::class, 'id_operator_country');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class TypeOperator
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $code
|
||||
* @property string|null $description_fr
|
||||
* @property string|null $description_en
|
||||
*
|
||||
* @property Collection|Operator[] $operators
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class TypeOperator extends Model
|
||||
{
|
||||
protected $table = 'type_operators';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'description_fr',
|
||||
'description_en'
|
||||
];
|
||||
|
||||
public function operators()
|
||||
{
|
||||
return $this->hasMany(Operator::class, 'type', 'code');
|
||||
}
|
||||
}
|
|
@ -78,4 +78,5 @@ Paying network : :network :country',
|
|||
"invalid_iban" => "The IBAN code is invalid",
|
||||
"country_not_match_iban" => "The IBAN code does not correspond to the country of this bank",
|
||||
"bank_not_match_iban" => "The IBAN code does not correspond to this bank",
|
||||
"not_banking_operator" => "This operator is not a banking operator",
|
||||
];
|
||||
|
|
|
@ -78,4 +78,5 @@ Réseau payeur : :network :country',
|
|||
"invalid_iban" => "Le code IBAN est invalide",
|
||||
"country_not_match_iban" => "Le code IBAN ne correspond pas au pays cette banque",
|
||||
"bank_not_match_iban" => "Le code IBAN ne correspond à cette banque",
|
||||
"not_banking_operator" => "Cet opérateur n'est pas un opérateur bancaire",
|
||||
];
|
||||
|
|
|
@ -69,8 +69,8 @@ $router->group(['prefix' => '', 'middleware' => 'auth'], function () use ($route
|
|||
// Wallets users iLink
|
||||
$router->group(['prefix' => '/users'], function () use ($router) {
|
||||
$router->get('{id_user}', 'WalletController@showWalletUser');
|
||||
//Liste des banques
|
||||
$router->get('banks/{id_wallet_network}', 'WalletController@getWalletBanks');
|
||||
//Liste des operateurs
|
||||
$router->get('operators/{type}/{id_wallet_network}', 'WalletController@getWalletOperators');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue