From b1593b48ec9f3a2af0722a8b93cf6a4619ed90fc Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Sat, 19 Nov 2022 13:08:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E8=BF=87=E5=B0=8F=E6=97=B6=E7=BB=9F=E8=AE=A1=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Host.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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); // 应得的余额