new check for kashkol ۴
This commit is contained in:
@@ -14,7 +14,6 @@ use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
|||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use \App\Http\Controllers\Customer\FundController;
|
use \App\Http\Controllers\Customer\FundController;
|
||||||
use App\Http\Controllers\Site\ReportController;
|
use App\Http\Controllers\Site\ReportController;
|
||||||
use App\Services\ConfigService;
|
|
||||||
use App\Services\ProductDisplayPriceService;
|
use App\Services\ProductDisplayPriceService;
|
||||||
use App\Services\ProductPriceService;
|
use App\Services\ProductPriceService;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
@@ -152,37 +151,17 @@ class ProductController extends SuperController
|
|||||||
|
|
||||||
public function listProduct()
|
public function listProduct()
|
||||||
{
|
{
|
||||||
$isCustomerApi = str_contains(request()->path(), '/customer/');
|
|
||||||
$config = app(ConfigService::class);
|
|
||||||
$isStore = $config->isStore();
|
|
||||||
|
|
||||||
// ادمین: sync اختیاری از کش — کاربر: فقط enrich از کش کران (بدون HTTP / بدون UPDATE)
|
// ادمین: sync اختیاری از کش — کاربر: فقط enrich از کش کران (بدون HTTP / بدون UPDATE)
|
||||||
if (! $isCustomerApi) {
|
if (! str_contains(request()->path(), '/customer/')) {
|
||||||
app(\App\Services\ProductPriceSyncService::class)->syncAll(false);
|
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();
|
$products = Product::with(['file'])->where('active', 1)->get();
|
||||||
|
|
||||||
if ($isCustomerApi) {
|
if (str_contains(request()->path(), '/customer/')) {
|
||||||
$displayPriceService = app(ProductDisplayPriceService::class);
|
$displayPriceService = app(ProductDisplayPriceService::class);
|
||||||
$displayPriceService->enrichForApi($products);
|
$displayPriceService->enrichForApi($products);
|
||||||
$showLastPrice = $config->getBool('show_last_price', false);
|
$products->each(function (Product $product) use ($displayPriceService) {
|
||||||
|
|
||||||
$products->each(function (Product $product) use ($displayPriceService, $isStore, $showLastPrice) {
|
|
||||||
if ($isStore) {
|
|
||||||
// فقط وقتی قیمت صفر است و fallback آخرین قیمت هم خاموش است
|
|
||||||
if (! $displayPriceService->hasCustomerDisplayPrice($product) && ! $showLastPrice) {
|
|
||||||
$product->setAttribute('show', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $displayPriceService->hasCustomerDisplayPrice($product)) {
|
if (! $displayPriceService->hasCustomerDisplayPrice($product)) {
|
||||||
$product->setAttribute('show', false);
|
$product->setAttribute('show', false);
|
||||||
}
|
}
|
||||||
@@ -237,6 +216,7 @@ class ProductController extends SuperController
|
|||||||
'show' => $show,
|
'show' => $show,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json(true);
|
return response()->json(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user