sdsf
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user