+ Fix bugs on User - Envoi wallet à wallet
This commit is contained in:
parent
0022e5451f
commit
6e2908bab9
|
@ -2,8 +2,11 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\ConfigWallet;
|
||||
use App\Models\Country;
|
||||
use App\Models\WalletsUser;
|
||||
use App\Traits\ApiResponser;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class HelperController extends Controller
|
||||
|
@ -27,10 +30,26 @@ class HelperController extends Controller
|
|||
return $this->successResponse($countries);
|
||||
}
|
||||
|
||||
public function paying_networks($id_country)
|
||||
public function paying_networks(Request $request)
|
||||
{
|
||||
$networks = DB::select('SELECT n.id , n.name , c.type FROM networks n INNER JOIN configWallet c ON c.id_network = n.id WHERE n.id IN ( SELECT distinct id_network FROM paying_networks )
|
||||
AND status = 1 AND country_id = :id;',['id'=>$id_country]);
|
||||
$this->validate($request,[
|
||||
'id_country' => 'required|integer|min:0|not_in:0',
|
||||
'id_wallet_user' => 'required|integer|min:0|not_in:0',
|
||||
]);
|
||||
|
||||
$walletUser = WalletsUser::findOrFail($request->id_wallet_user);
|
||||
$init_country = $walletUser->user->network->country->id;
|
||||
$result = ConfigWallet::join('networks', 'networks.id', '=', 'configWallet.id_network')
|
||||
->where('networks.country_id', $init_country)->where('configWallet.type', 'ilink')
|
||||
->select('configWallet.id')->first();
|
||||
if ($result) {
|
||||
$config = ConfigWallet::findOrFail($result->id);
|
||||
} else {
|
||||
return $this->errorResponse(trans('errors.no_ilink_network'));
|
||||
}
|
||||
$networks = DB::select('SELECT n.id , n.name , c.type FROM networks n INNER JOIN configWallet c ON c.id_network = n.id WHERE n.id
|
||||
IN ( SELECT distinct id_network FROM paying_networks WHERE id_configWallet = :id_config)
|
||||
AND status = 1 AND country_id = :id_country;',['id_country'=>$request->id_country, 'id_config'=> $config->id]);
|
||||
foreach ($networks as $network){
|
||||
if($network->type == 'ilink')
|
||||
$network->type = 'ilink-world';
|
||||
|
|
|
@ -73,7 +73,6 @@ class iLinkTransactionController extends Controller
|
|||
->select('configWallet.id')->first();
|
||||
if ($result) {
|
||||
$config = ConfigWallet::findOrFail($result->id);
|
||||
$transaction->network_emetteur = $config->id_network;
|
||||
} else {
|
||||
return $this->errorResponse(trans('errors.no_ilink_network'));
|
||||
}
|
||||
|
@ -82,7 +81,7 @@ class iLinkTransactionController extends Controller
|
|||
$wallet_agent_hyp = WalletAgent::where('agent_id', $hyperviseur->id)->firstOrFail();
|
||||
$walletHyperviseur = Wallet::findOrFail($wallet_agent_hyp->wallet_id);
|
||||
}
|
||||
|
||||
$transaction->network_emetteur = $config->id_network;
|
||||
|
||||
$taxesNationales = array_values(array_filter($config->taxes->all(), function ($tax) {
|
||||
return $tax->destination == 'national';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
// Helper routes
|
||||
$router->get('countries','HelperController@countries');
|
||||
$router->get('countries/{dial_code}','HelperController@country');
|
||||
$router->get('paying_networks/{id_country}','HelperController@paying_networks');
|
||||
$router->post('paying_networks','HelperController@paying_networks');
|
||||
|
||||
// Transactions routes
|
||||
$router->group(['prefix' => '/transactions'] , function () use ($router){
|
||||
|
|
Loading…
Reference in New Issue