feat(wallet-management): add magic wallet charge functionality with enhanced filtering options
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 11m8s

- Introduced a new tab for managing magic wallet charges, including user search and transaction ID filters.
- Implemented a data grid to display magic wallet charge details, including user information, amounts, and transaction dates.
- Updated the project to use Foursat.CMSMicroservice.Protobuf version 0.0.215 for compatibility with recent changes.
This commit is contained in:
masoodafar-web
2026-10-13 01:30:09 +03:30
parent 420201e3b8
commit ef99541157
2 changed files with 144 additions and 2 deletions
+1 -1
View File
@@ -143,7 +143,7 @@
<ProjectReference Include="../../../CMS/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj" /> <ProjectReference Include="../../../CMS/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="!Exists('../../../CMS/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj')"> <ItemGroup Condition="!Exists('../../../CMS/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj')">
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.214" /> <PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.215" />
</ItemGroup> </ItemGroup>
<!-- ============================================================ --> <!-- ============================================================ -->
@@ -1,9 +1,13 @@
@page "/wallets" @page "/wallets"
@attribute [Authorize(Roles = "Administrator")] @attribute [Authorize(Roles = "Administrator")]
@using BackOffice.Common.BaseComponents
@using BackOffice.Pages.AutoComplete
@using CMSMicroservice.Protobuf.Protos
@using CMSMicroservice.Protobuf.Protos.UserWallet @using CMSMicroservice.Protobuf.Protos.UserWallet
@using CMSMicroservice.Protobuf.Protos.UserWalletHistory @using CMSMicroservice.Protobuf.Protos.UserWalletHistory
@using BackOffice.Pages.AutoComplete @using DateTimeConverterCL
@using Google.Protobuf.WellKnownTypes
@inject UserWalletContract.UserWalletContractClient WalletClient @inject UserWalletContract.UserWalletContractClient WalletClient
@inject UserWalletHistoryContract.UserWalletHistoryContractClient ChangeLogClient @inject UserWalletHistoryContract.UserWalletHistoryContractClient ChangeLogClient
@@ -156,6 +160,90 @@
</PagerContent> </PagerContent>
</MudDataGrid> </MudDataGrid>
</MudTabPanel> </MudTabPanel>
@* ── تب سوم: شارژ کیف جادویی ── *@
<MudTabPanel Text="شارژ کیف جادویی" Icon="@Icons.Material.Filled.AutoAwesome">
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center" Class="mb-3 flex-wrap">
<UserAutoComplete Label="جستجوی کاربر" @bind-SelectedUserId="_magicFilterUserId" />
<MudTextField T="long?" Label="شناسه تراکنش" Variant="Variant.Outlined"
Margin="Margin.Dense" @bind-Value="_magicFilterTransactionId"
Style="max-width: 160px;" />
<MudTextField T="string" Label="RefId" Variant="Variant.Outlined"
Margin="Margin.Dense" @bind-Value="_magicFilterRefId"
Style="max-width: 180px;" />
<DateRangePicker @bind-From="_magicFilterFrom" @bind-To="_magicFilterTo" Label="بازه تاریخ" />
<MudButton Variant="Variant.Filled" Color="Color.Primary"
StartIcon="@Icons.Material.Filled.Search"
OnClick="ApplyMagicFilter">جستجو</MudButton>
</MudStack>
<MudDataGrid T="MagicWalletChargeModel" @ref="_magicGrid"
ServerData="LoadMagicCharges"
Hover="true" Dense="true"
Height="calc(100vh - 340px)">
<Columns>
<TemplateColumn Title="کاربر">
<CellTemplate>
<MudStack Spacing="0">
<MudText Typo="Typo.body2"><strong>@context.Item.UserName</strong></MudText>
<MudText Typo="Typo.caption" Color="Color.Secondary">ID: @context.Item.UserId</MudText>
</MudStack>
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="مبلغ شارژ">
<CellTemplate>
<MudText>@context.Item.DepositAmount.ToString("N0")</MudText>
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="ضریب">
<CellTemplate>
<MudText>@context.Item.Multiplier.ToString("0.0")</MudText>
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="مبلغ دریافتی">
<CellTemplate>
<MudText Color="Color.Success"><strong>@context.Item.CreditedAmount.ToString("N0")</strong></MudText>
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="باقیمانده ظرفیت">
<CellTemplate>
@(context.Item.RemainingCapacity != null
? context.Item.RemainingCapacity.Value.ToString("N0")
: "—")
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="تاریخ">
<CellTemplate>
@((context.Item.PaymentDate ?? context.Item.Created)?
.ToDateTime().ToLocalTime().MiladiToJalaliWithTime() ?? "—")
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="شناسه تراکنش">
<CellTemplate>
<MudStack Spacing="0">
<MudText Typo="Typo.body2">@context.Item.TransactionId</MudText>
<MudText Typo="Typo.caption" Color="Color.Secondary">
@(string.IsNullOrWhiteSpace(context.Item.RefId) ? "—" : context.Item.RefId)
</MudText>
</MudStack>
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="موجودی بعد از شارژ">
<CellTemplate>
<MudText Color="Color.Primary">@context.Item.NewBalance.ToString("N0")</MudText>
</CellTemplate>
</TemplateColumn>
</Columns>
<NoRecordsContent>
<MudAlert Severity="Severity.Info" Dense="true" Variant="Variant.Text" Class="my-4">موردی یافت نشد.</MudAlert>
</NoRecordsContent>
<PagerContent>
<MudDataGridPager T="MagicWalletChargeModel" PageSizeOptions="@(new int[] { 20, 50, 100 })"
InfoFormat="سطر {first_item} تا {last_item} از {all_items}"
RowsPerPageString="تعداد در صفحه" />
</PagerContent>
</MudDataGrid>
</MudTabPanel>
</MudTabs> </MudTabs>
</div> </div>
@@ -163,6 +251,7 @@
private int _activeTab; private int _activeTab;
private MudDataGrid<GetAllUserWalletByFilterResponseModel>? _walletGrid; private MudDataGrid<GetAllUserWalletByFilterResponseModel>? _walletGrid;
private MudDataGrid<GetAllUserWalletHistoryByFilterResponseModel>? _logGrid; private MudDataGrid<GetAllUserWalletHistoryByFilterResponseModel>? _logGrid;
private MudDataGrid<MagicWalletChargeModel>? _magicGrid;
// Wallet filters // Wallet filters
private long? _filterUserId; private long? _filterUserId;
@@ -171,6 +260,13 @@
private long? _logFilterUserId; private long? _logFilterUserId;
private bool? _logFilterIsIncrease; private bool? _logFilterIsIncrease;
// Magic charge filters
private long? _magicFilterUserId;
private long? _magicFilterTransactionId;
private string? _magicFilterRefId;
private DateTime? _magicFilterFrom;
private DateTime? _magicFilterTo;
private async Task<GridData<GetAllUserWalletByFilterResponseModel>> LoadWallets(GridState<GetAllUserWalletByFilterResponseModel> state) private async Task<GridData<GetAllUserWalletByFilterResponseModel>> LoadWallets(GridState<GetAllUserWalletByFilterResponseModel> state)
{ {
try try
@@ -238,6 +334,52 @@
if (_logGrid != null) await _logGrid.ReloadServerData(); if (_logGrid != null) await _logGrid.ReloadServerData();
} }
private async Task<GridData<MagicWalletChargeModel>> LoadMagicCharges(GridState<MagicWalletChargeModel> state)
{
try
{
var request = new GetMagicWalletChargesRequest
{
PaginationState = new PaginationState
{
PageNumber = state.Page + 1,
PageSize = state.PageSize
},
Filter = new GetMagicWalletChargesFilter()
};
if (_magicFilterUserId.HasValue && _magicFilterUserId.Value > 0)
request.Filter.UserId = _magicFilterUserId.Value;
if (_magicFilterTransactionId.HasValue)
request.Filter.TransactionId = _magicFilterTransactionId.Value;
if (!string.IsNullOrWhiteSpace(_magicFilterRefId))
request.Filter.RefId = _magicFilterRefId.Trim();
if (_magicFilterFrom.HasValue)
request.Filter.CreatedFrom = Timestamp.FromDateTime(
DateTime.SpecifyKind(_magicFilterFrom.Value, DateTimeKind.Utc));
if (_magicFilterTo.HasValue)
request.Filter.CreatedTo = Timestamp.FromDateTime(
DateTime.SpecifyKind(_magicFilterTo.Value, DateTimeKind.Utc));
var result = await WalletClient.GetMagicWalletChargesAsync(request);
return new GridData<MagicWalletChargeModel>
{
Items = result?.Models?.ToList() ?? new(),
TotalItems = (int)(result?.MetaData?.TotalCount ?? 0)
};
}
catch (Exception ex)
{
Snackbar.Add($"خطا: {ex.Message}", Severity.Error);
return new GridData<MagicWalletChargeModel>();
}
}
private async Task ApplyMagicFilter()
{
if (_magicGrid != null) await _magicGrid.ReloadServerData();
}
private void ShowChangeLog(GetAllUserWalletByFilterResponseModel wallet) private void ShowChangeLog(GetAllUserWalletByFilterResponseModel wallet)
{ {
_logFilterUserId = wallet.UserId; _logFilterUserId = wallet.UserId;