Update order system with new gRPC services and wallet integration
This commit is contained in:
@@ -10,71 +10,166 @@
|
||||
@if (CartData.Items.Count == 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info">سبد خرید شما خالی است.</MudAlert>
|
||||
<MudButton Variant="Variant.Outlined" StartIcon="@Icons.Material.Filled.ArrowBack" OnClick="() => Navigation.NavigateTo(RouteConstants.Store.Products)">بازگشت به محصولات</MudButton>
|
||||
<MudButton Variant="Variant.Outlined" StartIcon="@Icons.Material.Filled.ArrowBack"
|
||||
OnClick="() => Navigation.NavigateTo(RouteConstants.Store.Products)">بازگشت به محصولات
|
||||
</MudButton>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudHidden Breakpoint="Breakpoint.MdAndUp" Invert="true">
|
||||
<MudPaper Elevation="1" Class="pa-4 rounded-lg">
|
||||
<MudTable Items="CartData.Items">
|
||||
<HeaderContent>
|
||||
<MudTh>محصول</MudTh>
|
||||
<MudTh>قیمت واحد</MudTh>
|
||||
<MudTh>تعداد</MudTh>
|
||||
<MudTh>قیمت کل</MudTh>
|
||||
<MudTh></MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd>
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudAvatar Image="@context.ImageUrl" Size="Size.Medium" />
|
||||
<MudText>@context.Title</MudText>
|
||||
</MudStack>
|
||||
</MudTd>
|
||||
<MudTd>@FormatPrice(context.UnitPrice)</MudTd>
|
||||
<MudTd>
|
||||
<MudNumericField T="int" Value="@context.Quantity" Min="1" Max="50" Immediate="true" HideSpinButtons="true" ValueChanged="(v) => ChangeQty(context.ProductId, v)" Style="max-width:120px" />
|
||||
</MudTd>
|
||||
<MudTd>@FormatPrice(context.LineTotal)</MudTd>
|
||||
<MudTd>
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Color="Color.Error" OnClick="() => Remove(context.ProductId)" />
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
</MudPaper>
|
||||
<MudPaper Elevation="1" Class="pa-4 rounded-lg">
|
||||
<MudTable Items="CartData.Items">
|
||||
<HeaderContent>
|
||||
<MudTh>محصول</MudTh>
|
||||
<MudTh>قیمت واحد</MudTh>
|
||||
<MudTh>تعداد</MudTh>
|
||||
<MudTh>قیمت کل</MudTh>
|
||||
<MudTh></MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd>
|
||||
<MudStack Spacing="1">
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudAvatar Image="@context.ImageUrl" Size="Size.Medium"/>
|
||||
<MudText>@context.Title</MudText>
|
||||
</MudStack>
|
||||
@if (context.Discount > 0 || !string.IsNullOrWhiteSpace(context.Created) || !string.IsNullOrWhiteSpace(context.Description))
|
||||
{
|
||||
<MudStack Spacing="1">
|
||||
@if (context.Discount > 0)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Error" Variant="Variant.Outlined"
|
||||
Size="Size.Small">@($"{context.Discount}% تخفیف")</MudChip>
|
||||
}
|
||||
@if (!string.IsNullOrWhiteSpace(context.Description))
|
||||
{
|
||||
<MudText Typo="Typo.caption"
|
||||
Class="mud-text-secondary">@context.Description</MudText>
|
||||
}
|
||||
@if (!string.IsNullOrWhiteSpace(context.Created))
|
||||
{
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">تاریخ
|
||||
افزودن: @context.Created</MudText>
|
||||
}
|
||||
</MudStack>
|
||||
}
|
||||
</MudStack>
|
||||
</MudTd>
|
||||
<MudTd>@FormatPrice(context.UnitPrice)</MudTd>
|
||||
<MudTd>
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Remove"
|
||||
Color="Color.Default"
|
||||
OnClick="@(() => DecrementQty(context.ProductId))"/>
|
||||
<MudText>@context.Quantity</MudText>
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Add"
|
||||
Color="Color.Default"
|
||||
OnClick="@(() => IncrementQty(context.ProductId))"/>
|
||||
</MudStack>
|
||||
</MudTd>
|
||||
<MudTd>@FormatPrice(context.LineTotal)</MudTd>
|
||||
<MudTd>
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Color="Color.Error"
|
||||
OnClick="() => Remove(context.cartId)"/>
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
</MudPaper>
|
||||
</MudHidden>
|
||||
|
||||
<MudHidden Breakpoint="Breakpoint.MdAndUp">
|
||||
<MudStack Spacing="2">
|
||||
@foreach (var item in CartData.Items)
|
||||
{
|
||||
<MudPaper Class="pa-3 rounded-lg" Outlined="true">
|
||||
<MudPaper Class="pa-3 rounded-lg w-100-mobile" Outlined="true">
|
||||
<MudStack Spacing="1">
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudAvatar Image="@item.ImageUrl" />
|
||||
<MudText Typo="Typo.subtitle2">@item.Title</MudText>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Class="mud-text-secondary">@FormatPrice(item.UnitPrice) واحد</MudText>
|
||||
<MudNumericField T="int" Value="@item.Quantity" Min="1" Max="50" Immediate="true" HideSpinButtons="true" ValueChanged="(v) => ChangeQty(item.ProductId, v)" Class="qty-input" />
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudAvatar Image="@item.ImageUrl"/>
|
||||
<MudText Typo="Typo.subtitle2">@item.Title</MudText>
|
||||
</MudStack>
|
||||
@if (item.Discount > 0)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Error" Variant="Variant.Outlined"
|
||||
Size="Size.Small">@($"{item.Discount}% ")</MudChip>
|
||||
}
|
||||
</MudStack>
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText>جمع: @FormatPrice(item.LineTotal)</MudText>
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Color="Color.Error" OnClick="() => Remove(item.ProductId)" />
|
||||
|
||||
@if (item.Discount > 0 || !string.IsNullOrWhiteSpace(item.Created) || !string.IsNullOrWhiteSpace(item.Description))
|
||||
{
|
||||
<MudStack Spacing="1">
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(item.Description))
|
||||
{
|
||||
<MudText Typo="Typo.caption"
|
||||
Class="mud-text-secondary">@item.Description</MudText>
|
||||
}
|
||||
@* @if (!string.IsNullOrWhiteSpace(item.Created)) *@
|
||||
@* { *@
|
||||
@* <MudText Typo="Typo.caption" Class="mud-text-secondary">تاریخ افزودن: @item.Created</MudText> *@
|
||||
@* } *@
|
||||
</MudStack>
|
||||
}
|
||||
|
||||
<MudStack Spacing="1">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Class="mud-text-secondary">@FormatPrice(item.UnitPrice) واحد</MudText>
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
|
||||
<MudIconButton
|
||||
Icon="@(item.Quantity <= 1 ? Icons.Material.Filled.Delete : Icons.Material.Filled.Remove)"
|
||||
Color="Color.Default"
|
||||
OnClick="@(() => DecrementQty(item.ProductId))"/>
|
||||
<MudText>@item.Quantity</MudText>
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Add"
|
||||
Color="Color.Default"
|
||||
OnClick="@(() => IncrementQty(item.ProductId))"/>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText>جمع: @FormatPrice(item.LineTotal)</MudText>
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete"
|
||||
Color="Color.Error"
|
||||
OnClick="() => Remove(item.cartId)"/>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
}
|
||||
</MudStack>
|
||||
</MudHidden>
|
||||
@if (DeviceDetector.IsMobile())
|
||||
{
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center"
|
||||
Class="mobile-actions-stack px-5">
|
||||
<MudText Typo="Typo.subtitle2"> تخفیف کل: <b>@FormatPrice(CartData.TotalDiscount)</b></MudText>
|
||||
<MudText Typo="Typo.h5"> مبلغ کل: <b>@FormatPrice(CartData.Total)</b></MudText>
|
||||
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Class="mobile-actions-stack">
|
||||
<MudText Typo="Typo.h6">مبلغ قابل پرداخت: <b>@FormatPrice(CartData.Total)</b></MudText>
|
||||
<MudStack Row="true" Spacing="2" Class="mobile-actions-stack">
|
||||
<MudButton Variant="Variant.Text" OnClick="() => Navigation.NavigateTo(RouteConstants.Store.Products)">افزودن محصول</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="ProceedCheckout" StartIcon="@Icons.Material.Filled.CreditCard">ادامه فرایند خرید</MudButton>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" Spacing="2" Class="mobile-actions-stack">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary"
|
||||
OnClick="() => Navigation.NavigateTo(RouteConstants.Store.Products)">افزودن محصول
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Success" OnClick="ProceedCheckout"
|
||||
StartIcon="@Icons.Material.Filled.CreditCard">ادامه فرایند خرید
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center"
|
||||
Class="mobile-actions-stack px-5">
|
||||
<MudText Typo="Typo.subtitle2"> تخفیف کل: <b>@FormatPrice(CartData.TotalDiscount)</b></MudText>
|
||||
<MudText Typo="Typo.h5"> مبلغ کل: <b>@FormatPrice(CartData.Total)</b></MudText>
|
||||
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary"
|
||||
OnClick="() => Navigation.NavigateTo(RouteConstants.Store.Products)">افزودن محصول
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Success" OnClick="ProceedCheckout"
|
||||
StartIcon="@Icons.Material.Filled.CreditCard">ادامه فرایند خرید
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
}
|
||||
}
|
||||
</MudStack>
|
||||
</MudContainer>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using System.Linq;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Store;
|
||||
|
||||
@@ -14,14 +15,28 @@ public partial class Cart : ComponentBase, IDisposable
|
||||
CartService.OnChange += StateHasChanged;
|
||||
}
|
||||
|
||||
private async Task IncrementQty(long productId)
|
||||
{
|
||||
var item = CartData.Items.FirstOrDefault(i => i.ProductId == productId);
|
||||
if (item is null) return;
|
||||
await CartService.UpdateQuantity(productId, item.Quantity + 1);
|
||||
}
|
||||
|
||||
private async Task DecrementQty(long productId)
|
||||
{
|
||||
var item = CartData.Items.FirstOrDefault(i => i.ProductId == productId);
|
||||
if (item is null) return;
|
||||
await CartService.UpdateQuantity(productId, item.Quantity - 1);
|
||||
}
|
||||
|
||||
private async Task ChangeQty(long productId, int value)
|
||||
{
|
||||
await CartService.UpdateQuantity(productId, value);
|
||||
}
|
||||
|
||||
private async Task Remove(long productId)
|
||||
private async Task Remove(long cartId)
|
||||
{
|
||||
await CartService.Remove(productId);
|
||||
await CartService.Remove(cartId);
|
||||
}
|
||||
|
||||
private void ProceedCheckout()
|
||||
@@ -29,7 +44,7 @@ public partial class Cart : ComponentBase, IDisposable
|
||||
Navigation.NavigateTo(RouteConstants.Store.CheckoutSummary);
|
||||
}
|
||||
|
||||
private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price);
|
||||
private static string FormatPrice(long price) => string.Format("{0:N0} ", price);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
@using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder
|
||||
@attribute [Route(RouteConstants.Store.CheckoutSummary)]
|
||||
|
||||
<PageTitle>خلاصه خرید</PageTitle>
|
||||
@@ -20,7 +21,7 @@
|
||||
<MudAlert Severity="Severity.Warning">
|
||||
هیچ آدرسی ثبت نشده است. لطفاً از بخش پروفایل آدرس خود را اضافه کنید.
|
||||
</MudAlert>
|
||||
<MudButton Class="mt-2" Variant="Variant.Outlined" Href="/profile">افزودن آدرس</MudButton>
|
||||
<MudButton Class="mt-2" Variant="Variant.Outlined" Href="/profile/addresses">افزودن آدرس</MudButton>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -51,7 +52,15 @@
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.h6" Class="mb-2">روش پرداخت</MudText>
|
||||
<MudRadioGroup T="PaymentMethod" @bind-SelectedOption="_payment" Color="Color.Primary">
|
||||
<MudRadio T="PaymentMethod" Option="@PaymentMethod.Wallet" Color="Color.Primary">کیف پول</MudRadio>
|
||||
<MudRadio T="PaymentMethod" Option="@PaymentMethod.Wallet" Color="Color.Primary">
|
||||
@* <MudText></MudText> *@
|
||||
@* <MudText>20000</MudText> *@
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.subtitle1">کیف پول <b></b></MudText>
|
||||
<MudText Typo="Typo.subtitle2"> @(FormatPrice(walletBalance)) <b></b></MudText>
|
||||
|
||||
</MudStack>
|
||||
</MudRadio>
|
||||
</MudRadioGroup>
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined">در حال حاضر تنها پرداخت از طریق کیف پول فعال است.</MudAlert>
|
||||
</MudPaper>
|
||||
@@ -70,9 +79,15 @@
|
||||
@foreach (var item in Cart.Items)
|
||||
{
|
||||
<MudListItem T="CartItem">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" Class="w-100">
|
||||
<MudText>@item.Title x @item.Quantity</MudText>
|
||||
<MudText>@FormatPrice(item.LineTotal)</MudText>
|
||||
<MudStack Spacing="1" Class="w-100">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||
<MudText>@item.Title x @item.Quantity</MudText>
|
||||
<MudText>@FormatPrice(item.LineTotal)</MudText>
|
||||
</MudStack>
|
||||
@if (item.Discount > 0)
|
||||
{
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@($"تخفیف: {item.Discount}%")</MudText>
|
||||
}
|
||||
</MudStack>
|
||||
</MudListItem>
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress;
|
||||
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
@@ -10,11 +11,13 @@ public partial class CheckoutSummary : ComponentBase
|
||||
[Inject] private CartService Cart { get; set; } = default!;
|
||||
[Inject] private OrderService OrderService { get; set; } = default!;
|
||||
[Inject] private UserAddressContract.UserAddressContractClient UserAddressContract { get; set; } = default!;
|
||||
[Inject] private UserOrderContract.UserOrderContractClient UserOrderContract { get; set; } = default!;
|
||||
// Snackbar and Navigation are injected via _Imports.razor
|
||||
|
||||
private List<GetAllUserAddressByFilterResponseModel> _addresses = new();
|
||||
private GetAllUserAddressByFilterResponseModel? _selectedAddress;
|
||||
private bool _loadingAddresses;
|
||||
private long walletBalance;
|
||||
|
||||
private PaymentMethod _payment = PaymentMethod.Wallet;
|
||||
|
||||
@@ -23,6 +26,13 @@ public partial class CheckoutSummary : ComponentBase
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadAddresses();
|
||||
await LoadWalletBalance();
|
||||
}
|
||||
|
||||
private async Task LoadWalletBalance()
|
||||
{
|
||||
var walletResult = await WalletService.GetBalancesAsync();
|
||||
walletBalance = walletResult.CreditBalance + walletResult.NetworkBalance;
|
||||
}
|
||||
|
||||
private async Task LoadAddresses()
|
||||
@@ -61,21 +71,23 @@ public partial class CheckoutSummary : ComponentBase
|
||||
return;
|
||||
}
|
||||
|
||||
// Simulate wallet payment success and create local order
|
||||
var order = new Order
|
||||
try
|
||||
{
|
||||
Status = OrderStatus.Paid,
|
||||
PaymentMethod = _payment,
|
||||
AddressId = _selectedAddress.Id,
|
||||
AddressSummary = _selectedAddress.Address,
|
||||
Items = Cart.Items.Select(i => new OrderItem(i.ProductId, i.Title, i.ImageUrl, i.UnitPrice, i.Quantity)).ToList()
|
||||
};
|
||||
var request = new SubmitShopBuyOrderRequest
|
||||
{
|
||||
TotalAmount = Cart.Total
|
||||
};
|
||||
|
||||
var id = await OrderService.CreateOrderAsync(order);
|
||||
await Cart.Clear();
|
||||
Snackbar.Add("سفارش با موفقیت ثبت شد.", Severity.Success);
|
||||
Navigation.NavigateTo($"{RouteConstants.Store.OrderDetail}{id}");
|
||||
var response = await UserOrderContract.SubmitShopBuyOrderAsync(request);
|
||||
await Cart.Clear();
|
||||
Snackbar.Add("سفارش با موفقیت ثبت شد.", Severity.Success);
|
||||
Navigation.NavigateTo($"{RouteConstants.Store.OrderDetail}{response.Id}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در ثبت سفارش: {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price);
|
||||
}
|
||||
}
|
||||
@@ -24,13 +24,13 @@ else
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudStack Spacing="2">
|
||||
<MudText Typo="Typo.h5">سفارش #@_order.Id</MudText>
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">تاریخ: @_order.CreatedAt.ToString("yyyy/MM/dd HH:mm")</MudText>
|
||||
<MudText Typo="Typo.body2">وضعیت: @GetStatusText(_order.Status)</MudText>
|
||||
<MudText Typo="Typo.body2">روش پرداخت: کیف پول</MudText>
|
||||
<MudText Typo="Typo.body2">آدرس: @_order.AddressSummary</MudText>
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">تاریخ: @_order.PaymentDate.ToDateTime().MiladiToJalaliWithTime()</MudText>
|
||||
<MudText Typo="Typo.body2">وضعیت: @GetStatusText(_order.PaymentStatus)</MudText>
|
||||
<MudText Typo="Typo.body2">روش پرداخت: @GetPaymentMethodText(_order.PaymentMethod)</MudText>
|
||||
<MudText Typo="Typo.body2">آدرس: @_order.UserAddressText</MudText>
|
||||
<MudDivider Class="my-2" />
|
||||
<MudHidden Breakpoint="Breakpoint.MdAndUp" Invert="true">
|
||||
<MudTable Items="_order.Items">
|
||||
<MudTable Items="_order.FactorDetails">
|
||||
<HeaderContent>
|
||||
<MudTh>محصول</MudTh>
|
||||
<MudTh>قیمت واحد</MudTh>
|
||||
@@ -40,39 +40,39 @@ else
|
||||
<RowTemplate>
|
||||
<MudTd>
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudAvatar Image="@context.ImageUrl" Size="Size.Medium" />
|
||||
<MudText>@context.Title</MudText>
|
||||
<MudAvatar Image="@context.ProductThumbnailPath" Size="Size.Medium" />
|
||||
<MudText>@context.ProductTitle</MudText>
|
||||
</MudStack>
|
||||
</MudTd>
|
||||
<MudTd>@FormatPrice(context.UnitPrice)</MudTd>
|
||||
<MudTd>@context.Quantity</MudTd>
|
||||
<MudTd>@FormatPrice(context.LineTotal)</MudTd>
|
||||
<MudTd>@FormatPrice(context.UnitPrice.Value)</MudTd>
|
||||
<MudTd>@context.Count</MudTd>
|
||||
<MudTd>@FormatPrice(context.UnitPrice.Value*context.Count.Value)</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
</MudHidden>
|
||||
|
||||
<MudHidden Breakpoint="Breakpoint.MdAndUp">
|
||||
<MudStack Spacing="2">
|
||||
@foreach (var it in _order.Items)
|
||||
@foreach (var it in _order.FactorDetails)
|
||||
{
|
||||
<MudPaper Class="pa-3 rounded-lg" Outlined="true">
|
||||
<MudStack Spacing="1">
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudAvatar Image="@it.ImageUrl" />
|
||||
<MudText>@it.Title</MudText>
|
||||
<MudAvatar Image="@it.ProductThumbnailPath" />
|
||||
<MudText>@it.ProductTitle</MudText>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||
<MudText Class="mud-text-secondary">@FormatPrice(it.UnitPrice) واحد</MudText>
|
||||
<MudText>تعداد: @it.Quantity</MudText>
|
||||
<MudText Class="mud-text-secondary">@FormatPrice(it.UnitPrice.Value) واحد</MudText>
|
||||
<MudText>تعداد: @it.Count</MudText>
|
||||
</MudStack>
|
||||
<MudText>جمع: @FormatPrice(it.LineTotal)</MudText>
|
||||
<MudText>جمع: @FormatPrice(it.UnitPrice.Value*it.Count.Value)</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
}
|
||||
</MudStack>
|
||||
</MudHidden>
|
||||
<MudDivider Class="my-2" />
|
||||
<MudText Typo="Typo.h6" Align="Align.End">مبلغ کل: @FormatPrice(_order.Total)</MudText>
|
||||
<MudText Typo="Typo.h6" Align="Align.End">مبلغ کل: @FormatPrice(_order.FactorDetails.Sum(s=>s.UnitPrice.Value*s.Count.Value))</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
</MudContainer>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
@@ -9,7 +10,7 @@ public partial class OrderDetail : ComponentBase
|
||||
|
||||
[Parameter] public long id { get; set; }
|
||||
|
||||
private Order? _order;
|
||||
private GetUserOrderResponse? _order;
|
||||
private bool _loading;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
@@ -20,10 +21,26 @@ public partial class OrderDetail : ComponentBase
|
||||
}
|
||||
|
||||
private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price);
|
||||
private static string GetStatusText(OrderStatus status) => status switch
|
||||
|
||||
private string GetStatusText(PaymentStatus orderPaymentStatus)
|
||||
{
|
||||
OrderStatus.Paid => "پرداختشده",
|
||||
_ => "در انتظار",
|
||||
};
|
||||
return orderPaymentStatus switch
|
||||
{
|
||||
PaymentStatus.Pending => "در انتظار پرداخت",
|
||||
PaymentStatus.Success => "پرداخت شده",
|
||||
PaymentStatus.Reject => "پرداخت ناموفق",
|
||||
_ => "نامشخص",
|
||||
};
|
||||
}
|
||||
|
||||
private string GetPaymentMethodText(PaymentMethod orderPaymentMethod)
|
||||
{
|
||||
return orderPaymentMethod switch
|
||||
{
|
||||
PaymentMethod.Wallet => "کیف پول",
|
||||
PaymentMethod.Ipg => "درگاه پرداخت اینترنتی",
|
||||
_ => "نامشخص",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd>@context.Id</MudTd>
|
||||
<MudTd>@context.CreatedAt.ToString("yyyy/MM/dd HH:mm")</MudTd>
|
||||
<MudTd>@GetStatusText(context.Status)</MudTd>
|
||||
<MudTd>@FormatPrice(context.Total)</MudTd>
|
||||
<MudTd>@context.PaymentDate.ToDateTime().MiladiToJalaliWithTime()</MudTd>
|
||||
<MudTd>@GetStatusText(context.PaymentStatus)</MudTd>
|
||||
<MudTd>@FormatPrice(context.FactorDetails.Sum(s=>s.UnitPrice.Value*s.Count.Value))</MudTd>
|
||||
<MudTd>
|
||||
<MudButton Variant="Variant.Text" Href="@($"{RouteConstants.Store.OrderDetail}{context.Id}")" StartIcon="@Icons.Material.Filled.Receipt">جزئیات</MudButton>
|
||||
<MudButton Variant="Variant.Text" Href="@($"{RouteConstants.Store.OrderDetail}{context}")" StartIcon="@Icons.Material.Filled.Receipt">جزئیات</MudButton>
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
@@ -46,11 +46,11 @@
|
||||
<MudStack Spacing="1">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||
<MudText>سفارش #@o.Id</MudText>
|
||||
<MudText Class="mud-text-secondary">@o.CreatedAt.ToString("yy/MM/dd HH:mm")</MudText>
|
||||
<MudText Class="mud-text-secondary">@o.PaymentDate.ToDateTime().MiladiToJalaliWithTime()</MudText>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||
<MudText>وضعیت: @GetStatusText(o.Status)</MudText>
|
||||
<MudText Color="Color.Primary">@FormatPrice(o.Total)</MudText>
|
||||
<MudText>وضعیت: @GetStatusText(o.PaymentStatus)</MudText>
|
||||
<MudText Color="Color.Primary">@FormatPrice(o.FactorDetails.Sum(s=>s.UnitPrice.Value*s.Count.Value)))</MudText>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Justify="Justify.FlexEnd">
|
||||
<MudButton Size="Size.Small" Variant="Variant.Outlined" Href="@($"{RouteConstants.Store.OrderDetail}{o.Id}")" StartIcon="@Icons.Material.Filled.Receipt">جزئیات</MudButton>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
@@ -7,7 +8,7 @@ public partial class Orders : ComponentBase
|
||||
{
|
||||
[Inject] private OrderService OrderService { get; set; } = default!;
|
||||
|
||||
private List<Order> _orders = new();
|
||||
private List<GetUserOrderResponse> _orders = new();
|
||||
private bool _loading;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@@ -18,10 +19,17 @@ public partial class Orders : ComponentBase
|
||||
}
|
||||
|
||||
private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price);
|
||||
private static string GetStatusText(OrderStatus status) => status switch
|
||||
|
||||
|
||||
private string GetStatusText(PaymentStatus contextPaymentStatus)
|
||||
{
|
||||
OrderStatus.Paid => "پرداختشده",
|
||||
_ => "در انتظار",
|
||||
};
|
||||
return contextPaymentStatus switch
|
||||
{
|
||||
PaymentStatus.Pending => "در انتظار پرداخت",
|
||||
PaymentStatus.Success => "پرداخت شده",
|
||||
PaymentStatus.Reject => "پرداخت ناموفق",
|
||||
_ => "نامشخص",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user