asdasd
All checks were successful
Deploy / deploy-staging (push) Successful in 23s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-06-21 02:21:10 +02:00
parent cf3dacfd6b
commit 5c615aa878
3 changed files with 101 additions and 42 deletions

View File

@@ -257,6 +257,11 @@ final class Router
Http::json(['data' => $this->savePayout($projectKey, Http::input())], 201);
}
if (preg_match('~^payouts/(\d+)$~', $resource, $matches) && $method === 'DELETE') {
$this->deletePayout($projectKey, (int) $matches[1]);
Http::json(['data' => ['deleted' => true]]);
}
if ($resource === 'wallet-snapshots' && $method === 'GET') {
Http::json(['data' => $this->walletSnapshots($projectKey)]);
}
@@ -1766,6 +1771,11 @@ final class Router
return $this->repository()->savePayout($projectKey, $payload);
}
private function deletePayout(string $projectKey, int $payoutId): void
{
$this->repository()->deletePayout($projectKey, $payoutId);
}
private function walletSnapshots(string $projectKey): array
{
return $this->repository()->listWalletSnapshots($projectKey, 100);

View File

@@ -442,6 +442,23 @@ final class MiningRepository
return $this->normalizeRow($fetch->fetch() ?: []);
}
public function deletePayout(string $projectKey, int $payoutId): void
{
if ($payoutId <= 0) {
return;
}
$stmt = $this->pdo->prepare(
'DELETE FROM ' . $this->table('payouts') . '
WHERE id = :id AND project_key = :project_key AND owner_sub = :owner_sub'
);
$stmt->execute([
'id' => $payoutId,
'project_key' => $projectKey,
'owner_sub' => $this->ownerSub,
]);
}
public function listWalletSnapshots(string $projectKey, int $limit = 100): array
{
$stmt = $this->pdo->prepare(