+ Change structure of ID transaction

This commit is contained in:
Djery-Tom 2020-07-06 17:09:25 +01:00
parent 5cea0ca950
commit 6c0c4dbbce
2 changed files with 25 additions and 6 deletions

View File

@ -192,7 +192,7 @@ class iLinkTransactionController extends Controller
'net_final' => $this->toMoneyWithCurrency($montantDepot, $init_country, $request->final_country), 'fees' => $this->toMoney($frais + $taxe, $init_country), 'net_final' => $this->toMoneyWithCurrency($montantDepot, $init_country, $request->final_country), 'fees' => $this->toMoney($frais + $taxe, $init_country),
'init_country' => $this->getCountryName($init_country), 'final_country' => $this->getCountryName($request->final_country), 'init_country' => $this->getCountryName($init_country), 'final_country' => $this->getCountryName($request->final_country),
'sender_code' => $user->user_code, 'receiver_code' => $transaction->id_destinataire]); 'sender_code' => $user->user_code, 'receiver_code' => $transaction->id_destinataire]);
$this->sendMail($user->email, trans('messages.successful_transaction'), $message); // $this->sendMail($user->email, trans('messages.successful_transaction'), $message);
return $this->successResponse($message . trans('messages.sent_by_mail')); return $this->successResponse($message . trans('messages.sent_by_mail'));
} }
} else { } else {
@ -1183,4 +1183,23 @@ class iLinkTransactionController extends Controller
shuffle($temp_array); shuffle($temp_array);
return implode('', $temp_array); return implode('', $temp_array);
} }
private function getTransactionID(){
do{
$code=$this->generateTransactionCode();
$result = collect(DB::select('SELECT * FROM wallet_ilink_transaction WHERE id_transaction = :code',['code'=>$code]));
$codeCorrect=sizeof($result)<0;
}while($codeCorrect);
return $code;
}
private function generateTransactionCode($length = 12) {
$characters = '23456789abcdefghjkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
} }

View File

@ -131,11 +131,11 @@ trait Helper
} }
public function getTransactionID(){ // public function getTransactionID(){
$d = new DateTime(); // $d = new DateTime();
$first = str_replace(['-',':'], '',$d->format("y-m-d H:i:s.u")); // $first = str_replace(['-',':'], '',$d->format("y-m-d H:i:s.u"));
return str_replace(' ' ,'.',$first); // return str_replace(' ' ,'.',$first);
} // }
public function getCurrency($id_country){ public function getCurrency($id_country){
$cc = CountriesCurrency::findOrFail($id_country); $cc = CountriesCurrency::findOrFail($id_country);