From d20d11f33fb3aa489c0093f4dee9f74546eb4990 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Mon, 13 Feb 2023 17:07:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E5=8C=BA=E5=88=86?= =?UTF-8?q?=E6=96=B0=E8=B4=AD=E5=92=8C=E7=BB=AD=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Host.php | 4 ++-- app/Observers/HostObserver.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Models/Host.php b/app/Models/Host.php index 5596a7c..0ae3f31 100644 --- a/app/Models/Host.php +++ b/app/Models/Host.php @@ -116,7 +116,7 @@ public function isUnavailable(): bool return $this->status === 'unavailable'; } - public function renew(): bool + public function renew($first): bool { if (! $this->isCycle()) { return false; @@ -124,7 +124,7 @@ public function renew(): bool $price = $this->getRenewPrice(); - $description = '续费 '.$this->name.',价格:'.$price.' 元。'; + $description = ($first ? '新购' : '续费').' '.$this->name.',价格:'.$price.' 元。'; try { $this->user->reduce($price, $description, true, [ diff --git a/app/Observers/HostObserver.php b/app/Observers/HostObserver.php index 695d76a..09516b4 100644 --- a/app/Observers/HostObserver.php +++ b/app/Observers/HostObserver.php @@ -39,7 +39,7 @@ public function created(Host $host): void $host->user->notify(new WebNotification($host, 'hosts.created')); if ($host->isCycle()) { - $host->renew(); + $host->renew(true); } $host->save();