feat: force 100% discount — remove slider, auto-apply max discount from wallet
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
- 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)
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
<MudTd>@FormatPrice(context.UnitPrice)</MudTd>
|
||||
<MudTd>
|
||||
<MudChip T="string" Color="Color.Error" Variant="Variant.Outlined" Size="Size.Small">
|
||||
تا @context.MaxDiscountPercent%
|
||||
۱۰۰٪ تخفیفی
|
||||
</MudChip>
|
||||
</MudTd>
|
||||
<MudTd>
|
||||
@@ -86,7 +86,7 @@
|
||||
<MudText Typo="Typo.subtitle2">@item.Title</MudText>
|
||||
</MudStack>
|
||||
<MudChip T="string" Color="Color.Error" Variant="Variant.Outlined" Size="Size.Small">
|
||||
تا @item.MaxDiscountPercent%
|
||||
۱۰۰٪ تخفیفی
|
||||
</MudChip>
|
||||
</MudStack>
|
||||
|
||||
|
||||
@@ -52,11 +52,11 @@
|
||||
}
|
||||
</MudPaper>
|
||||
|
||||
<!-- Discount Balance (Hybrid Payment) -->
|
||||
<!-- Discount Balance (Auto Applied) -->
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg mb-3">
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center" Class="mb-3">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Loyalty" Color="Color.Secondary" />
|
||||
<MudText Typo="Typo.h6">پرداخت از کیف تخفیفی</MudText>
|
||||
<MudText Typo="Typo.h6">تخفیف کیف تخفیفی</MudText>
|
||||
</MudStack>
|
||||
|
||||
<MudStack Spacing="2">
|
||||
@@ -67,37 +67,35 @@
|
||||
</MudText>
|
||||
</MudStack>
|
||||
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Class="flex-wrap">
|
||||
<MudText Typo="Typo.body2">سقف مجاز تخفیف روی این سفارش:</MudText>
|
||||
<MudText Typo="Typo.subtitle2" Color="Color.Success">
|
||||
@FormatPrice(MaxAllowedDiscount) تومان
|
||||
</MudText>
|
||||
</MudStack>
|
||||
|
||||
<MudDivider />
|
||||
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">
|
||||
مبلغی که از کیف تخفیفی کسر شود (باقیمانده از درگاه پرداخت میشود):
|
||||
</MudText>
|
||||
|
||||
<MudSlider T="long" @bind-Value="_discountBalanceToUse"
|
||||
Min="0" Max="@MaxUsable"
|
||||
Step="1000"
|
||||
Color="Color.Secondary"
|
||||
Immediate="true">
|
||||
استفاده از @FormatPrice(_discountBalanceToUse) تومان
|
||||
</MudSlider>
|
||||
|
||||
<MudNumericField T="long" @bind-Value="_discountBalanceToUse"
|
||||
Min="0" Max="@MaxUsable"
|
||||
Label="مبلغ دلخواه (تومان)" Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense" Immediate="true" />
|
||||
|
||||
@if (_discountBalanceToUse > 0)
|
||||
@if (MaxUsable > 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined" Dense="true">
|
||||
مبلغ @FormatPrice(_discountBalanceToUse) تومان از کیف تخفیفی کسر و
|
||||
مبلغ @FormatPrice(GatewayAmount) تومان از درگاه پرداخت دریافت خواهد شد.
|
||||
<MudAlert Severity="Severity.Success" Variant="Variant.Outlined" Dense="true">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Class="flex-wrap">
|
||||
<MudText Typo="Typo.body2">مبلغ تخفیف اعمالشده:</MudText>
|
||||
<MudText Typo="Typo.subtitle1" Color="Color.Success" Class="fw-bold">
|
||||
@FormatPrice(MaxUsable) تومان
|
||||
</MudText>
|
||||
</MudStack>
|
||||
</MudAlert>
|
||||
|
||||
@if (GatewayAmount > 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined" Dense="true">
|
||||
مبلغ @FormatPrice(MaxUsable) تومان از کیف تخفیفی کسر و
|
||||
مبلغ @FormatPrice(GatewayAmount) تومان از درگاه پرداخت دریافت خواهد شد.
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudAlert Severity="Severity.Success" Variant="Variant.Outlined" Dense="true">
|
||||
کل مبلغ سفارش از کیف تخفیفی پرداخت خواهد شد.
|
||||
</MudAlert>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Variant="Variant.Outlined" Dense="true">
|
||||
موجودی کیف تخفیفی شما کافی نیست. کل مبلغ از درگاه پرداخت دریافت خواهد شد.
|
||||
</MudAlert>
|
||||
}
|
||||
</MudStack>
|
||||
@@ -139,10 +137,7 @@
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||
@item.Quantity × @FormatPrice(item.UnitPrice)
|
||||
</MudText>
|
||||
@if (item.MaxDiscountPercent > 0)
|
||||
{
|
||||
<MudText Typo="Typo.caption" Color="Color.Error">تا @item.MaxDiscountPercent% تخفیف</MudText>
|
||||
}
|
||||
<MudText Typo="Typo.caption" Color="Color.Error">۱۰۰٪ تخفیفی</MudText>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</MudListItemText>
|
||||
@@ -158,11 +153,11 @@
|
||||
<MudText Typo="Typo.body2">@FormatPrice(DiscountCart.TotalPrice)</MudText>
|
||||
</MudStack>
|
||||
|
||||
@if (_discountBalanceToUse > 0)
|
||||
@if (MaxUsable > 0)
|
||||
{
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||
<MudText Typo="Typo.body2" Color="Color.Success">از کیف تخفیفی:</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Success">@FormatPrice(_discountBalanceToUse)-</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Success">@FormatPrice(MaxUsable)-</MudText>
|
||||
</MudStack>
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
/// <summary>
|
||||
/// Maximum the user can actually use = min(balance, allowed discount)
|
||||
/// Always applied at 100% — no user selection
|
||||
/// </summary>
|
||||
private long MaxUsable => Math.Min(_discountBalance, MaxAllowedDiscount);
|
||||
|
||||
/// <summary>
|
||||
/// Amount to be charged via payment gateway
|
||||
/// Amount to be charged via payment gateway (total minus auto-applied discount)
|
||||
/// </summary>
|
||||
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)
|
||||
|
||||
@@ -71,15 +71,12 @@
|
||||
@($"{_product.Price:N0}") تومان
|
||||
</MudText>
|
||||
</MudStack>
|
||||
@if (_product.MaxDiscountPercent > 0)
|
||||
{
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">سقف پرداخت از کیف تخفیفی:</MudText>
|
||||
<MudChip T="string" Color="Color.Error" Variant="Variant.Filled" Size="Size.Small">
|
||||
تا @_product.MaxDiscountPercent% (تا @($"{_product.Price * _product.MaxDiscountPercent / 100:N0}") تومان)
|
||||
</MudChip>
|
||||
</MudStack>
|
||||
}
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">قابل پرداخت از کیف تخفیفی:</MudText>
|
||||
<MudChip T="string" Color="Color.Error" Variant="Variant.Filled" Size="Size.Small">
|
||||
۱۰۰٪ تخفیفی (@($"{_product.Price:N0}") تومان)
|
||||
</MudChip>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
|
||||
|
||||
@@ -93,13 +93,10 @@
|
||||
فقط @p.RemainingCount عدد
|
||||
</MudChip>
|
||||
}
|
||||
@if (p.MaxDiscountPercent > 0)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Error" Variant="Variant.Filled" Size="Size.Small"
|
||||
Style="position:absolute;top:8px;left:8px;">
|
||||
تا @p.MaxDiscountPercent% تخفیف
|
||||
</MudChip>
|
||||
}
|
||||
<MudChip T="string" Color="Color.Error" Variant="Variant.Filled" Size="Size.Small"
|
||||
Style="position:absolute;top:8px;left:8px;">
|
||||
۱۰۰٪ تخفیفی
|
||||
</MudChip>
|
||||
</div>
|
||||
<div class="pa-1 flex-grow-1 d-flex flex-column justify-space-between">
|
||||
<MudText Typo="Typo.subtitle1">@p.Title</MudText>
|
||||
|
||||
Reference in New Issue
Block a user