修复 金额过小时统计不到的问题

This commit is contained in:
iVampireSP.com 2022-11-19 13:08:39 +08:00
parent 9ff6a189d3
commit b1593b48ec
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -11,6 +11,7 @@
use Illuminate\Database\Eloquent\Relations\BelongsTo as BelongsToAlias; use Illuminate\Database\Eloquent\Relations\BelongsTo as BelongsToAlias;
use Illuminate\Database\Eloquent\Relations\HasMany as HasManyAlias; use Illuminate\Database\Eloquent\Relations\HasMany as HasManyAlias;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
// use Illuminate\Database\Eloquent\SoftDeletes; // 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_month = now()->month;
$current_year = now()->year; $current_year = now()->year;
@ -270,8 +275,21 @@ public function addLog($type = 'drops', $amount = 0)
if ($type == 'drops') { 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); $should_amount = round($amount * $commission, 2);