+ Add new field in savings requests
This commit is contained in:
parent
bf2e38508d
commit
21cc818763
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Models\AgentPlus;
|
||||
use App\Models\DemandeCredit;
|
||||
use App\Models\Network;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\WalletAgent;
|
||||
use App\Traits\ApiResponser;
|
||||
|
@ -56,7 +57,7 @@ class CreditController extends Controller
|
|||
$walletAgent->balance_princ += $request->montant;
|
||||
$walletParrain->balance_princ -= $request->montant;
|
||||
|
||||
DB::update('UPDATE demandeCredits SET montant = ? , `status` = \'1\' , date_modification = ? , date_creation = ? WHERE ( id = ? );', [$request->montant, $datetime, $datetime, $demand->id]);
|
||||
DB::update('UPDATE demandeCredits SET montant = ? , `status` = \'1\' , date_modification = ? WHERE ( id = ? );', [$request->montant, $datetime, $demand->id]);
|
||||
}else{
|
||||
if($walletParrain->balance_princ < $demand->montant)
|
||||
return $this->errorResponse(trans('messages.princ_balance_inf_to_demand_amount'),Response::HTTP_UPGRADE_REQUIRED);
|
||||
|
@ -64,7 +65,7 @@ class CreditController extends Controller
|
|||
$walletAgent->balance_princ += $demand->montant;
|
||||
$walletParrain->balance_princ -= $demand->montant;
|
||||
|
||||
DB::update('UPDATE demandeCredits SET `status` = \'1\' , date_modification = ? , date_creation = ? WHERE ( id = ? );', [$datetime, $datetime, $demand->id]);
|
||||
DB::update('UPDATE demandeCredits SET `status` = \'1\' , date_modification = ? WHERE ( id = ? );', [$datetime, $demand->id]);
|
||||
}
|
||||
|
||||
$walletAgent->save();
|
||||
|
@ -76,7 +77,7 @@ class CreditController extends Controller
|
|||
// echo "Error: " . $e->getMessage();
|
||||
// }
|
||||
$data = new \stdClass();
|
||||
$data->screen = "notificationview";
|
||||
$data->screen = "Historique";
|
||||
$data->data = new \stdClass();
|
||||
$data->data->id = $id_demand;
|
||||
|
||||
|
@ -105,11 +106,12 @@ class CreditController extends Controller
|
|||
|
||||
|
||||
$walletAgentParrain = WalletAgent::where('agent_id', $parrain->id)->firstOrFail();
|
||||
$datetime = $this->getCurrentTime($walletAgentParrain->network->country_id);
|
||||
$network = Network::findOrFail($walletAgentParrain->network_id);
|
||||
$datetime = $this->getCurrentTime($network->country_id);
|
||||
|
||||
|
||||
$data = new \stdClass();
|
||||
$data->screen = "notificationview";
|
||||
$data->screen = "Historique";
|
||||
$data->data = new \stdClass();
|
||||
$data->data->id = $id_demand;
|
||||
|
||||
|
|
|
@ -282,6 +282,7 @@ class NanoCreditController extends Controller
|
|||
"type": "SIMPLE",
|
||||
"etat": "EN COURS",
|
||||
"montant": "5000.00",
|
||||
"montant_retire": "0.00",
|
||||
"date_creation": "2020-11-07 14:08:45",
|
||||
"id_epargne": "BVZ5NA3M",
|
||||
"duree_mois": null,
|
||||
|
@ -297,7 +298,7 @@ class NanoCreditController extends Controller
|
|||
*/
|
||||
public function getSavingsDemandsInProgress($id_user)
|
||||
{
|
||||
$savings = DB::select("SELECT i.type , etat, montant, date_creation , id_epargne , duree_mois , interet , taxe , date_fin FROM infos_users_epargnes i WHERE i.id_user = :id AND i.etat = 'EN_COURS' ORDER BY i.date_creation DESC;", ['id' => $id_user]);
|
||||
$savings = DB::select("SELECT i.type , etat, montant, montant_retire , date_creation , id_epargne , duree_mois , interet , taxe , date_fin FROM infos_users_epargnes i WHERE i.id_user = :id AND i.etat = 'EN_COURS' ORDER BY i.date_creation DESC;", ['id' => $id_user]);
|
||||
$result = array_map(function ($demand) {
|
||||
$demand->etat = str_replace('_', ' ', $demand->etat);
|
||||
return $demand;
|
||||
|
@ -575,6 +576,8 @@ class NanoCreditController extends Controller
|
|||
$user->balance_epargne -= $montant_total;
|
||||
$walletUser->balance += $montant_total;
|
||||
$saving->etat = 'CASSE';
|
||||
$saving->montant = 0;
|
||||
$saving->montant_retire = $montant_total;
|
||||
$saving->date_cassation = $this->getCurrentTime($init_country);
|
||||
|
||||
$user->save();
|
||||
|
|
|
@ -16,6 +16,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property string $id_epargne
|
||||
* @property string $type
|
||||
* @property float $montant
|
||||
* @property float montant_retire
|
||||
* @property int $duree_mois
|
||||
* @property float $interet
|
||||
* @property float $taxe
|
||||
|
@ -35,6 +36,7 @@ class UsersEpargne extends Model
|
|||
|
||||
protected $casts = [
|
||||
'montant' => 'float',
|
||||
'montant_retire' => 'float',
|
||||
'duree_mois' => 'int',
|
||||
'interet' => 'float',
|
||||
'taxe' => 'float',
|
||||
|
@ -52,6 +54,7 @@ class UsersEpargne extends Model
|
|||
'id_epargne',
|
||||
'type',
|
||||
'montant',
|
||||
'montant_retire',
|
||||
'duree_mois',
|
||||
'interet',
|
||||
'taxe',
|
||||
|
|
|
@ -64,9 +64,4 @@ class WalletAgent extends Model
|
|||
'currency_code',
|
||||
'transactionNumber'
|
||||
];
|
||||
|
||||
public function network()
|
||||
{
|
||||
return $this->belongsTo(Network::class, 'network_id');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ trait Helper
|
|||
// set to whatever your rates are relative to
|
||||
$baseCurrency = 'USD';
|
||||
|
||||
// use your own credentials, or re-use your existing PDO connection
|
||||
// use your own credentials, or re-use your existing PDO connection
|
||||
$pdo = new PDO('mysql:host=' . env('DB_HOST') . ';dbname=' . env('DB_DATABASE'), env('DB_USERNAME'), env('DB_PASSWORD'));
|
||||
|
||||
$configuration = new PDOProviderConfiguration();
|
||||
|
|
Loading…
Reference in New Issue