fixed price

This commit is contained in:
2026-06-28 10:46:09 +03:30
parent e21e97988c
commit dec13e8537
4 changed files with 106 additions and 22 deletions
@@ -360,6 +360,54 @@ class ProductDisplayPriceService
return $this->extractBaseFromPayload($this->livePricePayload());
}
/** قیمت پایه سفارش — همان منبع نمایش اپ (کش / montzar_live_price / prices) */
public function resolveOrderBasePrice(?Product $product = null): int
{
$this->warmLivePriceCache();
if ($product instanceof Product) {
if ($this->usesAppPrice($product)) {
$useLast = $this->productUsesLastPriceIfZero($product);
$base = $useLast
? $this->resolveAppBasePrice()
: $this->resolveStrictLiveAppBasePrice();
if ($base <= 0 && $useLast) {
return $this->resolveLastPriceFallback($product);
}
if ($base <= 0) {
return 0;
}
$offset = Product::hasPriceOffsetColumn()
? (float) ($product->price_offset_percent ?? 0)
: 0.0;
return ProductPriceService::adjustedTotal($base, 0, $offset);
}
if ($product->reading_method) {
$this->enrichForApi(collect([$product]));
$unit = (int) (($product->price ?? 0) + ($product->price_profit ?? 0));
if ($unit > 0) {
return $unit;
}
}
if ((int) ($product->direct_price ?? 0) === 1) {
return (int) (($product->price ?? 0) + ($product->price_profit ?? 0));
}
}
$base = $this->resolveAppBasePrice();
if ($base > 0) {
return $base;
}
return $this->resolveHistoricalBasePrice();
}
/** @param array<string, mixed> $payload */
private function extractBaseFromPayload(array $payload): int
{