+ begin cancel ilink transaction
This commit is contained in:
parent
e1e74dc197
commit
d271d1b5f1
|
@ -184,8 +184,22 @@ class TransactionController extends Controller
|
|||
|
||||
public function lastTransactions($id_wallet)
|
||||
{
|
||||
$transactions = WalletTransaction::where('id_wallet', $id_wallet)->orderBy('date', 'desc')->limit(10)
|
||||
->get(['type', DB::raw('\'wallet\' as source'), 'montant', 'numCarte AS destinataire', 'date', 'id']);
|
||||
// $transactions = WalletTransaction::where('id_wallet',$id_wallet)->orderBy('date','desc')->limit(10)
|
||||
// ->get(['type' ,DB::raw('\'wallet\' as source'), 'montant' ,'numCarte AS destinataire' , 'date', 'id']);
|
||||
$transactions = WalletTransaction::where('id_wallet', $id_wallet)->where('canceled' ,'0')->orderBy('date', 'desc')->limit(10)
|
||||
->get(['type as operation', 'montant', 'numCarte AS destinataire', 'date', 'id' , 'commission_banque', 'commission_ag',
|
||||
'commission_sup', 'commission_hyp']);
|
||||
foreach ($transactions as $trans){
|
||||
$trans->frais = $trans->commission_banque + $trans->commission_sup + $trans->commission_ag + $trans->commission_hyp;
|
||||
$trans->montant_net_init = $trans->montant - $trans->frais;
|
||||
$trans->montant_net_final = null;
|
||||
$trans->init_country = null;
|
||||
$trans->final_country = null;
|
||||
$trans->reseau_payeur = null;
|
||||
$trans->id_transaction = null;
|
||||
$trans->emetteur = null;
|
||||
unset($trans->commission_banque, $trans->commission_sup,$trans->commission_ag,$trans->commission_hyp);
|
||||
}
|
||||
return $this->successResponse($transactions);
|
||||
}
|
||||
|
||||
|
|
|
@ -906,7 +906,7 @@ class iLinkTransactionController extends Controller
|
|||
|
||||
$transactions = DB::select('SELECT id_wallet_user , operation , id_transaction ,network_destinataire, init_country , final_country, date , id , montant , frais , taxe , pays_init , pays_final,
|
||||
destinataire_phone , destinataire_name , nom_destinataire, prenom_destinataire, montant_net ,montant_net_final_country FROM infos_ilink_transaction WHERE id_wallet_user = :id_wallet AND type <> 12 AND type <> 14
|
||||
ORDER BY date DESC LIMIT 10;', ['id_wallet' => $wallet_user->id]);
|
||||
ORDER BY date DESC LIMIT 10;', ['id_wallet' => $wallet_user->id])->paginate(15);
|
||||
|
||||
foreach ($transactions as $data){
|
||||
$date = $data->date;
|
||||
|
@ -1259,4 +1259,63 @@ class iLinkTransactionController extends Controller
|
|||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
// public function index(Request $request){
|
||||
//
|
||||
// $notices = DB::select('select notices.id,notices.title,notices.body,notices.created_at,notices.updated_at,
|
||||
//users.name,departments.department_name
|
||||
//FROM notices
|
||||
//INNER JOIN users ON notices.user_id = users.id
|
||||
//INNER JOIN departments on users.dpt_id = departments.id
|
||||
//ORDER BY users.id DESC');
|
||||
//
|
||||
// $notices = $this->arrayPaginator($notices, $request);
|
||||
//
|
||||
// return view('welcome')->with('allNotices', $notices);
|
||||
//
|
||||
// }
|
||||
|
||||
public function cancel($id_transaction)
|
||||
{
|
||||
$transaction = WalletIlinkTransaction::where('id_transaction',$id_transaction)->firstOrFail();
|
||||
$transactionInverse = $transaction->replicate();
|
||||
$transactionInverse->date = new \DateTime();
|
||||
$transactionInverse->montant = -$transaction->montant;
|
||||
$transactionInverse->montant_net = -$transaction->montant_net;
|
||||
$transactionInverse->montant_net_final_country = -$transaction->montant_net_final_country;
|
||||
$transactionInverse->taxe = -$transaction->taxe;
|
||||
$transactionInverse->frais = -$transaction->frais;
|
||||
$transactionInverse->commission_ag = -$transaction->commission_ag;
|
||||
$transactionInverse->commission_sup = -$transaction->commission_sup;
|
||||
$transactionInverse->commission_hyp = -$transaction->commission_hyp;
|
||||
$transactionInverse->commission_hyp_final_country = -$transaction->commission_hyp_final_country;
|
||||
$transactionInverse->commission_banque = -$transaction->commission_banque;
|
||||
$transactionInverse->id = null;
|
||||
$transactionInverse->id_transaction = $this->getTransactionID();
|
||||
|
||||
// $walletAgent = $transaction->wallet;
|
||||
// $walletSuperviseur = $transaction->wallet_sup;
|
||||
// $walletHyperviseur = $transaction->wallet_hyp;
|
||||
//
|
||||
// if ($transaction->type == 'credit'){
|
||||
// //Depot
|
||||
// $walletAgent->balance_princ += $transaction->montant;
|
||||
// }elseif ($transaction->type == 'debit'){
|
||||
// //Retrait
|
||||
// $walletAgent->balance_princ -= $transaction->montant;
|
||||
// }
|
||||
//
|
||||
// $walletAgent->balance_com -= $transaction->commission_ag;
|
||||
// $walletSuperviseur->balance_com -= $transaction->commission_sup;
|
||||
// $walletHyperviseur->balance_com -= $transaction->commission_hyp;
|
||||
$transaction->canceled = 1;
|
||||
|
||||
// $walletAgent->save();
|
||||
// $walletSuperviseur->save();
|
||||
// $walletHyperviseur->save();
|
||||
$transaction->save();
|
||||
$transactionInverse->save();
|
||||
return $this->successResponse(trans('messages.canceled_transaction'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -146,4 +146,14 @@ trait Helper
|
|||
$cc = CountriesCurrency::findOrFail($id_country);
|
||||
return $cc->currency_code;
|
||||
}
|
||||
|
||||
public function arrayPaginator($array, $request)
|
||||
{
|
||||
$page = Input::get('page', 1);
|
||||
$perPage = 10;
|
||||
$offset = ($page * $perPage) - $perPage;
|
||||
|
||||
return new LengthAwarePaginator(array_slice($array, $offset, $perPage, true), count($array), $perPage, $page,
|
||||
['path' => $request->url(), 'query' => $request->query()]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ $router->group(['prefix' => '/transactions'] , function () use ($router){
|
|||
$router->get('user/{id_wallet_user}','iLinkTransactionController@lastUserTransactions');
|
||||
$router->get('agent/{id_wallet_agent}','iLinkTransactionController@lastAgentTransactions');
|
||||
$router->post('check_retraits','iLinkTransactionController@getTransactionRetrait');
|
||||
$router->delete('{id_transaction}','iLinkTransactionController@cancel');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue