Compare commits
2 Commits
26ce7fd2b6
...
081b9d3c10
| Author | SHA1 | Date | |
|---|---|---|---|
| 081b9d3c10 | |||
| eab978188a |
@@ -5,22 +5,22 @@ using Grpc.Net.Client;
|
||||
using MudBlazor.Services;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using FrontOffice.BFF.Category.Protobuf.Protos.Category;
|
||||
using FrontOffice.BFF.Package.Protobuf.Protos.Package;
|
||||
using FrontOffice.BFF.Transaction.Protobuf.Protos.Transaction;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress;
|
||||
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
|
||||
using FrontOffice.BFF.UserWallet.Protobuf.Protos.UserWallet;
|
||||
using FrontOffice.BFF.ShopingCart.Protobuf.Protos.ShopingCart;
|
||||
// New Proto imports
|
||||
using FrontOffice.BFF.ClubMembership.Protobuf.Protos.ClubMembership;
|
||||
using FrontOffice.BFF.Commission.Protobuf.Protos.Commission;
|
||||
using FrontOffice.BFF.NetworkMembership.Protobuf.Protos.NetworkMembership;
|
||||
using FrontOffice.BFF.DiscountShop.Protobuf.Protos.DiscountShop;
|
||||
using FrontOffice.BFF.City.Protobuf;
|
||||
using FrontOffice.BFF.Configuration.Protobuf.Protos.Configuration;
|
||||
using FrontOffice.BFF.Configuration.Protobuf.Protos.AppVersion;
|
||||
// Updated imports to use CMS protobuf instead of FrontOffice.BFF
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
using CMSMicroservice.Protobuf.Protos.City;
|
||||
using CMSMicroservice.Protobuf.Protos.Package;
|
||||
using CMSMicroservice.Protobuf.Protos.Products;
|
||||
using CMSMicroservice.Protobuf.Protos.Transactions;
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
using CMSMicroservice.Protobuf.Protos.UserCarts;
|
||||
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||
using CMSMicroservice.Protobuf.Protos.UserWallet;
|
||||
using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog;
|
||||
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
||||
using CMSMicroservice.Protobuf.Protos.Configuration;
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using CMSMicroservice.Protobuf.Protos.AppVersion;
|
||||
using FrontOffice.Main.Utilities;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyInjection;
|
||||
@@ -64,6 +64,8 @@ public static class ConfigureServices
|
||||
services.AddScoped<CommissionService>();
|
||||
// App Version Service for cache invalidation
|
||||
services.AddScoped<AppVersionService>();
|
||||
// Main Service for core functionality
|
||||
services.AddScoped<MainService>();
|
||||
// Device detection: very light, dependency-free
|
||||
services.AddTransient<IDeviceDetector, DeviceDetector>();
|
||||
// PDF generation (Chromium only)
|
||||
@@ -95,25 +97,24 @@ public static class ConfigureServices
|
||||
};
|
||||
});
|
||||
|
||||
// Register gRPC clients with authentication
|
||||
services.AddScoped(CreateAuthenticatedClient<PackageContract.PackageContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<UserContract.UserContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<UserAddressContract.UserAddressContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<UserOrderContract.UserOrderContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<UserWalletContract.UserWalletContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CategoryContract.CategoryContractClient>);
|
||||
// Products gRPC
|
||||
services.AddScoped(CreateAuthenticatedClient<FrontOffice.BFF.Products.Protobuf.Protos.Products.ProductsContract.ProductsContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<TransactionContract.TransactionContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<ShopingCartContract.ShopingCartContractClient>);
|
||||
// New gRPC clients for Club, Network, Commission, DiscountShop
|
||||
services.AddScoped(CreateAuthenticatedClient<ClubMembershipContract.ClubMembershipContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CommissionContract.CommissionContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<ConfigurationContract.ConfigurationContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<NetworkMembershipContract.NetworkMembershipContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<DiscountShopContract.DiscountShopContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CityContract.CityContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<AppVersionContract.AppVersionContractClient>);
|
||||
// Register gRPC clients with authentication - Updated for CMS
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.Package.PackageContract.PackageContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.User.UserContract.UserContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.UserOrder.UserOrderContract.UserOrderContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.UserWallet.UserWalletContract.UserWalletContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.Category.CategoryContract.CategoryContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.Products.ProductsContract.ProductsContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.Transactions.TransactionsContract.TransactionsContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.UserCarts.UserCartsContract.UserCartsContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.City.CityContract.CityContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.UserAddress.UserAddressContract.UserAddressContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.UserWalletChangeLog.UserWalletChangeLogContract.UserWalletChangeLogContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.ClubMembership.ClubMembershipContract.ClubMembershipContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.OtpToken.OtpTokenContract.OtpTokenContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.Configuration.ConfigurationContract.ConfigurationContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.NetworkMembership.NetworkMembershipContract.NetworkMembershipContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.Commission.CommissionContract.CommissionContractClient>);
|
||||
services.AddScoped(CreateAuthenticatedClient<CMSMicroservice.Protobuf.Protos.AppVersion.AppVersionContract.AppVersionContractClient>);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -10,29 +10,9 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DateTimeConverterCL" Version="1.0.0" />
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.City.Protobuf" Version="0.0.2" />
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.ClubMembership.Protobuf" Version="0.0.4" />
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.Commission.Protobuf" Version="0.0.6" />
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.Configuration.Protobuf" Version="0.0.4" />
|
||||
<!-- <PackageReference Include="Foursat.FrontOffice.BFF.ClubMembership.Protobuf" Version="0.0.3" /> -->
|
||||
<!-- <PackageReference Include="Foursat.FrontOffice.BFF.Commission.Protobuf" Version="0.0.2" /> -->
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.DiscountShop.Protobuf" Version="0.0.3" />
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.NetworkMembership.Protobuf" Version="0.0.5" />
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.Package.Protobuf" Version="0.0.114" />
|
||||
<!-- <PackageReference Include="Foursat.FrontOffice.BFF.NetworkMembership.Protobuf" Version="0.0.2" />-->
|
||||
<!-- <PackageReference Include="Foursat.FrontOffice.BFF.Package.Protobuf" Version="0.0.113" /> -->
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.Products.Protobuf" Version="0.0.18" />
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.Transaction.Protobuf" Version="0.0.113" />
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.Category.Protobuf" Version="0.0.14" />
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.User.Protobuf" Version="0.0.118" />
|
||||
<!-- <PackageReference Include="Foursat.FrontOffice.BFF.User.Protobuf" Version="0.0.117" /> -->
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.UserAddress.Protobuf" Version="0.0.116" />
|
||||
<!-- <PackageReference Include="Foursat.FrontOffice.BFF.UserOrder.Protobuf" Version="0.0.115" />-->
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.ShopingCart.Protobuf" Version="0.0.17" />
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.UserOrder.Protobuf" Version="0.0.116" />
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.UserWallet.Protobuf" Version="0.0.16" />
|
||||
<!-- UserWallet moved to ProjectReference for latest proto with WeekDefinitionId -->
|
||||
<!-- <PackageReference Include="Foursat.FrontOffice.BFF.UserWallet.Protobuf" Version="0.0.15" /> -->
|
||||
<!-- Replace all FrontOffice.BFF protobuf packages with CMS protobuf -->
|
||||
<!--<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.177" />-->
|
||||
<ProjectReference Include="../../../CMS/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj" />
|
||||
<PackageReference Include="MudBlazor" Version="8.14.0" />
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
|
||||
<PackageReference Include="Mapster" Version="7.4.0" />
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using FrontOffice.BFF.Package.Protobuf.Protos.Package;
|
||||
using FrontOffice.BFF.Transaction.Protobuf.Protos.Transaction;
|
||||
using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress;
|
||||
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.Package;
|
||||
using CMSMicroservice.Protobuf.Protos.Transactions;
|
||||
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
||||
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -15,13 +16,13 @@ public partial class Checkout
|
||||
[Inject] private PackageContract.PackageContractClient PackageClient { get; set; } = default!;
|
||||
[Inject] private UserAddressContract.UserAddressContractClient UserAddressContract { get; set; } = default!;
|
||||
[Inject] private UserOrderContract.UserOrderContractClient UserOrderContract { get; set; } = default!;
|
||||
[Inject] private TransactionContract.TransactionContractClient TransactionContract { get; set; } = default!;
|
||||
[Inject] private TransactionsContract.TransactionsContractClient TransactionContract { get; set; } = default!;
|
||||
|
||||
[Parameter] public long? PackageId { get; set; }
|
||||
|
||||
private Pack? _selectedPackage;
|
||||
private List<GetAllUserAddressByFilterResponseModel> _addresses = new();
|
||||
private GetAllUserAddressByFilterResponseModel? _selectedAddress;
|
||||
private List<CustomerAddressModel> _addresses = new();
|
||||
private CustomerAddressModel? _selectedAddress;
|
||||
private bool _isLoadingAddresses;
|
||||
private bool _isProcessingPayment;
|
||||
|
||||
@@ -76,7 +77,7 @@ public partial class Checkout
|
||||
_isLoadingAddresses = true;
|
||||
try
|
||||
{
|
||||
var response = await UserAddressContract.GetAllUserAddressByFilterAsync(request: new());
|
||||
var response = await UserAddressContract.GetCustomerAddressesAsync(request: new());
|
||||
if (response?.Models?.Any() == true)
|
||||
{
|
||||
_addresses = response.Models.ToList();
|
||||
@@ -85,13 +86,13 @@ public partial class Checkout
|
||||
}
|
||||
else
|
||||
{
|
||||
_addresses = new List<GetAllUserAddressByFilterResponseModel>();
|
||||
_addresses = new List<CustomerAddressModel>();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در بارگذاری آدرسها: {ex.Message}", Severity.Error);
|
||||
_addresses = new List<GetAllUserAddressByFilterResponseModel>();
|
||||
_addresses = new List<CustomerAddressModel>();
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -186,7 +187,7 @@ public partial class Checkout
|
||||
try
|
||||
{
|
||||
// Step 1: Create payment request
|
||||
var paymentRequest = new PaymentRequestRequest
|
||||
var paymentRequest = new CustomerPaymentRequestRequest
|
||||
{
|
||||
Amount = _finalPrice,
|
||||
CallbackUrl = $"{Navigation.BaseUri}checkout/callback",
|
||||
@@ -195,7 +196,7 @@ public partial class Checkout
|
||||
Type = TransactionTypeEnum.Real
|
||||
};
|
||||
|
||||
var paymentResponse = await TransactionContract.PaymentRequestAsync(paymentRequest);
|
||||
var paymentResponse = await TransactionContract.CustomerPaymentRequestAsync(paymentRequest);
|
||||
|
||||
if (string.IsNullOrEmpty(paymentResponse.PaymentGWUrl))
|
||||
Snackbar.Add("آدرس درگاه پرداخت دریافت نشد.", Severity.Error);
|
||||
@@ -203,9 +204,9 @@ public partial class Checkout
|
||||
// Step 2: Create user order
|
||||
var orderRequest = new CreateNewUserOrderRequest
|
||||
{
|
||||
Price = _finalPrice,
|
||||
Amount = _finalPrice,
|
||||
PackageId = _selectedPackage.Id,
|
||||
PaymentStatus = false // Will be updated after payment verification
|
||||
PaymentStatus = CMSMicroservice.Protobuf.Protos.PaymentStatus.Pending
|
||||
};
|
||||
|
||||
var orderResponse = await UserOrderContract.CreateNewUserOrderAsync(orderRequest);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using FrontOffice.Main.Utilities;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
|
||||
@@ -56,19 +56,6 @@
|
||||
<MudAlert Severity="Severity.Warning" Variant="Variant.Outlined">
|
||||
<MudText>شما هنوز عضو باشگاه مشتریان نیستید. برای استفاده از مزایای ویژه، اکنون فعال کنید!</MudText>
|
||||
</MudAlert>
|
||||
|
||||
@if (_clubConfig != null)
|
||||
{
|
||||
<MudPaper Elevation="0" Class="pa-3 mt-3 rounded-lg" Style="background-color: var(--mud-palette-info-lighten);">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudStack Spacing="1">
|
||||
<MudText Typo="Typo.subtitle2" Color="Color.Info">هزینه عضویت در باشگاه مشتریان</MudText>
|
||||
<MudText Typo="Typo.caption">شامل @((_clubConfig.MembershipGiftValue / 10000).ToString("N0")) تومان هدیه</MudText>
|
||||
</MudStack>
|
||||
<MudText Typo="Typo.h6" Color="Color.Info">@((_clubConfig.ActivationFee / 10000).ToString("N0")) تومان</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
}
|
||||
}
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
@@ -103,11 +90,6 @@
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
|
||||
<!-- فعالسازی یا تمدید عضویت -->
|
||||
@if (!_membership.IsActive || (_membership.DaysRemaining.HasValue && _membership.DaysRemaining.Value <= 30))
|
||||
{
|
||||
<ActivationSection OnActivationSuccess="HandleActivationSuccess" />
|
||||
}
|
||||
|
||||
<!-- دکمه مشاهده ویژگیهای بیشتر -->
|
||||
<MudButton Variant="Variant.Outlined"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using FrontOffice.BFF.Package.Protobuf.Protos.Package;
|
||||
using CMSMicroservice.Protobuf.Protos.Package;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Blazored.LocalStorage;
|
||||
using FrontOffice.BFF.Package.Protobuf.Protos.Package;
|
||||
using CMSMicroservice.Protobuf.Protos.Package;
|
||||
using FrontOffice.Main.Shared;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Grpc.Core;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress;
|
||||
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
||||
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
||||
using FrontOffice.Main.Pages.Profile.Components;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
@@ -9,7 +10,7 @@ public partial class Addresses : ComponentBase
|
||||
{
|
||||
[Inject] private UserAddressContract.UserAddressContractClient UserAddressContract { get; set; } = default!;
|
||||
|
||||
private List<GetAllUserAddressByFilterResponseModel> _addresses = new();
|
||||
private List<CustomerAddressModel> _addresses = new();
|
||||
private bool _isLoadingAddresses;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@@ -22,7 +23,7 @@ public partial class Addresses : ComponentBase
|
||||
_isLoadingAddresses = true;
|
||||
try
|
||||
{
|
||||
var response = await UserAddressContract.GetAllUserAddressByFilterAsync(new());
|
||||
var response = await UserAddressContract.GetCustomerAddressesAsync(new());
|
||||
_addresses = response?.Models?.ToList() ?? new();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -44,7 +45,7 @@ public partial class Addresses : ComponentBase
|
||||
await LoadAddresses();
|
||||
}
|
||||
|
||||
private async Task OpenEditAddressDialog(GetAllUserAddressByFilterResponseModel address)
|
||||
private async Task OpenEditAddressDialog(CustomerAddressModel address)
|
||||
{
|
||||
var dialog = await DialogService.ShowAsync<EditAddressDialog>("ویرایش آدرس", new DialogParameters<EditAddressDialog>
|
||||
{
|
||||
@@ -59,7 +60,7 @@ public partial class Addresses : ComponentBase
|
||||
{
|
||||
try
|
||||
{
|
||||
await UserAddressContract.SetAddressAsDefaultAsync(new() { Id = id });
|
||||
await UserAddressContract.SetCustomerDefaultAddressAsync(new() { Id = id });
|
||||
Snackbar.Add("آدرس پیشفرض تغییر کرد.", Severity.Success);
|
||||
await LoadAddresses();
|
||||
}
|
||||
@@ -76,7 +77,7 @@ public partial class Addresses : ComponentBase
|
||||
{
|
||||
try
|
||||
{
|
||||
await UserAddressContract.DeleteUserAddressAsync(new() { Id = id });
|
||||
await UserAddressContract.DeleteCustomerAddressAsync(new() { Id = id });
|
||||
Snackbar.Add("آدرس حذف شد.", Severity.Success);
|
||||
await LoadAddresses();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
|
||||
@using CMSMicroservice.Protobuf.Protos.City
|
||||
<MudDialog>
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h4" Align="Align.Center">افزودن آدرس جدید</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<MudForm @ref="_form" Model="_request" Validation="@(_validator.ValidateValue)">
|
||||
<MudForm @ref="_form" Model="_request">
|
||||
<MudStack Spacing="3">
|
||||
<MudTextField @bind-Value="_request.Title"
|
||||
For="@(() => _request.Title)"
|
||||
@@ -29,12 +30,12 @@
|
||||
Required="true"
|
||||
RequiredError="کد پستی الزامی است." />
|
||||
|
||||
<MudAutocomplete T="CityProto.GetAllCitiesByFilterResponseModel"
|
||||
<MudAutocomplete T="object"
|
||||
@bind-Value="_selectedCity"
|
||||
Label="شهر"
|
||||
Variant="Variant.Outlined"
|
||||
SearchFunc="SearchCities"
|
||||
ToStringFunc="@(city => city != null ? $"{city.Native} ({city.StateName})" : string.Empty)"
|
||||
ToStringFunc="@(city => city != null ? $"{((CMSMicroservice.Protobuf.Protos.City.CityDto)city).Native} ({((CMSMicroservice.Protobuf.Protos.City.CityDto)city).StateName})" : string.Empty)"
|
||||
Required="true"
|
||||
RequiredError="شهر الزامی است."
|
||||
Clearable="true"
|
||||
@@ -49,8 +50,8 @@
|
||||
<ItemTemplate Context="city">
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudIcon Icon="@Icons.Material.Filled.LocationCity" Size="Size.Small" />
|
||||
<MudText>@city.Native</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">(@city.StateName)</MudText>
|
||||
<MudText>@(((CMSMicroservice.Protobuf.Protos.City.CityDto)city).Native)</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">(@(((CMSMicroservice.Protobuf.Protos.City.CityDto)city).StateName))</MudText>
|
||||
</MudStack>
|
||||
</ItemTemplate>
|
||||
<NoItemsTemplate>
|
||||
|
||||
@@ -1,43 +1,42 @@
|
||||
using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress;
|
||||
using FrontOffice.BFF.UserAddress.Protobuf.Validator;
|
||||
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
||||
using CMSMicroservice.Protobuf.Protos.City;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using Severity = MudBlazor.Severity;
|
||||
using CityProto = FrontOffice.BFF.City.Protobuf;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Profile.Components;
|
||||
|
||||
public record CityModel(long Id, string Name);
|
||||
|
||||
public partial class AddAddressDialog : ComponentBase
|
||||
{
|
||||
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = default!;
|
||||
[Inject] private UserAddressContract.UserAddressContractClient UserAddressContract { get; set; } = default!;
|
||||
[Inject] private CityProto.CityContract.CityContractClient CityContract { get; set; } = default!;
|
||||
[Inject] private CityContract.CityContractClient CityContract { get; set; } = default!;
|
||||
|
||||
private MudForm? _form;
|
||||
private readonly CreateNewUserAddressRequestValidator _validator = new();
|
||||
private bool _isSaving;
|
||||
private CreateNewUserAddressRequest _request = new();
|
||||
private CityProto.GetAllCitiesByFilterResponseModel? _selectedCity;
|
||||
private CreateCustomerAddressRequest _request = new();
|
||||
private object? _selectedCity;
|
||||
|
||||
private async Task<IEnumerable<CityProto.GetAllCitiesByFilterResponseModel>> SearchCities(string value,
|
||||
CancellationToken ct)
|
||||
private async Task<IEnumerable<object>> SearchCities(string value, CancellationToken ct)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value) || value.Length < 2)
|
||||
return Enumerable.Empty<CityProto.GetAllCitiesByFilterResponseModel>();
|
||||
return Enumerable.Empty<object>();
|
||||
|
||||
try
|
||||
{
|
||||
var response = await CityContract.GetAllCitiesByFilterAsync(new CityProto.GetAllCitiesByFilterRequest
|
||||
var response = await CityContract.GetAllCitiesByFilterAsync(new GetAllCitiesByFilterRequest
|
||||
{
|
||||
PaginationState = new CityProto.PaginationState { PageNumber = 1, PageSize = 20 },
|
||||
Filter = new CityProto.GetAllCitiesByFilterFilter { Name = value }
|
||||
}, cancellationToken: ct);
|
||||
PaginationState = new CMSMicroservice.Protobuf.Protos.City.PaginationState { PageNumber = 1, PageSize = 20 },
|
||||
Filter = new GetAllCitiesByFilterFilter { Name = value }
|
||||
});
|
||||
|
||||
return response?.Models?.ToList() ?? new List<CityProto.GetAllCitiesByFilterResponseModel>();
|
||||
return response?.Cities?.Cast<object>() ?? Enumerable.Empty<object>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Enumerable.Empty<CityProto.GetAllCitiesByFilterResponseModel>();
|
||||
return Enumerable.Empty<object>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,11 +52,11 @@ public partial class AddAddressDialog : ComponentBase
|
||||
return;
|
||||
}
|
||||
|
||||
_request.CityId = _selectedCity.Id;
|
||||
_request.CityId = (long)((dynamic)_selectedCity).Id;
|
||||
_isSaving = true;
|
||||
try
|
||||
{
|
||||
var response = await UserAddressContract.CreateNewUserAddressAsync(_request);
|
||||
var response = await UserAddressContract.CreateCustomerAddressAsync(_request);
|
||||
Snackbar.Add("آدرس با موفقیت اضافه شد.", Severity.Success);
|
||||
MudDialog.Close(DialogResult.Ok(true));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
@using CMSMicroservice.Protobuf.Protos.City
|
||||
<MudDialog>
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h4" Align="Align.Center">ویرایش آدرس</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<MudForm @ref="_form" Model="_request" Validation="@(_validator.ValidateValue)">
|
||||
<MudForm @ref="_form" Model="_request">
|
||||
<MudStack Spacing="3">
|
||||
<MudTextField @bind-Value="_request.Title"
|
||||
For="@(() => _request.Title)"
|
||||
@@ -28,12 +29,12 @@
|
||||
Required="true"
|
||||
RequiredError="کد پستی الزامی است." />
|
||||
|
||||
<MudAutocomplete T="CityProto.GetAllCitiesByFilterResponseModel"
|
||||
<MudAutocomplete T="object"
|
||||
@bind-Value="_selectedCity"
|
||||
Label="شهر"
|
||||
Variant="Variant.Outlined"
|
||||
SearchFunc="SearchCities"
|
||||
ToStringFunc="@(city => city != null ? $"{city.Native} ({city.StateName})" : string.Empty)"
|
||||
ToStringFunc="@(city => city != null ? $"{((CMSMicroservice.Protobuf.Protos.City.CityDto)city).Native} ({((CMSMicroservice.Protobuf.Protos.City.CityDto)city).StateName})" : string.Empty)"
|
||||
Required="true"
|
||||
RequiredError="شهر الزامی است."
|
||||
Clearable="true"
|
||||
@@ -48,8 +49,8 @@
|
||||
<ItemTemplate Context="city">
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudIcon Icon="@Icons.Material.Filled.LocationCity" Size="Size.Small" />
|
||||
<MudText>@city.Native</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">(@city.StateName)</MudText>
|
||||
<MudText>@(((CMSMicroservice.Protobuf.Protos.City.CityDto)city).Native)</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">(@(((CMSMicroservice.Protobuf.Protos.City.CityDto)city).StateName))</MudText>
|
||||
</MudStack>
|
||||
</ItemTemplate>
|
||||
<NoItemsTemplate>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress;
|
||||
using FrontOffice.BFF.UserAddress.Protobuf.Validator;
|
||||
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
||||
using CMSMicroservice.Protobuf.Protos.City;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using Severity = MudBlazor.Severity;
|
||||
using CityProto = FrontOffice.BFF.City.Protobuf;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Profile.Components;
|
||||
|
||||
@@ -12,22 +11,21 @@ public partial class EditAddressDialog : ComponentBase
|
||||
{
|
||||
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = default!;
|
||||
[Inject] private UserAddressContract.UserAddressContractClient UserAddressContract { get; set; } = default!;
|
||||
[Inject] private CityProto.CityContract.CityContractClient CityContract { get; set; } = default!;
|
||||
[Inject] private CityContract.CityContractClient CityContract { get; set; } = default!;
|
||||
|
||||
[Parameter] public GetAllUserAddressByFilterResponseModel? Model { get; set; }
|
||||
[Parameter] public CustomerAddressModel? Model { get; set; }
|
||||
|
||||
private MudForm? _form;
|
||||
private readonly UpdateUserAddressRequestValidator _validator = new();
|
||||
private bool _isSaving;
|
||||
private UpdateUserAddressRequest _request = new();
|
||||
private CityProto.GetAllCitiesByFilterResponseModel? _selectedCity;
|
||||
private UpdateCustomerAddressRequest _request = new();
|
||||
private object? _selectedCity;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
if (Model != null)
|
||||
{
|
||||
_request = Model.Adapt<UpdateUserAddressRequest>();
|
||||
_request = Model.Adapt<UpdateCustomerAddressRequest>();
|
||||
|
||||
// Load selected city if CityId exists
|
||||
if (Model.CityId > 0)
|
||||
@@ -41,13 +39,13 @@ public partial class EditAddressDialog : ComponentBase
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await CityContract.GetAllCitiesByFilterAsync(new CityProto.GetAllCitiesByFilterRequest
|
||||
var response = await CityContract.GetAllCitiesByFilterAsync(new GetAllCitiesByFilterRequest
|
||||
{
|
||||
PaginationState = new CityProto.PaginationState { PageNumber = 1, PageSize = 1 },
|
||||
Filter = new CityProto.GetAllCitiesByFilterFilter { Id = cityId }
|
||||
PaginationState = new CMSMicroservice.Protobuf.Protos.City.PaginationState { PageNumber = 1, PageSize = 1 },
|
||||
Filter = new GetAllCitiesByFilterFilter { Id = cityId }
|
||||
});
|
||||
|
||||
_selectedCity = response?.Models?.FirstOrDefault();
|
||||
_selectedCity = response?.Cities?.FirstOrDefault();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -55,24 +53,24 @@ public partial class EditAddressDialog : ComponentBase
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<CityProto.GetAllCitiesByFilterResponseModel>> SearchCities(string value, CancellationToken ct)
|
||||
private async Task<IEnumerable<object>> SearchCities(string value, CancellationToken ct)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value) || value.Length < 2)
|
||||
return Enumerable.Empty<CityProto.GetAllCitiesByFilterResponseModel>();
|
||||
return Enumerable.Empty<object>();
|
||||
|
||||
try
|
||||
{
|
||||
var response = await CityContract.GetAllCitiesByFilterAsync(new CityProto.GetAllCitiesByFilterRequest
|
||||
var response = await CityContract.GetAllCitiesByFilterAsync(new GetAllCitiesByFilterRequest
|
||||
{
|
||||
PaginationState = new CityProto.PaginationState { PageNumber = 1, PageSize = 20 },
|
||||
Filter = new CityProto.GetAllCitiesByFilterFilter { Native = value }
|
||||
}, cancellationToken: ct);
|
||||
PaginationState = new CMSMicroservice.Protobuf.Protos.City.PaginationState { PageNumber = 1, PageSize = 20 },
|
||||
Filter = new GetAllCitiesByFilterFilter { Name = value }
|
||||
});
|
||||
|
||||
return response?.Models?.ToList() ?? new List<CityProto.GetAllCitiesByFilterResponseModel>();
|
||||
return response?.Cities?.Cast<object>() ?? Enumerable.Empty<object>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Enumerable.Empty<CityProto.GetAllCitiesByFilterResponseModel>();
|
||||
return Enumerable.Empty<object>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,11 +86,11 @@ public partial class EditAddressDialog : ComponentBase
|
||||
return;
|
||||
}
|
||||
|
||||
_request.CityId = _selectedCity.Id;
|
||||
_request.CityId = (long)((dynamic)_selectedCity).Id;
|
||||
_isSaving = true;
|
||||
try
|
||||
{
|
||||
await UserAddressContract.UpdateUserAddressAsync(_request);
|
||||
await UserAddressContract.UpdateCustomerAddressAsync(_request);
|
||||
Snackbar.Add("آدرس با موفقیت ویرایش شد.", Severity.Success);
|
||||
MudDialog.Close(DialogResult.Ok(true));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using FluentValidation;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
using FrontOffice.BFF.User.Protobuf.Validator;
|
||||
using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress;
|
||||
using FrontOffice.BFF.UserAddress.Protobuf.Validator;
|
||||
using FrontOffice.BFF.Package.Protobuf.Protos.Package;
|
||||
|
||||
using FrontOffice.Main.Pages.Profile.Components;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Mapster;
|
||||
@@ -11,6 +7,11 @@ using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MudBlazor;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using CMSMicroservice.Protobuf.Protos.Package;
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
||||
using CMSMicroservice.Protobuf.Validator.User;
|
||||
using CMSMicroservice.Protobuf.Validator.UserAddress;
|
||||
using Severity = MudBlazor.Severity;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Profile;
|
||||
@@ -45,7 +46,7 @@ public partial class Index
|
||||
private bool _isProcessingPayment;
|
||||
|
||||
// Address management
|
||||
private List<GetAllUserAddressByFilterResponseModel> _addresses = new();
|
||||
private List<CustomerAddressModel> _addresses = new();
|
||||
private bool _isLoadingAddresses;
|
||||
private CreateNewUserAddressRequest _newAddressRequest = new();
|
||||
private UpdateUserAddressRequest _editAddressRequest = new();
|
||||
@@ -250,20 +251,20 @@ public partial class Index
|
||||
_isLoadingAddresses = true;
|
||||
try
|
||||
{
|
||||
var response = await UserAddressContract.GetAllUserAddressByFilterAsync(request: new());
|
||||
var response = await UserAddressContract.GetCustomerAddressesAsync(request: new());
|
||||
if (response?.Models?.Any() == true)
|
||||
{
|
||||
_addresses = response.Models.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_addresses = new List<GetAllUserAddressByFilterResponseModel>();
|
||||
_addresses = new List<CustomerAddressModel>();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در بارگذاری آدرسها: {ex.Message}", Severity.Error);
|
||||
_addresses = new List<GetAllUserAddressByFilterResponseModel>();
|
||||
_addresses = new List<CustomerAddressModel>();
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -283,7 +284,7 @@ public partial class Index
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OpenEditAddressDialog(GetAllUserAddressByFilterResponseModel address)
|
||||
private async Task OpenEditAddressDialog(CustomerAddressModel address)
|
||||
{
|
||||
var dialog = await DialogService.ShowAsync<EditAddressDialog>("ویرایش آدرس", new DialogParameters<EditAddressDialog>
|
||||
{
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
@page "/profile/payment-callback"
|
||||
@attribute [Authorize]
|
||||
@using Blazored.LocalStorage
|
||||
@using FrontOffice.BFF.Package.Protobuf.Protos.Package
|
||||
@using FrontOffice.BFF.User.Protobuf.Protos.User
|
||||
@using CMSMicroservice.Protobuf.Protos.Package
|
||||
@using CMSMicroservice.Protobuf.Protos.User
|
||||
|
||||
|
||||
<PageTitle>نتیجه پرداخت | کارا بازار سلامت</PageTitle>
|
||||
|
||||
@@ -112,13 +113,14 @@
|
||||
{
|
||||
OrderId = OrderId,
|
||||
TransactionId = TransactionId,
|
||||
Authority = Authority,
|
||||
Status = Status ?? "NOK"
|
||||
PaymentSuccess = Status == "OK",
|
||||
RefId = !string.IsNullOrEmpty(Authority) ? Authority : null,
|
||||
Message = !string.IsNullOrEmpty(Status) ? Status : null
|
||||
});
|
||||
|
||||
_isSuccess = response.Success;
|
||||
_message = response.Message;
|
||||
_refId = response.RefId;
|
||||
_refId = response.ReferenceCode ?? "";
|
||||
_walletBalance = response.WalletBalance;
|
||||
_discountBalance = response.DiscountBalance;
|
||||
|
||||
@@ -153,7 +155,7 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
var userResponse = await UserContractClient.GetUserAsync(new Google.Protobuf.WellKnownTypes.Empty());
|
||||
var userResponse = await UserContractClient.GetUserForCustomerAsync(new CMSMicroservice.Protobuf.Protos.User.GetUserForCustomerRequest());
|
||||
if (!string.IsNullOrWhiteSpace(userResponse.Token))
|
||||
{
|
||||
// ذخیره توکن جدید در localStorage
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using FluentValidation;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
using FrontOffice.BFF.User.Protobuf.Validator;
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
using CMSMicroservice.Protobuf.Validator.User;
|
||||
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
@@ -12,20 +12,20 @@
|
||||
<MudGrid Spacing="2">
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی اعتباری</MudText>
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی عادی</MudText>
|
||||
<MudText Typo="Typo.h4" Color="Color.Primary">@_balances.Credit</MudText>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی فروشگاه تخفیفی</MudText>
|
||||
<MudText Typo="Typo.h4" Color="Color.Warning">@_balances.Discount</MudText>
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی شبکه</MudText>
|
||||
<MudText Typo="Typo.h4" Color="Color.Success">@_balances.Network</MudText>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی پاداش تیمی</MudText>
|
||||
<MudText Typo="Typo.h4" Color="Color.Success">@_balances.Network</MudText>
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی تخفیفی</MudText>
|
||||
<MudText Typo="Typo.h4" Color="Color.Warning">@_balances.Discount</MudText>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
@@ -71,18 +71,45 @@
|
||||
</MudGrid>
|
||||
|
||||
<MudHidden Breakpoint="Breakpoint.MdAndUp" Invert="true">
|
||||
<MudTable Items="_txs" Dense="true">
|
||||
<MudTable Items="_txs" Dense="true" Hover="true" Striped="true">
|
||||
<HeaderContent>
|
||||
<MudTh>تاریخ</MudTh>
|
||||
<MudTh>مبلغ</MudTh>
|
||||
<MudTh>مسیر</MudTh>
|
||||
<MudTh>عادی (تغییرات / مانده)</MudTh>
|
||||
<MudTh>شبکه (تغییرات / مانده)</MudTh>
|
||||
<MudTh>تخفیفی (تغییرات / مانده)</MudTh>
|
||||
<MudTh>شناسه ارجاع</MudTh>
|
||||
<MudTh>توضیحات</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd>@context.Date</MudTd>
|
||||
<MudTd Color="@(context.Amount > 0 ? Color.Success : Color.Error)">@FormatPrice(context.Amount)</MudTd>
|
||||
<MudTd>@context.Channel</MudTd>
|
||||
<MudTd>@context.Description</MudTd>
|
||||
<MudTd DataLabel="تاریخ">
|
||||
<MudText Typo="Typo.caption">@context.Date</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="عادی">
|
||||
<MudStack Spacing="0">
|
||||
<MudText Color="@(context.CreditChange > 0 ? Color.Success : context.CreditChange < 0 ? Color.Error : Color.Default)" Typo="Typo.body2">
|
||||
@(context.CreditChange != 0 ? (context.CreditChange > 0 ? "+" : "") + FormatPrice(context.CreditChange) : "-")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@FormatPrice(context.CreditBalance)</MudText>
|
||||
</MudStack>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="شبکه">
|
||||
<MudStack Spacing="0">
|
||||
<MudText Color="@(context.NetworkChange > 0 ? Color.Success : context.NetworkChange < 0 ? Color.Error : Color.Default)" Typo="Typo.body2">
|
||||
@(context.NetworkChange != 0 ? (context.NetworkChange > 0 ? "+" : "") + FormatPrice(context.NetworkChange) : "-")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@FormatPrice(context.NetworkBalance)</MudText>
|
||||
</MudStack>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="تخفیفی">
|
||||
<MudStack Spacing="0">
|
||||
<MudText Color="@(context.DiscountChange > 0 ? Color.Success : context.DiscountChange < 0 ? Color.Error : Color.Default)" Typo="Typo.body2">
|
||||
@(context.DiscountChange != 0 ? (context.DiscountChange > 0 ? "+" : "") + FormatPrice(context.DiscountChange) : "-")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@FormatPrice(context.DiscountBalance)</MudText>
|
||||
</MudStack>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="شناسه">@context.Channel</MudTd>
|
||||
<MudTd DataLabel="توضیحات">@context.Description</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
</MudHidden>
|
||||
@@ -91,13 +118,50 @@
|
||||
<MudStack Spacing="2">
|
||||
@foreach (var tx in _txs)
|
||||
{
|
||||
<MudPaper Class="pa-3 rounded-lg" Outlined="true">
|
||||
<MudStack Spacing="1">
|
||||
<MudPaper Class="pa-3 rounded-lg" Outlined="true" Elevation="1">
|
||||
<MudStack Spacing="2">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText>@tx.Date</MudText>
|
||||
<MudText Color="@(tx.Amount > 0 ? Color.Success : Color.Error)">@FormatPrice(tx.Amount)</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@tx.Date</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">شناسه: @tx.Channel</MudText>
|
||||
</MudStack>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@tx.Channel</MudText>
|
||||
|
||||
<MudDivider />
|
||||
|
||||
<MudStack Row="true" Spacing="2" Justify="Justify.SpaceBetween">
|
||||
<!-- کیف پول عادی -->
|
||||
<MudPaper Class="pa-2 flex-grow-1" Outlined="true">
|
||||
<MudStack Spacing="1" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.caption" Color="Color.Primary">عادی</MudText>
|
||||
<MudText Color="@(tx.CreditChange > 0 ? Color.Success : tx.CreditChange < 0 ? Color.Error : Color.Default)" Style="font-weight: 600; font-size: 0.75rem;">
|
||||
@(tx.CreditChange != 0 ? (tx.CreditChange > 0 ? "+" : "") + FormatPrice(tx.CreditChange) : "-")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary" Style="font-size: 0.7rem;">@FormatPrice(tx.CreditBalance)</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
|
||||
<!-- کیف پول شبکه -->
|
||||
<MudPaper Class="pa-2 flex-grow-1" Outlined="true">
|
||||
<MudStack Spacing="1" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.caption" Color="Color.Success">شبکه</MudText>
|
||||
<MudText Color="@(tx.NetworkChange > 0 ? Color.Success : tx.NetworkChange < 0 ? Color.Error : Color.Default)" Style="font-weight: 600; font-size: 0.75rem;">
|
||||
@(tx.NetworkChange != 0 ? (tx.NetworkChange > 0 ? "+" : "") + FormatPrice(tx.NetworkChange) : "-")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary" Style="font-size: 0.7rem;">@FormatPrice(tx.NetworkBalance)</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
|
||||
<!-- کیف پول تخفیفی -->
|
||||
<MudPaper Class="pa-2 flex-grow-1" Outlined="true">
|
||||
<MudStack Spacing="1" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.caption" Color="Color.Warning">تخفیفی</MudText>
|
||||
<MudText Color="@(tx.DiscountChange > 0 ? Color.Success : tx.DiscountChange < 0 ? Color.Error : Color.Default)" Style="font-weight: 600; font-size: 0.75rem;">
|
||||
@(tx.DiscountChange != 0 ? (tx.DiscountChange > 0 ? "+" : "") + FormatPrice(tx.DiscountChange) : "-")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary" Style="font-size: 0.7rem;">@FormatPrice(tx.DiscountBalance)</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
|
||||
<MudText Typo="Typo.body2">@tx.Description</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using DateTimeConverterCL;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
using FrontOffice.Main.Shared;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
@@ -67,7 +67,7 @@ public partial class RegisterWizard
|
||||
{
|
||||
try
|
||||
{
|
||||
var existUser = await UserContract.GetUserAsync(new Empty());
|
||||
var existUser = await UserContract.GetUserForCustomerAsync(new GetUserForCustomerRequest());
|
||||
if (existUser != null && !string.IsNullOrEmpty(existUser.FirstName) &&
|
||||
string.IsNullOrWhiteSpace(_model.FirstName))
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder
|
||||
@using CMSMicroservice.Protobuf.Protos.UserOrder
|
||||
@using CMSMicroservice.Protobuf.Protos
|
||||
@attribute [Route(RouteConstants.Store.CheckoutSummary)]
|
||||
|
||||
<PageTitle>خلاصه خرید</PageTitle>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress;
|
||||
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
|
||||
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
||||
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using Messages = CMSMicroservice.Protobuf.Protos;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Store;
|
||||
|
||||
@@ -15,12 +16,12 @@ public partial class CheckoutSummary : ComponentBase
|
||||
[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 List<CustomerAddressModel> _addresses = new();
|
||||
private CustomerAddressModel? _selectedAddress;
|
||||
private bool _loadingAddresses;
|
||||
private long walletBalance;
|
||||
|
||||
private PaymentMethod _payment = PaymentMethod.Wallet;
|
||||
private Messages.PaymentMethod _payment = Messages.PaymentMethod.Wallet;
|
||||
|
||||
private bool CanPlaceOrder => Cart.Items.Count > 0 && _selectedAddress != null;
|
||||
|
||||
@@ -55,7 +56,7 @@ public partial class CheckoutSummary : ComponentBase
|
||||
_loadingAddresses = true;
|
||||
try
|
||||
{
|
||||
var response = await UserAddressContract.GetAllUserAddressByFilterAsync(new());
|
||||
var response = await UserAddressContract.GetCustomerAddressesAsync(new());
|
||||
if (response?.Models?.Any() == true)
|
||||
{
|
||||
_addresses = response.Models.ToList();
|
||||
|
||||
@@ -24,9 +24,15 @@ 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.PaymentDate.ToDateTime().MiladiToJalaliWithTime()</MudText>
|
||||
@if (_order.PaymentDate != null)
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">تاریخ پرداخت: @_order.PaymentDate.ToDateTime().MiladiToJalaliWithTime()</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">تاریخ ثبت: @DateTime.Now.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">
|
||||
@@ -42,12 +48,12 @@ else
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudImage Src="@GetProductImageUrl(context.ProductThumbnailPath)" Alt="@context.ProductTitle"
|
||||
Width="60" Height="60" Class="rounded-circle" />
|
||||
<MudText>@context.ProductThumbnailPath</MudText>
|
||||
<MudText>@context.ProductTitle</MudText>
|
||||
</MudStack>
|
||||
</MudTd>
|
||||
<MudTd>@FormatPrice(context.UnitPrice.Value)</MudTd>
|
||||
<MudTd>@FormatPrice(context.UnitPrice ?? 0)</MudTd>
|
||||
<MudTd>@context.Count</MudTd>
|
||||
<MudTd>@FormatPrice(context.UnitPrice.Value*context.Count.Value)</MudTd>
|
||||
<MudTd>@FormatPrice((context.UnitPrice ?? 0) * (context.Count ?? 0))</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
</MudHidden>
|
||||
@@ -64,10 +70,10 @@ else
|
||||
<MudText>@it.ProductTitle</MudText>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||
<MudText Class="mud-text-secondary">@FormatPrice(it.UnitPrice.Value) واحد</MudText>
|
||||
<MudText Class="mud-text-secondary">@FormatPrice(it.UnitPrice ?? 0) واحد</MudText>
|
||||
<MudText>تعداد: @it.Count</MudText>
|
||||
</MudStack>
|
||||
<MudText>جمع: @FormatPrice(it.UnitPrice.Value*it.Count.Value)</MudText>
|
||||
<MudText>جمع: @FormatPrice((it.UnitPrice ?? 0) * (it.Count ?? 0))</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
}
|
||||
@@ -77,7 +83,7 @@ else
|
||||
|
||||
@* نمایش جزئیات مالی *@
|
||||
@{
|
||||
var subtotal = _order.FactorDetails.Sum(s => s.UnitPrice.Value * s.Count.Value);
|
||||
var subtotal = _order.FactorDetails.Sum(s => (s.UnitPrice ?? 0) * (s.Count ?? 0));
|
||||
}
|
||||
<MudStack Spacing="1" Class="pa-2" Style="background-color: var(--mud-palette-background-grey); border-radius: 8px;">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
|
||||
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Messages = CMSMicroservice.Protobuf.Protos;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Store;
|
||||
|
||||
@@ -22,23 +23,23 @@ public partial class OrderDetail : ComponentBase
|
||||
|
||||
private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price);
|
||||
|
||||
private string GetStatusText(PaymentStatus orderPaymentStatus)
|
||||
private string GetStatusText(Messages.PaymentStatus orderPaymentStatus)
|
||||
{
|
||||
return orderPaymentStatus switch
|
||||
{
|
||||
PaymentStatus.Pending => "در انتظار پرداخت",
|
||||
PaymentStatus.Success => "پرداخت شده",
|
||||
PaymentStatus.Reject => "پرداخت ناموفق",
|
||||
Messages.PaymentStatus.Pending => "در انتظار پرداخت",
|
||||
Messages.PaymentStatus.Success => "پرداخت شده",
|
||||
Messages.PaymentStatus.Reject => "پرداخت ناموفق",
|
||||
_ => "نامشخص",
|
||||
};
|
||||
}
|
||||
|
||||
private string GetPaymentMethodText(PaymentMethod orderPaymentMethod)
|
||||
private string GetPaymentMethodText(Messages.PaymentMethod orderPaymentMethod)
|
||||
{
|
||||
return orderPaymentMethod switch
|
||||
{
|
||||
PaymentMethod.Wallet => "کیف پول",
|
||||
PaymentMethod.Ipg => "درگاه پرداخت اینترنتی",
|
||||
Messages.PaymentMethod.Wallet => "کیف پول",
|
||||
Messages.PaymentMethod.Ipg => "درگاه پرداخت اینترنتی",
|
||||
_ => "نامشخص",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder
|
||||
@using CMSMicroservice.Protobuf.Protos.UserOrder
|
||||
@attribute [Route(RouteConstants.Store.OrderTracking + "{id:long}")]
|
||||
|
||||
<PageTitle>پیگیری سفارش</PageTitle>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
|
||||
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Messages = CMSMicroservice.Protobuf.Protos;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Store;
|
||||
|
||||
@@ -45,7 +46,7 @@ public partial class OrderTracking : ComponentBase
|
||||
if (_order is null) return;
|
||||
|
||||
// Build tracking steps based on PaymentStatus
|
||||
var isPaid = _order.PaymentStatus == PaymentStatus.Success;
|
||||
var isPaid = _order.PaymentStatus == Messages.PaymentStatus.Success;
|
||||
|
||||
_trackingSteps = new List<TrackingStep>
|
||||
{
|
||||
@@ -107,10 +108,10 @@ public partial class OrderTracking : ComponentBase
|
||||
return $"{persianCalendar.GetYear(date)}/{persianCalendar.GetMonth(date):00}/{persianCalendar.GetDayOfMonth(date):00}";
|
||||
}
|
||||
|
||||
private static string GetPaymentMethodText(PaymentMethod method) => method switch
|
||||
private static string GetPaymentMethodText(Messages.PaymentMethod method) => method switch
|
||||
{
|
||||
PaymentMethod.Ipg => "پرداخت آنلاین",
|
||||
PaymentMethod.Wallet => "کیف پول",
|
||||
Messages.PaymentMethod.Ipg => "پرداخت آنلاین",
|
||||
Messages.PaymentMethod.Wallet => "کیف پول",
|
||||
_ => "نامشخص"
|
||||
};
|
||||
|
||||
|
||||
@@ -28,9 +28,18 @@
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd>@context.Id</MudTd>
|
||||
<MudTd>@context.PaymentDate.ToDateTime().MiladiToJalaliWithTime()</MudTd>
|
||||
<MudTd>
|
||||
@if (context.PaymentDate != null)
|
||||
{
|
||||
@context.PaymentDate.ToDateTime().MiladiToJalaliWithTime()
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>در انتظار پرداخت</text>
|
||||
}
|
||||
</MudTd>
|
||||
<MudTd>@GetStatusText(context.PaymentStatus)</MudTd>
|
||||
<MudTd>@FormatPrice(context.FactorDetails.Sum(s=>s.UnitPrice.Value*s.Count.Value))</MudTd>
|
||||
<MudTd>@FormatPrice(context.FactorDetails.Sum(s=>(s.UnitPrice ?? 0) * (s.Count ?? 0)))</MudTd>
|
||||
<MudTd>
|
||||
<MudButton Variant="Variant.Text" Href="@($"{RouteConstants.Store.OrderDetail}{context.Id}")" StartIcon="@Icons.Material.Filled.Receipt">جزئیات</MudButton>
|
||||
</MudTd>
|
||||
@@ -46,11 +55,20 @@
|
||||
<MudStack Spacing="1">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||
<MudText>سفارش #@o.Id</MudText>
|
||||
<MudText Class="mud-text-secondary">@o.PaymentDate.ToDateTime().MiladiToJalaliWithTime()</MudText>
|
||||
<MudText Class="mud-text-secondary">
|
||||
@if (o.PaymentDate != null)
|
||||
{
|
||||
@o.PaymentDate.ToDateTime().MiladiToJalaliWithTime()
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>در انتظار پرداخت</text>
|
||||
}
|
||||
</MudText>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||
<MudText>وضعیت: @GetStatusText(o.PaymentStatus)</MudText>
|
||||
<MudText Color="Color.Primary">@FormatPrice(o.FactorDetails.Sum(s=>s.UnitPrice.Value*s.Count.Value))</MudText>
|
||||
<MudText Color="Color.Primary">@FormatPrice(o.FactorDetails.Sum(s=>(s.UnitPrice ?? 0) * (s.Count ?? 0)))</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,7 +1,8 @@
|
||||
using System;
|
||||
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
|
||||
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Messages = CMSMicroservice.Protobuf.Protos;
|
||||
using MudBlazor;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Store;
|
||||
@@ -45,13 +46,13 @@ public partial class Orders : ComponentBase
|
||||
private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price);
|
||||
|
||||
|
||||
private string GetStatusText(PaymentStatus contextPaymentStatus)
|
||||
private string GetStatusText(Messages.PaymentStatus contextPaymentStatus)
|
||||
{
|
||||
return contextPaymentStatus switch
|
||||
{
|
||||
PaymentStatus.Pending => "در انتظار پرداخت",
|
||||
PaymentStatus.Success => "پرداخت شده",
|
||||
PaymentStatus.Reject => "پرداخت ناموفق",
|
||||
Messages.PaymentStatus.Pending => "در انتظار پرداخت",
|
||||
Messages.PaymentStatus.Success => "پرداخت شده",
|
||||
Messages.PaymentStatus.Reject => "پرداخت ناموفق",
|
||||
_ => "نامشخص",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ else
|
||||
__builder.AddContent(4, "لطفاً شماره موبایل خود را وارد کنید تا رمز پویا ارسال شود.");
|
||||
__builder.CloseComponent();
|
||||
|
||||
<MudForm @ref="_phoneForm" Model="_phoneRequest" Validation="@(_phoneRequestValidator.ValidateValue)">
|
||||
<MudForm @ref="_phoneForm" Model="_phoneRequest">
|
||||
<MudTextField @bind-Value="_phoneRequest.Mobile"
|
||||
For="@(() => _phoneRequest.Mobile)"
|
||||
Label="شماره موبایل"
|
||||
@@ -118,7 +118,7 @@ else
|
||||
وارد کنید.
|
||||
</MudText>
|
||||
|
||||
<MudForm @ref="_verifyForm" Model="_verifyRequest" Validation="@(_verifyRequestValidator.ValidateValue)">
|
||||
<MudForm @ref="_verifyForm" Model="_verifyRequest">
|
||||
<MudTextField @bind-Value="_verifyRequest.Code"
|
||||
For="@(() => _verifyRequest.Code)"
|
||||
Label="رمز پویا"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Blazored.LocalStorage;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
using FrontOffice.BFF.User.Protobuf.Validator;
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Grpc.Core;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -25,11 +24,9 @@ public partial class AuthDialog : IDisposable
|
||||
|
||||
public AuthStep _currentStep = AuthStep.Phone;
|
||||
|
||||
private readonly CreateNewOtpTokenRequestValidator _phoneRequestValidator = new();
|
||||
private readonly CreateNewOtpTokenRequest _phoneRequest = new();
|
||||
private MudForm? _phoneForm;
|
||||
|
||||
private readonly VerifyOtpTokenRequestValidator _verifyRequestValidator = new();
|
||||
private readonly VerifyOtpTokenRequest _verifyRequest = new();
|
||||
private MudForm? _verifyForm;
|
||||
|
||||
@@ -105,10 +102,10 @@ public partial class AuthDialog : IDisposable
|
||||
|
||||
try
|
||||
{
|
||||
var validationResult = _phoneRequestValidator.Validate(_phoneRequest);
|
||||
if (!validationResult.IsValid)
|
||||
var validationResult = true; // _phoneRequestValidator.Validate(_phoneRequest);
|
||||
if (!validationResult)
|
||||
{
|
||||
_errorMessage = string.Join(" ", validationResult.Errors.Select(e => e.ErrorMessage).Distinct());
|
||||
_errorMessage = "لطفاً شماره تلفن معتبر وارد کنید."; // string.Join(" ", validationResult.Errors.Select(e => e.ErrorMessage).Distinct());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -189,10 +186,10 @@ public partial class AuthDialog : IDisposable
|
||||
_verifyRequest.ParentReferralCode = storedReferralCode;
|
||||
}
|
||||
|
||||
var validationResult = _verifyRequestValidator.Validate(_verifyRequest);
|
||||
if (!validationResult.IsValid)
|
||||
var validationResult = true; // _verifyRequestValidator.Validate(_verifyRequest);
|
||||
if (!validationResult)
|
||||
{
|
||||
_errorMessage = string.Join(" ", validationResult.Errors.Select(e => e.ErrorMessage).Distinct());
|
||||
_errorMessage = "لطفاً کد تأیید معتبر وارد کنید."; // string.Join(" ", validationResult.Errors.Select(e => e.ErrorMessage).Distinct());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
@using FrontOffice.BFF.ClubMembership.Protobuf.Protos.ClubMembership
|
||||
@using CMSMicroservice.Protobuf.Protos.ClubMembership
|
||||
@using CMSMicroservice.Protobuf.Protos.OtpToken
|
||||
@using Blazored.LocalStorage
|
||||
@using FrontOffice.Main.Utilities
|
||||
@using MudBlazor
|
||||
@inject ClubMembershipContract.ClubMembershipContractClient ClubMembershipClient
|
||||
@inject OtpTokenContract.OtpTokenContractClient OtpTokenClient
|
||||
@inject ILocalStorageService LocalStorage
|
||||
@inject AuthService AuthService
|
||||
@inject ISnackbar Snackbar
|
||||
@@ -129,23 +131,25 @@
|
||||
_isLoading = true;
|
||||
try
|
||||
{
|
||||
var response = await ClubMembershipClient.RequestClubContractOtpAsync(
|
||||
new RequestClubContractOtpRequest
|
||||
var response = await OtpTokenClient.CreateNewOtpTokenAsync(
|
||||
new CMSMicroservice.Protobuf.Protos.OtpToken.CreateNewOtpTokenRequest
|
||||
{
|
||||
SignGuid = _signGuid.ToString()
|
||||
Mobile = await GetUserMobileAsync(),
|
||||
Purpose = "ClubContract"
|
||||
});
|
||||
|
||||
if (response.Success)
|
||||
{
|
||||
_step = ContractStep.EnterOtp;
|
||||
_remainingSeconds = response.RemainingSeconds > 0 ? response.RemainingSeconds : 120;
|
||||
_remainingSeconds = 120; // Default 2 minutes
|
||||
StartCountdown();
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add(response.Message, Severity.Error);
|
||||
Snackbar.Add(response.Message ?? "ارسال رمز پویا با خطا مواجه شد.", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در ارسال کد: {ex.Message}", Severity.Error);
|
||||
@@ -162,9 +166,11 @@
|
||||
_isLoading = true;
|
||||
try
|
||||
{
|
||||
var userId = await GetCurrentUserIdAsync();
|
||||
var response = await ClubMembershipClient.AcceptClubMembershipContractAsync(
|
||||
new AcceptClubMembershipContractRequest
|
||||
new CMSMicroservice.Protobuf.Protos.ClubMembership.AcceptClubMembershipContractRequest
|
||||
{
|
||||
UserId = userId,
|
||||
OtpCode = _otpCode,
|
||||
SignGuid = _signGuid.ToString(),
|
||||
ContractHtml = GetClubContractHtml()
|
||||
@@ -172,21 +178,16 @@
|
||||
|
||||
if (response.Success)
|
||||
{
|
||||
// ذخیره توکن جدید
|
||||
if (!string.IsNullOrEmpty(response.Token))
|
||||
{
|
||||
await LocalStorage.SetItemAsync(TokenStorageKey, response.Token);
|
||||
await AuthService.InitUserAuthInfo();
|
||||
}
|
||||
|
||||
_step = ContractStep.Success;
|
||||
StopCountdown();
|
||||
Snackbar.Add("قرارداد باشگاه مشتریان با موفقیت امضا شد.", Severity.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add(response.Message, Severity.Error);
|
||||
Snackbar.Add(response.Message ?? "امضای قرارداد با خطا مواجه شد.", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در ثبت قرارداد: {ex.Message}", Severity.Error);
|
||||
@@ -233,8 +234,7 @@
|
||||
|
||||
private string GetClubContractHtml()
|
||||
{
|
||||
return @"
|
||||
<div style='direction: rtl; font-family: Tahoma, sans-serif; line-height: 2; text-align: justify;'>
|
||||
return $@"<div style='direction: rtl; font-family: Tahoma, sans-serif; line-height: 2; text-align: justify;'>
|
||||
<h2 style='text-align: center; margin-bottom: 20px;'>قرارداد عضویت در باشگاه مشتریان کارابازار</h2>
|
||||
|
||||
<p><strong>ماده ۱ - تعاریف</strong></p>
|
||||
@@ -265,7 +265,21 @@
|
||||
<p>۶-۱. در صورت بروز اختلاف، طرفین ابتدا از طریق مذاکره اقدام به حل و فصل خواهند کرد.</p>
|
||||
<p>۶-۲. در صورت عدم توافق، مراجع قضایی صلاحیتدار رسیدگی خواهند کرد.</p>
|
||||
|
||||
<p style='text-align: center; margin-top: 30px;'><strong>شناسه قرارداد: " + _signGuid + @"</strong></p>
|
||||
<p style='text-align: center; margin-top: 30px;'><strong>شناسه قرارداد: {_signGuid}</strong></p>
|
||||
</div>";
|
||||
}
|
||||
|
||||
private async Task<string> GetUserMobileAsync()
|
||||
{
|
||||
// Get user mobile from auth service or localStorage
|
||||
var userInfo = await AuthService.GetUserAuthInfo();
|
||||
return userInfo?.MobileNumber ?? "";
|
||||
}
|
||||
|
||||
private async Task<long> GetCurrentUserIdAsync()
|
||||
{
|
||||
// Get current user ID from auth service
|
||||
var userInfo = await AuthService.GetUserAuthInfo();
|
||||
return userInfo?.UserId ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using FrontOffice.BFF.Configuration.Protobuf.Protos.AppVersion;
|
||||
using CMSMicroservice.Protobuf.Protos.AppVersion;
|
||||
using Blazored.LocalStorage;
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Blazored.LocalStorage;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
@@ -12,7 +12,7 @@ public class AuthService
|
||||
private readonly NavigationManager _navigation;
|
||||
private readonly ISnackbar _snackbar;
|
||||
private readonly UserAuthInfo _userAuthInfo;
|
||||
private readonly UserContract.UserContractClient _userContract;
|
||||
private readonly CMSMicroservice.Protobuf.Protos.User.UserContract.UserContractClient _userContract;
|
||||
private readonly ILogger<AuthService> _logger;
|
||||
|
||||
private const string TokenStorageKey = "auth:token";
|
||||
@@ -22,7 +22,7 @@ public class AuthService
|
||||
NavigationManager navigation,
|
||||
ISnackbar snackbar,
|
||||
UserAuthInfo userAuthInfo,
|
||||
UserContract.UserContractClient userContract,
|
||||
CMSMicroservice.Protobuf.Protos.User.UserContract.UserContractClient userContract,
|
||||
ILogger<AuthService> logger)
|
||||
{
|
||||
_localStorage = localStorage;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using DateTimeConverterCL;
|
||||
using FrontOffice.BFF.ShopingCart.Protobuf.Protos.ShopingCart;
|
||||
using CMSMicroservice.Protobuf.Protos.UserCarts;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Blazored.LocalStorage;
|
||||
|
||||
@@ -16,7 +16,7 @@ public record CartItem(long cartId,long ProductId, string Title, string ImageUrl
|
||||
|
||||
public class CartService
|
||||
{
|
||||
private readonly ShopingCartContract.ShopingCartContractClient _client;
|
||||
private readonly UserCartsContract.UserCartsContractClient _client;
|
||||
private readonly ILocalStorageService _localStorage;
|
||||
private readonly List<CartItem> _items = new();
|
||||
private const string TokenStorageKey = "auth:token";
|
||||
@@ -24,7 +24,7 @@ public class CartService
|
||||
|
||||
public event Action? OnChange;
|
||||
|
||||
public CartService(ShopingCartContract.ShopingCartContractClient client, ILocalStorageService localStorage)
|
||||
public CartService(CMSMicroservice.Protobuf.Protos.UserCarts.UserCartsContract.UserCartsContractClient client, ILocalStorageService localStorage)
|
||||
{
|
||||
_client = client;
|
||||
_localStorage = localStorage;
|
||||
@@ -71,7 +71,7 @@ public class CartService
|
||||
{
|
||||
if (existing is null)
|
||||
{
|
||||
await _client.AddNewUserCartAsync(new AddNewUserCartRequest
|
||||
await _client.AddNewUserCartForCustomerAsync(new AddNewUserCartForCustomerRequest
|
||||
{
|
||||
ProductId = product.Id,
|
||||
Count = newQuantity
|
||||
@@ -80,9 +80,9 @@ public class CartService
|
||||
}
|
||||
else
|
||||
{
|
||||
await _client.UpdateUserCartAsync(new UpdateUserCartRequest
|
||||
await _client.UpdateUserCartForCustomerAsync(new UpdateUserCartForCustomerRequest
|
||||
{
|
||||
UserCartId = existing.cartId,
|
||||
CartItemId = existing.cartId,
|
||||
Count = newQuantity
|
||||
});
|
||||
}
|
||||
@@ -111,9 +111,9 @@ public class CartService
|
||||
|
||||
try
|
||||
{
|
||||
await _client.UpdateUserCartAsync(new UpdateUserCartRequest
|
||||
await _client.UpdateUserCartForCustomerAsync(new UpdateUserCartForCustomerRequest
|
||||
{
|
||||
UserCartId = existing.cartId,
|
||||
CartItemId = existing.cartId,
|
||||
Count = quantity
|
||||
});
|
||||
}
|
||||
@@ -133,11 +133,10 @@ public class CartService
|
||||
|
||||
try
|
||||
{
|
||||
// Interpret Count=0 as remove from cart
|
||||
await _client.UpdateUserCartAsync(new UpdateUserCartRequest
|
||||
// Use dedicated remove endpoint
|
||||
await _client.RemoveUserCartForCustomerAsync(new RemoveUserCartForCustomerRequest
|
||||
{
|
||||
UserCartId = cartId,
|
||||
Count = 0
|
||||
CartItemId = cartId
|
||||
});
|
||||
}
|
||||
catch
|
||||
@@ -157,12 +156,11 @@ public class CartService
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var id in productIds)
|
||||
foreach (var item in productIds)
|
||||
{
|
||||
await _client.UpdateUserCartAsync(new UpdateUserCartRequest
|
||||
await _client.RemoveUserCartForCustomerAsync(new RemoveUserCartForCustomerRequest
|
||||
{
|
||||
UserCartId = id,
|
||||
Count = 0
|
||||
CartItemId = item
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -214,7 +212,7 @@ public class CartService
|
||||
|
||||
try
|
||||
{
|
||||
var response = await _client.GetAllUserCartAsync(new Empty());
|
||||
var response = await _client.GetCustomerCartAsync(new GetUserCartForCustomerRequest());
|
||||
_items.Clear();
|
||||
foreach (var model in response.Models)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using FrontOffice.BFF.Category.Protobuf.Protos.Category;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
|
||||
@@ -9,10 +9,10 @@ public sealed record CategoryItem(long Id, string Title, long? ParentId, string?
|
||||
|
||||
public class CategoryService
|
||||
{
|
||||
private readonly CategoryContract.CategoryContractClient _client;
|
||||
private readonly CMSMicroservice.Protobuf.Protos.Category.CategoryContract.CategoryContractClient _client;
|
||||
private List<CategoryItem>? _cache;
|
||||
|
||||
public CategoryService(CategoryContract.CategoryContractClient client)
|
||||
public CategoryService(CMSMicroservice.Protobuf.Protos.Category.CategoryContract.CategoryContractClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class CategoryService
|
||||
return _cache;
|
||||
}
|
||||
|
||||
var response = await _client.GetAllCategoriesAsync(new GetCategoriesRequest());
|
||||
var response = await _client.GetAllCategoriesForCustomerAsync(new GetAllCategoriesForCustomerRequest());
|
||||
_cache = response.Models
|
||||
.Select(dto => new CategoryItem(
|
||||
Id: dto.Id,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using FrontOffice.BFF.Configuration.Protobuf.Protos.Configuration;
|
||||
using CMSMicroservice.Protobuf.Protos.Configuration;
|
||||
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
using FrontOffice.BFF.ClubMembership.Protobuf.Protos.ClubMembership;
|
||||
using CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// Service for Club Membership operations
|
||||
/// Connected to FrontOffice.BFF gRPC ClubMembershipCQ
|
||||
/// Connected to CMS gRPC ClubMembershipCQ
|
||||
/// </summary>
|
||||
public class ClubMembershipService
|
||||
{
|
||||
private readonly ClubMembershipContract.ClubMembershipContractClient _client;
|
||||
private readonly UserAuthInfo _authInfo;
|
||||
|
||||
public ClubMembershipService(ClubMembershipContract.ClubMembershipContractClient client)
|
||||
public ClubMembershipService(
|
||||
ClubMembershipContract.ClubMembershipContractClient client,
|
||||
UserAuthInfo authInfo)
|
||||
{
|
||||
_client = client;
|
||||
_authInfo = authInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -24,7 +28,8 @@ public class ClubMembershipService
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _client.GetMyClubMembershipAsync(new Empty());
|
||||
// UserId = 0 میفرستیم تا CMS از JWT بخونه
|
||||
var response = await _client.GetClubMembershipAsync(new GetClubMembershipRequest { UserId = 0 });
|
||||
return new ClubMembershipDto
|
||||
{
|
||||
UserId = response.UserId,
|
||||
@@ -33,8 +38,11 @@ public class ClubMembershipService
|
||||
DaysRemaining = response.DaysRemaining > 0 ? response.DaysRemaining : null
|
||||
};
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Log the error for debugging
|
||||
Console.WriteLine($"GetMyMembershipAsync error: {ex.Message}");
|
||||
|
||||
// Return empty membership if backend is unavailable
|
||||
return new ClubMembershipDto
|
||||
{
|
||||
@@ -57,8 +65,23 @@ public class ClubMembershipService
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = new ActivateMyClubMembershipRequest
|
||||
var userId = await GetCurrentUserIdAsync();
|
||||
|
||||
// Check if user is authenticated
|
||||
if (userId <= 0)
|
||||
{
|
||||
return new ClubActivationResponseDto
|
||||
{
|
||||
Success = false,
|
||||
Message = "کاربر احراز هویت نشده است. لطفاً ابتدا وارد شوید.",
|
||||
ActivationDate = null,
|
||||
AmountPaid = 0
|
||||
};
|
||||
}
|
||||
|
||||
var request = new ActivateClubMembershipRequest
|
||||
{
|
||||
UserId = userId,
|
||||
PackageId = packageId,
|
||||
DurationMonths = durationMonths
|
||||
};
|
||||
@@ -68,13 +91,14 @@ public class ClubMembershipService
|
||||
request.ActivationCode = activationCode;
|
||||
}
|
||||
|
||||
var response = await _client.ActivateMyClubMembershipAsync(request);
|
||||
await _client.ActivateClubMembershipAsync(request);
|
||||
// Note: CMS ActivateClubMembership returns Empty, not detailed response
|
||||
return new ClubActivationResponseDto
|
||||
{
|
||||
Success = response.Success,
|
||||
Message = response.Message,
|
||||
ActivationDate = response.ActivationDate?.ToDateTime(),
|
||||
AmountPaid = response.AmountPaid
|
||||
Success = true,
|
||||
Message = "عضویت باشگاه با موفقیت فعال شد.",
|
||||
ActivationDate = DateTime.Now,
|
||||
AmountPaid = 0 // Not available in CMS response
|
||||
};
|
||||
}
|
||||
catch (Grpc.Core.RpcException ex)
|
||||
@@ -88,4 +112,9 @@ public class ClubMembershipService
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private Task<long> GetCurrentUserIdAsync()
|
||||
{
|
||||
return Task.FromResult(_authInfo.UserId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using FrontOffice.BFF.Commission.Protobuf.Protos.Commission;
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using FrontOffice.BFF.NetworkMembership.Protobuf.Protos.NetworkMembership;
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
@@ -122,7 +122,7 @@ public class NetworkMembershipService
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
private static NetworkNodeDto? MapNodeFromProto(NetworkNodeModel? node)
|
||||
private static NetworkNodeDto? MapNodeFromProto(NetworkTreeNodeModel? node)
|
||||
{
|
||||
if (node == null) return null;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
|
||||
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||
using Mapster;
|
||||
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
@@ -35,9 +35,9 @@ public class OrderService
|
||||
{
|
||||
private long _seq = 1000;
|
||||
private readonly List<GetUserOrderResponse> _orders = new();
|
||||
private readonly UserOrderContract.UserOrderContractClient _userOrderContractClient;
|
||||
private readonly CMSMicroservice.Protobuf.Protos.UserOrder.UserOrderContract.UserOrderContractClient _userOrderContractClient;
|
||||
|
||||
public OrderService(UserOrderContract.UserOrderContractClient userOrderContractClient)
|
||||
public OrderService(CMSMicroservice.Protobuf.Protos.UserOrder.UserOrderContract.UserOrderContractClient userOrderContractClient)
|
||||
{
|
||||
_userOrderContractClient = userOrderContractClient;
|
||||
}
|
||||
@@ -83,21 +83,18 @@ public class OrderService
|
||||
/// <summary>
|
||||
/// دریافت نرخ مالیات بر ارزش افزوده
|
||||
/// </summary>
|
||||
public async Task<GetVATRateResponse> GetVATRateAsync()
|
||||
public async Task<double> GetVATRateAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _userOrderContractClient.GetVATRateAsync(new Google.Protobuf.WellKnownTypes.Empty());
|
||||
// TODO: Use Configuration service to get VAT rate
|
||||
// return await _userOrderContractClient.GetVATRateAsync(new Google.Protobuf.WellKnownTypes.Empty());
|
||||
return 0.10; // Default 10%
|
||||
}
|
||||
catch
|
||||
{
|
||||
// در صورت خطا، مقادیر پیشفرض
|
||||
return new GetVATRateResponse
|
||||
{
|
||||
VatRate = 0.10,
|
||||
VatPercentage = 10,
|
||||
IsEnabled = true
|
||||
};
|
||||
return 0.10;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using FrontOffice.BFF.Package.Protobuf.Protos.Package;
|
||||
using CMSMicroservice.Protobuf.Protos.Package;
|
||||
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
|
||||
@@ -31,9 +31,9 @@ public record UserPackageStatusDto(
|
||||
/// </summary>
|
||||
public class PackageService
|
||||
{
|
||||
private readonly PackageContract.PackageContractClient _client;
|
||||
private readonly CMSMicroservice.Protobuf.Protos.Package.PackageContract.PackageContractClient _client;
|
||||
|
||||
public PackageService(PackageContract.PackageContractClient client)
|
||||
public PackageService(CMSMicroservice.Protobuf.Protos.Package.PackageContract.PackageContractClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
@@ -45,16 +45,9 @@ public class PackageService
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = new GetAllPackageByFilterRequest
|
||||
{
|
||||
PaginationState = new PaginationState
|
||||
{
|
||||
PageNumber = 1,
|
||||
PageSize = 100
|
||||
}
|
||||
};
|
||||
var request = new GetCustomerPackagesRequest();
|
||||
|
||||
var response = await _client.GetAllPackageByFilterAsync(request, cancellationToken: ct);
|
||||
var response = await _client.GetCustomerPackagesAsync(request, cancellationToken: ct);
|
||||
|
||||
return response.Models
|
||||
.Select(m => new PackageDto(
|
||||
@@ -81,8 +74,8 @@ public class PackageService
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _client.GetPackageAsync(
|
||||
new GetPackageRequest { Id = id },
|
||||
var response = await _client.GetCustomerPackageDetailsAsync(
|
||||
new GetCustomerPackageDetailsRequest { PackageId = id },
|
||||
cancellationToken: ct);
|
||||
|
||||
if (response == null) return null;
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using FrontOffice.BFF.Products.Protobuf.Protos.Products;
|
||||
using CMSMicroservice.Protobuf.Protos.Products;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
@@ -51,9 +51,9 @@ public class ProductService
|
||||
{
|
||||
private readonly ConcurrentDictionary<long, CacheEntry> _cache = new();
|
||||
private static readonly TimeSpan CacheDuration = TimeSpan.FromMinutes(1);
|
||||
private readonly ProductsContract.ProductsContractClient _client;
|
||||
private readonly CMSMicroservice.Protobuf.Protos.Products.ProductsContract.ProductsContractClient _client;
|
||||
|
||||
public ProductService(ProductsContract.ProductsContractClient client)
|
||||
public ProductService(CMSMicroservice.Protobuf.Protos.Products.ProductsContract.ProductsContractClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Blazored.LocalStorage;
|
||||
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
|
||||
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
@@ -93,7 +93,7 @@ public class VATService
|
||||
{
|
||||
// ایجاد scope برای دریافت client و localStorage
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
var client = scope.ServiceProvider.GetRequiredService<UserOrderContract.UserOrderContractClient>();
|
||||
var client = scope.ServiceProvider.GetRequiredService<CMSMicroservice.Protobuf.Protos.UserOrder.UserOrderContract.UserOrderContractClient>();
|
||||
// var localStorage = scope.ServiceProvider.GetRequiredService<ILocalStorageService>();
|
||||
|
||||
var response = await client.GetVATRateAsync(new Google.Protobuf.WellKnownTypes.Empty());
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
using DateTimeConverterCL;
|
||||
using FrontOffice.BFF.UserWallet.Protobuf.Protos.UserWallet;
|
||||
using CMSMicroservice.Protobuf.Protos.UserWallet;
|
||||
using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
|
||||
public record WalletBalances(long CreditBalance, long DiscountBalance, long NetworkBalance);
|
||||
public record WalletTransaction(string Date, long Amount, string Channel, string Description);
|
||||
public record WalletTransaction(
|
||||
string Date,
|
||||
long CreditChange,
|
||||
long CreditBalance,
|
||||
long NetworkChange,
|
||||
long NetworkBalance,
|
||||
long DiscountChange,
|
||||
long DiscountBalance,
|
||||
string Channel,
|
||||
string Description
|
||||
);
|
||||
public record WalletWithdrawal(long Id, long WeekDefinitionId, string WeekDisplayName, long Amount, int Status, int? Method, string? Iban, string Created);
|
||||
public enum WithdrawalMethodClient
|
||||
{
|
||||
@@ -16,9 +27,9 @@ public record WithdrawalSettings(long MinWithdrawalAmount);
|
||||
|
||||
public class WalletService
|
||||
{
|
||||
private readonly UserWalletContract.UserWalletContractClient _client;
|
||||
private readonly CMSMicroservice.Protobuf.Protos.UserWallet.UserWalletContract.UserWalletContractClient _client;
|
||||
|
||||
public WalletService(UserWalletContract.UserWalletContractClient client)
|
||||
public WalletService(CMSMicroservice.Protobuf.Protos.UserWallet.UserWalletContract.UserWalletContractClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
@@ -27,7 +38,7 @@ public class WalletService
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _client.GetUserWalletAsync(new Empty());
|
||||
var response = await _client.GetCustomerWalletAsync(new Empty());
|
||||
return new WalletBalances(response.Balance, response.DiscountBalance, response.NetworkBalance);
|
||||
}
|
||||
catch
|
||||
@@ -41,7 +52,7 @@ public class WalletService
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = new GetAllUserWalletChangeLogRequest();
|
||||
var request = new GetCustomerWalletChangeLogRequest();
|
||||
if (referenceId.HasValue)
|
||||
{
|
||||
request.ReferenceId = referenceId.Value;
|
||||
@@ -50,13 +61,20 @@ public class WalletService
|
||||
{
|
||||
request.IsIncrease = isIncrease.Value;
|
||||
}
|
||||
var response = await _client.GetAllUserWalletChangeLogAsync(request);
|
||||
var response = await _client.GetCustomerWalletChangeLogAsync(request);
|
||||
|
||||
return response.Models
|
||||
.Select(t => new WalletTransaction(
|
||||
ResolveTransactionDate(t),
|
||||
t.ChangeValue != 0 ? t.ChangeValue : t.CurrentBalance,
|
||||
t.RefrenceId?.ToString() ?? "-",
|
||||
ResolveDescription(t)))
|
||||
.Select(log => new WalletTransaction(
|
||||
ResolveTransactionDate(log),
|
||||
log.ChangeValue,
|
||||
log.CurrentBalance,
|
||||
log.ChangeNerworkValue,
|
||||
log.CurrentNetworkBalance,
|
||||
log.ChangeDiscountValue,
|
||||
log.CurrentDiscountBalance,
|
||||
log.RefrenceId?.ToString() ?? "-",
|
||||
ResolveDescription(log)
|
||||
))
|
||||
.OrderByDescending(t => t.Date)
|
||||
.ToList();
|
||||
}
|
||||
@@ -67,13 +85,14 @@ public class WalletService
|
||||
}
|
||||
}
|
||||
|
||||
private static string ResolveTransactionDate(GetAllUserWalletChangeLogResponseModel model)
|
||||
private static string ResolveTransactionDate(CustomerWalletChangeLogModel model)
|
||||
{
|
||||
if (model.CreatedAt is not null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return model.CreatedAt.ToDateTime().MiladiToJalaliWithTime();
|
||||
var utcDate = model.CreatedAt.ToDateTime();
|
||||
return utcDate.ToLocalTime().MiladiToJalaliWithTime();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -84,16 +103,25 @@ public class WalletService
|
||||
return DateTime.Now.MiladiToJalaliWithTime();
|
||||
}
|
||||
|
||||
private static string ResolveDescription(GetAllUserWalletChangeLogResponseModel model)
|
||||
private static string ResolveDescription(CustomerWalletChangeLogModel model)
|
||||
{
|
||||
if (model.ChangeValue > 0) return "شارژ کیف پول";
|
||||
if (model.ChangeValue < 0) return "برداشت/خرید";
|
||||
return "تراکنش کیف پول";
|
||||
var parts = new List<string>();
|
||||
|
||||
if (model.ChangeValue != 0)
|
||||
parts.Add(model.ChangeValue > 0 ? "شارژ عادی" : "برداشت عادی");
|
||||
|
||||
if (model.ChangeNerworkValue != 0)
|
||||
parts.Add(model.ChangeNerworkValue > 0 ? "دریافت شبکه" : "برداشت شبکه");
|
||||
|
||||
if (model.ChangeDiscountValue != 0)
|
||||
parts.Add(model.ChangeDiscountValue > 0 ? "شارژ تخفیفی" : "خرید تخفیفی");
|
||||
|
||||
return parts.Count > 0 ? string.Join(" | ", parts) : "تراکنش کیف پول";
|
||||
}
|
||||
|
||||
public async Task<bool> RequestWithdrawalAsync(long payoutId, WithdrawalMethodClient method, string? iban)
|
||||
{
|
||||
var request = new WithdrawBalanceRequest
|
||||
var request = new CustomerWithdrawBalanceRequest
|
||||
{
|
||||
PayoutId = payoutId,
|
||||
WithdrawalMethod = (int)method
|
||||
@@ -104,7 +132,7 @@ public class WalletService
|
||||
}
|
||||
try
|
||||
{
|
||||
await _client.WithdrawBalanceAsync(request);
|
||||
await _client.CustomerWithdrawBalanceAsync(request);
|
||||
return true;
|
||||
}
|
||||
catch (Grpc.Core.RpcException ex)
|
||||
@@ -117,13 +145,13 @@ public class WalletService
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = new GetUserWithdrawalsRequest();
|
||||
var request = new GetCustomerWithdrawalsRequest();
|
||||
if (status.HasValue)
|
||||
{
|
||||
request.Status = status.Value;
|
||||
}
|
||||
|
||||
var response = await _client.GetUserWithdrawalsAsync(request);
|
||||
var response = await _client.GetCustomerWithdrawalsAsync(request);
|
||||
return response.Models
|
||||
.Select(m => new WalletWithdrawal(
|
||||
m.Id,
|
||||
@@ -146,7 +174,7 @@ public class WalletService
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _client.GetWithdrawalSettingsAsync(new Empty());
|
||||
var response = await _client.GetCustomerWithdrawalSettingsAsync(new Empty());
|
||||
return new WithdrawalSettings(response.MinWithdrawalAmount);
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
@using MudBlazor
|
||||
@using FrontOffice.Main.Utilities
|
||||
@using DateTimeConverterCL
|
||||
@using CityProto = FrontOffice.BFF.City.Protobuf
|
||||
|
||||
|
||||
@inject NavigationManager Navigation
|
||||
@inject IDialogService DialogService
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
// "GwUrl": "https://localhost:34781",
|
||||
"GwUrl": "https://frontoffice-bff.se.kbs1.ir",
|
||||
"GwUrl": "https://localhost:32846",
|
||||
"DownloadUrl": "https://dl.afrino.co",
|
||||
"EncryptionSettings": {
|
||||
"Key": "kmcQ3XTmH4mrdh8VHziuscyf8LLYjG//Kyni81nH/0E=",
|
||||
|
||||
Reference in New Issue
Block a user