added percent in product price

This commit is contained in:
2026-07-04 18:00:57 +03:30
parent 4dea2fb212
commit 4ef0dfb2c0
7 changed files with 161 additions and 6 deletions
@@ -18,6 +18,7 @@ use App\Models\Price;
use App\Http\Controllers\Admin\ProductController;
use App\Http\Controllers\Admin\GiftCardController;
use App\Services\ConfigService;
use App\Services\ProductPriceService;
@@ -243,11 +244,16 @@ class CartController extends Controller
//محاسبه مجموع درصد کارمزد سبد با احتساب تعداد
$data['service_charge_percentage'] += $product->percent_fee_buy * $item->quantity;
//محاسبه مجموع کارمزد ثابت سبد با احتساب تعداد
$data['fee'] += $product->cash_fee_buy * $item->quantity;
$unitCashFee = ProductPriceService::resolveCashFeeRial(
$product,
1,
max((float) $goldPrice, ProductPriceService::productBasePriceRial($product))
);
$data['fee'] += $unitCashFee * $item->quantity;
// قیمت نهایی هر گرم
$priceWithFee = $goldPrice + $data['fee'];
//محاسبه مجموع کارمزد ثابت سبد با احتساب تعداد
$product_fees += $product->cash_fee_buy;
$product_fees += $unitCashFee;
// قیمت آیتم
$itemTotalPrice = $finalAmount * $priceWithFee;
@@ -375,7 +381,8 @@ class CartController extends Controller
throw new UnprocessableEntityHttpException("قیمت محصول {$product->title} مشخص نیست.");
}
$cashFee = (float) ($product->cash_fee_buy ?? 0) * $qty;
$unitCashFee = ProductPriceService::resolveCashFeeRial($product, 1, $unitPrice);
$cashFee = $unitCashFee * $qty;
$lineTotal = ($unitPrice * $qty) + $cashFee;
$total_price += $lineTotal;