fix(api): 修复节点流量限额共享统计与父子显隐联动

统一节点流量统计与限额展示口径,节点详情新增昨日流量,
并让今日、昨日和本月使用清晰的半开时间窗口聚合

同 machine_id 或同 host 的节点现在共享当前账期已用流量,
管理端优先使用后端 traffic_limit_snapshot 展示月额度状态,
mi-node 下发的 current_used 也改为共享账期统计

新增 parent_auto_hidden 标记与父节点显隐联动服务,父节点
因自动上线或流量限额变为不可展示时会隐藏当前显示的子节点,
恢复时只恢复这批自动隐藏的子节点,避免覆盖手动操作
This commit is contained in:
yinjianm
2026-04-29 02:24:57 +08:00
parent 922e86070d
commit e847252e12
27 changed files with 2078 additions and 47 deletions
+19
View File
@@ -53,6 +53,7 @@ class ServerAutoOnlineService
$wasShown = (bool) $server->show;
if ($wasShown === $shouldShow && !$shouldClearGfwAutoHidden) {
$this->syncChildrenForFinalState($server, $shouldShow, $result);
$result['unchanged']++;
return;
}
@@ -71,6 +72,24 @@ class ServerAutoOnlineService
if ($wasShown !== $shouldShow) {
$shouldShow ? $result['shown']++ : $result['hidden']++;
}
$this->syncChildrenForFinalState($server, $shouldShow, $result);
}
private function syncChildrenForFinalState(Server $server, bool $shouldShow, array &$result): void
{
$childResult = app(ServerParentVisibilityService::class)
->syncChildrenForParent($server, $shouldShow);
$hidden = (int) ($childResult['hidden'] ?? 0);
$restored = (int) ($childResult['restored'] ?? 0);
$childUpdates = $hidden + $restored;
if ($childUpdates <= 0) {
return;
}
$result['updated'] += $childUpdates;
$result['hidden'] += $hidden;
$result['shown'] += $restored;
}
private function emptyResult(int $total = 0): array