From 01b9f1eb980ad451de9696a6c6bbfa240fb1df75 Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Mon, 16 Feb 2026 21:57:18 +0330 Subject: [PATCH] =?UTF-8?q?fix:=20remove=20discount=20balance=20UI=20entir?= =?UTF-8?q?ely=20=E2=80=94=20100%=20discount=20auto-applied=20by=20server?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/DiscountStore/Checkout.razor | 74 ++----------------- .../Pages/DiscountStore/Checkout.razor.cs | 39 +--------- 2 files changed, 8 insertions(+), 105 deletions(-) diff --git a/src/FrontOffice.Main/Pages/DiscountStore/Checkout.razor b/src/FrontOffice.Main/Pages/DiscountStore/Checkout.razor index 647a7de..47b8b1a 100644 --- a/src/FrontOffice.Main/Pages/DiscountStore/Checkout.razor +++ b/src/FrontOffice.Main/Pages/DiscountStore/Checkout.razor @@ -52,55 +52,6 @@ } - - - - - تخفیف کیف تخفیفی - - - - - موجودی کیف تخفیفی شما: - - @FormatPrice(_discountBalance) تومان - - - - @if (MaxUsable > 0) - { - - - مبلغ تخفیف اعمال‌شده: - - @FormatPrice(MaxUsable) تومان - - - - - @if (GatewayAmount > 0) - { - - مبلغ @FormatPrice(MaxUsable) تومان از کیف تخفیفی کسر و - مبلغ @FormatPrice(GatewayAmount) تومان از درگاه پرداخت دریافت خواهد شد. - - } - else - { - - کل مبلغ سفارش از کیف تخفیفی پرداخت خواهد شد. - - } - } - else - { - - موجودی کیف تخفیفی شما کافی نیست. کل مبلغ از درگاه پرداخت دریافت خواهد شد. - - } - - - توضیحات سفارش @@ -149,30 +100,15 @@ - جمع کل: - @FormatPrice(DiscountCart.TotalPrice) - - - @if (MaxUsable > 0) - { - - از کیف تخفیفی: - @FormatPrice(MaxUsable)- - - } - - - - - پرداخت از درگاه: + جمع کل: - @FormatPrice(GatewayAmount) تومان + @FormatPrice(DiscountCart.TotalPrice) تومان - - مالیات بر ارزش افزوده صرفاً بر مبلغ درگاه محاسبه خواهد شد. - + + تخفیف ۱۰۰٪ از کیف تخفیفی اعمال می‌شود. + - /// Maximum discount allowed based on cart items' MaxDiscountPercent - /// - private long MaxAllowedDiscount => DiscountCart.TotalDiscount; - - /// - /// Maximum the user can actually use = min(balance, allowed discount) - /// Always applied at 100% — no user selection - /// - private long MaxUsable => Math.Min(_discountBalance, MaxAllowedDiscount); - - /// - /// Amount to be charged via payment gateway (total minus auto-applied discount) - /// - private long GatewayAmount => DiscountCart.TotalPrice - MaxUsable; - private bool CanPlaceOrder => DiscountCart.Items.Count > 0 && _selectedAddress is not null; protected override async Task OnInitializedAsync() { await DiscountCart.EnsureInitializedAsync(); - - var addressTask = LoadAddresses(); - var balanceTask = LoadDiscountBalance(); - await Task.WhenAll(addressTask, balanceTask); - } - - private async Task LoadDiscountBalance() - { - try - { - var balances = await WalletService.GetBalancesAsync(); - _discountBalance = balances.DiscountBalance; - } - catch - { - _discountBalance = 0; - } + await LoadAddresses(); } private async Task LoadAddresses() @@ -98,10 +65,10 @@ public partial class Checkout _placing = true; try { - // Always use maximum possible discount (100%) + // Always use 100% discount — send full price, server will apply max from wallet var result = await DiscountOrderService.PlaceOrderAsync( _selectedAddress.Id, - MaxUsable, + DiscountCart.TotalPrice, _notes); if (!result.Success)