fix bug 2

This commit is contained in:
2026-06-11 21:17:40 +03:30
parent 2636df99ad
commit a21dbcf3e1
5 changed files with 95 additions and 4 deletions
+31
View File
@@ -39,6 +39,37 @@ class ProductPriceSyncService
$synced = true;
}
if ($this->syncAppPriceProducts()) {
$synced = true;
}
return $synced;
}
/** محصولات آبشده با مرجع «قیمت اپ» — ذخیره آخرین قیمت در DB برای fallback */
private function syncAppPriceProducts(): bool
{
$display = app(ProductDisplayPriceService::class);
$products = Product::query()
->where('active', 1)
->get()
->filter(static fn (Product $product) => $display->usesAppPrice($product));
if ($products->isEmpty()) {
return false;
}
$basePrice = $display->resolveAppBasePrice();
if ($basePrice <= 0) {
return false;
}
$synced = false;
foreach ($products as $product) {
ProductPriceService::syncFromReference($product, $basePrice, 0);
$synced = true;
}
return $synced;
}