added setting for user

This commit is contained in:
2026-08-16 22:00:23 +03:30
parent c3c3a60088
commit bd8284e4f8
11 changed files with 769 additions and 12 deletions
@@ -54,6 +54,10 @@ class PriceStreamController extends Controller
$cache = app(LivePriceCacheService::class);
$last = $cache->get() ?? $cache->buildFromDatabase();
if (is_array($last) && $last !== []) {
if ($customerId > 0) {
$last = app(\App\Services\CustomerSpecialPricingService::class)
->applyToLastPayload($last, $customerId);
}
$send('last', app(ZaarboxPriceService::class)->attachGoldOunceToPayload($last));
}
@@ -62,6 +66,13 @@ class PriceStreamController extends Controller
$send('list', $list);
}
if ($customerId > 0) {
$send(
'special-pricing',
app(\App\Services\CustomerSpecialPricingService::class)->clientPayloadForCustomer($customerId)
);
}
$customerLastId = 0;
if ($customerId > 0) {
$assets = app(AssetSummaryService::class)->buildForCustomer(
+21 -9
View File
@@ -197,14 +197,14 @@ class ReportController extends Controller
if ($cached !== null) {
$cached['gold_ounce'] = $this->resolveGoldOuncePayload();
return $cached;
return $this->personalizeLastPriceForCustomer($cached);
}
// فقط وقتی کران اخیراً tick زده — وگرنه API زنده (جلوگیری از قفل قیمت)
if ($cache->hasRecentTick()) {
$dbBuilt = $cache->buildFromDatabase();
if (($dbBuilt['price'] ?? 0) > 0) {
return $this->appendUpPrices($dbBuilt, false);
return $this->personalizeLastPriceForCustomer($this->appendUpPrices($dbBuilt, false));
}
}
}
@@ -226,7 +226,7 @@ class ReportController extends Controller
);
}
return $this->appendUpPrices($storePayload, $forceRefresh);
return $this->personalizeLastPriceForCustomer($this->appendUpPrices($storePayload, $forceRefresh));
}
$closed = false;
@@ -246,7 +246,7 @@ class ReportController extends Controller
};
$zeroResponse = function () use ($forceRefresh) {
return $this->appendUpPrices([
return $this->personalizeLastPriceForCustomer($this->appendUpPrices([
'sell' => 0,
'buy' => 0,
'price_last' => 0,
@@ -256,7 +256,7 @@ class ReportController extends Controller
'zaarbox' => 0,
'closed' => true,
'time' => now(),
], $forceRefresh);
], $forceRefresh));
};
$priceProvider = $config->priceProvider();
@@ -440,7 +440,7 @@ class ReportController extends Controller
$priceSource = 'database_last';
} else {
// مظنه زنده نداریم و show_last_price خاموش است → نه «بسته»، بلکه «مظنه در دسترس نیست»
return $this->appendUpPrices([
return $this->personalizeLastPriceForCustomer($this->appendUpPrices([
'sell' => 0,
'buy' => 0,
'price_last' => 0,
@@ -451,7 +451,7 @@ class ReportController extends Controller
'closed' => false,
'status' => 'no_quote',
'time' => now(),
], $forceRefresh);
], $forceRefresh));
}
}
@@ -485,7 +485,7 @@ class ReportController extends Controller
);
}
return $this->appendUpPrices([
return $this->personalizeLastPriceForCustomer($this->appendUpPrices([
'sell' => $sell,
'buy' => $buy,
'price_last' => $priceLast,
@@ -496,7 +496,19 @@ class ReportController extends Controller
'zaarbox' => $zaarbox_price ?? 0,
'closed' => false,
'time' => now(),
], $forceRefresh);
], $forceRefresh));
}
/** اختلاف پکیج ویژه — فقط روی پاسخ مشتری؛ کش مشترک را آلوده نمی‌کند */
protected function personalizeLastPriceForCustomer(array $payload): array
{
$customerId = (int) (auth('customer')->id() ?? 0);
if ($customerId <= 0) {
return $payload;
}
return app(\App\Services\CustomerSpecialPricingService::class)
->applyToLastPayload($payload, $customerId);
}
protected function recordHalfHourPriceSnapshot(