改进 计费

This commit is contained in:
iVampireSP.com 2022-09-09 20:18:17 +08:00
parent 253b3f1be0
commit 60f2d5243e
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
2 changed files with 1 additions and 10 deletions

View File

@ -4,13 +4,10 @@
use App\Helpers\Lock;
use App\Models\Host;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Cache;
class HostCost implements ShouldQueue
{

View File

@ -77,23 +77,17 @@ public function scopeThisUser($query, $module = null)
// cost
public function cost($price = null)
{
$price = abs($price);
$this->load('user');
$cache_key = 'user_drops_' . $this->user_id;
$drops = Cache::get($cache_key);
// Log::debug($user);
if ($price !== null) {
$this->managed_price = $price;
$this->price = $price;
}
if ($this->managed_price) {
$this->price = $this->managed_price;
}
$amount = $price / Cache::get('drops_rate', 100) + 1;