改进 判断

This commit is contained in:
iVampireSP.com 2023-02-10 13:10:45 +08:00
parent 438c3ac504
commit 17b5862a7c
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -37,8 +37,7 @@ public function transfer(Request $request): RedirectResponse
$amount = $request->input('amount');
// 使用 bc 判断金额是否足够
if (bccomp($amount, $user->balance, 2) > 0) {
if ($user->hasBalance($amount) === false) {
return back()->withErrors(['amount' => '余额不足。']);
}