added percent in product price 3
This commit is contained in:
@@ -693,7 +693,12 @@ class ProductController extends SuperController
|
||||
}
|
||||
|
||||
if (is_string($value)) {
|
||||
$value = str_replace([',', ' ', '٬'], '', $value);
|
||||
$value = trim(str_replace([' ', '٬'], '', $value));
|
||||
if (str_contains($value, ',') && ! str_contains($value, '.')) {
|
||||
$value = str_replace(',', '.', $value);
|
||||
} else {
|
||||
$value = str_replace(',', '', $value);
|
||||
}
|
||||
}
|
||||
|
||||
return (float) $value;
|
||||
|
||||
@@ -6,20 +6,22 @@ use App\Models\Product;
|
||||
|
||||
class ProductPriceService
|
||||
{
|
||||
/** 5 => 5% ، 0.05 => 5% (اعشاری) */
|
||||
public static function feePercentRatio(float $percentValue): float
|
||||
/** 0.5 => 0.5% ، 5 => 5% — همیشه عدد درصد، نه اعشار (۰.۵ ≠ ۵۰٪) */
|
||||
public static function cashFeePercentRatio(float $percentValue): float
|
||||
{
|
||||
if ($percentValue == 0.0) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (abs($percentValue) > 0 && abs($percentValue) < 1) {
|
||||
return $percentValue;
|
||||
}
|
||||
|
||||
return $percentValue / 100;
|
||||
}
|
||||
|
||||
/** @deprecated از cashFeePercentRatio استفاده کنید */
|
||||
public static function feePercentRatio(float $percentValue): float
|
||||
{
|
||||
return self::cashFeePercentRatio($percentValue);
|
||||
}
|
||||
|
||||
public static function resolveCashFeeRial(Product $product, int $direction, float $basePriceRial): float
|
||||
{
|
||||
$isBuy = $direction === 1;
|
||||
@@ -41,7 +43,7 @@ class ProductPriceService
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return round(abs($basePriceRial * self::feePercentRatio($rawFee)));
|
||||
return round(abs($basePriceRial * self::cashFeePercentRatio($rawFee)));
|
||||
}
|
||||
|
||||
public static function productBasePriceRial(Product $product): float
|
||||
|
||||
Reference in New Issue
Block a user