改进 只计费动态计费实例

This commit is contained in:
iVampireSP.com 2023-02-13 02:37:02 +08:00
parent 81ba72d85f
commit ee4720fe2c
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -36,14 +36,14 @@ public function __construct($minute, Host $host = null)
*/ */
public function handle(): void public function handle(): void
{ {
if (! $this->host) { if (!$this->host) {
$host = new Host(); $host = new Host();
if (app()->environment() != 'local') { if (app()->environment() != 'local') {
$host = $host->where('minute_at', $this->minute); $host = $host->where('minute_at', $this->minute);
} }
$host->whereIn('status', ['running', 'stopped'])->with('user')->chunk(500, function ($hosts) { $host->whereIn('status', ['running', 'stopped'])->whereNull('billing_cycle')->with('user')->chunk(500, function ($hosts) {
foreach ($hosts as $host) { foreach ($hosts as $host) {
dispatch(new self($this->minute, $host)); dispatch(new self($this->minute, $host));
} }