host = $host; $this->onQueue('host-cost'); } /** * Execute the job. */ public function handle(): void { $now = now(); if (! $this->host) { $host = new Host(); // 查找试用到期的主机 $host->where('day_at', $now->day) ->where('hour_at', $now->hour) ->where('trial_ends_at', '<', $now) ->whereNot('billing_cycle', 'hourly') ->chunk(500, function ($hosts) { $hosts->each(function ($host) { /* @var Host $host */ if ($host->module->isUp()) { dispatch(new self($host)); } }); }); // 查找到期的主机 $host->where('expired_at', '<', $now) ->whereNot('billing_cycle', 'hourly') ->chunk(500, function ($hosts) { $hosts->each(function ($host) { /* @var Host $host */ if ($host->module->isUp()) { dispatch(new self($host)); } }); }); } else { if ($this->host->isHourly()) { return; } if ($this->host->isNextMonthCancel()) { $this->host->safeDelete(); } else { $this->host->cost(); } } } }