doku
This commit is contained in:
@@ -1005,12 +1005,12 @@ final class MiningRepository
|
||||
'INSERT INTO ' . $this->table('purchased_miners') . ' (
|
||||
project_key, owner_sub, miner_offer_id, purchased_at, label, runtime_months,
|
||||
mining_speed_value, mining_speed_unit, bonus_speed_value, bonus_speed_unit,
|
||||
total_cost_amount, currency, usd_reference_amount, reference_price_amount, reference_price_currency, settled_value_amount, settled_value_currency,
|
||||
total_cost_amount, currency, usd_reference_amount, reference_price_amount, reference_price_currency, settled_value_amount, settled_value_currency, settled_fx_fetch_id,
|
||||
daily_cost_amount, daily_cost_currency, auto_renew, note, is_active
|
||||
) VALUES (
|
||||
:project_key, :owner_sub, :miner_offer_id, :purchased_at, :label, :runtime_months,
|
||||
:mining_speed_value, :mining_speed_unit, :bonus_speed_value, :bonus_speed_unit,
|
||||
:total_cost_amount, :currency, :usd_reference_amount, :reference_price_amount, :reference_price_currency, :settled_value_amount, :settled_value_currency,
|
||||
:total_cost_amount, :currency, :usd_reference_amount, :reference_price_amount, :reference_price_currency, :settled_value_amount, :settled_value_currency, :settled_fx_fetch_id,
|
||||
:daily_cost_amount, :daily_cost_currency, :auto_renew, :note, :is_active
|
||||
)
|
||||
RETURNING *'
|
||||
@@ -1023,12 +1023,12 @@ final class MiningRepository
|
||||
'INSERT INTO ' . $this->table('purchased_miners') . ' (
|
||||
project_key, owner_sub, miner_offer_id, purchased_at, label, runtime_months,
|
||||
mining_speed_value, mining_speed_unit, bonus_speed_value, bonus_speed_unit,
|
||||
total_cost_amount, currency, usd_reference_amount, reference_price_amount, reference_price_currency, settled_value_amount, settled_value_currency,
|
||||
total_cost_amount, currency, usd_reference_amount, reference_price_amount, reference_price_currency, settled_value_amount, settled_value_currency, settled_fx_fetch_id,
|
||||
daily_cost_amount, daily_cost_currency, auto_renew, note, is_active
|
||||
) VALUES (
|
||||
:project_key, :owner_sub, :miner_offer_id, :purchased_at, :label, :runtime_months,
|
||||
:mining_speed_value, :mining_speed_unit, :bonus_speed_value, :bonus_speed_unit,
|
||||
:total_cost_amount, :currency, :usd_reference_amount, :reference_price_amount, :reference_price_currency, :settled_value_amount, :settled_value_currency,
|
||||
:total_cost_amount, :currency, :usd_reference_amount, :reference_price_amount, :reference_price_currency, :settled_value_amount, :settled_value_currency, :settled_fx_fetch_id,
|
||||
:daily_cost_amount, :daily_cost_currency, :auto_renew, :note, :is_active
|
||||
)'
|
||||
);
|
||||
@@ -1059,6 +1059,7 @@ final class MiningRepository
|
||||
'reference_price_currency' => $payload['reference_price_currency'] ?? null,
|
||||
'settled_value_amount' => $payload['settled_value_amount'] ?? null,
|
||||
'settled_value_currency' => $payload['settled_value_currency'] ?? null,
|
||||
'settled_fx_fetch_id' => $payload['settled_fx_fetch_id'] ?? null,
|
||||
'daily_cost_amount' => $payload['daily_cost_amount'] ?? $this->deriveDailyCostAmount($payload['total_cost_amount'] ?? null, $payload['runtime_months'] ?? null),
|
||||
'daily_cost_currency' => $payload['daily_cost_currency'] ?? ($payload['currency'] ?? null),
|
||||
'auto_renew' => $payload['auto_renew'] ?? 0,
|
||||
@@ -1071,12 +1072,12 @@ final class MiningRepository
|
||||
'INSERT INTO ' . $this->table('purchased_miners') . ' (
|
||||
project_key, owner_sub, miner_offer_id, purchased_at, label, runtime_months,
|
||||
mining_speed_value, mining_speed_unit, bonus_speed_value, bonus_speed_unit,
|
||||
total_cost_amount, currency, usd_reference_amount, reference_price_amount, reference_price_currency, settled_value_amount, settled_value_currency,
|
||||
total_cost_amount, currency, usd_reference_amount, reference_price_amount, reference_price_currency, settled_value_amount, settled_value_currency, settled_fx_fetch_id,
|
||||
daily_cost_amount, daily_cost_currency, auto_renew, note, is_active
|
||||
) VALUES (
|
||||
:project_key, :owner_sub, :miner_offer_id, :purchased_at, :label, :runtime_months,
|
||||
:mining_speed_value, :mining_speed_unit, :bonus_speed_value, :bonus_speed_unit,
|
||||
:total_cost_amount, :currency, :usd_reference_amount, :reference_price_amount, :reference_price_currency, :settled_value_amount, :settled_value_currency,
|
||||
:total_cost_amount, :currency, :usd_reference_amount, :reference_price_amount, :reference_price_currency, :settled_value_amount, :settled_value_currency, :settled_fx_fetch_id,
|
||||
:daily_cost_amount, :daily_cost_currency, :auto_renew, :note, :is_active
|
||||
)
|
||||
RETURNING *'
|
||||
@@ -1089,12 +1090,12 @@ final class MiningRepository
|
||||
'INSERT INTO ' . $this->table('purchased_miners') . ' (
|
||||
project_key, owner_sub, miner_offer_id, purchased_at, label, runtime_months,
|
||||
mining_speed_value, mining_speed_unit, bonus_speed_value, bonus_speed_unit,
|
||||
total_cost_amount, currency, usd_reference_amount, reference_price_amount, reference_price_currency, settled_value_amount, settled_value_currency,
|
||||
total_cost_amount, currency, usd_reference_amount, reference_price_amount, reference_price_currency, settled_value_amount, settled_value_currency, settled_fx_fetch_id,
|
||||
daily_cost_amount, daily_cost_currency, auto_renew, note, is_active
|
||||
) VALUES (
|
||||
:project_key, :owner_sub, :miner_offer_id, :purchased_at, :label, :runtime_months,
|
||||
:mining_speed_value, :mining_speed_unit, :bonus_speed_value, :bonus_speed_unit,
|
||||
:total_cost_amount, :currency, :usd_reference_amount, :reference_price_amount, :reference_price_currency, :settled_value_amount, :settled_value_currency,
|
||||
:total_cost_amount, :currency, :usd_reference_amount, :reference_price_amount, :reference_price_currency, :settled_value_amount, :settled_value_currency, :settled_fx_fetch_id,
|
||||
:daily_cost_amount, :daily_cost_currency, :auto_renew, :note, :is_active
|
||||
)'
|
||||
);
|
||||
@@ -1650,6 +1651,7 @@ final class MiningRepository
|
||||
'reference_price_currency' => $payload['reference_price_currency'] ?? null,
|
||||
'settled_value_amount' => $payload['settled_value_amount'] ?? null,
|
||||
'settled_value_currency' => $payload['settled_value_currency'] ?? null,
|
||||
'settled_fx_fetch_id' => $payload['settled_fx_fetch_id'] ?? null,
|
||||
'daily_cost_amount' => $dailyCostAmount,
|
||||
'daily_cost_currency' => $dailyCostCurrency,
|
||||
'auto_renew' => $payload['auto_renew'] ?? 0,
|
||||
|
||||
@@ -261,7 +261,8 @@ final class SchemaManager
|
||||
}
|
||||
if ($this->tableExists($this->prefix . 'purchased_miners') && (
|
||||
!$this->columnExists($this->prefix . 'purchased_miners', 'settled_value_amount') ||
|
||||
!$this->columnExists($this->prefix . 'purchased_miners', 'settled_value_currency')
|
||||
!$this->columnExists($this->prefix . 'purchased_miners', 'settled_value_currency') ||
|
||||
!$this->columnExists($this->prefix . 'purchased_miners', 'settled_fx_fetch_id')
|
||||
)) {
|
||||
$this->upgradePurchasedMinerSettlementColumns();
|
||||
$applied[] = 'purchased_miner_settlement_columns';
|
||||
@@ -410,7 +411,8 @@ final class SchemaManager
|
||||
}
|
||||
if ($this->tableExists($this->prefix . 'purchased_miners') && (
|
||||
!$this->columnExists($this->prefix . 'purchased_miners', 'settled_value_amount') ||
|
||||
!$this->columnExists($this->prefix . 'purchased_miners', 'settled_value_currency')
|
||||
!$this->columnExists($this->prefix . 'purchased_miners', 'settled_value_currency') ||
|
||||
!$this->columnExists($this->prefix . 'purchased_miners', 'settled_fx_fetch_id')
|
||||
)) {
|
||||
$this->upgradePurchasedMinerSettlementColumns();
|
||||
$applied[] = 'purchased_miner_settlement_columns';
|
||||
@@ -770,7 +772,8 @@ final class SchemaManager
|
||||
}
|
||||
if ($this->tableExists($this->prefix . 'purchased_miners') && (
|
||||
!$this->columnExists($this->prefix . 'purchased_miners', 'settled_value_amount') ||
|
||||
!$this->columnExists($this->prefix . 'purchased_miners', 'settled_value_currency')
|
||||
!$this->columnExists($this->prefix . 'purchased_miners', 'settled_value_currency') ||
|
||||
!$this->columnExists($this->prefix . 'purchased_miners', 'settled_fx_fetch_id')
|
||||
)) {
|
||||
$upgrades[] = 'purchased_miner_settlement_columns';
|
||||
}
|
||||
@@ -1529,11 +1532,13 @@ final class SchemaManager
|
||||
? [
|
||||
'ALTER TABLE ' . $table . ' ADD COLUMN IF NOT EXISTS settled_value_amount NUMERIC(20,8)',
|
||||
'ALTER TABLE ' . $table . ' ADD COLUMN IF NOT EXISTS settled_value_currency VARCHAR(10)',
|
||||
'ALTER TABLE ' . $table . ' ADD COLUMN IF NOT EXISTS settled_fx_fetch_id BIGINT',
|
||||
"UPDATE " . $table . " SET settled_value_amount = CASE WHEN reference_price_amount IS NOT NULL AND NULLIF(BTRIM(reference_price_currency), '') IS NOT NULL AND UPPER(reference_price_currency) <> UPPER(currency) THEN reference_price_amount ELSE total_cost_amount * 0.07 END, settled_value_currency = CASE WHEN reference_price_amount IS NOT NULL AND NULLIF(BTRIM(reference_price_currency), '') IS NOT NULL AND UPPER(reference_price_currency) <> UPPER(currency) THEN reference_price_currency ELSE 'EUR' END WHERE UPPER(currency) IN ('ADA','ARB','BNB','BTC','DAI','DOGE','DOT','ETH','LINK','LTC','SOL','USDC','USDT','XRP') AND settled_value_amount IS NULL",
|
||||
]
|
||||
: [
|
||||
'ALTER TABLE `' . $table . '` ADD COLUMN settled_value_amount DECIMAL(20,8) NULL',
|
||||
'ALTER TABLE `' . $table . '` ADD COLUMN settled_value_currency VARCHAR(10) NULL',
|
||||
'ALTER TABLE `' . $table . '` ADD COLUMN settled_fx_fetch_id BIGINT UNSIGNED NULL',
|
||||
"UPDATE `" . $table . "` SET settled_value_amount = CASE WHEN reference_price_amount IS NOT NULL AND NULLIF(TRIM(reference_price_currency), '') IS NOT NULL AND UPPER(reference_price_currency) <> UPPER(currency) THEN reference_price_amount ELSE total_cost_amount * 0.07 END, settled_value_currency = CASE WHEN reference_price_amount IS NOT NULL AND NULLIF(TRIM(reference_price_currency), '') IS NOT NULL AND UPPER(reference_price_currency) <> UPPER(currency) THEN reference_price_currency ELSE 'EUR' END WHERE UPPER(currency) IN ('ADA','ARB','BNB','BTC','DAI','DOGE','DOT','ETH','LINK','LTC','SOL','USDC','USDT','XRP') AND settled_value_amount IS NULL",
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user