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>@FormatPrice(context.UnitPrice)</MudTd>
|
||||||
<MudTd>
|
<MudTd>
|
||||||
<MudChip T="string" Color="Color.Error" Variant="Variant.Outlined" Size="Size.Small">
|
<MudChip T="string" Color="Color.Error" Variant="Variant.Outlined" Size="Size.Small">
|
||||||
تا @context.MaxDiscountPercent%
|
۱۰۰٪ تخفیفی
|
||||||
</MudChip>
|
</MudChip>
|
||||||
</MudTd>
|
</MudTd>
|
||||||
<MudTd>
|
<MudTd>
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
<MudText Typo="Typo.subtitle2">@item.Title</MudText>
|
<MudText Typo="Typo.subtitle2">@item.Title</MudText>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
<MudChip T="string" Color="Color.Error" Variant="Variant.Outlined" Size="Size.Small">
|
<MudChip T="string" Color="Color.Error" Variant="Variant.Outlined" Size="Size.Small">
|
||||||
تا @item.MaxDiscountPercent%
|
۱۰۰٪ تخفیفی
|
||||||
</MudChip>
|
</MudChip>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
|
|||||||
@@ -52,11 +52,11 @@
|
|||||||
}
|
}
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
|
|
||||||
<!-- Discount Balance (Hybrid Payment) -->
|
<!-- Discount Balance (Auto Applied) -->
|
||||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg mb-3">
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg mb-3">
|
||||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center" Class="mb-3">
|
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center" Class="mb-3">
|
||||||
<MudIcon Icon="@Icons.Material.Filled.Loyalty" Color="Color.Secondary" />
|
<MudIcon Icon="@Icons.Material.Filled.Loyalty" Color="Color.Secondary" />
|
||||||
<MudText Typo="Typo.h6">پرداخت از کیف تخفیفی</MudText>
|
<MudText Typo="Typo.h6">تخفیف کیف تخفیفی</MudText>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
<MudStack Spacing="2">
|
<MudStack Spacing="2">
|
||||||
@@ -67,39 +67,37 @@
|
|||||||
</MudText>
|
</MudText>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
|
@if (MaxUsable > 0)
|
||||||
|
{
|
||||||
|
<MudAlert Severity="Severity.Success" Variant="Variant.Outlined" Dense="true">
|
||||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Class="flex-wrap">
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Class="flex-wrap">
|
||||||
<MudText Typo="Typo.body2">سقف مجاز تخفیف روی این سفارش:</MudText>
|
<MudText Typo="Typo.body2">مبلغ تخفیف اعمالشده:</MudText>
|
||||||
<MudText Typo="Typo.subtitle2" Color="Color.Success">
|
<MudText Typo="Typo.subtitle1" Color="Color.Success" Class="fw-bold">
|
||||||
@FormatPrice(MaxAllowedDiscount) تومان
|
@FormatPrice(MaxUsable) تومان
|
||||||
</MudText>
|
</MudText>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
</MudAlert>
|
||||||
|
|
||||||
<MudDivider />
|
@if (GatewayAmount > 0)
|
||||||
|
|
||||||
<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)
|
|
||||||
{
|
{
|
||||||
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined" Dense="true">
|
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined" Dense="true">
|
||||||
مبلغ @FormatPrice(_discountBalanceToUse) تومان از کیف تخفیفی کسر و
|
مبلغ @FormatPrice(MaxUsable) تومان از کیف تخفیفی کسر و
|
||||||
مبلغ @FormatPrice(GatewayAmount) تومان از درگاه پرداخت دریافت خواهد شد.
|
مبلغ @FormatPrice(GatewayAmount) تومان از درگاه پرداخت دریافت خواهد شد.
|
||||||
</MudAlert>
|
</MudAlert>
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<MudAlert Severity="Severity.Success" Variant="Variant.Outlined" Dense="true">
|
||||||
|
کل مبلغ سفارش از کیف تخفیفی پرداخت خواهد شد.
|
||||||
|
</MudAlert>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<MudAlert Severity="Severity.Warning" Variant="Variant.Outlined" Dense="true">
|
||||||
|
موجودی کیف تخفیفی شما کافی نیست. کل مبلغ از درگاه پرداخت دریافت خواهد شد.
|
||||||
|
</MudAlert>
|
||||||
|
}
|
||||||
</MudStack>
|
</MudStack>
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
|
|
||||||
@@ -139,10 +137,7 @@
|
|||||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||||
@item.Quantity × @FormatPrice(item.UnitPrice)
|
@item.Quantity × @FormatPrice(item.UnitPrice)
|
||||||
</MudText>
|
</MudText>
|
||||||
@if (item.MaxDiscountPercent > 0)
|
<MudText Typo="Typo.caption" Color="Color.Error">۱۰۰٪ تخفیفی</MudText>
|
||||||
{
|
|
||||||
<MudText Typo="Typo.caption" Color="Color.Error">تا @item.MaxDiscountPercent% تخفیف</MudText>
|
|
||||||
}
|
|
||||||
</MudStack>
|
</MudStack>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
</MudListItemText>
|
</MudListItemText>
|
||||||
@@ -158,11 +153,11 @@
|
|||||||
<MudText Typo="Typo.body2">@FormatPrice(DiscountCart.TotalPrice)</MudText>
|
<MudText Typo="Typo.body2">@FormatPrice(DiscountCart.TotalPrice)</MudText>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
@if (_discountBalanceToUse > 0)
|
@if (MaxUsable > 0)
|
||||||
{
|
{
|
||||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||||
<MudText Typo="Typo.body2" Color="Color.Success">از کیف تخفیفی:</MudText>
|
<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>
|
</MudStack>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ public partial class Checkout
|
|||||||
private bool _loadingAddresses;
|
private bool _loadingAddresses;
|
||||||
|
|
||||||
private long _discountBalance;
|
private long _discountBalance;
|
||||||
private long _discountBalanceToUse;
|
|
||||||
private string? _notes;
|
private string? _notes;
|
||||||
private bool _placing;
|
private bool _placing;
|
||||||
|
|
||||||
@@ -27,13 +26,14 @@ public partial class Checkout
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Maximum the user can actually use = min(balance, allowed discount)
|
/// Maximum the user can actually use = min(balance, allowed discount)
|
||||||
|
/// Always applied at 100% — no user selection
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private long MaxUsable => Math.Min(_discountBalance, MaxAllowedDiscount);
|
private long MaxUsable => Math.Min(_discountBalance, MaxAllowedDiscount);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Amount to be charged via payment gateway
|
/// Amount to be charged via payment gateway (total minus auto-applied discount)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private long GatewayAmount => DiscountCart.TotalPrice - _discountBalanceToUse;
|
private long GatewayAmount => DiscountCart.TotalPrice - MaxUsable;
|
||||||
|
|
||||||
private bool CanPlaceOrder => DiscountCart.Items.Count > 0 && _selectedAddress is not null;
|
private bool CanPlaceOrder => DiscountCart.Items.Count > 0 && _selectedAddress is not null;
|
||||||
|
|
||||||
@@ -44,9 +44,6 @@ public partial class Checkout
|
|||||||
var addressTask = LoadAddresses();
|
var addressTask = LoadAddresses();
|
||||||
var balanceTask = LoadDiscountBalance();
|
var balanceTask = LoadDiscountBalance();
|
||||||
await Task.WhenAll(addressTask, balanceTask);
|
await Task.WhenAll(addressTask, balanceTask);
|
||||||
|
|
||||||
// Default: use maximum possible discount
|
|
||||||
_discountBalanceToUse = MaxUsable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task LoadDiscountBalance()
|
private async Task LoadDiscountBalance()
|
||||||
@@ -101,12 +98,10 @@ public partial class Checkout
|
|||||||
_placing = true;
|
_placing = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Clamp the discount balance to use
|
// Always use maximum possible discount (100%)
|
||||||
var discountToUse = Math.Min(_discountBalanceToUse, MaxUsable);
|
|
||||||
|
|
||||||
var result = await DiscountOrderService.PlaceOrderAsync(
|
var result = await DiscountOrderService.PlaceOrderAsync(
|
||||||
_selectedAddress.Id,
|
_selectedAddress.Id,
|
||||||
discountToUse,
|
MaxUsable,
|
||||||
_notes);
|
_notes);
|
||||||
|
|
||||||
if (!result.Success)
|
if (!result.Success)
|
||||||
|
|||||||
@@ -71,15 +71,12 @@
|
|||||||
@($"{_product.Price:N0}") تومان
|
@($"{_product.Price:N0}") تومان
|
||||||
</MudText>
|
</MudText>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
@if (_product.MaxDiscountPercent > 0)
|
|
||||||
{
|
|
||||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">سقف پرداخت از کیف تخفیفی:</MudText>
|
<MudText Typo="Typo.body2" Class="mud-text-secondary">قابل پرداخت از کیف تخفیفی:</MudText>
|
||||||
<MudChip T="string" Color="Color.Error" Variant="Variant.Filled" Size="Size.Small">
|
<MudChip T="string" Color="Color.Error" Variant="Variant.Filled" Size="Size.Small">
|
||||||
تا @_product.MaxDiscountPercent% (تا @($"{_product.Price * _product.MaxDiscountPercent / 100:N0}") تومان)
|
۱۰۰٪ تخفیفی (@($"{_product.Price:N0}") تومان)
|
||||||
</MudChip>
|
</MudChip>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
}
|
|
||||||
</MudStack>
|
</MudStack>
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
|
|
||||||
|
|||||||
@@ -93,13 +93,10 @@
|
|||||||
فقط @p.RemainingCount عدد
|
فقط @p.RemainingCount عدد
|
||||||
</MudChip>
|
</MudChip>
|
||||||
}
|
}
|
||||||
@if (p.MaxDiscountPercent > 0)
|
|
||||||
{
|
|
||||||
<MudChip T="string" Color="Color.Error" Variant="Variant.Filled" Size="Size.Small"
|
<MudChip T="string" Color="Color.Error" Variant="Variant.Filled" Size="Size.Small"
|
||||||
Style="position:absolute;top:8px;left:8px;">
|
Style="position:absolute;top:8px;left:8px;">
|
||||||
تا @p.MaxDiscountPercent% تخفیف
|
۱۰۰٪ تخفیفی
|
||||||
</MudChip>
|
</MudChip>
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="pa-1 flex-grow-1 d-flex flex-column justify-space-between">
|
<div class="pa-1 flex-grow-1 d-flex flex-column justify-space-between">
|
||||||
<MudText Typo="Typo.subtitle1">@p.Title</MudText>
|
<MudText Typo="Typo.subtitle1">@p.Title</MudText>
|
||||||
|
|||||||
Reference in New Issue
Block a user