zarbox added 4
This commit is contained in:
@@ -50,15 +50,31 @@ class ZaarboxPriceService
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** UUID سری زمانی نمودار در API تاریخچه Zaarbox */
|
/**
|
||||||
|
* UUID سری نمودار: settings.chart_id؛ وگرنه پیشفرض گلد علی.
|
||||||
|
* GET https://price.zaarbox.ir/api/history/{id}
|
||||||
|
*/
|
||||||
public function historyId(): string
|
public function historyId(): string
|
||||||
{
|
{
|
||||||
$id = trim((string) $this->config->getString(
|
$chartId = $this->config->getString('chart_id', '');
|
||||||
'zaarbox_gold_history_id',
|
if ($chartId !== '') {
|
||||||
(string) config('price_providers.zaarbox_gold_history_id', self::DEFAULT_HISTORY_ID)
|
return $chartId;
|
||||||
));
|
}
|
||||||
|
|
||||||
return $id !== '' ? $id : self::DEFAULT_HISTORY_ID;
|
$legacy = $this->config->getString(
|
||||||
|
'zaarbox_gold_history_id',
|
||||||
|
(string) config('price_providers.zaarbox_gold_history_id', '')
|
||||||
|
);
|
||||||
|
if ($legacy !== '') {
|
||||||
|
return $legacy;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::DEFAULT_HISTORY_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function cacheKey(): string
|
||||||
|
{
|
||||||
|
return self::CACHE_KEY . ':' . $this->historyId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,7 +82,7 @@ class ZaarboxPriceService
|
|||||||
*/
|
*/
|
||||||
public function getAllPrices(): array
|
public function getAllPrices(): array
|
||||||
{
|
{
|
||||||
$cached = Cache::get(self::CACHE_KEY);
|
$cached = Cache::get($this->cacheKey());
|
||||||
|
|
||||||
if (is_array($cached) && isset($cached['prices'])) {
|
if (is_array($cached) && isset($cached['prices'])) {
|
||||||
return $cached['prices'];
|
return $cached['prices'];
|
||||||
@@ -82,7 +98,7 @@ class ZaarboxPriceService
|
|||||||
{
|
{
|
||||||
$prices = $this->fetchChartPrices();
|
$prices = $this->fetchChartPrices();
|
||||||
|
|
||||||
Cache::put(self::CACHE_KEY, [
|
Cache::put($this->cacheKey(), [
|
||||||
'prices' => $prices,
|
'prices' => $prices,
|
||||||
'refreshed_at' => now()->toIso8601String(),
|
'refreshed_at' => now()->toIso8601String(),
|
||||||
], now()->addMinutes(self::CACHE_TTL_MINUTES));
|
], now()->addMinutes(self::CACHE_TTL_MINUTES));
|
||||||
@@ -244,7 +260,7 @@ class ZaarboxPriceService
|
|||||||
|
|
||||||
$result[] = [
|
$result[] = [
|
||||||
'value' => intdiv($lastPoint['price'], 1000),
|
'value' => intdiv($lastPoint['price'], 1000),
|
||||||
'timestamp' => $lastPoint['timestamp'],
|
'timestamp' => $bucket,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ return [
|
|||||||
'etehadie_api_url' => 'http://109.122.246.48:4949/api/free',
|
'etehadie_api_url' => 'http://109.122.246.48:4949/api/free',
|
||||||
'zaarbox_api_url' => 'https://price.zaarbox.ir/api/free',
|
'zaarbox_api_url' => 'https://price.zaarbox.ir/api/free',
|
||||||
'zaarbox_price_key' => '',
|
'zaarbox_price_key' => '',
|
||||||
/** UUID سری زمانی نمودار — GET /api/history/{id} */
|
/** UUID نمودار Zaarbox — خالی = پیشفرض ca3800a0-... در ZaarboxPriceService */
|
||||||
'zaarbox_gold_history_id' => 'ca3800a0-1f57-3528-b963-178f9168e04f',
|
'chart_id' => '',
|
||||||
'price_method' => '',
|
'price_method' => '',
|
||||||
'register_jibit_verify' => false,
|
'register_jibit_verify' => false,
|
||||||
'register_referral_sms_to_referrer' => false,
|
'register_referral_sms_to_referrer' => false,
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ SELECT 'zaarbox_price_key', 'estjt_41670cdf0270a874b68a0a95a235f9a1', 'شناس
|
|||||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'zaarbox_price_key' LIMIT 1);
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'zaarbox_price_key' LIMIT 1);
|
||||||
UPDATE `settings` SET `value` = 'estjt_41670cdf0270a874b68a0a95a235f9a1' WHERE `key` = 'zaarbox_price_key';
|
UPDATE `settings` SET `value` = 'estjt_41670cdf0270a874b68a0a95a235f9a1' WHERE `key` = 'zaarbox_price_key';
|
||||||
|
|
||||||
|
-- نمودار: chart_id = UUID از /api/history/{id} — اگر خالی باشد ca3800a0-1f57-3528-b963-178f9168e04f
|
||||||
|
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
||||||
|
SELECT 'chart_id', '', 'UUID نمودار Zaarbox', 1, 1, 'خالی = پیشفرض آبشده گلد علی'
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'chart_id' LIMIT 1);
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
-- بعد: GET /api/price/last
|
-- بعد: GET /api/price/last
|
||||||
|
|||||||
Reference in New Issue
Block a user