fix bug 22/4 2

This commit is contained in:
2026-07-13 19:03:30 +03:30
parent 7eb4650b80
commit 277cf31d93
8 changed files with 217 additions and 29 deletions
@@ -26,6 +26,11 @@ class ProductDisplayPriceService
return false;
}
// پرچم صریح «قیمت اپ» برای هر دسته‌ای (شمش، سکه، …) — قیمت هر گرم × وزن
if (Product::hasAppPriceColumn() && (bool) ($product->app_price ?? false)) {
return true;
}
if ((int) ($product->direct_price ?? 0) === 1) {
return false;
}
@@ -34,6 +39,22 @@ class ProductDisplayPriceService
|| $this->usesQuantityAppPrice($product);
}
/** محصولی که با پرچم صریح app_price قیمت اپ می‌گیرد (نه استنتاج آبشده/مقداری) */
public function usesFlaggedAppPrice(Product $product): bool
{
return Product::hasAppPriceColumn()
&& (bool) ($product->app_price ?? false)
&& ! $product->reading_method;
}
/** ضریب وزن برای محصول قیمت‌اپ: وزن واحد به گرم‌واحد محصول (amount) یا ۱ */
public function appPriceWeightFactor(Product $product): float
{
$amount = (float) ($product->amount ?? 0);
return $amount > 0 ? $amount : 1.0;
}
/** معامله مقداری با قیمت اپ — نه قیمت دستی قدیمی با price پر در DB */
private function usesQuantityAppPrice(Product $product): bool
{