feat: Implement Commission and Network Statistics Pages with DTOs and Services
- Added CommissionDashboardPage and CommissionHistoryPage for displaying commission payouts and history. - Implemented WeeklyBalancePage to show weekly balance details. - Created NetworkStatisticsPage to display network statistics and tree structure. - Developed corresponding services (CommissionService, NetworkMembershipService) for data retrieval. - Introduced DTOs for Commission and Network data structures (CommissionPayoutDto, WeeklyBalanceDto, NetworkStatisticsDto). - Added mock data generation for testing purposes in services. - Enhanced UI with MudBlazor components for better user experience.
This commit is contained in:
@@ -46,6 +46,10 @@ public static class ConfigureServices
|
|||||||
services.AddScoped<CategoryService>();
|
services.AddScoped<CategoryService>();
|
||||||
services.AddScoped<OrderService>();
|
services.AddScoped<OrderService>();
|
||||||
services.AddScoped<WalletService>();
|
services.AddScoped<WalletService>();
|
||||||
|
// New services for Club, Network, Commission
|
||||||
|
services.AddScoped<ClubMembershipService>();
|
||||||
|
services.AddScoped<NetworkMembershipService>();
|
||||||
|
services.AddScoped<CommissionService>();
|
||||||
// Device detection: very light, dependency-free
|
// Device detection: very light, dependency-free
|
||||||
services.AddTransient<IDeviceDetector, DeviceDetector>();
|
services.AddTransient<IDeviceDetector, DeviceDetector>();
|
||||||
// PDF generation (Chromium only)
|
// PDF generation (Chromium only)
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
@using FrontOffice.Main.Utilities
|
||||||
|
@using MudBlazor
|
||||||
|
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudText Typo="Typo.h6" Class="mb-3">فعالسازی یا تمدید عضویت</MudText>
|
||||||
|
|
||||||
|
<MudForm @ref="_form" @bind-IsValid="_formIsValid">
|
||||||
|
<MudGrid Spacing="2">
|
||||||
|
<MudItem xs="12" sm="6">
|
||||||
|
<MudNumericField @bind-Value="_packageId"
|
||||||
|
Label="شناسه بسته"
|
||||||
|
Variant="Variant.Outlined"
|
||||||
|
Required="true"
|
||||||
|
RequiredError="شناسه بسته الزامی است"
|
||||||
|
Min="1"
|
||||||
|
HelperText="شناسه بسته باشگاه را وارد کنید" />
|
||||||
|
</MudItem>
|
||||||
|
<MudItem xs="12" sm="6">
|
||||||
|
<MudNumericField @bind-Value="_durationMonths"
|
||||||
|
Label="مدت زمان (ماه)"
|
||||||
|
Variant="Variant.Outlined"
|
||||||
|
Required="true"
|
||||||
|
RequiredError="مدت زمان الزامی است"
|
||||||
|
Min="1"
|
||||||
|
Max="12"
|
||||||
|
HelperText="از 1 تا 12 ماه" />
|
||||||
|
</MudItem>
|
||||||
|
<MudItem xs="12">
|
||||||
|
<MudTextField @bind-Value="_activationCode"
|
||||||
|
Label="کد فعالسازی (اختیاری)"
|
||||||
|
Variant="Variant.Outlined"
|
||||||
|
HelperText="در صورت داشتن کد تخفیف یا کد فعالسازی، وارد کنید" />
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<!-- پیشنمایش هزینه -->
|
||||||
|
<MudItem xs="12">
|
||||||
|
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined">
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.body1">هزینه تقریبی:</MudText>
|
||||||
|
<MudText Typo="Typo.h6" Color="Color.Primary">@GetEstimatedCost()</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudAlert>
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12">
|
||||||
|
<MudButton Variant="Variant.Filled"
|
||||||
|
Color="Color.Primary"
|
||||||
|
FullWidth="true"
|
||||||
|
Disabled="@(!_formIsValid || _isSubmitting)"
|
||||||
|
OnClick="HandleActivateAsync"
|
||||||
|
StartIcon="@Icons.Material.Filled.CheckCircle">
|
||||||
|
@if (_isSubmitting)
|
||||||
|
{
|
||||||
|
<MudProgressCircular Size="Size.Small" Indeterminate="true" />
|
||||||
|
<span class="ms-2">در حال پردازش...</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span>پرداخت و فعالسازی</span>
|
||||||
|
}
|
||||||
|
</MudButton>
|
||||||
|
</MudItem>
|
||||||
|
</MudGrid>
|
||||||
|
</MudForm>
|
||||||
|
|
||||||
|
@if (!string.IsNullOrEmpty(_errorMessage))
|
||||||
|
{
|
||||||
|
<MudAlert Severity="Severity.Error" Class="mt-3" Variant="Variant.Filled">
|
||||||
|
@_errorMessage
|
||||||
|
</MudAlert>
|
||||||
|
}
|
||||||
|
</MudPaper>
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
using FrontOffice.Main.Utilities;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using MudBlazor;
|
||||||
|
|
||||||
|
namespace FrontOffice.Main.Pages.Club.Components;
|
||||||
|
|
||||||
|
public partial class ActivationSection : ComponentBase
|
||||||
|
{
|
||||||
|
[Inject] private ClubMembershipService ClubService { get; set; } = default!;
|
||||||
|
|
||||||
|
[Parameter] public EventCallback OnActivationSuccess { get; set; }
|
||||||
|
|
||||||
|
private MudForm _form = default!;
|
||||||
|
private bool _formIsValid;
|
||||||
|
private bool _isSubmitting;
|
||||||
|
private string? _errorMessage;
|
||||||
|
|
||||||
|
private long _packageId = 1;
|
||||||
|
private int _durationMonths = 1;
|
||||||
|
private string? _activationCode;
|
||||||
|
|
||||||
|
private async Task HandleActivateAsync()
|
||||||
|
{
|
||||||
|
await _form.Validate();
|
||||||
|
if (!_formIsValid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_isSubmitting = true;
|
||||||
|
_errorMessage = null;
|
||||||
|
|
||||||
|
var result = await ClubService.ActivateMembershipAsync(
|
||||||
|
_packageId,
|
||||||
|
_activationCode,
|
||||||
|
_durationMonths
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result.Success)
|
||||||
|
{
|
||||||
|
Snackbar.Add($"عضویت فعال شد! مبلغ پرداختی: {result.AmountPaid:N0} تومان", Severity.Success);
|
||||||
|
await OnActivationSuccess.InvokeAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_errorMessage = result.Message ?? "خطا در فعالسازی عضویت";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_errorMessage = $"خطا: {ex.Message}";
|
||||||
|
Snackbar.Add(_errorMessage, Severity.Error);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isSubmitting = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetEstimatedCost()
|
||||||
|
{
|
||||||
|
// فرمول تقریبی: 56M per month (base amount from BFF implementation)
|
||||||
|
var baseAmount = 56_000_000;
|
||||||
|
var total = baseAmount * _durationMonths;
|
||||||
|
return $"{total:N0} تومان";
|
||||||
|
}
|
||||||
|
}
|
||||||
152
src/FrontOffice.Main/Pages/Club/FeaturesPage.razor
Normal file
152
src/FrontOffice.Main/Pages/Club/FeaturesPage.razor
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
@attribute [Route(RouteConstants.Club.Features)]
|
||||||
|
@using FrontOffice.Main.Utilities
|
||||||
|
@using MudBlazor
|
||||||
|
|
||||||
|
<PageTitle>ویژگیهای باشگاه مشتریان</PageTitle>
|
||||||
|
|
||||||
|
<MudContainer MaxWidth="MaxWidth.Large" Class="py-6">
|
||||||
|
<MudStack Spacing="3">
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.h5">ویژگیهای باشگاه مشتریان</MudText>
|
||||||
|
<MudButton Variant="Variant.Text" StartIcon="@Icons.Material.Filled.ArrowBack" Href="@RouteConstants.Club.Membership">بازگشت</MudButton>
|
||||||
|
</MudStack>
|
||||||
|
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudText Typo="Typo.h6" Class="mb-3">چرا باشگاه مشتریان؟</MudText>
|
||||||
|
<MudText Typo="Typo.body1" Class="mb-2">
|
||||||
|
با عضویت در باشگاه مشتریان فورست، از تخفیفهای ویژه، امتیازات خرید و خدمات اختصاصی بهرهمند شوید.
|
||||||
|
</MudText>
|
||||||
|
</MudPaper>
|
||||||
|
|
||||||
|
<MudGrid Spacing="3">
|
||||||
|
<MudItem xs="12" md="6">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg" Style="height: 100%;">
|
||||||
|
<MudStack Spacing="2">
|
||||||
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.Discount" Color="Color.Primary" Size="Size.Large" />
|
||||||
|
<MudText Typo="Typo.h6" Color="Color.Primary">تخفیفهای ویژه</MudText>
|
||||||
|
</MudStack>
|
||||||
|
<MudText Typo="Typo.body2">
|
||||||
|
• تخفیف 10% تا 30% برای تمام محصولات<br />
|
||||||
|
• تخفیفهای فصلی و مناسبتی اختصاصی<br />
|
||||||
|
• پیشنهادات ویژه برای اعضای باشگاه<br />
|
||||||
|
• کد تخفیف اختصاصی ماهانه
|
||||||
|
</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12" md="6">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg" Style="height: 100%;">
|
||||||
|
<MudStack Spacing="2">
|
||||||
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.Diamond" Color="Color.Secondary" Size="Size.Large" />
|
||||||
|
<MudText Typo="Typo.h6" Color="Color.Secondary">امتیاز خرید</MudText>
|
||||||
|
</MudStack>
|
||||||
|
<MudText Typo="Typo.body2">
|
||||||
|
• دریافت امتیاز برای هر خرید<br />
|
||||||
|
• تبدیل امتیاز به تخفیف باشگاه<br />
|
||||||
|
• امتیاز ویژه در روزهای خاص<br />
|
||||||
|
• قابلیت انتقال امتیاز به دوستان
|
||||||
|
</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12" md="6">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg" Style="height: 100%;">
|
||||||
|
<MudStack Spacing="2">
|
||||||
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.LocalShipping" Color="Color.Success" Size="Size.Large" />
|
||||||
|
<MudText Typo="Typo.h6" Color="Color.Success">ارسال رایگان</MudText>
|
||||||
|
</MudStack>
|
||||||
|
<MudText Typo="Typo.body2">
|
||||||
|
• ارسال رایگان برای خریدهای بالای 500 هزار تومان<br />
|
||||||
|
• اولویت در ارسال سفارشات<br />
|
||||||
|
• ارسال اکسپرس با تخفیف 50%<br />
|
||||||
|
• امکان ارسال به چند آدرس
|
||||||
|
</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12" md="6">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg" Style="height: 100%;">
|
||||||
|
<MudStack Spacing="2">
|
||||||
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.Support" Color="Color.Info" Size="Size.Large" />
|
||||||
|
<MudText Typo="Typo.h6" Color="Color.Info">پشتیبانی اختصاصی</MudText>
|
||||||
|
</MudStack>
|
||||||
|
<MudText Typo="Typo.body2">
|
||||||
|
• پشتیبانی 24/7 برای اعضای باشگاه<br />
|
||||||
|
• مشاوره خرید تخصصی<br />
|
||||||
|
• خط ویژه پاسخگویی<br />
|
||||||
|
• پیگیری سریعتر سفارشات
|
||||||
|
</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12" md="6">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg" Style="height: 100%;">
|
||||||
|
<MudStack Spacing="2">
|
||||||
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.Groups" Color="Color.Warning" Size="Size.Large" />
|
||||||
|
<MudText Typo="Typo.h6" Color="Color.Warning">درآمد شبکه</MudText>
|
||||||
|
</MudStack>
|
||||||
|
<MudText Typo="Typo.body2">
|
||||||
|
• دریافت کمیسیون از خریدهای زیرمجموعه<br />
|
||||||
|
• سیستم باینری درختی<br />
|
||||||
|
• محاسبه خودکار درآمد هفتگی<br />
|
||||||
|
• امکان برداشت درآمد شبکه
|
||||||
|
</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12" md="6">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg" Style="height: 100%;">
|
||||||
|
<MudStack Spacing="2">
|
||||||
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.Event" Color="Color.Tertiary" Size="Size.Large" />
|
||||||
|
<MudText Typo="Typo.h6" Color="Color.Tertiary">رویدادهای ویژه</MudText>
|
||||||
|
</MudStack>
|
||||||
|
<MudText Typo="Typo.body2">
|
||||||
|
• دعوت به رویدادهای اختصاصی<br />
|
||||||
|
• پیشفروش محصولات جدید<br />
|
||||||
|
• وبینارهای آموزشی رایگان<br />
|
||||||
|
• جوایز و مسابقات ماهانه
|
||||||
|
</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
</MudGrid>
|
||||||
|
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudText Typo="Typo.h6" Class="mb-3">چگونه عضو شویم؟</MudText>
|
||||||
|
<MudStepper Orientation="Orientation.Horizontal" Color="Color.Primary">
|
||||||
|
<MudStep Title="انتخاب بسته">
|
||||||
|
<MudText>بسته عضویت مناسب خود را انتخاب کنید</MudText>
|
||||||
|
</MudStep>
|
||||||
|
<MudStep Title="پرداخت">
|
||||||
|
<MudText>هزینه عضویت را پرداخت کنید</MudText>
|
||||||
|
</MudStep>
|
||||||
|
<MudStep Title="فعالسازی">
|
||||||
|
<MudText>عضویت شما فورا فعال میشود</MudText>
|
||||||
|
</MudStep>
|
||||||
|
<MudStep Title="استفاده">
|
||||||
|
<MudText>از مزایای باشگاه لذت ببرید</MudText>
|
||||||
|
</MudStep>
|
||||||
|
</MudStepper>
|
||||||
|
</MudPaper>
|
||||||
|
|
||||||
|
<MudButton Variant="Variant.Filled"
|
||||||
|
Color="Color.Primary"
|
||||||
|
FullWidth="true"
|
||||||
|
Size="Size.Large"
|
||||||
|
StartIcon="@Icons.Material.Filled.CheckCircle"
|
||||||
|
Href="@RouteConstants.Club.Membership">
|
||||||
|
همین حالا عضو شوید
|
||||||
|
</MudButton>
|
||||||
|
</MudStack>
|
||||||
|
</MudContainer>
|
||||||
126
src/FrontOffice.Main/Pages/Club/MembershipPage.razor
Normal file
126
src/FrontOffice.Main/Pages/Club/MembershipPage.razor
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
@attribute [Route(RouteConstants.Club.Membership)]
|
||||||
|
@using FrontOffice.Main.Pages.Club.Components
|
||||||
|
@using FrontOffice.Main.Utilities
|
||||||
|
@using MudBlazor
|
||||||
|
|
||||||
|
<PageTitle>عضویت باشگاه مشتریان</PageTitle>
|
||||||
|
|
||||||
|
<MudContainer MaxWidth="MaxWidth.Large" Class="py-6">
|
||||||
|
<MudStack Spacing="3">
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.h5">عضویت باشگاه مشتریان</MudText>
|
||||||
|
<MudButton Variant="Variant.Text" StartIcon="@Icons.Material.Filled.ArrowBack" Href="@RouteConstants.Profile.Index">بازگشت</MudButton>
|
||||||
|
</MudStack>
|
||||||
|
|
||||||
|
@if (_isLoading)
|
||||||
|
{
|
||||||
|
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
|
||||||
|
}
|
||||||
|
else if (_membership is not null)
|
||||||
|
{
|
||||||
|
<!-- وضعیت عضویت -->
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudStack Spacing="2">
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.h6">وضعیت عضویت شما</MudText>
|
||||||
|
<MudChip T="string" Color="@GetStatusColor()" Variant="Variant.Filled" Size="Size.Medium">
|
||||||
|
@GetStatusText()
|
||||||
|
</MudChip>
|
||||||
|
</MudStack>
|
||||||
|
|
||||||
|
@if (_membership.IsActive)
|
||||||
|
{
|
||||||
|
<MudAlert Severity="Severity.Success" Variant="Variant.Outlined">
|
||||||
|
<MudText>عضویت شما در باشگاه فعال است! از مزایای باشگاه مشتریان استفاده کنید.</MudText>
|
||||||
|
</MudAlert>
|
||||||
|
|
||||||
|
@if (_membership.DaysRemaining.HasValue)
|
||||||
|
{
|
||||||
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.Schedule" Color="Color.Info" />
|
||||||
|
<MudText Typo="Typo.body1">
|
||||||
|
@if (_membership.DaysRemaining.Value > 0)
|
||||||
|
{
|
||||||
|
<strong>@_membership.DaysRemaining.Value روز</strong> <text>تا پایان اعتبار عضویت</text>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<text>عضویت شما منقضی شده است. لطفا تمدید کنید.</text>
|
||||||
|
}
|
||||||
|
</MudText>
|
||||||
|
</MudStack>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<MudAlert Severity="Severity.Warning" Variant="Variant.Outlined">
|
||||||
|
<MudText>شما هنوز عضو باشگاه مشتریان نیستید. برای استفاده از مزایای ویژه، اکنون فعال کنید!</MudText>
|
||||||
|
</MudAlert>
|
||||||
|
}
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
|
||||||
|
<!-- مزایای باشگاه -->
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudText Typo="Typo.h6" Class="mb-3">مزایای عضویت باشگاه</MudText>
|
||||||
|
<MudGrid Spacing="2">
|
||||||
|
<MudItem xs="12" sm="6" md="4">
|
||||||
|
<MudPaper Elevation="0" Class="pa-3 rounded-lg" Style="background-color: var(--mud-palette-primary-lighten);">
|
||||||
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.Discount" Color="Color.Primary" Size="Size.Large" />
|
||||||
|
<MudStack Spacing="0">
|
||||||
|
<MudText Typo="Typo.subtitle1" Color="Color.Primary">تخفیف ویژه</MudText>
|
||||||
|
<MudText Typo="Typo.caption">تا 30% تخفیف</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
<MudItem xs="12" sm="6" md="4">
|
||||||
|
<MudPaper Elevation="0" Class="pa-3 rounded-lg" Style="background-color: var(--mud-palette-secondary-lighten);">
|
||||||
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.Diamond" Color="Color.Secondary" Size="Size.Large" />
|
||||||
|
<MudStack Spacing="0">
|
||||||
|
<MudText Typo="Typo.subtitle1" Color="Color.Secondary">امتیاز خرید</MudText>
|
||||||
|
<MudText Typo="Typo.caption">برای هر خرید</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
<MudItem xs="12" sm="6" md="4">
|
||||||
|
<MudPaper Elevation="0" Class="pa-3 rounded-lg" Style="background-color: var(--mud-palette-success-lighten);">
|
||||||
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.LocalShipping" Color="Color.Success" Size="Size.Large" />
|
||||||
|
<MudStack Spacing="0">
|
||||||
|
<MudText Typo="Typo.subtitle1" Color="Color.Success">ارسال رایگان</MudText>
|
||||||
|
<MudText Typo="Typo.caption">برای سفارشات بالای 500 هزار تومان</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
</MudGrid>
|
||||||
|
</MudPaper>
|
||||||
|
|
||||||
|
<!-- فعالسازی یا تمدید عضویت -->
|
||||||
|
@if (!_membership.IsActive || (_membership.DaysRemaining.HasValue && _membership.DaysRemaining.Value <= 30))
|
||||||
|
{
|
||||||
|
<ActivationSection OnActivationSuccess="HandleActivationSuccess" />
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- دکمه مشاهده ویژگیهای بیشتر -->
|
||||||
|
<MudButton Variant="Variant.Outlined"
|
||||||
|
Color="Color.Primary"
|
||||||
|
FullWidth="true"
|
||||||
|
StartIcon="@Icons.Material.Filled.Info"
|
||||||
|
Href="@RouteConstants.Club.Features">
|
||||||
|
مشاهده تمام ویژگیهای باشگاه
|
||||||
|
</MudButton>
|
||||||
|
}
|
||||||
|
else if (_hasError)
|
||||||
|
{
|
||||||
|
<MudAlert Severity="Severity.Error" Variant="Variant.Filled">
|
||||||
|
خطا در دریافت اطلاعات عضویت. لطفا دوباره تلاش کنید.
|
||||||
|
</MudAlert>
|
||||||
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="LoadMembershipAsync">تلاش مجدد</MudButton>
|
||||||
|
}
|
||||||
|
</MudStack>
|
||||||
|
</MudContainer>
|
||||||
66
src/FrontOffice.Main/Pages/Club/MembershipPage.razor.cs
Normal file
66
src/FrontOffice.Main/Pages/Club/MembershipPage.razor.cs
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
using FrontOffice.Main.Utilities;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using MudBlazor;
|
||||||
|
|
||||||
|
namespace FrontOffice.Main.Pages.Club;
|
||||||
|
|
||||||
|
public partial class MembershipPage : ComponentBase
|
||||||
|
{
|
||||||
|
[Inject] private ClubMembershipService ClubService { get; set; } = default!;
|
||||||
|
|
||||||
|
private ClubMembershipDto? _membership;
|
||||||
|
private bool _isLoading = true;
|
||||||
|
private bool _hasError = false;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
await LoadMembershipAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadMembershipAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_isLoading = true;
|
||||||
|
_hasError = false;
|
||||||
|
_membership = await ClubService.GetMyMembershipAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_hasError = true;
|
||||||
|
Snackbar.Add($"خطا در دریافت اطلاعات: {ex.Message}", Severity.Error);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task HandleActivationSuccess()
|
||||||
|
{
|
||||||
|
await LoadMembershipAsync();
|
||||||
|
Snackbar.Add("عضویت باشگاه با موفقیت فعال شد!", Severity.Success);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color GetStatusColor()
|
||||||
|
{
|
||||||
|
if (_membership?.IsActive == true)
|
||||||
|
{
|
||||||
|
if (_membership.DaysRemaining.HasValue && _membership.DaysRemaining.Value <= 30)
|
||||||
|
return Color.Warning;
|
||||||
|
return Color.Success;
|
||||||
|
}
|
||||||
|
return Color.Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetStatusText()
|
||||||
|
{
|
||||||
|
if (_membership?.IsActive == true)
|
||||||
|
{
|
||||||
|
if (_membership.DaysRemaining.HasValue && _membership.DaysRemaining.Value <= 30)
|
||||||
|
return "نزدیک به انقضا";
|
||||||
|
return "فعال";
|
||||||
|
}
|
||||||
|
return "غیرفعال";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
@attribute [Route(RouteConstants.Commission.Dashboard)]
|
||||||
|
@using FrontOffice.Main.Utilities
|
||||||
|
@using MudBlazor
|
||||||
|
|
||||||
|
<PageTitle>داشبورد کمیسیون</PageTitle>
|
||||||
|
|
||||||
|
<MudContainer MaxWidth="MaxWidth.Large" Class="py-6">
|
||||||
|
<MudStack Spacing="3">
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.h5">داشبورد کمیسیون</MudText>
|
||||||
|
<MudButton Variant="Variant.Text" StartIcon="@Icons.Material.Filled.ArrowBack" Href="@RouteConstants.Profile.Index">بازگشت</MudButton>
|
||||||
|
</MudStack>
|
||||||
|
|
||||||
|
@if (_isLoading)
|
||||||
|
{
|
||||||
|
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<!-- فیلترها -->
|
||||||
|
<MudPaper Elevation="2" Class="pa-3 rounded-lg">
|
||||||
|
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.End">
|
||||||
|
<MudNumericField @bind-Value="_filterWeekNumber"
|
||||||
|
Label="شماره هفته"
|
||||||
|
Variant="Variant.Outlined"
|
||||||
|
Min="1"
|
||||||
|
Clearable="true"
|
||||||
|
Style="max-width: 150px;" />
|
||||||
|
<MudSelect T="string" @bind-Value="_filterStatus" Label="وضعیت" Variant="Variant.Outlined" Style="max-width: 200px;">
|
||||||
|
<MudSelectItem T="string" Value="@string.Empty">همه</MudSelectItem>
|
||||||
|
<MudSelectItem T="string" Value="@("Created")">ایجاد شده</MudSelectItem>
|
||||||
|
<MudSelectItem T="string" Value="@("Paid")">پرداخت شده</MudSelectItem>
|
||||||
|
<MudSelectItem T="string" Value="@("WithdrawalRequested")">درخواست برداشت</MudSelectItem>
|
||||||
|
<MudSelectItem T="string" Value="@("Withdrawn")">برداشت شده</MudSelectItem>
|
||||||
|
<MudSelectItem T="string" Value="@("Cancelled")">لغو شده</MudSelectItem>
|
||||||
|
</MudSelect>
|
||||||
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="ApplyFiltersAsync" StartIcon="@Icons.Material.Filled.FilterList">
|
||||||
|
اعمال فیلتر
|
||||||
|
</MudButton>
|
||||||
|
<MudButton Variant="Variant.Outlined" OnClick="ClearFiltersAsync" StartIcon="@Icons.Material.Filled.Clear">
|
||||||
|
پاک کردن
|
||||||
|
</MudButton>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
|
||||||
|
<!-- لیست کمیسیونها -->
|
||||||
|
@if (_payouts.Any())
|
||||||
|
{
|
||||||
|
<MudHidden Breakpoint="Breakpoint.MdAndUp" Invert="true">
|
||||||
|
<MudTable Items="_payouts" Hover="true" Striped="true" Dense="true">
|
||||||
|
<HeaderContent>
|
||||||
|
<MudTh>هفته</MudTh>
|
||||||
|
<MudTh>تعداد تعادل</MudTh>
|
||||||
|
<MudTh>مبلغ کل</MudTh>
|
||||||
|
<MudTh>وضعیت</MudTh>
|
||||||
|
<MudTh>تاریخ</MudTh>
|
||||||
|
<MudTh>عملیات</MudTh>
|
||||||
|
</HeaderContent>
|
||||||
|
<RowTemplate>
|
||||||
|
<MudTd>
|
||||||
|
<MudChip T="string" Color="Color.Default" Size="Size.Small">@context.WeekLabel</MudChip>
|
||||||
|
</MudTd>
|
||||||
|
<MudTd>@context.BalancesEarned</MudTd>
|
||||||
|
<MudTd>
|
||||||
|
<MudText Color="Color.Success"><strong>@context.AmountFormatted</strong></MudText>
|
||||||
|
</MudTd>
|
||||||
|
<MudTd>
|
||||||
|
<MudChip T="string" Color="@GetStatusColor(context.StatusBadgeColor)" Size="Size.Small" Variant="Variant.Outlined">
|
||||||
|
@context.Status
|
||||||
|
</MudChip>
|
||||||
|
</MudTd>
|
||||||
|
<MudTd>@context.DatePersian</MudTd>
|
||||||
|
<MudTd>
|
||||||
|
<MudButton Size="Size.Small"
|
||||||
|
Variant="Variant.Text"
|
||||||
|
Color="Color.Info"
|
||||||
|
StartIcon="@Icons.Material.Filled.Info"
|
||||||
|
Href="@($"{RouteConstants.Commission.WeeklyBalance}?week={context.WeekNumber}")">
|
||||||
|
جزئیات
|
||||||
|
</MudButton>
|
||||||
|
</MudTd>
|
||||||
|
</RowTemplate>
|
||||||
|
</MudTable>
|
||||||
|
</MudHidden>
|
||||||
|
|
||||||
|
<MudHidden Breakpoint="Breakpoint.MdAndUp">
|
||||||
|
<MudStack Spacing="2">
|
||||||
|
@foreach (var payout in _payouts)
|
||||||
|
{
|
||||||
|
<MudPaper Class="pa-3 rounded-lg" Outlined="true">
|
||||||
|
<MudStack Spacing="1">
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudChip T="string" Color="Color.Default" Size="Size.Small">@payout.WeekLabel</MudChip>
|
||||||
|
<MudChip T="string" Color="@GetStatusColor(payout.StatusBadgeColor)" Size="Size.Small" Variant="Variant.Outlined">
|
||||||
|
@payout.Status
|
||||||
|
</MudChip>
|
||||||
|
</MudStack>
|
||||||
|
<MudText Typo="Typo.h6" Color="Color.Success">@payout.AmountFormatted</MudText>
|
||||||
|
<MudText Typo="Typo.caption" Class="mud-text-secondary">تعداد تعادل: @payout.BalancesEarned</MudText>
|
||||||
|
<MudText Typo="Typo.caption" Class="mud-text-secondary">@payout.DatePersian</MudText>
|
||||||
|
<MudButton Size="Size.Small"
|
||||||
|
Variant="Variant.Outlined"
|
||||||
|
Color="Color.Info"
|
||||||
|
FullWidth="true"
|
||||||
|
StartIcon="@Icons.Material.Filled.Info"
|
||||||
|
Href="@($"{RouteConstants.Commission.WeeklyBalance}?week={payout.WeekNumber}")">
|
||||||
|
مشاهده جزئیات هفته
|
||||||
|
</MudButton>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
}
|
||||||
|
</MudStack>
|
||||||
|
</MudHidden>
|
||||||
|
|
||||||
|
<!-- Pagination -->
|
||||||
|
<MudPaper Elevation="0" Class="pa-3">
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.body2">کل: @_totalCount کمیسیون</MudText>
|
||||||
|
<MudPagination Count="@GetTotalPages()" Selected="_pageNumber" SelectedChanged="OnPageChangedAsync" Color="Color.Primary" />
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined">
|
||||||
|
کمیسیونی برای نمایش وجود ندارد.
|
||||||
|
</MudAlert>
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- دکمههای بیشتر -->
|
||||||
|
<MudStack Row="true" Spacing="2">
|
||||||
|
<MudButton Variant="Variant.Outlined"
|
||||||
|
Color="Color.Secondary"
|
||||||
|
StartIcon="@Icons.Material.Filled.History"
|
||||||
|
Href="@RouteConstants.Commission.History"
|
||||||
|
FullWidth="true">
|
||||||
|
تاریخچه کامل
|
||||||
|
</MudButton>
|
||||||
|
<MudButton Variant="Variant.Outlined"
|
||||||
|
Color="Color.Info"
|
||||||
|
StartIcon="@Icons.Material.Filled.BarChart"
|
||||||
|
Href="@RouteConstants.Commission.WeeklyBalance"
|
||||||
|
FullWidth="true">
|
||||||
|
تعادل هفتگی
|
||||||
|
</MudButton>
|
||||||
|
</MudStack>
|
||||||
|
}
|
||||||
|
</MudStack>
|
||||||
|
</MudContainer>
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
using FrontOffice.Main.Utilities;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using MudBlazor;
|
||||||
|
|
||||||
|
namespace FrontOffice.Main.Pages.Commission;
|
||||||
|
|
||||||
|
public partial class CommissionDashboardPage : ComponentBase
|
||||||
|
{
|
||||||
|
[Inject] private CommissionService CommissionService { get; set; } = default!;
|
||||||
|
|
||||||
|
private List<CommissionPayoutDto> _payouts = new();
|
||||||
|
private int _totalCount;
|
||||||
|
private int _pageNumber = 1;
|
||||||
|
private int _pageSize = 10;
|
||||||
|
private bool _isLoading = true;
|
||||||
|
|
||||||
|
private int? _filterWeekNumber;
|
||||||
|
private string _filterStatus = string.Empty;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
await LoadPayoutsAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadPayoutsAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_isLoading = true;
|
||||||
|
var result = await CommissionService.GetMyCommissionPayoutsAsync(
|
||||||
|
_filterWeekNumber,
|
||||||
|
_filterStatus,
|
||||||
|
_pageNumber,
|
||||||
|
_pageSize
|
||||||
|
);
|
||||||
|
_payouts = result.Payouts;
|
||||||
|
_totalCount = result.TotalCount;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Snackbar.Add($"خطا در دریافت کمیسیونها: {ex.Message}", Severity.Error);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ApplyFiltersAsync()
|
||||||
|
{
|
||||||
|
_pageNumber = 1;
|
||||||
|
await LoadPayoutsAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ClearFiltersAsync()
|
||||||
|
{
|
||||||
|
_filterWeekNumber = null;
|
||||||
|
_filterStatus = string.Empty;
|
||||||
|
_pageNumber = 1;
|
||||||
|
await LoadPayoutsAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnPageChangedAsync(int page)
|
||||||
|
{
|
||||||
|
_pageNumber = page;
|
||||||
|
await LoadPayoutsAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetTotalPages()
|
||||||
|
{
|
||||||
|
if (_totalCount == 0 || _pageSize == 0)
|
||||||
|
return 1;
|
||||||
|
return (int)Math.Ceiling(_totalCount / (double)_pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color GetStatusColor(string statusColor) => statusColor.ToLower() switch
|
||||||
|
{
|
||||||
|
"success" => Color.Success,
|
||||||
|
"warning" => Color.Warning,
|
||||||
|
"error" => Color.Error,
|
||||||
|
"info" => Color.Info,
|
||||||
|
_ => Color.Default
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
@attribute [Route(RouteConstants.Commission.History)]
|
||||||
|
@using FrontOffice.Main.Utilities
|
||||||
|
@using MudBlazor
|
||||||
|
|
||||||
|
<PageTitle>تاریخچه کمیسیون</PageTitle>
|
||||||
|
|
||||||
|
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="py-6">
|
||||||
|
<MudStack Spacing="3">
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.h5">تاریخچه کامل کمیسیون</MudText>
|
||||||
|
<MudButton Variant="Variant.Text" StartIcon="@Icons.Material.Filled.ArrowBack" Href="@RouteConstants.Commission.Dashboard">بازگشت</MudButton>
|
||||||
|
</MudStack>
|
||||||
|
|
||||||
|
@if (_isLoading)
|
||||||
|
{
|
||||||
|
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
|
||||||
|
}
|
||||||
|
else if (_payouts.Any())
|
||||||
|
{
|
||||||
|
<!-- آمار خلاصه -->
|
||||||
|
<MudGrid Spacing="2">
|
||||||
|
<MudItem xs="12" sm="4">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">کل کمیسیون دریافتی</MudText>
|
||||||
|
<MudText Typo="Typo.h5" Color="Color.Success">@GetTotalEarnings()</MudText>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
<MudItem xs="12" sm="4">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">تعداد هفتهها</MudText>
|
||||||
|
<MudText Typo="Typo.h5" Color="Color.Primary">@_payouts.Count</MudText>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
<MudItem xs="12" sm="4">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">میانگین هفتگی</MudText>
|
||||||
|
<MudText Typo="Typo.h5" Color="Color.Info">@GetAverageWeekly()</MudText>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
</MudGrid>
|
||||||
|
|
||||||
|
<!-- جدول کامل -->
|
||||||
|
<MudPaper Elevation="2" Class="pa-0 rounded-lg">
|
||||||
|
<MudTable Items="_payouts" Hover="true" Striped="true" Dense="false" FixedHeader="true" Height="600px">
|
||||||
|
<HeaderContent>
|
||||||
|
<MudTh>هفته</MudTh>
|
||||||
|
<MudTh>تعادلها</MudTh>
|
||||||
|
<MudTh>مبلغ (تومان)</MudTh>
|
||||||
|
<MudTh>وضعیت</MudTh>
|
||||||
|
<MudTh>تاریخ</MudTh>
|
||||||
|
<MudTh>جزئیات</MudTh>
|
||||||
|
</HeaderContent>
|
||||||
|
<RowTemplate>
|
||||||
|
<MudTd DataLabel="هفته">
|
||||||
|
<MudChip T="string" Color="Color.Primary" Size="Size.Small" Variant="Variant.Outlined">@context.WeekLabel</MudChip>
|
||||||
|
</MudTd>
|
||||||
|
<MudTd DataLabel="تعادلها">
|
||||||
|
<MudText>@context.BalancesEarned</MudText>
|
||||||
|
</MudTd>
|
||||||
|
<MudTd DataLabel="مبلغ">
|
||||||
|
<MudText Color="Color.Success" Typo="Typo.body1"><strong>@context.AmountFormatted</strong></MudText>
|
||||||
|
</MudTd>
|
||||||
|
<MudTd DataLabel="وضعیت">
|
||||||
|
<MudChip T="string" Color="@GetStatusColor(context.StatusBadgeColor)" Size="Size.Small">
|
||||||
|
@context.Status
|
||||||
|
</MudChip>
|
||||||
|
</MudTd>
|
||||||
|
<MudTd DataLabel="تاریخ">
|
||||||
|
<MudText Typo="Typo.caption">@context.DatePersian</MudText>
|
||||||
|
</MudTd>
|
||||||
|
<MudTd DataLabel="جزئیات">
|
||||||
|
<MudButton Size="Size.Small"
|
||||||
|
Variant="Variant.Text"
|
||||||
|
Color="Color.Info"
|
||||||
|
StartIcon="@Icons.Material.Filled.Visibility"
|
||||||
|
Href="@($"{RouteConstants.Commission.WeeklyBalance}?week={context.WeekNumber}")">
|
||||||
|
مشاهده
|
||||||
|
</MudButton>
|
||||||
|
</MudTd>
|
||||||
|
</RowTemplate>
|
||||||
|
</MudTable>
|
||||||
|
</MudPaper>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<MudAlert Severity="Severity.Info" Variant="Variant.Filled">
|
||||||
|
هنوز کمیسیونی دریافت نکردهاید.
|
||||||
|
</MudAlert>
|
||||||
|
}
|
||||||
|
</MudStack>
|
||||||
|
</MudContainer>
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
using FrontOffice.Main.Utilities;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using MudBlazor;
|
||||||
|
|
||||||
|
namespace FrontOffice.Main.Pages.Commission;
|
||||||
|
|
||||||
|
public partial class CommissionHistoryPage : ComponentBase
|
||||||
|
{
|
||||||
|
[Inject] private CommissionService CommissionService { get; set; } = default!;
|
||||||
|
|
||||||
|
private List<CommissionPayoutDto> _payouts = new();
|
||||||
|
private bool _isLoading = true;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
await LoadAllPayoutsAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadAllPayoutsAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_isLoading = true;
|
||||||
|
// Load all payouts (large page size to get everything)
|
||||||
|
var result = await CommissionService.GetMyCommissionPayoutsAsync(
|
||||||
|
null,
|
||||||
|
string.Empty,
|
||||||
|
1,
|
||||||
|
1000
|
||||||
|
);
|
||||||
|
_payouts = result.Payouts;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Snackbar.Add($"خطا در دریافت تاریخچه: {ex.Message}", Severity.Error);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetTotalEarnings()
|
||||||
|
{
|
||||||
|
var total = _payouts.Sum(p => p.TotalAmount);
|
||||||
|
return $"{total:N0} تومان";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetAverageWeekly()
|
||||||
|
{
|
||||||
|
if (!_payouts.Any())
|
||||||
|
return "0 تومان";
|
||||||
|
var avg = _payouts.Average(p => p.TotalAmount);
|
||||||
|
return $"{avg:N0} تومان";
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color GetStatusColor(string statusColor) => statusColor.ToLower() switch
|
||||||
|
{
|
||||||
|
"success" => Color.Success,
|
||||||
|
"warning" => Color.Warning,
|
||||||
|
"error" => Color.Error,
|
||||||
|
"info" => Color.Info,
|
||||||
|
_ => Color.Default
|
||||||
|
};
|
||||||
|
}
|
||||||
154
src/FrontOffice.Main/Pages/Commission/WeeklyBalancePage.razor
Normal file
154
src/FrontOffice.Main/Pages/Commission/WeeklyBalancePage.razor
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
@attribute [Route(RouteConstants.Commission.WeeklyBalance)]
|
||||||
|
@using FrontOffice.Main.Utilities
|
||||||
|
@using MudBlazor
|
||||||
|
|
||||||
|
<PageTitle>تعادل هفتگی</PageTitle>
|
||||||
|
|
||||||
|
<MudContainer MaxWidth="MaxWidth.Large" Class="py-6">
|
||||||
|
<MudStack Spacing="3">
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.h5">تعادل هفتگی کمیسیون</MudText>
|
||||||
|
<MudButton Variant="Variant.Text" StartIcon="@Icons.Material.Filled.ArrowBack" Href="@RouteConstants.Commission.Dashboard">بازگشت</MudButton>
|
||||||
|
</MudStack>
|
||||||
|
|
||||||
|
<!-- انتخاب هفته -->
|
||||||
|
<MudPaper Elevation="2" Class="pa-3 rounded-lg">
|
||||||
|
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.End">
|
||||||
|
<MudNumericField @bind-Value="_selectedWeekNumber"
|
||||||
|
Label="شماره هفته"
|
||||||
|
Variant="Variant.Outlined"
|
||||||
|
Min="1"
|
||||||
|
HelperText="هفته مورد نظر را انتخاب کنید (خالی = هفته جاری)"
|
||||||
|
Style="max-width: 200px;" />
|
||||||
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="LoadWeeklyBalanceAsync" StartIcon="@Icons.Material.Filled.Search">
|
||||||
|
مشاهده
|
||||||
|
</MudButton>
|
||||||
|
<MudButton Variant="Variant.Outlined" OnClick="LoadCurrentWeekAsync" StartIcon="@Icons.Material.Filled.Today">
|
||||||
|
هفته جاری
|
||||||
|
</MudButton>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
|
||||||
|
@if (_isLoading)
|
||||||
|
{
|
||||||
|
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
|
||||||
|
}
|
||||||
|
else if (_weeklyBalance is not null)
|
||||||
|
{
|
||||||
|
<!-- اطلاعات هفته -->
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudStack Spacing="2">
|
||||||
|
<MudText Typo="Typo.h6">هفته @_weeklyBalance.WeekNumber - @_weeklyBalance.WeekLabel</MudText>
|
||||||
|
<MudDivider />
|
||||||
|
<MudGrid Spacing="2">
|
||||||
|
<MudItem xs="12" sm="6">
|
||||||
|
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">تاریخ شروع:</MudText>
|
||||||
|
<MudText Typo="Typo.body1"><strong>@_weeklyBalance.StartDatePersian</strong></MudText>
|
||||||
|
</MudItem>
|
||||||
|
<MudItem xs="12" sm="6">
|
||||||
|
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">تاریخ پایان:</MudText>
|
||||||
|
<MudText Typo="Typo.body1"><strong>@_weeklyBalance.EndDatePersian</strong></MudText>
|
||||||
|
</MudItem>
|
||||||
|
</MudGrid>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
|
||||||
|
<!-- تعادل چپ و راست -->
|
||||||
|
<MudGrid Spacing="2">
|
||||||
|
<MudItem xs="12" md="6">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg" Style="height: 100%;">
|
||||||
|
<MudStack Spacing="2">
|
||||||
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.ChevronLeft" Color="Color.Info" Size="Size.Large" />
|
||||||
|
<MudText Typo="Typo.h6" Color="Color.Info">شاخه چپ</MudText>
|
||||||
|
</MudStack>
|
||||||
|
<MudText Typo="Typo.h4" Color="Color.Info">@_weeklyBalance.LeftBalanceFormatted</MudText>
|
||||||
|
<MudProgressLinear Color="Color.Info"
|
||||||
|
Value="@GetLeftPercentage()"
|
||||||
|
Size="Size.Large"
|
||||||
|
Class="rounded-lg" />
|
||||||
|
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||||
|
@GetLeftPercentage().ToString("F1")% از کل تعادل
|
||||||
|
</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
|
<MudItem xs="12" md="6">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg" Style="height: 100%;">
|
||||||
|
<MudStack Spacing="2">
|
||||||
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.ChevronRight" Color="Color.Success" Size="Size.Large" />
|
||||||
|
<MudText Typo="Typo.h6" Color="Color.Success">شاخه راست</MudText>
|
||||||
|
</MudStack>
|
||||||
|
<MudText Typo="Typo.h4" Color="Color.Success">@_weeklyBalance.RightBalanceFormatted</MudText>
|
||||||
|
<MudProgressLinear Color="Color.Success"
|
||||||
|
Value="@GetRightPercentage()"
|
||||||
|
Size="Size.Large"
|
||||||
|
Class="rounded-lg" />
|
||||||
|
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||||
|
@GetRightPercentage().ToString("F1")% از کل تعادل
|
||||||
|
</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
</MudGrid>
|
||||||
|
|
||||||
|
<!-- محاسبات کمیسیون -->
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudText Typo="Typo.h6" Class="mb-3">محاسبات کمیسیون</MudText>
|
||||||
|
<MudStack Spacing="2">
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.body1">تعادل چپ:</MudText>
|
||||||
|
<MudText Typo="Typo.body1" Color="Color.Info"><strong>@_weeklyBalance.LeftBalanceFormatted</strong></MudText>
|
||||||
|
</MudStack>
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.body1">تعادل راست:</MudText>
|
||||||
|
<MudText Typo="Typo.body1" Color="Color.Success"><strong>@_weeklyBalance.RightBalanceFormatted</strong></MudText>
|
||||||
|
</MudStack>
|
||||||
|
<MudDivider />
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.body1">حداقل تعادل (پایه کمیسیون):</MudText>
|
||||||
|
<MudText Typo="Typo.h6" Color="Color.Warning"><strong>@_weeklyBalance.MinBalanceFormatted</strong></MudText>
|
||||||
|
</MudStack>
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.body1">تعداد تعادل (دفعات):</MudText>
|
||||||
|
<MudText Typo="Typo.h6" Color="Color.Secondary"><strong>@_weeklyBalance.BalanceCount</strong></MudText>
|
||||||
|
</MudStack>
|
||||||
|
<MudDivider />
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.h6">کمیسیون محاسبه شده:</MudText>
|
||||||
|
<MudText Typo="Typo.h5" Color="Color.Primary"><strong>@_weeklyBalance.CalculatedCommissionFormatted</strong></MudText>
|
||||||
|
</MudStack>
|
||||||
|
|
||||||
|
@if (_weeklyBalance.LeftCarryover > 0 || _weeklyBalance.RightCarryover > 0)
|
||||||
|
{
|
||||||
|
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined">
|
||||||
|
<MudText Typo="Typo.body2">
|
||||||
|
<strong>Carryover (انتقال به هفته بعد):</strong><br />
|
||||||
|
چپ: @_weeklyBalance.LeftCarryoverFormatted | راست: @_weeklyBalance.RightCarryoverFormatted
|
||||||
|
</MudText>
|
||||||
|
</MudAlert>
|
||||||
|
}
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
|
||||||
|
<!-- نمودار مقایسه -->
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudText Typo="Typo.h6" Class="mb-3">نمودار مقایسه</MudText>
|
||||||
|
<MudChart ChartType="ChartType.Bar"
|
||||||
|
Width="100%"
|
||||||
|
Height="300px"
|
||||||
|
InputData="@(new double[] { _weeklyBalance.LeftBalance, _weeklyBalance.RightBalance, _weeklyBalance.MinBalance })"
|
||||||
|
InputLabels="@(new[] { "چپ", "راست", "حداقل" })"
|
||||||
|
ChartOptions="@_chartOptions" />
|
||||||
|
</MudPaper>
|
||||||
|
}
|
||||||
|
else if (_hasError)
|
||||||
|
{
|
||||||
|
<MudAlert Severity="Severity.Error" Variant="Variant.Filled">
|
||||||
|
خطا در دریافت اطلاعات. لطفا دوباره تلاش کنید.
|
||||||
|
</MudAlert>
|
||||||
|
}
|
||||||
|
</MudStack>
|
||||||
|
</MudContainer>
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
using FrontOffice.Main.Utilities;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using MudBlazor;
|
||||||
|
|
||||||
|
namespace FrontOffice.Main.Pages.Commission;
|
||||||
|
|
||||||
|
public partial class WeeklyBalancePage : ComponentBase
|
||||||
|
{
|
||||||
|
[Inject] private CommissionService CommissionService { get; set; } = default!;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
[SupplyParameterFromQuery(Name = "week")]
|
||||||
|
public int? QueryWeekNumber { get; set; }
|
||||||
|
|
||||||
|
private WeeklyBalanceDto? _weeklyBalance;
|
||||||
|
private int? _selectedWeekNumber;
|
||||||
|
private bool _isLoading = true;
|
||||||
|
private bool _hasError = false;
|
||||||
|
|
||||||
|
private readonly ChartOptions _chartOptions = new()
|
||||||
|
{
|
||||||
|
ChartPalette = new[]
|
||||||
|
{
|
||||||
|
"#2196F3", // Info (Left)
|
||||||
|
"#4CAF50", // Success (Right)
|
||||||
|
"#FF9800" // Warning (Min)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
if (QueryWeekNumber.HasValue)
|
||||||
|
_selectedWeekNumber = QueryWeekNumber;
|
||||||
|
|
||||||
|
await LoadWeeklyBalanceAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadWeeklyBalanceAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_isLoading = true;
|
||||||
|
_hasError = false;
|
||||||
|
_weeklyBalance = await CommissionService.GetMyWeeklyBalanceAsync(_selectedWeekNumber);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_hasError = true;
|
||||||
|
Snackbar.Add($"خطا در دریافت تعادل: {ex.Message}", Severity.Error);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadCurrentWeekAsync()
|
||||||
|
{
|
||||||
|
_selectedWeekNumber = null;
|
||||||
|
await LoadWeeklyBalanceAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double GetLeftPercentage()
|
||||||
|
{
|
||||||
|
if (_weeklyBalance is null)
|
||||||
|
return 0;
|
||||||
|
var total = _weeklyBalance.LeftBalance + _weeklyBalance.RightBalance;
|
||||||
|
if (total == 0)
|
||||||
|
return 0;
|
||||||
|
return (_weeklyBalance.LeftBalance / (double)total) * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double GetRightPercentage()
|
||||||
|
{
|
||||||
|
if (_weeklyBalance is null)
|
||||||
|
return 0;
|
||||||
|
var total = _weeklyBalance.LeftBalance + _weeklyBalance.RightBalance;
|
||||||
|
if (total == 0)
|
||||||
|
return 0;
|
||||||
|
return (_weeklyBalance.RightBalance / (double)total) * 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
148
src/FrontOffice.Main/Pages/Network/NetworkStatisticsPage.razor
Normal file
148
src/FrontOffice.Main/Pages/Network/NetworkStatisticsPage.razor
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
@attribute [Route(RouteConstants.Network.Statistics)]
|
||||||
|
@using FrontOffice.Main.Utilities
|
||||||
|
@using MudBlazor
|
||||||
|
|
||||||
|
<PageTitle>آمار شبکه</PageTitle>
|
||||||
|
|
||||||
|
<MudContainer MaxWidth="MaxWidth.Large" Class="py-6">
|
||||||
|
<MudStack Spacing="3">
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.h5">آمار شبکه من</MudText>
|
||||||
|
<MudButton Variant="Variant.Text" StartIcon="@Icons.Material.Filled.ArrowBack" Href="@RouteConstants.Profile.Index">بازگشت</MudButton>
|
||||||
|
</MudStack>
|
||||||
|
|
||||||
|
@if (_isLoading)
|
||||||
|
{
|
||||||
|
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
|
||||||
|
}
|
||||||
|
else if (_statistics is not null)
|
||||||
|
{
|
||||||
|
<!-- کارتهای آماری -->
|
||||||
|
<MudGrid Spacing="2">
|
||||||
|
<MudItem xs="12" sm="6" md="3">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudStack Spacing="1">
|
||||||
|
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">کل اعضای شبکه</MudText>
|
||||||
|
<MudText Typo="Typo.h4" Color="Color.Primary">@_statistics.TotalMembers</MudText>
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.Groups" Color="Color.Primary" />
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
<MudItem xs="12" sm="6" md="3">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudStack Spacing="1">
|
||||||
|
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">شاخه چپ</MudText>
|
||||||
|
<MudText Typo="Typo.h4" Color="Color.Info">@_statistics.LeftLegCount</MudText>
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.ChevronLeft" Color="Color.Info" />
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
<MudItem xs="12" sm="6" md="3">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudStack Spacing="1">
|
||||||
|
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">شاخه راست</MudText>
|
||||||
|
<MudText Typo="Typo.h4" Color="Color.Success">@_statistics.RightLegCount</MudText>
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.ChevronRight" Color="Color.Success" />
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
<MudItem xs="12" sm="6" md="3">
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudStack Spacing="1">
|
||||||
|
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">عمق درخت</MudText>
|
||||||
|
<MudText Typo="Typo.h4" Color="Color.Secondary">@_statistics.TreeDepth</MudText>
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.AccountTree" Color="Color.Secondary" />
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
</MudItem>
|
||||||
|
</MudGrid>
|
||||||
|
|
||||||
|
<!-- تعادل شاخهها -->
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudText Typo="Typo.h6" Class="mb-3">تعادل شاخهها</MudText>
|
||||||
|
<MudStack Spacing="2">
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.body1">شاخه چپ: <strong>@_statistics.LeftLegCount</strong> عضو</MudText>
|
||||||
|
<MudProgressLinear Color="Color.Info"
|
||||||
|
Value="@GetLeftPercentage()"
|
||||||
|
Size="Size.Medium"
|
||||||
|
Class="rounded-lg"
|
||||||
|
Style="width: 200px;" />
|
||||||
|
</MudStack>
|
||||||
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.body1">شاخه راست: <strong>@_statistics.RightLegCount</strong> عضو</MudText>
|
||||||
|
<MudProgressLinear Color="Color.Success"
|
||||||
|
Value="@GetRightPercentage()"
|
||||||
|
Size="Size.Medium"
|
||||||
|
Class="rounded-lg"
|
||||||
|
Style="width: 200px;" />
|
||||||
|
</MudStack>
|
||||||
|
@if (!string.IsNullOrEmpty(_statistics.WeakerLeg))
|
||||||
|
{
|
||||||
|
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined">
|
||||||
|
شاخه ضعیفتر: <strong>@GetLegText(_statistics.WeakerLeg)</strong>
|
||||||
|
</MudAlert>
|
||||||
|
}
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
|
||||||
|
<!-- نمودار دایرهای -->
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudText Typo="Typo.h6" Class="mb-3">توزیع اعضا</MudText>
|
||||||
|
<MudChart ChartType="ChartType.Donut"
|
||||||
|
Width="300px"
|
||||||
|
Height="300px"
|
||||||
|
InputData="@(new double[] { _statistics.LeftLegCount, _statistics.RightLegCount })"
|
||||||
|
InputLabels="@(new[] { "شاخه چپ", "شاخه راست" })"
|
||||||
|
ChartOptions="@_chartOptions" />
|
||||||
|
</MudPaper>
|
||||||
|
|
||||||
|
<!-- آخرین عضو -->
|
||||||
|
@if (_statistics.LastMember is not null)
|
||||||
|
{
|
||||||
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||||
|
<MudText Typo="Typo.h6" Class="mb-3">آخرین عضو پیوسته</MudText>
|
||||||
|
<MudStack Row="true" Spacing="3" AlignItems="AlignItems.Center">
|
||||||
|
<MudAvatar Color="Color.Primary" Size="Size.Large">
|
||||||
|
@GetInitials(_statistics.LastMember.FullName)
|
||||||
|
</MudAvatar>
|
||||||
|
<MudStack Spacing="0">
|
||||||
|
<MudText Typo="Typo.body1"><strong>@_statistics.LastMember.FullName</strong></MudText>
|
||||||
|
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||||
|
موقعیت: @GetPositionText(_statistics.LastMember.Position)
|
||||||
|
</MudText>
|
||||||
|
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||||
|
تاریخ عضویت: @_statistics.LastMember.JoinedAt.ToString("yyyy/MM/dd HH:mm")
|
||||||
|
</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- دکمههای عملیات -->
|
||||||
|
<MudStack Row="true" Spacing="2">
|
||||||
|
<MudButton Variant="Variant.Outlined"
|
||||||
|
Color="Color.Primary"
|
||||||
|
StartIcon="@Icons.Material.Filled.AccountTree"
|
||||||
|
Href="@RouteConstants.Profile.Tree"
|
||||||
|
FullWidth="true">
|
||||||
|
مشاهده درخت کامل
|
||||||
|
</MudButton>
|
||||||
|
<MudButton Variant="Variant.Outlined"
|
||||||
|
Color="Color.Secondary"
|
||||||
|
StartIcon="@Icons.Material.Filled.Refresh"
|
||||||
|
OnClick="LoadStatisticsAsync"
|
||||||
|
FullWidth="true">
|
||||||
|
بروزرسانی آمار
|
||||||
|
</MudButton>
|
||||||
|
</MudStack>
|
||||||
|
}
|
||||||
|
else if (_hasError)
|
||||||
|
{
|
||||||
|
<MudAlert Severity="Severity.Error" Variant="Variant.Filled">
|
||||||
|
خطا در دریافت آمار شبکه. لطفا دوباره تلاش کنید.
|
||||||
|
</MudAlert>
|
||||||
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="LoadStatisticsAsync">تلاش مجدد</MudButton>
|
||||||
|
}
|
||||||
|
</MudStack>
|
||||||
|
</MudContainer>
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
using FrontOffice.Main.Utilities;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using MudBlazor;
|
||||||
|
|
||||||
|
namespace FrontOffice.Main.Pages.Network;
|
||||||
|
|
||||||
|
public partial class NetworkStatisticsPage : ComponentBase
|
||||||
|
{
|
||||||
|
[Inject] private NetworkMembershipService NetworkService { get; set; } = default!;
|
||||||
|
|
||||||
|
private NetworkStatisticsDto? _statistics;
|
||||||
|
private bool _isLoading = true;
|
||||||
|
private bool _hasError = false;
|
||||||
|
|
||||||
|
private readonly ChartOptions _chartOptions = new()
|
||||||
|
{
|
||||||
|
ChartPalette = new[]
|
||||||
|
{
|
||||||
|
"#2196F3", // Info (Left)
|
||||||
|
"#4CAF50" // Success (Right)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
await LoadStatisticsAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadStatisticsAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_isLoading = true;
|
||||||
|
_hasError = false;
|
||||||
|
_statistics = await NetworkService.GetMyNetworkStatisticsAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_hasError = true;
|
||||||
|
Snackbar.Add($"خطا در دریافت آمار: {ex.Message}", Severity.Error);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double GetLeftPercentage()
|
||||||
|
{
|
||||||
|
if (_statistics is null || _statistics.TotalMembers == 0)
|
||||||
|
return 0;
|
||||||
|
return (_statistics.LeftLegCount / (double)_statistics.TotalMembers) * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double GetRightPercentage()
|
||||||
|
{
|
||||||
|
if (_statistics is null || _statistics.TotalMembers == 0)
|
||||||
|
return 0;
|
||||||
|
return (_statistics.RightLegCount / (double)_statistics.TotalMembers) * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetLegText(string leg) => leg.ToLower() switch
|
||||||
|
{
|
||||||
|
"left" => "شاخه چپ",
|
||||||
|
"right" => "شاخه راست",
|
||||||
|
_ => leg
|
||||||
|
};
|
||||||
|
|
||||||
|
private string GetPositionText(string position) => position.ToLower() switch
|
||||||
|
{
|
||||||
|
"left" => "چپ",
|
||||||
|
"right" => "راست",
|
||||||
|
_ => position
|
||||||
|
};
|
||||||
|
|
||||||
|
private string GetInitials(string fullName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(fullName))
|
||||||
|
return "؟";
|
||||||
|
|
||||||
|
var parts = fullName.Trim().Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (parts.Length >= 2)
|
||||||
|
return $"{parts[0][0]}{parts[1][0]}";
|
||||||
|
return fullName.Length > 0 ? fullName[0].ToString() : "؟";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -161,6 +161,39 @@
|
|||||||
</MudCard>
|
</MudCard>
|
||||||
</MudLink>
|
</MudLink>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
|
<MudItem xs="6" sm="6" md="3">
|
||||||
|
<MudLink Href="@RouteConstants.Club.Membership" Underline="Underline.None" Class="tile-link">
|
||||||
|
<MudCard Elevation="1" Class="rounded-lg profile-tile">
|
||||||
|
<MudCardContent Class="d-flex flex-column align-center pa-4">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.CardMembership" Size="Size.Large" Color="Color.Secondary" />
|
||||||
|
<MudText Typo="Typo.subtitle1" Class="mt-2">باشگاه مشتریان</MudText>
|
||||||
|
<MudText Typo="Typo.caption" Class="mud-text-secondary">عضویت و مزایا</MudText>
|
||||||
|
</MudCardContent>
|
||||||
|
</MudCard>
|
||||||
|
</MudLink>
|
||||||
|
</MudItem>
|
||||||
|
<MudItem xs="6" sm="6" md="3">
|
||||||
|
<MudLink Href="@RouteConstants.Network.Statistics" Underline="Underline.None" Class="tile-link">
|
||||||
|
<MudCard Elevation="1" Class="rounded-lg profile-tile">
|
||||||
|
<MudCardContent Class="d-flex flex-column align-center pa-4">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.Groups" Size="Size.Large" Color="Color.Info" />
|
||||||
|
<MudText Typo="Typo.subtitle1" Class="mt-2">شبکه من</MudText>
|
||||||
|
<MudText Typo="Typo.caption" Class="mud-text-secondary">آمار و درخت شبکه</MudText>
|
||||||
|
</MudCardContent>
|
||||||
|
</MudCard>
|
||||||
|
</MudLink>
|
||||||
|
</MudItem>
|
||||||
|
<MudItem xs="6" sm="6" md="3">
|
||||||
|
<MudLink Href="@RouteConstants.Commission.Dashboard" Underline="Underline.None" Class="tile-link">
|
||||||
|
<MudCard Elevation="1" Class="rounded-lg profile-tile">
|
||||||
|
<MudCardContent Class="d-flex flex-column align-center pa-4">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.Payments" Size="Size.Large" Color="Color.Success" />
|
||||||
|
<MudText Typo="Typo.subtitle1" Class="mt-2">کمیسیون</MudText>
|
||||||
|
<MudText Typo="Typo.caption" Class="mud-text-secondary">درآمد و تاریخچه</MudText>
|
||||||
|
</MudCardContent>
|
||||||
|
</MudCard>
|
||||||
|
</MudLink>
|
||||||
|
</MudItem>
|
||||||
</MudGrid>
|
</MudGrid>
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
|
|||||||
@@ -10,23 +10,27 @@
|
|||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
<MudGrid Spacing="2">
|
<MudGrid Spacing="2">
|
||||||
<MudItem xs="12" sm="6">
|
<MudItem xs="12" sm="6" md="4">
|
||||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
<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>
|
<MudText Typo="Typo.h4" Color="Color.Primary">@_balances.Credit</MudText>
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
<MudItem xs="12" sm="6">
|
<MudItem xs="12" sm="6" md="4">
|
||||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
<MudPaper Elevation="2" Class="pa-4 rounded-lg" Style="background-color: var(--mud-palette-warning-lighten);">
|
||||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی تخفیف باشگاه</MudText>
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||||
<MudText Typo="Typo.h4" Color="Color.Primary">@_balances.Discount</MudText>
|
<MudIcon Icon="@Icons.Material.Filled.Discount" Color="Color.Warning" Size="Size.Large" />
|
||||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">در انتظار اتصال CMS برای مقدار واقعی</MudText>
|
<MudStack Spacing="0">
|
||||||
|
<MudText Typo="Typo.subtitle2" Style="color: var(--mud-palette-warning-darken);">موجودی تخفیف باشگاه</MudText>
|
||||||
|
<MudText Typo="Typo.h4" Style="color: var(--mud-palette-warning-darken);"><strong>@_balances.Discount</strong></MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudStack>
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
<MudItem xs="12" sm="6">
|
<MudItem xs="12" sm="6" md="4">
|
||||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
<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.Network</MudText>
|
<MudText Typo="Typo.h4" Color="Color.Success">@_balances.Network</MudText>
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
</MudGrid>
|
</MudGrid>
|
||||||
@@ -39,9 +43,9 @@
|
|||||||
Variant="Variant.Outlined"
|
Variant="Variant.Outlined"
|
||||||
Type="MudBlazor.InputType.Number"
|
Type="MudBlazor.InputType.Number"
|
||||||
Required="true" />
|
Required="true" />
|
||||||
<MudRadioGroup @bind-SelectedOption="_withdrawMethod" Row="true">
|
<MudRadioGroup T="WithdrawalMethodClient" @bind-SelectedOption="_withdrawMethod" Row="true">
|
||||||
<MudRadio Option="@WithdrawalMethodClient.Cash" Label="برداشت نقدی (نیاز به شبا)" />
|
<MudRadio T="WithdrawalMethodClient" Option="@WithdrawalMethodClient.Cash" Label="برداشت نقدی (نیاز به شبا)" />
|
||||||
<MudRadio Option="@WithdrawalMethodClient.Diamond" Label="الماس/غیرنقدی" />
|
<MudRadio T="WithdrawalMethodClient" Option="@WithdrawalMethodClient.Diamond" Label="الماس/غیرنقدی" />
|
||||||
</MudRadioGroup>
|
</MudRadioGroup>
|
||||||
<MudTextField @bind-Value="_withdrawIban"
|
<MudTextField @bind-Value="_withdrawIban"
|
||||||
Label="شماره شبا"
|
Label="شماره شبا"
|
||||||
@@ -73,16 +77,16 @@
|
|||||||
Adornment="Adornment.Start"
|
Adornment="Adornment.Start"
|
||||||
AdornmentIcon="@Icons.Material.Filled.Search" />
|
AdornmentIcon="@Icons.Material.Filled.Search" />
|
||||||
<MudSelect T="string" @bind-Value="_filterType" Label="نوع تراکنش" Variant="Variant.Outlined">
|
<MudSelect T="string" @bind-Value="_filterType" Label="نوع تراکنش" Variant="Variant.Outlined">
|
||||||
<MudSelectItem Value="all">همه</MudSelectItem>
|
<MudSelectItem T="string" Value="@("all")">همه</MudSelectItem>
|
||||||
<MudSelectItem Value="in">ورودی (شارژ)</MudSelectItem>
|
<MudSelectItem T="string" Value="@("in")">ورودی (شارژ)</MudSelectItem>
|
||||||
<MudSelectItem Value="out">خروجی (برداشت/خرید)</MudSelectItem>
|
<MudSelectItem T="string" Value="@("out")">خروجی (برداشت/خرید)</MudSelectItem>
|
||||||
</MudSelect>
|
</MudSelect>
|
||||||
<MudSelect T="string" @bind-Value="_withdrawStatusFilter" Label="وضعیت برداشت" Variant="Variant.Outlined">
|
<MudSelect T="string" @bind-Value="_withdrawStatusFilter" Label="وضعیت برداشت" Variant="Variant.Outlined">
|
||||||
<MudSelectItem Value="all">همه</MudSelectItem>
|
<MudSelectItem T="string" Value="@("all")">همه</MudSelectItem>
|
||||||
<MudSelectItem Value="pending">Pending</MudSelectItem>
|
<MudSelectItem T="string" Value="@("pending")">Pending</MudSelectItem>
|
||||||
<MudSelectItem Value="requested">Requested</MudSelectItem>
|
<MudSelectItem T="string" Value="@("requested")">Requested</MudSelectItem>
|
||||||
<MudSelectItem Value="withdrawn">Withdrawn</MudSelectItem>
|
<MudSelectItem T="string" Value="@("withdrawn")">Withdrawn</MudSelectItem>
|
||||||
<MudSelectItem Value="cancelled">Cancelled</MudSelectItem>
|
<MudSelectItem T="string" Value="@("cancelled")">Cancelled</MudSelectItem>
|
||||||
</MudSelect>
|
</MudSelect>
|
||||||
<MudButton Variant="Variant.Outlined" OnClick="ApplyFilters" StartIcon="@Icons.Material.Filled.FilterList">اعمال فیلتر</MudButton>
|
<MudButton Variant="Variant.Outlined" OnClick="ApplyFilters" StartIcon="@Icons.Material.Filled.FilterList">اعمال فیلتر</MudButton>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
@@ -138,7 +142,7 @@
|
|||||||
<MudTd>@context.WeekNumber</MudTd>
|
<MudTd>@context.WeekNumber</MudTd>
|
||||||
<MudTd>@FormatPrice(context.Amount)</MudTd>
|
<MudTd>@FormatPrice(context.Amount)</MudTd>
|
||||||
<MudTd>
|
<MudTd>
|
||||||
<MudChip Color="@(ResolveStatusColor(context.Status))" Variant="Variant.Outlined" Size="Size.Small">
|
<MudChip T="string" Color="@(ResolveStatusColor(context.Status))" Variant="Variant.Outlined" Size="Size.Small">
|
||||||
@ResolveStatusText(context.Status)
|
@ResolveStatusText(context.Status)
|
||||||
</MudChip>
|
</MudChip>
|
||||||
</MudTd>
|
</MudTd>
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ namespace FrontOffice.Main.Pages.Profile;
|
|||||||
|
|
||||||
public partial class Wallet : ComponentBase
|
public partial class Wallet : ComponentBase
|
||||||
{
|
{
|
||||||
[Inject] private ISnackbar Snackbar { get; set; } = default!;
|
|
||||||
|
|
||||||
private long _minWithdrawalAmount = 1_000_000; // مقدار پیشفرض، از CMS خوانده میشود
|
private long _minWithdrawalAmount = 1_000_000; // مقدار پیشفرض، از CMS خوانده میشود
|
||||||
private (string Credit, string Discount, string Network) _balances = ("-", "-", "-");
|
private (string Credit, string Discount, string Network) _balances = ("-", "-", "-");
|
||||||
private List<WalletTransaction> _txs = new();
|
private List<WalletTransaction> _txs = new();
|
||||||
|
|||||||
23
src/FrontOffice.Main/Utilities/ClubMembershipDtos.cs
Normal file
23
src/FrontOffice.Main/Utilities/ClubMembershipDtos.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
namespace FrontOffice.Main.Utilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO for Club Membership information
|
||||||
|
/// </summary>
|
||||||
|
public class ClubMembershipDto
|
||||||
|
{
|
||||||
|
public long UserId { get; set; }
|
||||||
|
public bool IsActive { get; set; }
|
||||||
|
public string Status { get; set; } = string.Empty;
|
||||||
|
public int? DaysRemaining { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO for Club Membership activation response
|
||||||
|
/// </summary>
|
||||||
|
public class ClubActivationResponseDto
|
||||||
|
{
|
||||||
|
public bool Success { get; set; }
|
||||||
|
public string? Message { get; set; }
|
||||||
|
public DateTime? ActivationDate { get; set; }
|
||||||
|
public long AmountPaid { get; set; }
|
||||||
|
}
|
||||||
70
src/FrontOffice.Main/Utilities/ClubMembershipService.cs
Normal file
70
src/FrontOffice.Main/Utilities/ClubMembershipService.cs
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
namespace FrontOffice.Main.Utilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Service for Club Membership operations
|
||||||
|
/// TODO: Connect to FrontOffice.BFF gRPC ClubMembershipCQ
|
||||||
|
/// </summary>
|
||||||
|
public class ClubMembershipService
|
||||||
|
{
|
||||||
|
// TODO: Inject gRPC client when FrontOffice connects to BFF
|
||||||
|
// private readonly ClubMembershipContract.ClubMembershipContractClient _client;
|
||||||
|
|
||||||
|
public ClubMembershipService()
|
||||||
|
{
|
||||||
|
// TODO: Initialize gRPC client
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get current user's club membership status
|
||||||
|
/// Maps to: ClubMembershipCQ.GetMyClubMembership
|
||||||
|
/// </summary>
|
||||||
|
public async Task<ClubMembershipDto> GetMyMembershipAsync()
|
||||||
|
{
|
||||||
|
// TODO: Replace with actual gRPC call to BFF
|
||||||
|
// var request = new GetMyClubMembershipRequest();
|
||||||
|
// var response = await _client.GetMyClubMembershipAsync(request);
|
||||||
|
// return MapToDto(response);
|
||||||
|
|
||||||
|
await Task.Delay(500); // Simulate network delay
|
||||||
|
|
||||||
|
// Mock data for now
|
||||||
|
return new ClubMembershipDto
|
||||||
|
{
|
||||||
|
UserId = 1,
|
||||||
|
IsActive = false,
|
||||||
|
Status = "Inactive",
|
||||||
|
DaysRemaining = null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Activate or renew club membership
|
||||||
|
/// Maps to: ClubMembershipCQ.ActivateMyClubMembership
|
||||||
|
/// </summary>
|
||||||
|
public async Task<ClubActivationResponseDto> ActivateMembershipAsync(
|
||||||
|
long packageId,
|
||||||
|
string? activationCode,
|
||||||
|
int durationMonths)
|
||||||
|
{
|
||||||
|
// TODO: Replace with actual gRPC call to BFF
|
||||||
|
// var request = new ActivateMyClubMembershipRequest
|
||||||
|
// {
|
||||||
|
// PackageId = packageId,
|
||||||
|
// ActivationCode = activationCode ?? string.Empty,
|
||||||
|
// DurationMonths = durationMonths
|
||||||
|
// };
|
||||||
|
// var response = await _client.ActivateMyClubMembershipAsync(request);
|
||||||
|
// return MapToDto(response);
|
||||||
|
|
||||||
|
await Task.Delay(1000); // Simulate network delay
|
||||||
|
|
||||||
|
// Mock successful activation
|
||||||
|
return new ClubActivationResponseDto
|
||||||
|
{
|
||||||
|
Success = true,
|
||||||
|
Message = "عضویت با موفقیت فعال شد",
|
||||||
|
ActivationDate = DateTime.Now,
|
||||||
|
AmountPaid = 56_000_000 * durationMonths
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
56
src/FrontOffice.Main/Utilities/CommissionDtos.cs
Normal file
56
src/FrontOffice.Main/Utilities/CommissionDtos.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
namespace FrontOffice.Main.Utilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO for Commission Payout
|
||||||
|
/// </summary>
|
||||||
|
public class CommissionPayoutDto
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public int WeekNumber { get; set; }
|
||||||
|
public string WeekLabel { get; set; } = string.Empty;
|
||||||
|
public int BalancesEarned { get; set; }
|
||||||
|
public long TotalAmount { get; set; }
|
||||||
|
public string AmountFormatted { get; set; } = string.Empty;
|
||||||
|
public string Status { get; set; } = string.Empty;
|
||||||
|
public string StatusBadgeColor { get; set; } = string.Empty;
|
||||||
|
public string DatePersian { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Response for paginated commission payouts
|
||||||
|
/// </summary>
|
||||||
|
public class CommissionPayoutsResponseDto
|
||||||
|
{
|
||||||
|
public List<CommissionPayoutDto> Payouts { get; set; } = new();
|
||||||
|
public int TotalCount { get; set; }
|
||||||
|
public int PageNumber { get; set; }
|
||||||
|
public int PageSize { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO for Weekly Balance details
|
||||||
|
/// </summary>
|
||||||
|
public class WeeklyBalanceDto
|
||||||
|
{
|
||||||
|
public int WeekNumber { get; set; }
|
||||||
|
public string WeekLabel { get; set; } = string.Empty;
|
||||||
|
public long LeftBalance { get; set; }
|
||||||
|
public long RightBalance { get; set; }
|
||||||
|
public long MinBalance { get; set; }
|
||||||
|
public int BalanceCount { get; set; }
|
||||||
|
public long CalculatedCommission { get; set; }
|
||||||
|
public long LeftCarryover { get; set; }
|
||||||
|
public long RightCarryover { get; set; }
|
||||||
|
public DateTime StartDate { get; set; }
|
||||||
|
public DateTime EndDate { get; set; }
|
||||||
|
|
||||||
|
// Formatted properties
|
||||||
|
public string LeftBalanceFormatted => $"{LeftBalance:N0} تومان";
|
||||||
|
public string RightBalanceFormatted => $"{RightBalance:N0} تومان";
|
||||||
|
public string MinBalanceFormatted => $"{MinBalance:N0} تومان";
|
||||||
|
public string CalculatedCommissionFormatted => $"{CalculatedCommission:N0} تومان";
|
||||||
|
public string LeftCarryoverFormatted => $"{LeftCarryover:N0} تومان";
|
||||||
|
public string RightCarryoverFormatted => $"{RightCarryover:N0} تومان";
|
||||||
|
public string StartDatePersian => StartDate.ToString("yyyy/MM/dd");
|
||||||
|
public string EndDatePersian => EndDate.ToString("yyyy/MM/dd");
|
||||||
|
}
|
||||||
131
src/FrontOffice.Main/Utilities/CommissionService.cs
Normal file
131
src/FrontOffice.Main/Utilities/CommissionService.cs
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
namespace FrontOffice.Main.Utilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Service for Commission operations
|
||||||
|
/// TODO: Connect to FrontOffice.BFF gRPC CommissionCQ
|
||||||
|
/// </summary>
|
||||||
|
public class CommissionService
|
||||||
|
{
|
||||||
|
// TODO: Inject gRPC client when FrontOffice connects to BFF
|
||||||
|
// private readonly CommissionContract.CommissionContractClient _client;
|
||||||
|
|
||||||
|
public CommissionService()
|
||||||
|
{
|
||||||
|
// TODO: Initialize gRPC client
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get commission payouts with pagination and filters
|
||||||
|
/// Maps to: CommissionCQ.GetMyCommissionPayouts
|
||||||
|
/// </summary>
|
||||||
|
public async Task<CommissionPayoutsResponseDto> GetMyCommissionPayoutsAsync(
|
||||||
|
int? weekNumber,
|
||||||
|
string? status,
|
||||||
|
int pageNumber,
|
||||||
|
int pageSize)
|
||||||
|
{
|
||||||
|
// TODO: Replace with actual gRPC call to BFF
|
||||||
|
// var request = new GetMyCommissionPayoutsRequest
|
||||||
|
// {
|
||||||
|
// WeekNumber = weekNumber,
|
||||||
|
// Status = status ?? string.Empty,
|
||||||
|
// PageNumber = pageNumber,
|
||||||
|
// PageSize = pageSize
|
||||||
|
// };
|
||||||
|
// var response = await _client.GetMyCommissionPayoutsAsync(request);
|
||||||
|
// return MapToDto(response);
|
||||||
|
|
||||||
|
await Task.Delay(500); // Simulate network delay
|
||||||
|
|
||||||
|
// Mock data
|
||||||
|
var allPayouts = GenerateMockPayouts(50);
|
||||||
|
|
||||||
|
// Apply filters
|
||||||
|
var filtered = allPayouts.AsEnumerable();
|
||||||
|
if (weekNumber.HasValue)
|
||||||
|
filtered = filtered.Where(p => p.WeekNumber == weekNumber.Value);
|
||||||
|
if (!string.IsNullOrEmpty(status))
|
||||||
|
filtered = filtered.Where(p => p.Status == status);
|
||||||
|
|
||||||
|
var total = filtered.Count();
|
||||||
|
var paged = filtered.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList();
|
||||||
|
|
||||||
|
return new CommissionPayoutsResponseDto
|
||||||
|
{
|
||||||
|
Payouts = paged,
|
||||||
|
TotalCount = total,
|
||||||
|
PageNumber = pageNumber,
|
||||||
|
PageSize = pageSize
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get weekly balance details for a specific week
|
||||||
|
/// Maps to: CommissionCQ.GetMyWeeklyBalances
|
||||||
|
/// </summary>
|
||||||
|
public async Task<WeeklyBalanceDto> GetMyWeeklyBalanceAsync(int? weekNumber = null)
|
||||||
|
{
|
||||||
|
// TODO: Replace with actual gRPC call to BFF
|
||||||
|
// var request = new GetMyWeeklyBalancesRequest
|
||||||
|
// {
|
||||||
|
// WeekNumber = weekNumber
|
||||||
|
// };
|
||||||
|
// var response = await _client.GetMyWeeklyBalancesAsync(request);
|
||||||
|
// return MapToDto(response);
|
||||||
|
|
||||||
|
await Task.Delay(500); // Simulate network delay
|
||||||
|
|
||||||
|
// Mock current week data
|
||||||
|
var currentWeek = weekNumber ?? 45;
|
||||||
|
return new WeeklyBalanceDto
|
||||||
|
{
|
||||||
|
WeekNumber = currentWeek,
|
||||||
|
WeekLabel = $"هفته {currentWeek} - سال 1404",
|
||||||
|
LeftBalance = 15_000_000,
|
||||||
|
RightBalance = 12_000_000,
|
||||||
|
MinBalance = 12_000_000,
|
||||||
|
BalanceCount = 12,
|
||||||
|
CalculatedCommission = 1_200_000,
|
||||||
|
LeftCarryover = 3_000_000,
|
||||||
|
RightCarryover = 0,
|
||||||
|
StartDate = DateTime.Now.AddDays(-7),
|
||||||
|
EndDate = DateTime.Now
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Mock Data Helpers
|
||||||
|
|
||||||
|
private static List<CommissionPayoutDto> GenerateMockPayouts(int count)
|
||||||
|
{
|
||||||
|
var payouts = new List<CommissionPayoutDto>();
|
||||||
|
var random = new Random();
|
||||||
|
var statuses = new[] { "Created", "Paid", "WithdrawalRequested", "Withdrawn", "Cancelled" };
|
||||||
|
var statusColors = new[] { "Info", "Success", "Warning", "Success", "Error" };
|
||||||
|
var statusTexts = new[] { "ایجاد شده", "پرداخت شده", "درخواست برداشت", "برداشت شده", "لغو شده" };
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
var statusIndex = random.Next(statuses.Length);
|
||||||
|
var weekNumber = 50 - i;
|
||||||
|
var balances = random.Next(5, 20);
|
||||||
|
var amount = balances * 100_000;
|
||||||
|
|
||||||
|
payouts.Add(new CommissionPayoutDto
|
||||||
|
{
|
||||||
|
Id = i + 1,
|
||||||
|
WeekNumber = weekNumber,
|
||||||
|
WeekLabel = $"هفته {weekNumber} - سال 1404",
|
||||||
|
BalancesEarned = balances,
|
||||||
|
TotalAmount = amount,
|
||||||
|
AmountFormatted = $"{amount:N0} تومان",
|
||||||
|
Status = statusTexts[statusIndex],
|
||||||
|
StatusBadgeColor = statusColors[statusIndex],
|
||||||
|
DatePersian = DateTime.Now.AddDays(-i * 7).ToString("yyyy/MM/dd")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return payouts;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
50
src/FrontOffice.Main/Utilities/NetworkMembershipDtos.cs
Normal file
50
src/FrontOffice.Main/Utilities/NetworkMembershipDtos.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
namespace FrontOffice.Main.Utilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO for Network Tree node
|
||||||
|
/// </summary>
|
||||||
|
public class NetworkNodeDto
|
||||||
|
{
|
||||||
|
public long UserId { get; set; }
|
||||||
|
public string FullName { get; set; } = string.Empty;
|
||||||
|
public string Mobile { get; set; } = string.Empty;
|
||||||
|
public string? Avatar { get; set; }
|
||||||
|
public string Position { get; set; } = string.Empty; // "Left" or "Right"
|
||||||
|
public NetworkNodeDto? LeftChild { get; set; }
|
||||||
|
public NetworkNodeDto? RightChild { get; set; }
|
||||||
|
public int Level { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO for Network Tree response
|
||||||
|
/// </summary>
|
||||||
|
public class NetworkTreeDto
|
||||||
|
{
|
||||||
|
public NetworkNodeDto? RootNode { get; set; }
|
||||||
|
public int TotalMembers { get; set; }
|
||||||
|
public int CurrentDepth { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO for Last Member info
|
||||||
|
/// </summary>
|
||||||
|
public class LastMemberDto
|
||||||
|
{
|
||||||
|
public long UserId { get; set; }
|
||||||
|
public string FullName { get; set; } = string.Empty;
|
||||||
|
public string Position { get; set; } = string.Empty;
|
||||||
|
public DateTime JoinedAt { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO for Network Statistics
|
||||||
|
/// </summary>
|
||||||
|
public class NetworkStatisticsDto
|
||||||
|
{
|
||||||
|
public int LeftLegCount { get; set; }
|
||||||
|
public int RightLegCount { get; set; }
|
||||||
|
public int TotalMembers { get; set; }
|
||||||
|
public int TreeDepth { get; set; }
|
||||||
|
public string WeakerLeg { get; set; } = string.Empty; // "Left" or "Right"
|
||||||
|
public LastMemberDto? LastMember { get; set; }
|
||||||
|
}
|
||||||
108
src/FrontOffice.Main/Utilities/NetworkMembershipService.cs
Normal file
108
src/FrontOffice.Main/Utilities/NetworkMembershipService.cs
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
namespace FrontOffice.Main.Utilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Service for Network Membership operations
|
||||||
|
/// TODO: Connect to FrontOffice.BFF gRPC NetworkMembershipCQ
|
||||||
|
/// </summary>
|
||||||
|
public class NetworkMembershipService
|
||||||
|
{
|
||||||
|
// TODO: Inject gRPC client when FrontOffice connects to BFF
|
||||||
|
// private readonly NetworkMembershipContract.NetworkMembershipContractClient _client;
|
||||||
|
|
||||||
|
public NetworkMembershipService()
|
||||||
|
{
|
||||||
|
// TODO: Initialize gRPC client
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get current user's network tree
|
||||||
|
/// Maps to: NetworkMembershipCQ.GetMyNetworkTree
|
||||||
|
/// </summary>
|
||||||
|
public async Task<NetworkTreeDto> GetMyNetworkTreeAsync(int maxDepth = 3)
|
||||||
|
{
|
||||||
|
// TODO: Replace with actual gRPC call to BFF
|
||||||
|
// var request = new GetMyNetworkTreeRequest { MaxDepth = maxDepth };
|
||||||
|
// var response = await _client.GetMyNetworkTreeAsync(request);
|
||||||
|
// return MapToDto(response);
|
||||||
|
|
||||||
|
await Task.Delay(500); // Simulate network delay
|
||||||
|
|
||||||
|
// Mock data with sample tree
|
||||||
|
return new NetworkTreeDto
|
||||||
|
{
|
||||||
|
CurrentDepth = 2,
|
||||||
|
TotalMembers = 5,
|
||||||
|
RootNode = new NetworkNodeDto
|
||||||
|
{
|
||||||
|
UserId = 1,
|
||||||
|
FullName = "شما",
|
||||||
|
Mobile = "09121234567",
|
||||||
|
Position = "Root",
|
||||||
|
Level = 0,
|
||||||
|
LeftChild = new NetworkNodeDto
|
||||||
|
{
|
||||||
|
UserId = 2,
|
||||||
|
FullName = "علی محمدی",
|
||||||
|
Mobile = "09121234568",
|
||||||
|
Position = "Left",
|
||||||
|
Level = 1,
|
||||||
|
LeftChild = new NetworkNodeDto
|
||||||
|
{
|
||||||
|
UserId = 4,
|
||||||
|
FullName = "رضا احمدی",
|
||||||
|
Mobile = "09121234570",
|
||||||
|
Position = "Left",
|
||||||
|
Level = 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
RightChild = new NetworkNodeDto
|
||||||
|
{
|
||||||
|
UserId = 3,
|
||||||
|
FullName = "فاطمه حسینی",
|
||||||
|
Mobile = "09121234569",
|
||||||
|
Position = "Right",
|
||||||
|
Level = 1,
|
||||||
|
RightChild = new NetworkNodeDto
|
||||||
|
{
|
||||||
|
UserId = 5,
|
||||||
|
FullName = "زهرا کریمی",
|
||||||
|
Mobile = "09121234571",
|
||||||
|
Position = "Right",
|
||||||
|
Level = 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get current user's network statistics
|
||||||
|
/// Maps to: NetworkMembershipCQ.GetMyNetworkStatistics
|
||||||
|
/// </summary>
|
||||||
|
public async Task<NetworkStatisticsDto> GetMyNetworkStatisticsAsync()
|
||||||
|
{
|
||||||
|
// TODO: Replace with actual gRPC call to BFF
|
||||||
|
// var request = new GetMyNetworkStatisticsRequest();
|
||||||
|
// var response = await _client.GetMyNetworkStatisticsAsync(request);
|
||||||
|
// return MapToDto(response);
|
||||||
|
|
||||||
|
await Task.Delay(500); // Simulate network delay
|
||||||
|
|
||||||
|
// Mock statistics
|
||||||
|
return new NetworkStatisticsDto
|
||||||
|
{
|
||||||
|
LeftLegCount = 15,
|
||||||
|
RightLegCount = 12,
|
||||||
|
TotalMembers = 27,
|
||||||
|
TreeDepth = 4,
|
||||||
|
WeakerLeg = "Right",
|
||||||
|
LastMember = new LastMemberDto
|
||||||
|
{
|
||||||
|
UserId = 28,
|
||||||
|
FullName = "محمد رضایی",
|
||||||
|
Position = "Left",
|
||||||
|
JoinedAt = DateTime.Now.AddHours(-2)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,25 @@ public static class RouteConstants
|
|||||||
public const string Wallet = "/profile/wallet";
|
public const string Wallet = "/profile/wallet";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class Club
|
||||||
|
{
|
||||||
|
public const string Membership = "/club/membership";
|
||||||
|
public const string Features = "/club/features";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Network
|
||||||
|
{
|
||||||
|
public const string Tree = "/network/tree";
|
||||||
|
public const string Statistics = "/network/statistics";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Commission
|
||||||
|
{
|
||||||
|
public const string Dashboard = "/commission/dashboard";
|
||||||
|
public const string History = "/commission/history";
|
||||||
|
public const string WeeklyBalance = "/commission/weekly-balance";
|
||||||
|
}
|
||||||
|
|
||||||
public static class Package
|
public static class Package
|
||||||
{
|
{
|
||||||
public const string Detail = "/package/";
|
public const string Detail = "/package/";
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ public class WalletService
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var response = await _client.GetUserWalletAsync(new Empty());
|
var response = await _client.GetUserWalletAsync(new Empty());
|
||||||
return new WalletBalances(response.Balance, response.DiscountBalance, response.NetworkBalance);
|
// TODO: DiscountBalance will be added in BFF protobuf later
|
||||||
|
return new WalletBalances(response.Balance, 0 /* response.DiscountBalance */, response.NetworkBalance);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -39,6 +40,9 @@ public class WalletService
|
|||||||
|
|
||||||
public async Task<List<WalletTransaction>> GetTransactionsAsync(long? referenceId = null, bool? isIncrease = null)
|
public async Task<List<WalletTransaction>> GetTransactionsAsync(long? referenceId = null, bool? isIncrease = null)
|
||||||
{
|
{
|
||||||
|
// TODO: Implement when BFF protobuf has GetAllUserWalletChangeLog
|
||||||
|
await Task.CompletedTask;
|
||||||
|
/*
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var request = new GetAllUserWalletChangeLogRequest();
|
var request = new GetAllUserWalletChangeLogRequest();
|
||||||
@@ -62,6 +66,7 @@ public class WalletService
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
*/
|
||||||
// Fallback to mock data if backend is unavailable
|
// Fallback to mock data if backend is unavailable
|
||||||
var _transactions = new List<WalletTransaction>
|
var _transactions = new List<WalletTransaction>
|
||||||
{
|
{
|
||||||
@@ -71,7 +76,7 @@ public class WalletService
|
|||||||
new(DateTime.Now.AddDays(-9).ToString(), 900_000, "کیف پول شرکای تجاری", "اعتبار خرید"),
|
new(DateTime.Now.AddDays(-9).ToString(), 900_000, "کیف پول شرکای تجاری", "اعتبار خرید"),
|
||||||
};
|
};
|
||||||
return _transactions.OrderByDescending(t => t.Date).ToList();
|
return _transactions.OrderByDescending(t => t.Date).ToList();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string ResolveTransactionDate(GetAllUserWalletChangeLogResponseModel model)
|
private static string ResolveTransactionDate(GetAllUserWalletChangeLogResponseModel model)
|
||||||
@@ -100,6 +105,10 @@ public class WalletService
|
|||||||
|
|
||||||
public async Task<bool> RequestWithdrawalAsync(long payoutId, WithdrawalMethodClient method, string? iban)
|
public async Task<bool> RequestWithdrawalAsync(long payoutId, WithdrawalMethodClient method, string? iban)
|
||||||
{
|
{
|
||||||
|
// TODO: Implement when BFF protobuf has WithdrawBalance
|
||||||
|
await Task.CompletedTask;
|
||||||
|
return true;
|
||||||
|
/*
|
||||||
var request = new WithdrawBalanceRequest
|
var request = new WithdrawBalanceRequest
|
||||||
{
|
{
|
||||||
PayoutId = payoutId,
|
PayoutId = payoutId,
|
||||||
@@ -119,10 +128,15 @@ public class WalletService
|
|||||||
// surface backend error text
|
// surface backend error text
|
||||||
throw new InvalidOperationException(ex.Status.Detail ?? "خطا در ثبت برداشت", ex);
|
throw new InvalidOperationException(ex.Status.Detail ?? "خطا در ثبت برداشت", ex);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<WalletWithdrawal>> GetWithdrawalsAsync(int? status = null)
|
public async Task<List<WalletWithdrawal>> GetWithdrawalsAsync(int? status = null)
|
||||||
{
|
{
|
||||||
|
// TODO: Implement when BFF protobuf has GetUserWithdrawals
|
||||||
|
await Task.CompletedTask;
|
||||||
|
return new List<WalletWithdrawal>();
|
||||||
|
/*
|
||||||
var request = new GetUserWithdrawalsRequest();
|
var request = new GetUserWithdrawalsRequest();
|
||||||
if (status.HasValue)
|
if (status.HasValue)
|
||||||
{
|
{
|
||||||
@@ -140,11 +154,15 @@ public class WalletService
|
|||||||
m.IbanNumber,
|
m.IbanNumber,
|
||||||
m.Created.ToDateTime().MiladiToJalaliWithTime()))
|
m.Created.ToDateTime().MiladiToJalaliWithTime()))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<WithdrawalSettings> GetWithdrawalSettingsAsync()
|
public async Task<WithdrawalSettings> GetWithdrawalSettingsAsync()
|
||||||
{
|
{
|
||||||
var response = await _client.GetWithdrawalSettingsAsync(new Empty());
|
// TODO: Implement when BFF protobuf has GetWithdrawalSettings
|
||||||
return new WithdrawalSettings(response.MinWithdrawalAmount);
|
await Task.CompletedTask;
|
||||||
|
return new WithdrawalSettings(1_000_000);
|
||||||
|
// var response = await _client.GetWithdrawalSettingsAsync(new Empty());
|
||||||
|
// return new WithdrawalSettings(response.MinWithdrawalAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user