fixed show true when price is 0

This commit is contained in:
2026-06-22 19:14:24 +03:30
parent f44cb7263b
commit 27d58e8a11
5 changed files with 161 additions and 55 deletions
+17
View File
@@ -51,6 +51,10 @@ class ProductPriceService
$data['price_profit'] = 0;
}
if (\Illuminate\Support\Facades\Schema::hasColumn($product->getTable(), 'show')) {
$data['show'] = self::resolveShowAfterPriceSync($product, $adjustedPrice);
}
Product::where('id', $product->id)->update($data);
return [
@@ -67,6 +71,19 @@ class ProductPriceService
];
}
private static function resolveShowAfterPriceSync(Product $product, int $adjustedPrice): bool
{
if (! ($product->active ?? true)) {
return false;
}
if (! app(ConfigService::class)->isProductWithinTradingHours($product)) {
return false;
}
return $adjustedPrice > 0;
}
/** وقتی فقط درصد در ادمین عوض می‌شود (بدون sync جدید) */
public static function reapplyOffsetPercent(Product $product, float $newOffsetPercent, ?float $oldOffsetPercent = null): void
{