From 1dc60faf4a3ee040968d46ba919d0f964045ebb1 Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Mon, 16 Feb 2026 21:52:21 +0330 Subject: [PATCH] =?UTF-8?q?feat:=20force=20100%=20discount=20=E2=80=94=20r?= =?UTF-8?q?emove=20slider,=20auto-apply=20max=20discount=20from=20wallet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove MudSlider and MudNumericField from Checkout - Auto-apply MaxUsable (full discount balance) - Show fixed '100% تخفیفی' badge on Products, Cart, ProductDetail, Checkout - GatewayAmount = TotalPrice - MaxUsable (no user choice) --- .../Pages/DiscountStore/Cart.razor | 4 +- .../Pages/DiscountStore/Checkout.razor | 71 +++++++++---------- .../Pages/DiscountStore/Checkout.razor.cs | 15 ++-- .../Pages/DiscountStore/ProductDetail.razor | 15 ++-- .../Pages/DiscountStore/Products.razor | 11 ++- 5 files changed, 50 insertions(+), 66 deletions(-) diff --git a/src/FrontOffice.Main/Pages/DiscountStore/Cart.razor b/src/FrontOffice.Main/Pages/DiscountStore/Cart.razor index 72f705b..2df1155 100644 --- a/src/FrontOffice.Main/Pages/DiscountStore/Cart.razor +++ b/src/FrontOffice.Main/Pages/DiscountStore/Cart.razor @@ -40,7 +40,7 @@ @FormatPrice(context.UnitPrice) - تا @context.MaxDiscountPercent% + ۱۰۰٪ تخفیفی @@ -86,7 +86,7 @@ @item.Title - تا @item.MaxDiscountPercent% + ۱۰۰٪ تخفیفی diff --git a/src/FrontOffice.Main/Pages/DiscountStore/Checkout.razor b/src/FrontOffice.Main/Pages/DiscountStore/Checkout.razor index 41b664a..647a7de 100644 --- a/src/FrontOffice.Main/Pages/DiscountStore/Checkout.razor +++ b/src/FrontOffice.Main/Pages/DiscountStore/Checkout.razor @@ -52,11 +52,11 @@ } - + - پرداخت از کیف تخفیفی + تخفیف کیف تخفیفی @@ -67,37 +67,35 @@ - - سقف مجاز تخفیف روی این سفارش: - - @FormatPrice(MaxAllowedDiscount) تومان - - - - - - - مبلغی که از کیف تخفیفی کسر شود (باقیمانده از درگاه پرداخت می‌شود): - - - - استفاده از @FormatPrice(_discountBalanceToUse) تومان - - - - - @if (_discountBalanceToUse > 0) + @if (MaxUsable > 0) { - - مبلغ @FormatPrice(_discountBalanceToUse) تومان از کیف تخفیفی کسر و - مبلغ @FormatPrice(GatewayAmount) تومان از درگاه پرداخت دریافت خواهد شد. + + + مبلغ تخفیف اعمال‌شده: + + @FormatPrice(MaxUsable) تومان + + + + + @if (GatewayAmount > 0) + { + + مبلغ @FormatPrice(MaxUsable) تومان از کیف تخفیفی کسر و + مبلغ @FormatPrice(GatewayAmount) تومان از درگاه پرداخت دریافت خواهد شد. + + } + else + { + + کل مبلغ سفارش از کیف تخفیفی پرداخت خواهد شد. + + } + } + else + { + + موجودی کیف تخفیفی شما کافی نیست. کل مبلغ از درگاه پرداخت دریافت خواهد شد. } @@ -139,10 +137,7 @@ @item.Quantity × @FormatPrice(item.UnitPrice) - @if (item.MaxDiscountPercent > 0) - { - تا @item.MaxDiscountPercent% تخفیف - } + ۱۰۰٪ تخفیفی @@ -158,11 +153,11 @@ @FormatPrice(DiscountCart.TotalPrice) - @if (_discountBalanceToUse > 0) + @if (MaxUsable > 0) { از کیف تخفیفی: - @FormatPrice(_discountBalanceToUse)- + @FormatPrice(MaxUsable)- } diff --git a/src/FrontOffice.Main/Pages/DiscountStore/Checkout.razor.cs b/src/FrontOffice.Main/Pages/DiscountStore/Checkout.razor.cs index a7fa826..1dd0751 100644 --- a/src/FrontOffice.Main/Pages/DiscountStore/Checkout.razor.cs +++ b/src/FrontOffice.Main/Pages/DiscountStore/Checkout.razor.cs @@ -16,7 +16,6 @@ public partial class Checkout private bool _loadingAddresses; private long _discountBalance; - private long _discountBalanceToUse; private string? _notes; private bool _placing; @@ -27,13 +26,14 @@ public partial class Checkout /// /// 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 + /// Amount to be charged via payment gateway (total minus auto-applied discount) /// - private long GatewayAmount => DiscountCart.TotalPrice - _discountBalanceToUse; + private long GatewayAmount => DiscountCart.TotalPrice - MaxUsable; private bool CanPlaceOrder => DiscountCart.Items.Count > 0 && _selectedAddress is not null; @@ -44,9 +44,6 @@ public partial class Checkout var addressTask = LoadAddresses(); var balanceTask = LoadDiscountBalance(); await Task.WhenAll(addressTask, balanceTask); - - // Default: use maximum possible discount - _discountBalanceToUse = MaxUsable; } private async Task LoadDiscountBalance() @@ -101,12 +98,10 @@ public partial class Checkout _placing = true; try { - // Clamp the discount balance to use - var discountToUse = Math.Min(_discountBalanceToUse, MaxUsable); - + // Always use maximum possible discount (100%) var result = await DiscountOrderService.PlaceOrderAsync( _selectedAddress.Id, - discountToUse, + MaxUsable, _notes); if (!result.Success) diff --git a/src/FrontOffice.Main/Pages/DiscountStore/ProductDetail.razor b/src/FrontOffice.Main/Pages/DiscountStore/ProductDetail.razor index fcabe1d..2f031e4 100644 --- a/src/FrontOffice.Main/Pages/DiscountStore/ProductDetail.razor +++ b/src/FrontOffice.Main/Pages/DiscountStore/ProductDetail.razor @@ -71,15 +71,12 @@ @($"{_product.Price:N0}") تومان - @if (_product.MaxDiscountPercent > 0) - { - - سقف پرداخت از کیف تخفیفی: - - تا @_product.MaxDiscountPercent% (تا @($"{_product.Price * _product.MaxDiscountPercent / 100:N0}") تومان) - - - } + + قابل پرداخت از کیف تخفیفی: + + ۱۰۰٪ تخفیفی (@($"{_product.Price:N0}") تومان) + + diff --git a/src/FrontOffice.Main/Pages/DiscountStore/Products.razor b/src/FrontOffice.Main/Pages/DiscountStore/Products.razor index 7312608..4b996a1 100644 --- a/src/FrontOffice.Main/Pages/DiscountStore/Products.razor +++ b/src/FrontOffice.Main/Pages/DiscountStore/Products.razor @@ -93,13 +93,10 @@ فقط @p.RemainingCount عدد } - @if (p.MaxDiscountPercent > 0) - { - - تا @p.MaxDiscountPercent% تخفیف - - } + + ۱۰۰٪ تخفیفی +
@p.Title