store
This commit is contained in:
@@ -14,8 +14,10 @@ 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 App\Services\ProductPriceSyncService;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
@@ -151,9 +153,18 @@ class ProductController extends SuperController
|
||||
|
||||
public function listProduct()
|
||||
{
|
||||
// ادمین: sync اختیاری از کش — کاربر: فقط enrich از کش کران (بدون HTTP / بدون UPDATE)
|
||||
if (app(ConfigService::class)->isStore()) {
|
||||
app(ProductPriceSyncService::class)->syncStorePrices(true);
|
||||
$this->auto_close_open();
|
||||
|
||||
return response()->json(
|
||||
Product::with(['file'])->where('active', 1)->get()
|
||||
);
|
||||
}
|
||||
|
||||
// آبشده خانگی — ادمین: sync از کش؛ کاربر: enrich بدون UPDATE
|
||||
if (! str_contains(request()->path(), '/customer/')) {
|
||||
app(\App\Services\ProductPriceSyncService::class)->syncAll(false);
|
||||
app(ProductPriceSyncService::class)->syncAll(false);
|
||||
}
|
||||
|
||||
$products = Product::with(['file'])->where('active', 1)->get();
|
||||
@@ -162,7 +173,9 @@ class ProductController extends SuperController
|
||||
$displayPriceService = app(ProductDisplayPriceService::class);
|
||||
$displayPriceService->enrichForApi($products);
|
||||
$products->each(function (Product $product) use ($displayPriceService) {
|
||||
$product->setAttribute('show', $displayPriceService->resolveCustomerShow($product));
|
||||
if (! $displayPriceService->hasCustomerDisplayPrice($product)) {
|
||||
$product->setAttribute('show', false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -179,7 +192,7 @@ class ProductController extends SuperController
|
||||
|
||||
public function ProductById($id)
|
||||
{
|
||||
$this->getPrice();
|
||||
app(ProductPriceSyncService::class)->syncStorePrices(true);
|
||||
$this->auto_close_open();
|
||||
$product = Product::with(['file'])
|
||||
->where('id', $id)
|
||||
@@ -199,7 +212,11 @@ class ProductController extends SuperController
|
||||
|
||||
public function getPrice()
|
||||
{
|
||||
app(\App\Services\ProductPriceSyncService::class)->syncAll(true);
|
||||
if (app(ConfigService::class)->isStore()) {
|
||||
app(ProductPriceSyncService::class)->syncStorePrices(true);
|
||||
} else {
|
||||
app(ProductPriceSyncService::class)->syncAll(true);
|
||||
}
|
||||
|
||||
return response()->json(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user