+ Fix bugs on User - Envoi wallet à wallet

This commit is contained in:
Djery-Tom 2020-06-24 16:49:41 +01:00
parent 0022e5451f
commit 6e2908bab9
3 changed files with 24 additions and 6 deletions

View File

@ -2,8 +2,11 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\ConfigWallet;
use App\Models\Country; use App\Models\Country;
use App\Models\WalletsUser;
use App\Traits\ApiResponser; use App\Traits\ApiResponser;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
class HelperController extends Controller class HelperController extends Controller
@ -27,10 +30,26 @@ class HelperController extends Controller
return $this->successResponse($countries); 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 ) $this->validate($request,[
AND status = 1 AND country_id = :id;',['id'=>$id_country]); '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){ foreach ($networks as $network){
if($network->type == 'ilink') if($network->type == 'ilink')
$network->type = 'ilink-world'; $network->type = 'ilink-world';

View File

@ -73,7 +73,6 @@ class iLinkTransactionController extends Controller
->select('configWallet.id')->first(); ->select('configWallet.id')->first();
if ($result) { if ($result) {
$config = ConfigWallet::findOrFail($result->id); $config = ConfigWallet::findOrFail($result->id);
$transaction->network_emetteur = $config->id_network;
} else { } else {
return $this->errorResponse(trans('errors.no_ilink_network')); 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(); $wallet_agent_hyp = WalletAgent::where('agent_id', $hyperviseur->id)->firstOrFail();
$walletHyperviseur = Wallet::findOrFail($wallet_agent_hyp->wallet_id); $walletHyperviseur = Wallet::findOrFail($wallet_agent_hyp->wallet_id);
} }
$transaction->network_emetteur = $config->id_network;
$taxesNationales = array_values(array_filter($config->taxes->all(), function ($tax) { $taxesNationales = array_values(array_filter($config->taxes->all(), function ($tax) {
return $tax->destination == 'national'; return $tax->destination == 'national';

View File

@ -17,7 +17,7 @@
// Helper routes // Helper routes
$router->get('countries','HelperController@countries'); $router->get('countries','HelperController@countries');
$router->get('countries/{dial_code}','HelperController@country'); $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 // Transactions routes
$router->group(['prefix' => '/transactions'] , function () use ($router){ $router->group(['prefix' => '/transactions'] , function () use ($router){