sdsad
This commit is contained in:
@@ -267,6 +267,70 @@ final class MiningRepository
|
||||
return $this->normalizeRow($fetch->fetch() ?: []);
|
||||
}
|
||||
|
||||
public function getCostPlan(string $projectKey, int $planId): ?array
|
||||
{
|
||||
$stmt = $this->pdo->prepare(
|
||||
'SELECT * FROM ' . $this->table('cost_plans') . ' WHERE project_key = :project_key AND owner_sub = :owner_sub AND id = :id LIMIT 1'
|
||||
);
|
||||
$stmt->execute([
|
||||
'project_key' => $projectKey,
|
||||
'owner_sub' => $this->ownerSub,
|
||||
'id' => $planId,
|
||||
]);
|
||||
$row = $stmt->fetch();
|
||||
if (is_array($row)) {
|
||||
return $this->normalizeRow($row);
|
||||
}
|
||||
|
||||
$legacyStmt = $this->pdo->prepare(
|
||||
'SELECT * FROM ' . $this->table('cost_plans') . ' WHERE project_key = :project_key AND id = :id LIMIT 1'
|
||||
);
|
||||
$legacyStmt->execute([
|
||||
'project_key' => $projectKey,
|
||||
'id' => $planId,
|
||||
]);
|
||||
$legacyRow = $legacyStmt->fetch();
|
||||
return is_array($legacyRow) ? $this->normalizeRow($legacyRow) : null;
|
||||
}
|
||||
|
||||
public function updateCostPlanAutoRenew(string $projectKey, int $planId, bool $autoRenew): array
|
||||
{
|
||||
$stmt = $this->pdo->prepare(
|
||||
'UPDATE ' . $this->table('cost_plans') . '
|
||||
SET auto_renew = :auto_renew
|
||||
WHERE project_key = :project_key AND owner_sub = :owner_sub AND id = :id'
|
||||
);
|
||||
$stmt->execute([
|
||||
'auto_renew' => $autoRenew ? 1 : 0,
|
||||
'project_key' => $projectKey,
|
||||
'owner_sub' => $this->ownerSub,
|
||||
'id' => $planId,
|
||||
]);
|
||||
|
||||
if ($stmt->rowCount() === 0) {
|
||||
$legacyUpdate = $this->pdo->prepare(
|
||||
'UPDATE ' . $this->table('cost_plans') . '
|
||||
SET auto_renew = :auto_renew
|
||||
WHERE project_key = :project_key AND id = :id'
|
||||
);
|
||||
$legacyUpdate->execute([
|
||||
'auto_renew' => $autoRenew ? 1 : 0,
|
||||
'project_key' => $projectKey,
|
||||
'id' => $planId,
|
||||
]);
|
||||
}
|
||||
|
||||
$fetch = $this->pdo->prepare(
|
||||
'SELECT * FROM ' . $this->table('cost_plans') . ' WHERE project_key = :project_key AND owner_sub = :owner_sub AND id = :id LIMIT 1'
|
||||
);
|
||||
$fetch->execute([
|
||||
'project_key' => $projectKey,
|
||||
'owner_sub' => $this->ownerSub,
|
||||
'id' => $planId,
|
||||
]);
|
||||
return $this->normalizeRow($fetch->fetch() ?: []);
|
||||
}
|
||||
|
||||
public function listMeasurements(string $projectKey, int $limit = 200): array
|
||||
{
|
||||
$stmt = $this->pdo->prepare(
|
||||
@@ -915,7 +979,19 @@ final class MiningRepository
|
||||
'id' => $minerId,
|
||||
]);
|
||||
$row = $stmt->fetch();
|
||||
return is_array($row) ? $this->normalizeRow($row) : null;
|
||||
if (is_array($row)) {
|
||||
return $this->normalizeRow($row);
|
||||
}
|
||||
|
||||
$legacyStmt = $this->pdo->prepare(
|
||||
'SELECT * FROM ' . $this->table('purchased_miners') . ' WHERE project_key = :project_key AND id = :id LIMIT 1'
|
||||
);
|
||||
$legacyStmt->execute([
|
||||
'project_key' => $projectKey,
|
||||
'id' => $minerId,
|
||||
]);
|
||||
$legacyRow = $legacyStmt->fetch();
|
||||
return is_array($legacyRow) ? $this->normalizeRow($legacyRow) : null;
|
||||
}
|
||||
|
||||
public function purchaseMiner(string $projectKey, ?int $offerId, array $payload): array
|
||||
@@ -1027,6 +1103,19 @@ final class MiningRepository
|
||||
'id' => $minerId,
|
||||
]);
|
||||
|
||||
if ($stmt->rowCount() === 0) {
|
||||
$legacyUpdate = $this->pdo->prepare(
|
||||
'UPDATE ' . $this->table('purchased_miners') . '
|
||||
SET auto_renew = :auto_renew
|
||||
WHERE project_key = :project_key AND id = :id'
|
||||
);
|
||||
$legacyUpdate->execute([
|
||||
'auto_renew' => $autoRenew ? 1 : 0,
|
||||
'project_key' => $projectKey,
|
||||
'id' => $minerId,
|
||||
]);
|
||||
}
|
||||
|
||||
$fetch = $this->pdo->prepare(
|
||||
'SELECT * FROM ' . $this->table('purchased_miners') . ' WHERE project_key = :project_key AND owner_sub = :owner_sub AND id = :id LIMIT 1'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user