改进 保留 8 位小数

This commit is contained in:
iVampireSP.com 2022-11-23 12:04:56 +08:00
parent 38240aeceb
commit 51d168d1a9
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -322,16 +322,18 @@ public function cost($amount = null, $auto = true): bool
$month = now()->month;
$month_cache_key = 'user_' . $this->user_id . '_month_' . $month . '_hosts_balances';
$hosts_drops = Cache::get($month_cache_key, []);
$hosts_balances = Cache::get($month_cache_key, []);
// 统计 Host 消耗的 Balance
if (isset($hosts_drops[$this->id])) {
$hosts_drops[$this->id] += $real_price;
if (isset($hosts_balances[$this->id])) {
$hosts_balances[$this->id] += $real_price;
} else {
$hosts_drops[$this->id] = $real_price;
$hosts_balances[$this->id] = $real_price;
}
Cache::put($month_cache_key, $hosts_drops, 604800);
$hosts_balances[$this->id] = round($hosts_balances[$this->id], 8);
Cache::put($month_cache_key, $hosts_balances, 604800);
$description = '模块发起的扣费。';