fixed show true when price is 0 2

This commit is contained in:
2026-06-22 19:35:20 +03:30
parent 27d58e8a11
commit 8858cf968b
2 changed files with 32 additions and 24 deletions
+32 -7
View File
@@ -73,6 +73,19 @@ class ProductDisplayPriceService
continue;
}
if ($product->reading_method && ! $this->productUsesLastPriceIfZero($product)) {
$product->setAttribute('reference_provider_active', false);
$this->zeroProductPrice($product);
continue;
}
if ($product->reading_method) {
$product->setAttribute('reference_provider_active', true);
continue;
}
if ($this->isWeightBasedStoreProduct($product)) {
$this->enrichWeightBasedPrice($product);
}
@@ -100,7 +113,7 @@ class ProductDisplayPriceService
? $this->resolveLiveBuyPriceWithFallback()
: $this->resolveStrictLiveBuyPrice();
if ($unitBuy <= 0 && $useLast) {
if ($unitBuy <= 0 && app(ConfigService::class)->getBool('show_last_price', false)) {
$unitBuy = $this->resolveHistoricalBasePrice();
}
@@ -265,6 +278,7 @@ class ProductDisplayPriceService
$useLast = $this->productUsesLastPriceIfZero($product);
$row = $zaarbox->findFeedRow($feed, (string) $product->reading_method);
if ($row === null) {
$product->setAttribute('reference_provider_active', $useLast);
$offset = ProductPriceService::offsetPercent($product);
$historical = $useLast ? $this->resolveHistoricalBasePrice() : 0;
$computed = $historical > 0
@@ -275,6 +289,17 @@ class ProductDisplayPriceService
return;
}
$normalized = $zaarbox->normalizeFeedRow($row);
$providerRaw = (int) round((float) ($normalized['price'] ?? 0) + (float) ($normalized['profit'] ?? 0));
$providerActive = $useLast || $providerRaw > 0;
$product->setAttribute('reference_provider_active', $providerActive);
if (! $useLast && $providerRaw <= 0) {
$this->zeroProductPrice($product);
return;
}
$computed = $zaarbox->computeAdjustedProductPrice($product, $row);
if ($computed <= 0) {
if ($useLast) {
@@ -441,11 +466,10 @@ class ProductDisplayPriceService
/**
* نمایش در اپ کاربر:
* • خاموش (active=false در DB) → false
* • خارج از ساعات معامله → false
* • خاموش (show=false در DB) → false
* • قیمت نمایشی بعد از enrich → true
* • قیمت صفر و use_last_price_if_zero خاموش → false
* • قیمت صفر و use_last_price_if_zero روشن و fallback موجود → true
* • قیمت صفر و show_last_price خاموش → false
* • قیمت صفر و show_last_price روشن و fallback موجود → true
*/
public function resolveCustomerShow(Product $product): bool
{
@@ -461,10 +485,11 @@ class ProductDisplayPriceService
return true;
}
if (! $this->productUsesLastPriceIfZero($product)) {
if (! app(ConfigService::class)->getBool('show_last_price', false)) {
return false;
}
return $this->resolveLastPriceFallback($product) > 0;
return $this->resolveLastPriceFallback($product) > 0
|| $this->resolveHistoricalBasePrice() > 0;
}
}