fix bug 2
This commit is contained in:
@@ -65,7 +65,20 @@ class ProductDisplayPriceService
|
||||
|
||||
private function applyAppPrice(Product $product, int $basePrice): void
|
||||
{
|
||||
$storedPrice = (int) ($product->price ?? 0);
|
||||
$useLast = Product::hasUseLastPriceIfZeroColumn()
|
||||
&& ($product->use_last_price_if_zero ?? false);
|
||||
|
||||
if ($basePrice <= 0) {
|
||||
if ($useLast && $storedPrice > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$product->setAttribute('price', 0);
|
||||
if (Schema::hasColumn($product->getTable(), 'price_profit')) {
|
||||
$product->setAttribute('price_profit', 0);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,6 +88,15 @@ class ProductDisplayPriceService
|
||||
|
||||
$computed = ProductPriceService::adjustedTotal($basePrice, 0, $offset);
|
||||
if ($computed <= 0) {
|
||||
if ($useLast && $storedPrice > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$product->setAttribute('price', 0);
|
||||
if (Schema::hasColumn($product->getTable(), 'price_profit')) {
|
||||
$product->setAttribute('price_profit', 0);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -232,4 +254,23 @@ class ProductDisplayPriceService
|
||||
|
||||
return in_array($group, ['آبشده', 'کاتد مس'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* آیا بعد از enrich قیمت پایه برای نمایش در اپ کاربر وجود دارد؟
|
||||
* کارمزد (cash_fee) بهتنهایی قیمت محسوب نمیشود.
|
||||
*/
|
||||
public function hasCustomerDisplayPrice(Product $product): bool
|
||||
{
|
||||
if ((int) ($product->price ?? 0) > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Schema::hasColumn($product->getTable(), 'price_profit')) {
|
||||
if ((int) ($product->price_profit ?? 0) > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user