dootask/app/Console/Commands/OnlineLicenseRenew.php
kuaifan 4ca7fc10d1 feat(license): 新增在线授权(App Store 账号自助签发 + 自动续期)
- OnlineLicense 模块:登录/试用/续期/释放/状态机,离线↔在线互斥(last-write-wins)
- LicenseController + 动态路由;容器内 supervisor 独立进程定时续期(不依赖 LARAVELS_TIMER)
- license.vue 双 Tab:在线授权 + 离线绑定二次确认,已绑定在线时离线页提示+按需绑定
- 进入授权页静默刷新;同步 ai-kb 在线授权知识库

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 08:22:26 +00:00

30 lines
904 B
PHP

<?php
namespace App\Console\Commands;
use App\Module\OnlineLicense;
use Illuminate\Console\Command;
/**
* 在线授权续期(容器内独立进程按小时调用,无需 LARAVELS_TIMER、不经过 HTTP 转发)。
*
* 由 php 容器 supervisor 程序 [program:license] 循环调用:
* while true; do php artisan online-license:renew; sleep 3600; done
*/
class OnlineLicenseRenew extends Command
{
protected $signature = 'online-license:renew';
protected $description = '在线授权:本地状态机推进 + 租约将尽时自动续期';
public function handle(): int
{
if (!OnlineLicense::enabled()) {
return 0;
}
OnlineLicense::cron();
$status = OnlineLicense::status();
$this->info('online-license: ' . ($status['status'] ?? 'offline') . ' lease=' . ($status['lease_expired_at'] ?? '-'));
return 0;
}
}