+ Fix bug

This commit is contained in:
Djery-Tom 2020-06-30 14:09:00 +01:00
parent 29e6282bc1
commit f208af131a
1 changed files with 104 additions and 110 deletions

View File

@ -370,9 +370,7 @@ class iLinkTransactionController extends Controller
$this->validate($request, $transaction->user_card_rules()); $this->validate($request, $transaction->user_card_rules());
$user = $walletUser->user; $user = $walletUser->user;
if ($this->checkPassword($request->password, $user->encrypted_password, $user->salt)) { if ($this->checkPassword($request->password, $user->encrypted_password, $user->salt)) {
if ($request->montant > $walletUser->balance) {
return $this->errorResponse(trans('errors.insufficient_balance'));
} else {
if (!(isset($user->numero_carte) && isset($user->expiration_date))) if (!(isset($user->numero_carte) && isset($user->expiration_date)))
return $this->errorResponse(trans('errors.no_bank_card_attached')); return $this->errorResponse(trans('errors.no_bank_card_attached'));
@ -414,7 +412,7 @@ class iLinkTransactionController extends Controller
} else { } else {
return $this->errorResponse(trans('errors.visa_api_failed'), Response::HTTP_INTERNAL_SERVER_ERROR); return $this->errorResponse(trans('errors.visa_api_failed'), Response::HTTP_INTERNAL_SERVER_ERROR);
} }
}
} else { } else {
return $this->errorResponse(trans('messages.incorrect_user_password')); return $this->errorResponse(trans('messages.incorrect_user_password'));
} }
@ -423,9 +421,7 @@ class iLinkTransactionController extends Controller
$this->validate($request, $transaction->user_card_rules()); $this->validate($request, $transaction->user_card_rules());
$user = $walletUser->user; $user = $walletUser->user;
if ($this->checkPassword($request->password, $user->encrypted_password, $user->salt)) { if ($this->checkPassword($request->password, $user->encrypted_password, $user->salt)) {
if ($request->montant > $walletUser->balance) {
return $this->errorResponse(trans('errors.insufficient_balance'));
} else {
if (!(isset($user->numero_carte) && isset($user->expiration_date))) if (!(isset($user->numero_carte) && isset($user->expiration_date)))
return $this->errorResponse(trans('errors.no_bank_card_attached')); return $this->errorResponse(trans('errors.no_bank_card_attached'));
@ -451,7 +447,6 @@ class iLinkTransactionController extends Controller
$transaction->encrypted_code_retrait = $hash['encrypted']; $transaction->encrypted_code_retrait = $hash['encrypted'];
$transaction->code_retrait_salt = $hash['salt']; $transaction->code_retrait_salt = $hash['salt'];
$walletUser->balance -= $transaction->montant;
$transaction->commission_hyp = $frais * $config->taux_com_hyp_retrait_carte_cash_ilink / 100; $transaction->commission_hyp = $frais * $config->taux_com_hyp_retrait_carte_cash_ilink / 100;
$walletHyperviseur->balance_com += $transaction->commission_hyp; $walletHyperviseur->balance_com += $transaction->commission_hyp;
$transaction->id_wallet_hyp = $walletHyperviseur->id; $transaction->id_wallet_hyp = $walletHyperviseur->id;
@ -459,7 +454,6 @@ class iLinkTransactionController extends Controller
$transaction->date = new \DateTime(); $transaction->date = new \DateTime();
$transaction->status_retrait = 0; $transaction->status_retrait = 0;
$walletHyperviseur->save(); $walletHyperviseur->save();
$walletUser->save();
$transaction->id_transaction = $this->getTransactionID(); $transaction->id_transaction = $this->getTransactionID();
$transaction->save(); $transaction->save();
$message = trans('messages.successful_user_remove_from_cart_to_cash', $message = trans('messages.successful_user_remove_from_cart_to_cash',
@ -472,7 +466,7 @@ class iLinkTransactionController extends Controller
} else { } else {
return $this->errorResponse(trans('errors.visa_api_failed'), Response::HTTP_INTERNAL_SERVER_ERROR); return $this->errorResponse(trans('errors.visa_api_failed'), Response::HTTP_INTERNAL_SERVER_ERROR);
} }
}
} else { } else {
return $this->errorResponse(trans('messages.incorrect_user_password')); return $this->errorResponse(trans('messages.incorrect_user_password'));
} }