diff --git a/app/Models/Host.php b/app/Models/Host.php index c720397..462e524 100644 --- a/app/Models/Host.php +++ b/app/Models/Host.php @@ -11,6 +11,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo as BelongsToAlias; use Illuminate\Database\Eloquent\Relations\HasMany as HasManyAlias; use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Log; // use Illuminate\Database\Eloquent\SoftDeletes; @@ -254,8 +255,12 @@ public function costBalance($amount = 1): bool } - public function addLog($type = 'drops', $amount = 0) + public function addLog($type = 'drops', float $amount = 0) { + if ($amount == 0) { + return false; + } + /** 统计收益开始 */ $current_month = now()->month; $current_year = now()->year; @@ -270,9 +275,22 @@ public function addLog($type = 'drops', $amount = 0) if ($type == 'drops') { // 换成 余额 - $amount = round($amount / $rate, 2); + // 如果小于 0.00,则不四舍五入 + $c = $amount / $rate; + + if ($c > 0.01) { + $amount = $amount / $rate; + } } + $amount = round($amount, 2); + Log::debug('addLog', [ + 'amount' => $amount, + 'rate' => $rate, + 'commission' => $commission, + ]); + + $should_amount = round($amount * $commission, 2); // 应得的余额