增加 状态判断函数

This commit is contained in:
iVampireSP.com 2023-02-13 15:26:33 +08:00
parent 803cb019b2
commit ac6112ac20
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
2 changed files with 47 additions and 19 deletions

View File

@ -110,6 +110,16 @@ public function isStopped(): bool
return $this->status === 'stopped'; return $this->status === 'stopped';
} }
public function isPending(): bool
{
return $this->status === 'pending';
}
public function isUnavailable(): bool
{
return $this->status === 'unavailable';
}
public function renew(): bool public function renew(): bool
{ {
if (! $this->isCycle()) { if (! $this->isCycle()) {

View File

@ -111,6 +111,7 @@ private function getResponse(Response $response): array
* @param $path * @param $path
* @param $requests * @param $requests
* @param array $files * @param array $files
*
* @return array * @return array
*/ */
public function request($method, $path, $requests, array $files = []): array public function request($method, $path, $requests, array $files = []): array
@ -206,6 +207,7 @@ public function calculate(): array
* @param string|null $description * @param string|null $description
* @param bool $fail * @param bool $fail
* @param array $options * @param array $options
*
* @return string * @return string
*/ */
public function reduce(string|null $amount = '0', string|null $description = '消费', bool $fail = false, array $options = []): string public function reduce(string|null $amount = '0', string|null $description = '消费', bool $fail = false, array $options = []): string
@ -253,6 +255,7 @@ public function reduce(string|null $amount = '0', string|null $description = '
* @param string $payment * @param string $payment
* @param string|null $description * @param string|null $description
* @param array $options * @param array $options
*
* @return string * @return string
*/ */
public function charge(string|null $amount = '0', string $payment = 'console', string|null $description = '充值', array $options = []): string public function charge(string|null $amount = '0', string $payment = 'console', string|null $description = '充值', array $options = []): string
@ -297,4 +300,19 @@ public function whereHasBalance(string $amount = '0'): self|Builder|CachedBuilde
{ {
return $this->where('balance', '>=', $amount); return $this->where('balance', '>=', $amount);
} }
public function isUp(): bool
{
return $this->status === 'up';
}
public function isDown(): bool
{
return $this->status === 'down';
}
public function isMaintenance(): bool
{
return $this->status === 'maintenance';
}
} }