khanegi setting and prices records
This commit is contained in:
@@ -5,7 +5,7 @@ namespace App\Http\Controllers\Admin;
|
||||
use App\DB\Te\TableEngine;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\PriceSyncLog;
|
||||
use App\Services\ProductPriceSyncService;
|
||||
use App\Services\LivePriceTickService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PriceSyncLogController extends Controller
|
||||
@@ -29,14 +29,14 @@ class PriceSyncLogController extends Controller
|
||||
return response()->json($log);
|
||||
}
|
||||
|
||||
public function runSync(ProductPriceSyncService $syncService)
|
||||
public function runSync(LivePriceTickService $tickService)
|
||||
{
|
||||
$syncService->syncStorePrices(true);
|
||||
$tickService->tick();
|
||||
|
||||
$log = PriceSyncLog::with('items')->orderByDesc('id')->first();
|
||||
|
||||
return response()->json([
|
||||
'message' => $log ? 'قیمتها بهروزرسانی شد' : 'تغییری در قیمت محصولات نبود',
|
||||
'message' => $log ? 'قیمتها بهروزرسانی شد' : 'همگامسازی انجام شد',
|
||||
'data' => $log,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -175,15 +175,12 @@ class ProductController extends SuperController
|
||||
return response()->json($products);
|
||||
}
|
||||
|
||||
// آبشده خانگی — ادمین: sync از کش؛ کاربر: enrich بدون UPDATE
|
||||
if (! str_contains(request()->path(), '/customer/')) {
|
||||
app(ProductPriceSyncService::class)->syncAll(false);
|
||||
}
|
||||
|
||||
// آبشده خانگی — کران قیمت را آپدیت میکند؛ list فقط از DB میخواند
|
||||
$products = Product::with(['file'])->where('active', 1)->get();
|
||||
|
||||
if (str_contains(request()->path(), '/customer/')) {
|
||||
$displayPriceService = app(ProductDisplayPriceService::class);
|
||||
$displayPriceService->warmLivePriceCache();
|
||||
$displayPriceService->enrichForApi($products);
|
||||
$products->each(function (Product $product) use ($displayPriceService) {
|
||||
if (! $displayPriceService->hasCustomerDisplayPrice($product)) {
|
||||
|
||||
Reference in New Issue
Block a user