Route to Calculate refunded amount per agent - UBA Fs iLink

This commit is contained in:
Djery-Tom 2021-10-03 09:58:41 +01:00
parent 6e4cd34390
commit 9df0cedfbc
7 changed files with 4698 additions and 1379 deletions

View File

@ -0,0 +1,30 @@
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
class RefundAmountImport implements FromArray, WithColumnFormatting, ShouldAutoSize
{
protected $data;
public function __construct(array $data)
{
$this->data = $data;
}
public function array(): array
{
return $this->data;
}
public function columnFormats(): array
{
return [
'C' => NumberFormat::FORMAT_TEXT,
];
}
}

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Exports\RefundAmountImport;
use App\Jobs\TestJob;
use App\Models\AgentPlus;
use App\Models\ConfigWallet;
@ -9,11 +10,14 @@ use App\Models\Country;
use App\Models\NetworksAgent;
use App\Models\User;
use App\Models\Wallet;
use App\Models\WalletAgent;
use App\Models\WalletsUser;
use App\Models\WalletTransaction;
use App\Traits\ApiResponser;
use App\Traits\Helper;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Facades\Excel;
class HelperController extends Controller
{
@ -146,4 +150,43 @@ class HelperController extends Controller
}
return $this->successResponse($codes);
}
public function fixTransactionAmount()
{
$data = [['ID Wallet', 'Agent', 'Contact', 'Role', 'Parrain', 'Nombre de transactions', 'Montant à rembourser']];
// Calcul du montant a prelever pour tous les agents loc du reseau iLink World
$config = ConfigWallet::where('id_network', 237)->first();
if (isset($config)) {
$walletAgents = WalletAgent::where('network_id', 237)->orderBy('category')->orderBy('lastname', 'ASC')->get();
foreach ($walletAgents as $wallet) {
$refund = 0;
$totalTransactions = 0;
if ($wallet->category == 'geolocated') {
$totalTransactions = WalletTransaction::where('id_wallet', $wallet->wallet_id)->where('type', 'credit')
->where('canceled', '0')->where('deleted', 0)->count();
// Montant à rembourser
$refund = $totalTransactions * $config->frais_min_banque_depot * $config->taux_com_ag_depot / 100;
} elseif ($wallet->category == 'super') {
$totalTransactions = WalletTransaction::where('id_wallet_sup', $wallet->wallet_id)->where('type', 'credit')
->where('canceled', '0')->where('deleted', 0)->count();
// Montant à rembourser
$refund = $totalTransactions * $config->frais_min_banque_depot * $config->taux_com_sup_depot / 100;
} elseif ($wallet->category == 'hyper') {
$totalTransactions = WalletTransaction::where('id_wallet_hyp', $wallet->wallet_id)->where('type', 'credit')
->where('canceled', '0')->where('deleted', 0)->count();
// Montant à rembourser
$refund = $totalTransactions * $config->frais_min_banque_depot * (100 - $config->taux_com_ag_depot - $config->taux_com_sup_depot) / 100;
}
array_push($data, [$wallet->wallet_id, $wallet->lastname, substr($wallet->transactionNumber, 4), $wallet->category, $wallet->parrain,
$totalTransactions, $refund]);
}
}
$export = new RefundAmountImport($data);
return Excel::download($export, 'refund.xlsx');
}
}

View File

@ -89,7 +89,7 @@ class TransactionController extends Controller
if ($code == 200) {
$banqueCommission = floatval(($frais + $config->frais_min_banque_depot) * $config->part_banque_depot / 100);
$banqueCommission = floatval($frais * $config->part_banque_depot / 100);
$transaction->commission_banque = $banqueCommission;
// 2---> Emmètre via API sécurisé SSL une requête de débit de notre
//compte marchand du (Part de la banque partenaire en %
@ -99,9 +99,9 @@ class TransactionController extends Controller
$walletAgent->balance_princ -= $transaction->montant;
$agentCommission = floatval(($frais + $config->frais_min_banque_depot) * $config->taux_com_ag_depot / 100);
$superviseurCommission = floatval(($frais + $config->frais_min_banque_depot) * $config->taux_com_sup_depot / 100);
$hyperviseurCommission = $frais + $config->frais_min_banque_depot - $superviseurCommission - $agentCommission - $banqueCommission;
$agentCommission = floatval($frais * $config->taux_com_ag_depot / 100);
$superviseurCommission = floatval($frais * $config->taux_com_sup_depot / 100);
$hyperviseurCommission = $frais - $superviseurCommission - $agentCommission - $banqueCommission;
$walletAgent->balance_com += $agentCommission;
$walletSuperviseur->balance_com += $superviseurCommission;

View File

@ -66,8 +66,8 @@ $app->alias('mailer', Illuminate\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\MailQueue::class);
$app->configure('swagger-lume');
$app->register(\SwaggerLume\ServiceProvider::class);
$app->configure('dompdf');
$app->alias('Excel', Maatwebsite\Excel\Facades\Excel::class);
/*
|--------------------------------------------------------------------------
| Register Middleware
@ -104,7 +104,11 @@ $app->routeMiddleware([
// $app->register(App\Providers\AppServiceProvider::class);
// $app->register(App\Providers\AuthServiceProvider::class);
// $app->register(App\Providers\EventServiceProvider::class);
$app->register(Illuminate\Mail\MailServiceProvider::class);
$app->register(Illuminate\Database\Eloquent\LegacyFactoryServiceProvider::class);
$app->register(Illuminate\Mail\MailServiceProvider::class);
$app->register(\SwaggerLume\ServiceProvider::class);
$app->register(Maatwebsite\Excel\ExcelServiceProvider::class);
$app->register(\Barryvdh\DomPDF\ServiceProvider::class);
/*
|--------------------------------------------------------------------------

View File

@ -5,26 +5,27 @@
"license": "MIT",
"type": "project",
"require": {
"php": "^7.2.5",
"brick/money": "^0.4.5",
"php": "^7.3|^8.0",
"barryvdh/laravel-dompdf": "^0.9.0",
"brick/money": "^0.5.2",
"darkaonline/swagger-lume": "^8.0",
"guzzlehttp/guzzle": "^6.5",
"illuminate/mail": "^7.13",
"laravel/lumen-framework": "^7.0",
"twilio/sdk": "^6.3"
"guzzlehttp/guzzle": "^7.0.1",
"illuminate/mail": "^8.62",
"laravel/legacy-factories": "^1.1",
"laravel/lumen-framework": "^8.0",
"maatwebsite/excel": "^3.1",
"twilio/sdk": "^6.28"
},
"require-dev": {
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"phpunit/phpunit": "^8.5"
"phpunit/phpunit": "^9.3"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {

5959
composer.lock generated Executable file → Normal file

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@
| and give it the Closure to call when that URI is requested.
|
*/
$router->get('fix-transactions-amount', 'HelperController@fixTransactionAmount');
//$router->get('/', function () use ($router) {
// return $router->app->version();
//});