new check for kashkol ۴

This commit is contained in:
2026-06-12 17:02:12 +03:30
parent 8540d57abc
commit ebaeb441c5
@@ -14,7 +14,6 @@ use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
use Illuminate\Support\Facades\Http;
use \App\Http\Controllers\Customer\FundController;
use App\Http\Controllers\Site\ReportController;
use App\Services\ConfigService;
use App\Services\ProductDisplayPriceService;
use App\Services\ProductPriceService;
use Illuminate\Support\Facades\Schema;
@@ -152,37 +151,17 @@ class ProductController extends SuperController
public function listProduct()
{
$isCustomerApi = str_contains(request()->path(), '/customer/');
$config = app(ConfigService::class);
$isStore = $config->isStore();
// ادمین: sync اختیاری از کش — کاربر: فقط enrich از کش کران (بدون HTTP / بدون UPDATE)
if (! $isCustomerApi) {
if (! str_contains(request()->path(), '/customer/')) {
app(\App\Services\ProductPriceSyncService::class)->syncAll(false);
}
// فروشگاه (قطره / کشکول): مثل ghatre — show بر اساس ساعت auto_open/auto_close
if ($isCustomerApi && $isStore) {
$this->auto_close_open();
}
$products = Product::with(['file'])->where('active', 1)->get();
if ($isCustomerApi) {
if (str_contains(request()->path(), '/customer/')) {
$displayPriceService = app(ProductDisplayPriceService::class);
$displayPriceService->enrichForApi($products);
$showLastPrice = $config->getBool('show_last_price', false);
$products->each(function (Product $product) use ($displayPriceService, $isStore, $showLastPrice) {
if ($isStore) {
// فقط وقتی قیمت صفر است و fallback آخرین قیمت هم خاموش است
if (! $displayPriceService->hasCustomerDisplayPrice($product) && ! $showLastPrice) {
$product->setAttribute('show', false);
}
return;
}
$products->each(function (Product $product) use ($displayPriceService) {
if (! $displayPriceService->hasCustomerDisplayPrice($product)) {
$product->setAttribute('show', false);
}
@@ -237,6 +216,7 @@ class ProductController extends SuperController
'show' => $show,
]);
}
return response()->json(true);
}