Remove FS services endpoint

This commit is contained in:
Djery-Tom 2021-10-20 17:09:29 +01:00
parent bfb0612ead
commit b70c4ed6b5
3 changed files with 42 additions and 44 deletions

View File

@ -3,7 +3,6 @@
namespace App\Http\Controllers;
use App\Exports\RefundAmountExport;
use App\Imports\RefundAmountImport;
use App\Jobs\TestJob;
use App\Models\AgentPlus;
use App\Models\ConfigWallet;
@ -18,9 +17,7 @@ use App\Traits\ApiResponser;
use App\Traits\Helper;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Maatwebsite\Excel\Facades\Excel;
use Throwable;
class HelperController extends Controller
{
@ -193,34 +190,34 @@ class HelperController extends Controller
return Excel::download($export, 'refund.xlsx');
}
public function fixFSServicesAmounts()
{
$data = Excel::toArray(new RefundAmountImport, storage_path('refund.xlsx'));
$result = [];
foreach ($data[0] as $key => $row) {
if ($key > 0) {
array_push($result, $row);
}
}
try {
DB::beginTransaction();
// Fix amount
foreach ($result as $r) {
if (isset($r[6])) {
if ($r[3] == 'hyper') continue;
$refund = $r[3] == 'geolocated' ? 50 * $r[5] : 25 * $r[5];
$wallet = Wallet::find($r[0]);
$wallet->balance_com += $refund;
$wallet->save();
}
}
DB::commit();
return $this->successResponse(trans('messages.success_treated_demand'));
} catch (Throwable $exception) {
DB::rollBack();
Log::error($exception->getMessage());
return $this->errorResponse(trans('errors.unexpected_error'));
}
}
// public function fixFSServicesAmounts()
// {
// $data = Excel::toArray(new RefundAmountImport, storage_path('refund.xlsx'));
// $result = [];
// foreach ($data[0] as $key => $row) {
// if ($key > 0) {
// array_push($result, $row);
// }
// }
//
// try {
// DB::beginTransaction();
// // Fix amount
// foreach ($result as $r) {
// if (isset($r[6])) {
// if ($r[3] == 'hyper') continue;
// $refund = $r[3] == 'geolocated' ? 50 * $r[5] : 25 * $r[5];
// $wallet = Wallet::find($r[0]);
// $wallet->balance_com += $refund;
// $wallet->save();
// }
// }
// DB::commit();
// return $this->successResponse(trans('messages.success_treated_demand'));
// } catch (Throwable $exception) {
// DB::rollBack();
// Log::error($exception->getMessage());
// return $this->errorResponse(trans('errors.unexpected_error'));
// }
// }
}

View File

@ -34,6 +34,7 @@ use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use PDO;
use Throwable;
trait Helper
{
@ -45,7 +46,7 @@ trait Helper
$message->subject($title);
$message->to($recipients);
});
} catch (\Throwable $t) {
} catch (Throwable $t) {
Log::error('-------- Mail not sent -----------');
Log::error($t->getMessage());
}
@ -68,7 +69,7 @@ trait Helper
$body->data = $data;
try {
$body->date = ($date instanceof \DateTime) ? $date->format('Y-m-d H:i:s') : $date;
} catch (\Throwable $t) {
} catch (Throwable $t) {
Log::error($t->getMessage());
$body->date = $date;
}
@ -83,7 +84,7 @@ trait Helper
// );
$promise->wait();
// return $response->getBody()->getContents();
} catch (\Throwable $t) {
} catch (Throwable $t) {
Log::error('-------- User notification not sent-----------');
Log::error($t->getMessage());
}
@ -105,13 +106,13 @@ trait Helper
$body->data = $data;
try {
$body->date = ($date instanceof \DateTime) ? $date->format('Y-m-d H:i:s') : $date;
} catch (\Throwable $t) {
} catch (Throwable $t) {
Log::error($t->getMessage());
$body->date = $date;
}
$promise = $client->requestAsync('POST', '/onesignal/pushToAgent', ['json' => $body, 'headers' => $headers])->then();
$promise->wait();
} catch (\Throwable $t) {
} catch (Throwable $t) {
Log::error('-------- Agent notification not sent-----------');
Log::error($t->getMessage());
}
@ -148,20 +149,20 @@ trait Helper
WHERE n.id = :id', ['id' => $id_network]))->first();
$money = Money::of(round($amount, 2), $currency ? $currency->code : 'XAF', new AutoContext());
return $money->formatTo('fr_FR');
return $money->formatTo(app()->getLocale());
}
public function toMoney($amount, $id_country)
{
$country = Country::findOrFail($id_country);
$money = Money::of(round($amount, 2), $country->currency->code, new AutoContext());
return $money->formatTo('fr_FR');
return $money->formatTo(app()->getLocale());
}
public function toMoneyWithCurrencyCode($amount, $currency_code)
{
$money = Money::of(round($amount, 2), $currency_code, new AutoContext());
return $money->formatTo('fr_FR');
return $money->formatTo(app()->getLocale());
}
private function convertMoney($amount, $init_country, $final_country)
@ -195,7 +196,7 @@ trait Helper
public function toMoneyWithCurrency($amount, $init_country, $final_country)
{
return $this->convertMoney($amount, $init_country, $final_country)->formatTo('fr_FR');
return $this->convertMoney($amount, $init_country, $final_country)->formatTo(app()->getLocale());
}
public function toMoneyAmount($amount, $init_country, $final_country)

View File

@ -15,7 +15,7 @@
//});
$router->group(['prefix' => '', 'middleware' => 'auth'], function () use ($router) {
// Helper routes
$router->get('fixFSServicesAmounts', 'HelperController@fixFSServicesAmounts');
// $router->get('fixFSServicesAmounts', 'HelperController@fixFSServicesAmounts');
$router->post('update_password', 'UserController@updatePassword');
$router->get('agent_codes/{agent_code}', 'HelperController@agentCodes');
$router->get('countries', 'HelperController@countries');
@ -35,7 +35,7 @@ $router->group(['prefix' => '', 'middleware' => 'auth'], function () use ($route
$router->group(['prefix' => '/ilink'], function () use ($router) {
$router->post('', 'iLinkTransactionController@add');
$router->post('commission', 'iLinkTransactionController@calculateCommission');
$router->get('user/{id_wallet_user}', 'iLinkTransactionController@lastUserTransactions');
$router->get('user/{id_user}', 'iLinkTransactionController@lastUserTransactions');
$router->get('agent/{id_wallet_agent}', 'iLinkTransactionController@lastAgentTransactions');
$router->post('check_retraits', 'iLinkTransactionController@getTransactionRetrait');
$router->delete('{id_transaction}', 'iLinkTransactionController@cancel');