改进 小数位数

This commit is contained in:
iVampireSP.com 2023-01-18 00:09:15 +08:00
parent 3a0b6d27bc
commit 81a229793b
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -47,7 +47,7 @@ class User extends Authenticatable
protected $casts = [
'email_verified_at' => 'datetime',
'real_name_verified_at' => 'datetime',
'balance' => 'decimal:2',
'balance' => 'decimal:4',
'banned_at' => 'datetime',
'birthday_at' => 'date:Y-m-d'
];
@ -191,7 +191,7 @@ public function reduce(string|null $amount = "0", string $description = "消费"
}
}
$this->balance = bcsub($this->balance, $amount, 2);
$this->balance = bcsub($this->balance, $amount, 4);
$this->save();
$data = [
@ -230,7 +230,7 @@ public function charge(string|null $amount = "0", string $payment = 'console', s
Cache::lock('user_balance_' . $this->id, 10)->block(10, function () use ($amount, $description, $payment, $options) {
$this->refresh();
$this->balance = bcadd($this->balance, $amount, 2);
$this->balance = bcadd($this->balance, $amount, 4);
$this->save();
$data = [