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

This commit is contained in:
2026-06-24 00:50:15 +02:00
parent 30d7456fde
commit 9ea248753e
7 changed files with 387 additions and 4 deletions

View File

@@ -1788,6 +1788,40 @@ final class Router
private function savePayout(string $projectKey, array $input): array
{
$transferMode = $this->enumValue($input['transfer_mode'] ?? 'manual', ['manual', 'full_latest'], 'transfer_mode');
if ($transferMode === 'full_latest') {
$measurements = $this->repository()->listRecentMeasurements($projectKey, 1);
$latestMeasurement = $measurements[0] ?? null;
if (!is_array($latestMeasurement)) {
throw new ApiException('Es ist kein aktueller Mining-Upload vorhanden.', 422);
}
$latestTs = strtotime((string) ($latestMeasurement['measured_at'] ?? ''));
if ($latestTs === false || (time() - $latestTs) > 180) {
throw new ApiException('Alles uebertragen ist nur moeglich, wenn der letzte Upload hoechstens 3 Minuten alt ist.', 422);
}
$settings = $this->settings($projectKey, [
'currencies' => false,
'miner_offers' => false,
]);
$summary = $this->analytics()->buildSummary($measurements, $settings, [], ['include_offer_scenarios' => false]);
$visibleCoins = (float) ($summary['payouts']['current_visible_coins'] ?? 0.0);
if ($visibleCoins <= 0) {
throw new ApiException('Es stehen keine Coins fuer einen Kompletttransfer zur Verfuegung.', 422);
}
$coinCurrency = strtoupper(trim((string) ($latestMeasurement['coin_currency'] ?? $settings['crypto_currency'] ?? 'DOGE')));
$payload = [
'payout_at' => (string) ($latestMeasurement['measured_at'] ?? ''),
'coins_amount' => $visibleCoins,
'payout_currency' => $coinCurrency !== '' ? $coinCurrency : 'DOGE',
'note' => $this->optionalString($input['note'] ?? 'Kompletttransfer aus letztem Upload', 1000),
];
return $this->repository()->savePayout($projectKey, $payload);
}
$payload = [
'payout_at' => $this->requiredDateTime($input['payout_at'] ?? null, 'payout_at', $this->projectTimezone($projectKey)),
'coins_amount' => $this->requiredDecimal($input['coins_amount'] ?? null, 'coins_amount'),