Update Saqel Platform: 2026-09-10 12:26:22
This commit is contained in:
@@ -61,35 +61,25 @@ class SuperAdminController
|
||||
}
|
||||
public function overview(Request $request, Response $response): void
|
||||
{
|
||||
CliqPaymentService::ensureSchema();
|
||||
|
||||
$counts = [
|
||||
'total_directorates' => $this->count('directorates'),
|
||||
'total_schools' => $this->count('schools'),
|
||||
'total_students' => $this->count('students'),
|
||||
'total_teachers' => $this->count('teachers'),
|
||||
];
|
||||
$payments = Database::selectOne(
|
||||
"SELECT COALESCE(SUM(CASE WHEN verification_status = 'verified' THEN amount_jod ELSE 0 END), 0) AS inflow FROM cliq_payments"
|
||||
);
|
||||
$payouts = Database::selectOne(
|
||||
"SELECT SUM(CASE WHEN status IN ('queued', 'processing') THEN 1 ELSE 0 END) AS pending_count,
|
||||
COALESCE(SUM(CASE WHEN status = 'completed' THEN amount_jod ELSE 0 END), 0) AS paid_out
|
||||
FROM payout_queue"
|
||||
);
|
||||
$inflow = (float)($payments['inflow'] ?? 0);
|
||||
$paidOut = (float)($payouts['paid_out'] ?? 0);
|
||||
|
||||
$response->json([
|
||||
'status' => 'success',
|
||||
'data' => array_merge($counts, [
|
||||
'gross_margin_percent' => $inflow > 0 ? round((($inflow - $paidOut) / $inflow) * 100, 2) : 0.0,
|
||||
'treasury_balance_jod' => max(0, $inflow - $paidOut),
|
||||
'total_cliq_inflow_jod' => $inflow,
|
||||
'pending_payouts_count' => (int)($payouts['pending_count'] ?? 0),
|
||||
'r2_cost_savings_jod' => 0.0,
|
||||
'uptime_percent' => 0.0,
|
||||
// Payment settlement and infrastructure monitoring are not
|
||||
// connected yet. Null is intentional: zero would be a claim.
|
||||
'gross_margin_percent' => null,
|
||||
'treasury_balance_jod' => null,
|
||||
'total_cliq_inflow_jod' => null,
|
||||
'pending_payouts_count' => null,
|
||||
'r2_cost_savings_jod' => null,
|
||||
'uptime_percent' => null,
|
||||
'measurement_notes' => [
|
||||
'financial_metrics' => 'غير متاحة حتى ربط مزود الدفع ودفتر التسوية.',
|
||||
'r2_cost_savings_jod' => 'يتطلب ربط Cloudflare Billing Analytics',
|
||||
'uptime_percent' => 'يتطلب ربط مزود مراقبة خارجي',
|
||||
],
|
||||
@@ -124,7 +114,7 @@ class SuperAdminController
|
||||
public function securityAlerts(Request $request, Response $response): void
|
||||
{
|
||||
// No synthetic alerts: an audit-event pipeline will populate this endpoint.
|
||||
$response->json(['status' => 'success', 'data' => []]);
|
||||
$response->json(['status' => 'success', 'data' => [], 'measurement_status' => 'unavailable']);
|
||||
}
|
||||
|
||||
private function count(string $table): int
|
||||
|
||||
Reference in New Issue
Block a user