+ Change Agent - Retrait en cash method
This commit is contained in:
parent
6c0c4dbbce
commit
95127012a8
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||
use App\Models\ConfigWallet;
|
||||
use App\Models\Network;
|
||||
use App\Models\NetworksAgent;
|
||||
use App\Models\TransfertCommissionTransaction;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\WalletTransaction;
|
||||
use App\Traits\ApiResponser;
|
||||
|
@ -33,9 +34,17 @@ class CommissionController extends Controller
|
|||
if($wallet->balance_com <=0 )
|
||||
return $this->errorResponse(trans('messages.empty_com_balance') , Response::HTTP_BAD_REQUEST);
|
||||
|
||||
$transaction = new TransfertCommissionTransaction();
|
||||
$transaction->balance_princ_init = $wallet->balance_princ;
|
||||
$transaction->balance_com_init = $wallet->balance_com;
|
||||
$wallet->balance_princ += $wallet->balance_com;
|
||||
$wallet->balance_com = 0;
|
||||
$transaction->balance_princ_final = $wallet->balance_princ;
|
||||
$transaction->balance_com_final = $wallet->balance_com;
|
||||
$transaction->id_wallet_ag = $wallet->id;
|
||||
$transaction->date = new \DateTime();
|
||||
$wallet->save();
|
||||
$transaction->save();
|
||||
|
||||
return $this->successResponse($wallet);
|
||||
|
||||
|
|
|
@ -1076,13 +1076,19 @@ class iLinkTransactionController extends Controller
|
|||
$this->validate($request, [
|
||||
'id_transaction' => 'required',
|
||||
'id_wallet_agent' => 'required|integer|min:0|not_in:0',
|
||||
'code_retrait' => 'required',
|
||||
]);
|
||||
$transaction = WalletIlinkTransaction::select('nom_destinataire', 'prenom_destinataire', 'type_document_destinataire', 'id_document_destinataire', 'type',
|
||||
'id_wallet_user', 'init_country', 'final_country', 'network_destinataire' ,'id_transaction')->where('id_transaction', $request->id_transaction)->first();
|
||||
|
||||
$transaction = WalletIlinkTransaction::select('nom_destinataire', 'prenom_destinataire', 'type_document_destinataire', 'id_document_destinataire', 'type','encrypted_code_retrait','code_retrait_salt',
|
||||
'id_wallet_user', 'init_country', 'final_country', 'network_destinataire' ,'id_transaction', 'montant_net_final_country')->where('id_transaction', $request->id_transaction)->first();
|
||||
|
||||
if (!$transaction)
|
||||
return $this->errorResponse(trans('errors.transaction_not_exist'), Response::HTTP_NOT_FOUND);
|
||||
|
||||
if(!$this->checkPassword($request->code_retrait, $transaction->encrypted_code_retrait, $transaction->code_retrait_salt))
|
||||
return $this->errorResponse(trans('errors.invalid_withdrawal_code'));
|
||||
|
||||
|
||||
//Verifier que le reseau payeur est de type iLink
|
||||
if (in_array($transaction->type, [3, 17])) {
|
||||
$configPayeur = ConfigWallet::where('id_network', $transaction->network_destinataire)->firstOrFail();
|
||||
|
@ -1113,7 +1119,9 @@ class iLinkTransactionController extends Controller
|
|||
$data->id_document_destinataire = $identification->id_identity_document;
|
||||
// $data->user_code = $transaction->wallet_user->user->user_code;
|
||||
}
|
||||
unset($data->type, $data->init_country, $data->final_country, $data->id_wallet_user, $data->network_destinataire);
|
||||
$data->montant = $transaction->type == 11 ? $transaction->montant_net : $transaction->montant_net_final_country;
|
||||
unset($data->type, $data->init_country, $data->final_country, $data->id_wallet_user, $data->network_destinataire,$data->code_retrait_salt,
|
||||
$data->encrypted_code_retrait,$data->montant_net_final_country, $data->montant_net);
|
||||
|
||||
return $this->successResponse($data);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class TransfertCommissionTransaction
|
||||
*
|
||||
* @property int $id
|
||||
* @property float $balance_princ_init
|
||||
* @property float $balance_com_init
|
||||
* @property float $balance_princ_final
|
||||
* @property float $balance_com_final
|
||||
* @property Carbon $date
|
||||
* @property int $id_wallet_ag
|
||||
*
|
||||
* @property Wallet $wallet
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class TransfertCommissionTransaction extends Model
|
||||
{
|
||||
protected $table = 'transfert_commission_transaction';
|
||||
public $incrementing = false;
|
||||
public $timestamps = false;
|
||||
|
||||
protected $casts = [
|
||||
'id' => 'int',
|
||||
'balance_princ_init' => 'float',
|
||||
'balance_com_init' => 'float',
|
||||
'balance_princ_final' => 'float',
|
||||
'balance_com_final' => 'float',
|
||||
'id_wallet_ag' => 'int'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'date'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'balance_princ_init',
|
||||
'balance_com_init',
|
||||
'balance_princ_final',
|
||||
'balance_com_final',
|
||||
'date',
|
||||
'id_wallet_ag'
|
||||
];
|
||||
|
||||
public function wallet()
|
||||
{
|
||||
return $this->belongsTo(Wallet::class, 'id_wallet_ag');
|
||||
}
|
||||
}
|
|
@ -40,7 +40,7 @@ $router->group(['prefix' => '/transactions'] , function () use ($router){
|
|||
|
||||
// Credits routes
|
||||
$router->group(['prefix' => '/credits'] , function () use ($router){
|
||||
$router->put('treatDemand/{id_demand}','CreditController@treatDemand');
|
||||
$router->put('treatDemand/{id_demand}','CreditfController@treatDemand');
|
||||
$router->put('cancelDemand/{id_demand}','CreditController@cancelDemand');
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue