mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-03 02:58:42 +00:00
- Use chunkById() with default chunk size for batch processing; - Improve plan/package expiration and prepaid activation logic; - Refactor user–node permission update logic - Optimize OrderService state handling - Minor fixes (null handling, query order, comments)
32 lines
820 B
PHP
32 lines
820 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Order;
|
|
use Illuminate\Console\Command;
|
|
use Log;
|
|
|
|
class ServiceTimer extends Command
|
|
{
|
|
protected $signature = 'serviceTimer';
|
|
|
|
protected $description = '服务计时器';
|
|
|
|
public function handle(): void
|
|
{
|
|
$jobTime = microtime(true);
|
|
|
|
$this->expiredPlan(); // 过期套餐
|
|
|
|
$jobTime = round(microtime(true) - $jobTime, 4);
|
|
Log::info(__('----「:job」Completed, Used :time seconds ----', ['job' => $this->description, 'time' => $jobTime]));
|
|
}
|
|
|
|
private function expiredPlan(): void
|
|
{
|
|
Order::activePlan()->where('expired_at', '<=', now())->chunkById((int) sysConfig('tasks_chunk', 3000), function ($orders) {
|
|
$orders->each->expired(); // 过期订单,触发 Observer
|
|
});
|
|
}
|
|
}
|