From ebaeb441c5da01d6c23fd447ca40df66df1597f9 Mon Sep 17 00:00:00 2001 From: mohammad sedighi Date: Fri, 12 Jun 2026 17:02:12 +0330 Subject: [PATCH] =?UTF-8?q?new=20check=20for=20kashkol=20=DB=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Admin/ProductController.php | 28 +++---------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php index da17027..6613627 100644 --- a/app/Http/Controllers/Admin/ProductController.php +++ b/app/Http/Controllers/Admin/ProductController.php @@ -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); }