fix some issu
This commit is contained in:
@@ -76,12 +76,14 @@ class Controller extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* گزینههای Guzzle/cURL — فقط وقتی افزونه curl و ثابتها موجود باشند.
|
||||
* Direct connect (no local VPN/proxy) + IPv4 + HTTP/1.1:
|
||||
* dead 127.0.0.1 proxies, broken AAAA, and flaky HTTP/2 cause
|
||||
* "Connection refused" / stream errors while browsers still work.
|
||||
*
|
||||
* @param array<int, mixed> $curlOptions
|
||||
* @return array<string, array<int, mixed>>
|
||||
* @param array<int, mixed> $curlOptions
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function httpClientOptions(array $curlOptions = []): array
|
||||
public static function httpClientOptions(array $curlOptions = [], ?float $timeout = null): array
|
||||
{
|
||||
$curl = $curlOptions;
|
||||
|
||||
@@ -92,7 +94,24 @@ class Controller extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
return $curl === [] ? [] : ['curl' => $curl];
|
||||
if (defined('CURLOPT_HTTP_VERSION') && defined('CURL_HTTP_VERSION_1_1')) {
|
||||
$verOpt = (int) constant('CURLOPT_HTTP_VERSION');
|
||||
if (! array_key_exists($verOpt, $curl)) {
|
||||
$curl[$verOpt] = (int) constant('CURL_HTTP_VERSION_1_1');
|
||||
}
|
||||
}
|
||||
|
||||
$options = ['proxy' => false];
|
||||
|
||||
if ($timeout !== null) {
|
||||
$options['connect_timeout'] = min(5.0, max(2.0, (float) $timeout));
|
||||
}
|
||||
|
||||
if ($curl !== []) {
|
||||
$options['curl'] = $curl;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public static function Send($to , $msg, $is_customer = true)
|
||||
|
||||
@@ -52,7 +52,12 @@ class PriceStreamController extends Controller
|
||||
}
|
||||
|
||||
$cache = app(LivePriceCacheService::class);
|
||||
$last = $cache->get() ?? $cache->buildFromDatabase();
|
||||
$config = app(\App\Services\ConfigService::class);
|
||||
$last = $cache->get();
|
||||
// کش ممکن است no_quote صفرِ کوتاهعمر داشته باشد؛ با build از montzar_live_price جبران کن
|
||||
if (! is_array($last) || ! $config->payloadHasDisplayablePrice($last)) {
|
||||
$last = $cache->buildFromDatabase();
|
||||
}
|
||||
if (is_array($last) && $last !== []) {
|
||||
if ($customerId > 0) {
|
||||
$last = app(\App\Services\CustomerSpecialPricingService::class)
|
||||
|
||||
@@ -327,19 +327,19 @@ class ReportController extends Controller
|
||||
|
||||
$config->UpdateConfig('montzar_closed', 'false');
|
||||
} catch (\Throwable $e) {
|
||||
$montzarLivePrice = 0;
|
||||
|
||||
\Log::error('MONZAR PRICE ERROR', [
|
||||
'message' => $e->getMessage(),
|
||||
'montzar_product_id' => $montzarProductId ?? null,
|
||||
'montzar_response' => $montzar ?? null,
|
||||
]);
|
||||
|
||||
// قطع لحظهای همکار → قیمت ذخیرهشده را نگه دار و دوباره در تیک بعدی تلاش کن
|
||||
$config->applyMontzarSyncFailure();
|
||||
if (!$config->getBool('montzar_closed', true)) {
|
||||
$stale = $config->getInt('montzar_live_price', 0);
|
||||
$montzarLivePrice = $config->isPlausibleQuotePrice((float) $stale) ? $stale : 0;
|
||||
}
|
||||
$stale = $config->getInt('montzar_live_price', 0);
|
||||
$montzarLivePrice = $config->isPlausibleQuotePrice((float) $stale) ? $stale : 0;
|
||||
$montzarFlags = $config->montzarOpenFlags();
|
||||
$montzar_open_buy = $montzarFlags['open_buy'];
|
||||
$montzar_open_sell = $montzarFlags['open_sell'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,12 +584,9 @@ class ReportController extends Controller
|
||||
|
||||
$config->UpdateConfig('montzar_closed', 'false');
|
||||
} catch (\Throwable $e) {
|
||||
$montzar = 0;
|
||||
$config->applyMontzarSyncFailure();
|
||||
if (!$config->getBool('montzar_closed', true)) {
|
||||
$stale = $config->getInt('montzar_live_price', 0);
|
||||
$montzar = $config->isPlausibleQuotePrice((float) $stale) ? $stale : 0;
|
||||
}
|
||||
$stale = $config->getInt('montzar_live_price', 0);
|
||||
$montzar = $config->isPlausibleQuotePrice((float) $stale) ? $stale : 0;
|
||||
\Log::error('STORE MONZAR PRICE ERROR', ['message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user