fix: remove discount balance UI entirely — 100% discount auto-applied by server
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -52,55 +52,6 @@
|
||||
}
|
||||
</MudPaper>
|
||||
|
||||
<!-- 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>
|
||||
</MudStack>
|
||||
|
||||
<MudStack Spacing="2">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Class="flex-wrap">
|
||||
<MudText Typo="Typo.body2">موجودی کیف تخفیفی شما:</MudText>
|
||||
<MudText Typo="Typo.subtitle1" Color="Color.Secondary" Class="fw-bold">
|
||||
@FormatPrice(_discountBalance) تومان
|
||||
</MudText>
|
||||
</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">
|
||||
<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>
|
||||
</MudPaper>
|
||||
|
||||
<!-- Notes -->
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.h6" Class="mb-2">توضیحات سفارش</MudText>
|
||||
@@ -149,30 +100,15 @@
|
||||
|
||||
<MudStack Spacing="1">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||
<MudText Typo="Typo.body2">جمع کل:</MudText>
|
||||
<MudText Typo="Typo.body2">@FormatPrice(DiscountCart.TotalPrice)</MudText>
|
||||
</MudStack>
|
||||
|
||||
@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(MaxUsable)-</MudText>
|
||||
</MudStack>
|
||||
}
|
||||
|
||||
<MudDivider Class="my-1" />
|
||||
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||
<MudText Typo="Typo.subtitle1" Class="fw-bold">پرداخت از درگاه:</MudText>
|
||||
<MudText Typo="Typo.subtitle1" Class="fw-bold">جمع کل:</MudText>
|
||||
<MudText Typo="Typo.subtitle1" Color="Color.Primary" Class="fw-bold">
|
||||
@FormatPrice(GatewayAmount) تومان
|
||||
@FormatPrice(DiscountCart.TotalPrice) تومان
|
||||
</MudText>
|
||||
</MudStack>
|
||||
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||
مالیات بر ارزش افزوده صرفاً بر مبلغ درگاه محاسبه خواهد شد.
|
||||
</MudText>
|
||||
<MudAlert Severity="Severity.Success" Variant="Variant.Text" Dense="true" Class="mt-1">
|
||||
تخفیف ۱۰۰٪ از کیف تخفیفی اعمال میشود.
|
||||
</MudAlert>
|
||||
</MudStack>
|
||||
|
||||
<MudButton Disabled="@(!CanPlaceOrder || _placing)" Class="mt-3 w-100-mobile"
|
||||
|
||||
@@ -15,48 +15,15 @@ public partial class Checkout
|
||||
private CustomerAddressModel? _selectedAddress;
|
||||
private bool _loadingAddresses;
|
||||
|
||||
private long _discountBalance;
|
||||
private string? _notes;
|
||||
private bool _placing;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum discount allowed based on cart items' MaxDiscountPercent
|
||||
/// </summary>
|
||||
private long MaxAllowedDiscount => DiscountCart.TotalDiscount;
|
||||
|
||||
/// <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 (total minus auto-applied discount)
|
||||
/// </summary>
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user