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

This commit is contained in:
2026-06-22 00:12:32 +02:00
parent 5c615aa878
commit 650a0bd11a
10 changed files with 413 additions and 34 deletions

View File

@@ -459,6 +459,76 @@ final class MiningRepository
]);
}
public function listWalletWithdrawals(string $projectKey): array
{
$stmt = $this->pdo->prepare(
'SELECT * FROM ' . $this->table('wallet_withdrawals') . ' WHERE project_key = :project_key AND owner_sub = :owner_sub ORDER BY withdrawal_at ASC, id ASC'
);
$stmt->execute(['project_key' => $projectKey, 'owner_sub' => $this->ownerSub]);
return $this->normalizeRows($stmt->fetchAll() ?: []);
}
public function saveWalletWithdrawal(string $projectKey, array $payload): array
{
if ($this->driver === 'pgsql') {
$stmt = $this->pdo->prepare(
'INSERT INTO ' . $this->table('wallet_withdrawals') . ' (
project_key, owner_sub, withdrawal_at, coins_amount, withdrawal_currency, note
) VALUES (
:project_key, :owner_sub, :withdrawal_at, :coins_amount, :withdrawal_currency, :note
)
RETURNING *'
);
$stmt->execute([
'project_key' => $projectKey,
'owner_sub' => $this->ownerSub,
'withdrawal_at' => $payload['withdrawal_at'],
'coins_amount' => $payload['coins_amount'],
'withdrawal_currency' => $payload['withdrawal_currency'],
'note' => $payload['note'],
]);
return $this->normalizeRow($stmt->fetch() ?: []);
}
$stmt = $this->pdo->prepare(
'INSERT INTO ' . $this->table('wallet_withdrawals') . ' (
project_key, owner_sub, withdrawal_at, coins_amount, withdrawal_currency, note
) VALUES (
:project_key, :owner_sub, :withdrawal_at, :coins_amount, :withdrawal_currency, :note
)'
);
$stmt->execute([
'project_key' => $projectKey,
'owner_sub' => $this->ownerSub,
'withdrawal_at' => $payload['withdrawal_at'],
'coins_amount' => $payload['coins_amount'],
'withdrawal_currency' => $payload['withdrawal_currency'],
'note' => $payload['note'],
]);
$id = (int) $this->pdo->lastInsertId();
$fetch = $this->pdo->prepare('SELECT * FROM ' . $this->table('wallet_withdrawals') . ' WHERE id = :id LIMIT 1');
$fetch->execute(['id' => $id]);
return $this->normalizeRow($fetch->fetch() ?: []);
}
public function deleteWalletWithdrawal(string $projectKey, int $withdrawalId): void
{
if ($withdrawalId <= 0) {
return;
}
$stmt = $this->pdo->prepare(
'DELETE FROM ' . $this->table('wallet_withdrawals') . '
WHERE id = :id AND project_key = :project_key AND owner_sub = :owner_sub'
);
$stmt->execute([
'id' => $withdrawalId,
'project_key' => $projectKey,
'owner_sub' => $this->ownerSub,
]);
}
public function listWalletSnapshots(string $projectKey, int $limit = 100): array
{
$stmt = $this->pdo->prepare(

View File

@@ -205,6 +205,10 @@ final class SchemaManager
$this->ensureWalletSnapshotsTable();
$applied[] = 'wallet_snapshots_table';
}
if (!$this->tableExists($this->prefix . 'wallet_withdrawals')) {
$this->ensureWalletWithdrawalsTable();
$applied[] = 'wallet_withdrawals_table';
}
if (!$this->tableExists($this->prefix . 'fx_fetches') || !$this->tableExists($this->prefix . 'fx_rates')) {
$this->ensureFxRatesTable();
$applied[] = 'fx_rates_table';
@@ -324,6 +328,10 @@ final class SchemaManager
$this->ensureWalletSnapshotsTable();
$applied[] = 'wallet_snapshots_table';
}
if (!$this->tableExists($this->prefix . 'wallet_withdrawals')) {
$this->ensureWalletWithdrawalsTable();
$applied[] = 'wallet_withdrawals_table';
}
if (!$this->tableExists($this->prefix . 'miner_offers')) {
$this->upgradeMinerOffersTable();
@@ -679,6 +687,9 @@ final class SchemaManager
if (!$this->tableExists($this->prefix . 'wallet_snapshots')) {
$upgrades[] = 'wallet_snapshots_table';
}
if (!$this->tableExists($this->prefix . 'wallet_withdrawals')) {
$upgrades[] = 'wallet_withdrawals_table';
}
if (!$this->tableExists($this->prefix . 'miner_offers')) {
$upgrades[] = 'miner_offers_table';
}
@@ -978,6 +989,49 @@ final class SchemaManager
$this->executeUpgradeStatements($statements, 'Schema-Upgrade fuer Wallet-Snapshots fehlgeschlagen.');
}
public function ensureWalletWithdrawalsTable(): void
{
if ($this->tableExists($this->prefix . 'wallet_withdrawals')) {
return;
}
$table = $this->prefix . 'wallet_withdrawals';
$projectTable = $this->prefix . 'projects';
$statements = $this->driver === 'pgsql'
? [
'CREATE TABLE IF NOT EXISTS ' . $table . ' (
id BIGSERIAL PRIMARY KEY,
project_key VARCHAR(64) NOT NULL,
owner_sub VARCHAR(128) NOT NULL,
withdrawal_at TIMESTAMP NOT NULL,
coins_amount NUMERIC(20,6) NOT NULL,
withdrawal_currency VARCHAR(10) NOT NULL DEFAULT \'DOGE\',
note TEXT,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT fk_mining_wallet_withdrawals_project FOREIGN KEY (project_key) REFERENCES ' . $projectTable . '(project_key) ON DELETE CASCADE
)',
'CREATE INDEX IF NOT EXISTS idx_miningcheck_wallet_withdrawals_project_owner_at ON ' . $table . ' (project_key, owner_sub, withdrawal_at)',
]
: [
'CREATE TABLE IF NOT EXISTS `' . $table . '` (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
project_key VARCHAR(64) NOT NULL,
owner_sub VARCHAR(128) NOT NULL,
withdrawal_at TIMESTAMP NOT NULL,
coins_amount DECIMAL(20,6) NOT NULL,
withdrawal_currency VARCHAR(10) NOT NULL DEFAULT \'DOGE\',
note TEXT,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT fk_mining_wallet_withdrawals_project FOREIGN KEY (project_key) REFERENCES `' . $projectTable . '`(project_key) ON DELETE CASCADE,
KEY idx_miningcheck_wallet_withdrawals_project_owner_at (project_key, owner_sub, withdrawal_at)
)',
];
$this->executeUpgradeStatements($statements, 'Schema-Upgrade fuer Wallet-Auszahlungen fehlgeschlagen.');
}
public function ensureMinerTables(): void
{
if (!$this->tableExists($this->prefix . 'miner_offers')) {
@@ -1451,6 +1505,7 @@ final class SchemaManager
$this->prefix . 'measurement_rates',
$this->prefix . 'payouts',
$this->prefix . 'wallet_snapshots',
$this->prefix . 'wallet_withdrawals',
$this->prefix . 'miner_offers',
$this->prefix . 'purchased_miners',
];
@@ -1471,6 +1526,7 @@ final class SchemaManager
$this->prefix . 'measurement_rates',
$this->prefix . 'payouts',
$this->prefix . 'wallet_snapshots',
$this->prefix . 'wallet_withdrawals',
$this->prefix . 'miner_offers',
$this->prefix . 'targets',
$this->prefix . 'dashboard_definitions',