49017027d0
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 2m20s
- Blog management pages (posts, categories) - Content management pages (site pages, sections) - Contract management pages - Discount shop improvements (order details, product form, categories) - Wallet management pages - Commission withdrawal details/reject dialogs - Orders hub, sales reports - System hub, global search, breadcrumb - Club features page, club hub - UI/UX improvements across all pages - AppBreadcrumb, GlobalSearch components - NavMenu updates and styling
696 lines
35 KiB
Plaintext
696 lines
35 KiB
Plaintext
@* Merged into /system *@
|
|
@attribute [Authorize(Roles = "Administrator")]
|
|
|
|
@using CMSMicroservice.Protobuf.Protos.Configuration
|
|
@using CMSMicroservice.Protobuf.Protos
|
|
@using MudBlazor
|
|
|
|
<div>
|
|
<MudText Typo="Typo.h4" GutterBottom="true">تنظیمات سیستم</MudText>
|
|
<MudText Typo="Typo.body1" Color="Color.Secondary" Class="mb-4">
|
|
مدیریت پارامترهای سیستم و قوانین محاسبات
|
|
</MudText>
|
|
|
|
<MudTabs Elevation="2" Rounded="true" ApplyEffectsToContainer="true" PanelClass="pa-6">
|
|
<!-- Commission Settings -->
|
|
<MudTabPanel Text="تنظیمات کمیسیون" Icon="@Icons.Material.Filled.AccountBalanceWallet">
|
|
<MudCard Elevation="0">
|
|
<MudCardContent>
|
|
<MudText Typo="Typo.h6" Class="mb-4">پارامترهای محاسبه کمیسیون</MudText>
|
|
|
|
<MudGrid>
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_commissionConfig.MinBalanceForPayout"
|
|
Label="حداقل موجودی برای پرداخت"
|
|
Variant="Variant.Outlined"
|
|
Adornment="Adornment.End"
|
|
AdornmentText="تومان"
|
|
Min="0"
|
|
HelperText="حداقل موجودی لازم برای درخواست برداشت" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_commissionConfig.MaxWithdrawalAmount"
|
|
Label="حداکثر مبلغ برداشت"
|
|
Variant="Variant.Outlined"
|
|
Adornment="Adornment.End"
|
|
AdornmentText="تومان"
|
|
Min="0"
|
|
HelperText="حداکثر مبلغ قابل برداشت در هر درخواست" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_commissionConfig.CommissionPercentage"
|
|
Label="درصد کمیسیون"
|
|
Variant="Variant.Outlined"
|
|
Adornment="Adornment.End"
|
|
AdornmentText="%"
|
|
Min="0"
|
|
Max="100"
|
|
HelperText="درصد کمیسیون از فروش" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_commissionConfig.WeeklyPoolPercentage"
|
|
Label="درصد استخر هفتگی"
|
|
Variant="Variant.Outlined"
|
|
Adornment="Adornment.End"
|
|
AdornmentText="%"
|
|
Min="0"
|
|
Max="100"
|
|
HelperText="درصد اختصاص به استخر هفتگی" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudSelect @bind-Value="_commissionConfig.CalculationDay"
|
|
Label="روز محاسبه هفتگی"
|
|
Variant="Variant.Outlined">
|
|
<MudSelectItem T="string" Value="@("Saturday")">شنبه</MudSelectItem>
|
|
<MudSelectItem T="string" Value="@("Sunday")">یکشنبه</MudSelectItem>
|
|
<MudSelectItem T="string" Value="@("Monday")">دوشنبه</MudSelectItem>
|
|
<MudSelectItem T="string" Value="@("Tuesday")">سهشنبه</MudSelectItem>
|
|
<MudSelectItem T="string" Value="@("Wednesday")">چهارشنبه</MudSelectItem>
|
|
<MudSelectItem T="string" Value="@("Thursday")">پنجشنبه</MudSelectItem>
|
|
<MudSelectItem T="string" Value="@("Friday")">جمعه</MudSelectItem>
|
|
</MudSelect>
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudTimePicker @bind-Time="_commissionConfig.CalculationTime"
|
|
Label="ساعت محاسبه"
|
|
Variant="Variant.Outlined"
|
|
AmPm="false" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudSwitch T="bool" @bind-Value="_commissionConfig.AutoCalculationEnabled"
|
|
Color="Color.Primary"
|
|
Label="محاسبه خودکار هفتگی فعال باشد" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudSwitch T="bool" @bind-Value="_commissionConfig.AutoPayoutEnabled"
|
|
Color="Color.Primary"
|
|
Label="پرداخت خودکار فعال باشد" />
|
|
</MudItem>
|
|
</MudGrid>
|
|
|
|
<MudDivider Class="my-4" />
|
|
|
|
<MudStack Row="true" Justify="Justify.FlexEnd" Spacing="2">
|
|
<MudButton Variant="Variant.Text"
|
|
Color="Color.Default"
|
|
OnClick="ResetCommissionConfig">
|
|
بازگشت به پیشفرض
|
|
</MudButton>
|
|
<MudButton Variant="Variant.Filled"
|
|
Color="Color.Primary"
|
|
OnClick="SaveCommissionConfig"
|
|
StartIcon="@Icons.Material.Filled.Save">
|
|
ذخیره تنظیمات
|
|
</MudButton>
|
|
</MudStack>
|
|
</MudCardContent>
|
|
</MudCard>
|
|
</MudTabPanel>
|
|
|
|
<!-- Network Settings -->
|
|
<MudTabPanel Text="تنظیمات شبکه" Icon="@Icons.Material.Filled.AccountTree">
|
|
<MudCard Elevation="0">
|
|
<MudCardContent>
|
|
<MudText Typo="Typo.h6" Class="mb-4">قوانین شبکه باینری</MudText>
|
|
|
|
<MudGrid>
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_networkConfig.MaxTreeDepth"
|
|
Label="حداکثر عمق درخت"
|
|
Variant="Variant.Outlined"
|
|
Min="1"
|
|
Max="20"
|
|
HelperText="حداکثر سطوح مجاز در درخت شبکه" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_networkConfig.MaxDirectChildren"
|
|
Label="حداکثر زیرمجموعه مستقیم"
|
|
Variant="Variant.Outlined"
|
|
Min="2"
|
|
Max="10"
|
|
HelperText="حداکثر تعداد افراد زیر یک کاربر" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_networkConfig.MinimumPurchaseForActivation"
|
|
Label="حداقل خرید برای فعالسازی"
|
|
Variant="Variant.Outlined"
|
|
Adornment="Adornment.End"
|
|
AdornmentText="تومان"
|
|
Min="0"
|
|
HelperText="حداقل مبلغ خرید برای فعال شدن در شبکه" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_networkConfig.BalanceExpirationDays"
|
|
Label="مدت اعتبار موجودی"
|
|
Variant="Variant.Outlined"
|
|
Adornment="Adornment.End"
|
|
AdornmentText="روز"
|
|
Min="0"
|
|
HelperText="تعداد روز اعتبار موجودی (0 = نامحدود)" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudSwitch T="bool" @bind-Value="_networkConfig.BinaryTreeEnabled"
|
|
Color="Color.Primary"
|
|
Label="سیستم باینری فعال باشد" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudSwitch T="bool" @bind-Value="_networkConfig.AutoPlacementEnabled"
|
|
Color="Color.Primary"
|
|
Label="جایگذاری خودکار در درخت" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudSwitch T="bool" @bind-Value="_networkConfig.SpilloverEnabled"
|
|
Color="Color.Primary"
|
|
Label="Spillover فعال باشد"
|
|
HelperText="اعضای اضافی به پایین درخت منتقل شوند" />
|
|
</MudItem>
|
|
</MudGrid>
|
|
|
|
<MudDivider Class="my-4" />
|
|
|
|
<MudStack Row="true" Justify="Justify.FlexEnd" Spacing="2">
|
|
<MudButton Variant="Variant.Text"
|
|
Color="Color.Default"
|
|
OnClick="ResetNetworkConfig">
|
|
بازگشت به پیشفرض
|
|
</MudButton>
|
|
<MudButton Variant="Variant.Filled"
|
|
Color="Color.Primary"
|
|
OnClick="SaveNetworkConfig"
|
|
StartIcon="@Icons.Material.Filled.Save">
|
|
ذخیره تنظیمات
|
|
</MudButton>
|
|
</MudStack>
|
|
</MudCardContent>
|
|
</MudCard>
|
|
</MudTabPanel>
|
|
|
|
<!-- Club Settings -->
|
|
<MudTabPanel Text="تنظیمات باشگاه" Icon="@Icons.Material.Filled.CardMembership">
|
|
<MudCard Elevation="0">
|
|
<MudCardContent>
|
|
<MudText Typo="Typo.h6" Class="mb-4">تنظیمات عضویت باشگاه</MudText>
|
|
|
|
<MudGrid>
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_clubConfig.MonthlyFee"
|
|
Label="هزینه ماهانه عضویت"
|
|
Variant="Variant.Outlined"
|
|
Adornment="Adornment.End"
|
|
AdornmentText="تومان"
|
|
Min="0"
|
|
HelperText="هزینه اشتراک ماهانه باشگاه" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_clubConfig.GracePeriodDays"
|
|
Label="مهلت پرداخت"
|
|
Variant="Variant.Outlined"
|
|
Adornment="Adornment.End"
|
|
AdornmentText="روز"
|
|
Min="0"
|
|
HelperText="تعداد روز مهلت پس از انقضا" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_clubConfig.MembershipDurationMonths"
|
|
Label="مدت عضویت"
|
|
Variant="Variant.Outlined"
|
|
Adornment="Adornment.End"
|
|
AdornmentText="ماه"
|
|
Min="1"
|
|
HelperText="طول دوره عضویت به ماه" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_clubConfig.MinimumPurchaseForClub"
|
|
Label="حداقل خرید برای ورود"
|
|
Variant="Variant.Outlined"
|
|
Adornment="Adornment.End"
|
|
AdornmentText="تومان"
|
|
Min="0"
|
|
HelperText="حداقل خرید برای عضویت باشگاه" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudSwitch T="bool" @bind-Value="_clubConfig.AutoRenewalEnabled"
|
|
Color="Color.Primary"
|
|
Label="تمدید خودکار عضویت" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudSwitch T="bool" @bind-Value="_clubConfig.EmailNotificationsEnabled"
|
|
Color="Color.Primary"
|
|
Label="ارسال ایمیل یادآوری انقضا" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudSwitch T="bool" @bind-Value="_clubConfig.SmsNotificationsEnabled"
|
|
Color="Color.Primary"
|
|
Label="ارسال پیامک یادآوری انقضا" />
|
|
</MudItem>
|
|
</MudGrid>
|
|
|
|
<MudDivider Class="my-4" />
|
|
|
|
<MudStack Row="true" Justify="Justify.FlexEnd" Spacing="2">
|
|
<MudButton Variant="Variant.Text"
|
|
Color="Color.Default"
|
|
OnClick="ResetClubConfig">
|
|
بازگشت به پیشفرض
|
|
</MudButton>
|
|
<MudButton Variant="Variant.Filled"
|
|
Color="Color.Primary"
|
|
OnClick="SaveClubConfig"
|
|
StartIcon="@Icons.Material.Filled.Save">
|
|
ذخیره تنظیمات
|
|
</MudButton>
|
|
</MudStack>
|
|
</MudCardContent>
|
|
</MudCard>
|
|
</MudTabPanel>
|
|
|
|
<!-- System Settings -->
|
|
<MudTabPanel Text="تنظیمات عمومی" Icon="@Icons.Material.Filled.Settings">
|
|
<MudCard Elevation="0">
|
|
<MudCardContent>
|
|
<MudText Typo="Typo.h6" Class="mb-4">تنظیمات سیستم</MudText>
|
|
|
|
<MudGrid>
|
|
<MudItem xs="12" md="6">
|
|
<MudTextField @bind-Value="_systemConfig.SystemName"
|
|
Label="نام سیستم"
|
|
Variant="Variant.Outlined" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudTextField @bind-Value="_systemConfig.SupportEmail"
|
|
Label="ایمیل پشتیبانی"
|
|
Variant="Variant.Outlined"
|
|
InputType="InputType.Email" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudTextField @bind-Value="_systemConfig.SupportPhone"
|
|
Label="تلفن پشتیبانی"
|
|
Variant="Variant.Outlined" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_systemConfig.SessionTimeoutMinutes"
|
|
Label="مدت اعتبار نشست"
|
|
Variant="Variant.Outlined"
|
|
Adornment="Adornment.End"
|
|
AdornmentText="دقیقه"
|
|
Min="5"
|
|
Max="1440" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_systemConfig.MaxLoginAttempts"
|
|
Label="حداکثر تلاش ورود"
|
|
Variant="Variant.Outlined"
|
|
Min="1"
|
|
Max="10"
|
|
HelperText="قبل از قفل شدن حساب" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" md="6">
|
|
<MudNumericField @bind-Value="_systemConfig.LockoutDurationMinutes"
|
|
Label="مدت قفل حساب"
|
|
Variant="Variant.Outlined"
|
|
Adornment="Adornment.End"
|
|
AdornmentText="دقیقه"
|
|
Min="5" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudSwitch @bind-Value="_systemConfig.MaintenanceMode"
|
|
Color="Color.Warning"
|
|
Label="حالت تعمیر و نگهداری"
|
|
HelperText="غیرفعال کردن موقت سیستم برای بهروزرسانی" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudSwitch @bind-Value="_systemConfig.TwoFactorAuthEnabled"
|
|
Color="Color.Primary"
|
|
Label="احراز هویت دو مرحلهای فعال باشد" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudSwitch @bind-Value="_systemConfig.EmailVerificationRequired"
|
|
Color="Color.Primary"
|
|
Label="تایید ایمیل الزامی باشد" />
|
|
</MudItem>
|
|
</MudGrid>
|
|
|
|
<MudDivider Class="my-4" />
|
|
|
|
<MudStack Row="true" Justify="Justify.FlexEnd" Spacing="2">
|
|
<MudButton Variant="Variant.Text"
|
|
Color="Color.Default"
|
|
OnClick="ResetSystemConfig">
|
|
بازگشت به پیشفرض
|
|
</MudButton>
|
|
<MudButton Variant="Variant.Filled"
|
|
Color="Color.Primary"
|
|
OnClick="SaveSystemConfig"
|
|
StartIcon="@Icons.Material.Filled.Save">
|
|
ذخیره تنظیمات
|
|
</MudButton>
|
|
</MudStack>
|
|
</MudCardContent>
|
|
</MudCard>
|
|
|
|
<MudCard Class="mt-4" Elevation="0">
|
|
<MudCardContent>
|
|
<MudText Typo="Typo.h6" Class="mb-2">تنظیمات مالیات بر ارزش افزوده (VAT)</MudText>
|
|
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-2">
|
|
درصد پیشفرض VAT که روی سفارشها اعمال میشود.
|
|
</MudText>
|
|
|
|
<MudGrid>
|
|
<MudItem xs="12" md="4">
|
|
<MudNumericField @bind-Value="_vatConfig.DefaultVatPercentage"
|
|
Label="درصد VAT پیشفرض"
|
|
Variant="Variant.Outlined"
|
|
Adornment="Adornment.End"
|
|
AdornmentText="%"
|
|
Min="0"
|
|
Max="100" />
|
|
</MudItem>
|
|
</MudGrid>
|
|
|
|
<MudDivider Class="my-4" />
|
|
|
|
<MudStack Row="true" Justify="Justify.FlexEnd" Spacing="2">
|
|
<MudButton Variant="Variant.Filled"
|
|
Color="Color.Primary"
|
|
OnClick="SaveVatConfig"
|
|
StartIcon="@Icons.Material.Filled.Save">
|
|
ذخیره تنظیمات VAT
|
|
</MudButton>
|
|
</MudStack>
|
|
</MudCardContent>
|
|
</MudCard>
|
|
</MudTabPanel>
|
|
</MudTabs>
|
|
</div>
|
|
|
|
@code {
|
|
[Inject] public ConfigurationContract.ConfigurationContractClient ConfigurationClient { get; set; }
|
|
|
|
private CommissionConfig _commissionConfig = new();
|
|
private NetworkConfig _networkConfig = new();
|
|
private ClubConfig _clubConfig = new();
|
|
private SystemConfig _systemConfig = new();
|
|
private VatConfig _vatConfig = new();
|
|
|
|
private Dictionary<string, string> _configurations = new();
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await LoadConfigurations();
|
|
}
|
|
|
|
private async Task LoadConfigurations()
|
|
{
|
|
try
|
|
{
|
|
var request = new GetAllConfigurationsRequest
|
|
{
|
|
PaginationState = new PaginationState
|
|
{
|
|
PageNumber = 1,
|
|
PageSize = 100
|
|
}
|
|
};
|
|
|
|
var response = await ConfigurationClient.GetAllConfigurationsAsync(request);
|
|
|
|
// Build dictionary from response
|
|
_configurations = response.Models.ToDictionary(m => m.Key, m => m.Value);
|
|
|
|
// Map to UI models
|
|
_commissionConfig = new CommissionConfig
|
|
{
|
|
MinBalanceForPayout = GetDecimalConfig("Commission.MinimumPayoutAmount", 100000),
|
|
MaxWithdrawalAmount = GetDecimalConfig("Commission.MaxWithdrawalAmount", 50000000),
|
|
CommissionPercentage = GetDoubleConfig("Commission.WeeklyPoolContributionPercent", 10),
|
|
WeeklyPoolPercentage = GetDoubleConfig("Commission.PoolPercentage", 40),
|
|
CalculationDay = GetStringConfig("Commission.CalculationDay", "Saturday"),
|
|
CalculationTime = TimeSpan.Parse(GetStringConfig("Commission.CalculationTime", "02:00:00")),
|
|
AutoCalculationEnabled = GetBoolConfig("Commission.AutoCalculationEnabled", true),
|
|
AutoPayoutEnabled = GetBoolConfig("Commission.AutoPayoutEnabled", false)
|
|
};
|
|
|
|
_networkConfig = new NetworkConfig
|
|
{
|
|
MaxTreeDepth = GetIntConfig("Network.MaxDepth", 10),
|
|
MaxDirectChildren = GetIntConfig("Network.MaxDirectChildren", 2),
|
|
MinimumPurchaseForActivation = GetDecimalConfig("Network.MinimumPurchase", 500000),
|
|
BalanceExpirationDays = GetIntConfig("Network.BalanceExpirationDays", 365),
|
|
BinaryTreeEnabled = GetBoolConfig("Network.BinaryTreeEnabled", true),
|
|
AutoPlacementEnabled = GetBoolConfig("Network.AllowOrphanNodes", false),
|
|
SpilloverEnabled = GetBoolConfig("Network.SpilloverEnabled", true)
|
|
};
|
|
|
|
_clubConfig = new ClubConfig
|
|
{
|
|
MonthlyFee = GetDecimalConfig("Club.MonthlyFee", 1000000),
|
|
GracePeriodDays = GetIntConfig("Club.GracePeriodDays", 7),
|
|
MembershipDurationMonths = GetIntConfig("Club.DefaultMembershipDurationMonths", 12),
|
|
MinimumPurchaseForClub = GetDecimalConfig("Club.MinimumActivationAmount", 5000000),
|
|
AutoRenewalEnabled = GetBoolConfig("Club.AutoRenewalEnabled", false),
|
|
EmailNotificationsEnabled = GetBoolConfig("Club.EmailNotifications", true),
|
|
SmsNotificationsEnabled = GetBoolConfig("Club.SmsNotifications", true)
|
|
};
|
|
|
|
_systemConfig = new SystemConfig
|
|
{
|
|
SystemName = GetStringConfig("System.Name", "FourSat Network"),
|
|
SupportEmail = GetStringConfig("System.SupportEmail", "support@foursat.com"),
|
|
SupportPhone = GetStringConfig("System.SupportPhone", "021-12345678"),
|
|
SessionTimeoutMinutes = GetIntConfig("System.SessionTimeout", 60),
|
|
MaxLoginAttempts = GetIntConfig("System.MaxLoginAttempts", 5),
|
|
LockoutDurationMinutes = GetIntConfig("System.LockoutDuration", 30),
|
|
MaintenanceMode = GetBoolConfig("System.MaintenanceMode", false),
|
|
TwoFactorAuthEnabled = GetBoolConfig("System.TwoFactorAuth", true),
|
|
EmailVerificationRequired = GetBoolConfig("System.EmailVerification", true)
|
|
};
|
|
|
|
_vatConfig = new VatConfig
|
|
{
|
|
DefaultVatPercentage = GetIntConfig("DefaultVatPercentage", 10)
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Snackbar.Add($"خطا در بارگذاری تنظیمات: {ex.Message}", Severity.Error);
|
|
}
|
|
}
|
|
|
|
private async Task SaveCommissionConfig()
|
|
{
|
|
try
|
|
{
|
|
await SaveConfig("Commission.MinimumPayoutAmount", _commissionConfig.MinBalanceForPayout.ToString(), 3);
|
|
await SaveConfig("Commission.MaxWithdrawalAmount", _commissionConfig.MaxWithdrawalAmount.ToString(), 3);
|
|
await SaveConfig("Commission.WeeklyPoolContributionPercent", _commissionConfig.CommissionPercentage.ToString(), 3);
|
|
await SaveConfig("Commission.PoolPercentage", _commissionConfig.WeeklyPoolPercentage.ToString(), 3);
|
|
await SaveConfig("Commission.CalculationDay", _commissionConfig.CalculationDay, 3);
|
|
await SaveConfig("Commission.CalculationTime", _commissionConfig.CalculationTime?.ToString(@"hh\:mm\:ss") ?? "02:00:00", 3);
|
|
await SaveConfig("Commission.AutoCalculationEnabled", _commissionConfig.AutoCalculationEnabled.ToString(), 3);
|
|
await SaveConfig("Commission.AutoPayoutEnabled", _commissionConfig.AutoPayoutEnabled.ToString(), 3);
|
|
|
|
Snackbar.Add("تنظیمات کمیسیون با موفقیت ذخیره شد", Severity.Success);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Snackbar.Add($"خطا در ذخیره: {ex.Message}", Severity.Error);
|
|
}
|
|
}
|
|
|
|
private async Task SaveNetworkConfig()
|
|
{
|
|
try
|
|
{
|
|
await SaveConfig("Network.MaxDepth", _networkConfig.MaxTreeDepth.ToString(), 1);
|
|
await SaveConfig("Network.MaxDirectChildren", _networkConfig.MaxDirectChildren.ToString(), 1);
|
|
await SaveConfig("Network.MinimumPurchase", _networkConfig.MinimumPurchaseForActivation.ToString(), 1);
|
|
await SaveConfig("Network.BalanceExpirationDays", _networkConfig.BalanceExpirationDays.ToString(), 1);
|
|
await SaveConfig("Network.BinaryTreeEnabled", _networkConfig.BinaryTreeEnabled.ToString(), 1);
|
|
await SaveConfig("Network.AllowOrphanNodes", _networkConfig.AutoPlacementEnabled.ToString(), 1);
|
|
await SaveConfig("Network.SpilloverEnabled", _networkConfig.SpilloverEnabled.ToString(), 1);
|
|
|
|
Snackbar.Add("تنظیمات شبکه با موفقیت ذخیره شد", Severity.Success);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Snackbar.Add($"خطا در ذخیره: {ex.Message}", Severity.Error);
|
|
}
|
|
}
|
|
|
|
private async Task SaveClubConfig()
|
|
{
|
|
try
|
|
{
|
|
await SaveConfig("Club.MonthlyFee", _clubConfig.MonthlyFee.ToString(), 2);
|
|
await SaveConfig("Club.GracePeriodDays", _clubConfig.GracePeriodDays.ToString(), 2);
|
|
await SaveConfig("Club.DefaultMembershipDurationMonths", _clubConfig.MembershipDurationMonths.ToString(), 2);
|
|
await SaveConfig("Club.MinimumActivationAmount", _clubConfig.MinimumPurchaseForClub.ToString(), 2);
|
|
await SaveConfig("Club.AutoRenewalEnabled", _clubConfig.AutoRenewalEnabled.ToString(), 2);
|
|
await SaveConfig("Club.EmailNotifications", _clubConfig.EmailNotificationsEnabled.ToString(), 2);
|
|
await SaveConfig("Club.SmsNotifications", _clubConfig.SmsNotificationsEnabled.ToString(), 2);
|
|
|
|
Snackbar.Add("تنظیمات باشگاه با موفقیت ذخیره شد", Severity.Success);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Snackbar.Add($"خطا در ذخیره: {ex.Message}", Severity.Error);
|
|
}
|
|
}
|
|
|
|
private async Task SaveSystemConfig()
|
|
{
|
|
try
|
|
{
|
|
await SaveConfig("System.Name", _systemConfig.SystemName, 0);
|
|
await SaveConfig("System.SupportEmail", _systemConfig.SupportEmail, 0);
|
|
await SaveConfig("System.SupportPhone", _systemConfig.SupportPhone, 0);
|
|
await SaveConfig("System.SessionTimeout", _systemConfig.SessionTimeoutMinutes.ToString(), 0);
|
|
await SaveConfig("System.MaxLoginAttempts", _systemConfig.MaxLoginAttempts.ToString(), 0);
|
|
await SaveConfig("System.LockoutDuration", _systemConfig.LockoutDurationMinutes.ToString(), 0);
|
|
await SaveConfig("System.MaintenanceMode", _systemConfig.MaintenanceMode.ToString(), 0);
|
|
await SaveConfig("System.TwoFactorAuth", _systemConfig.TwoFactorAuthEnabled.ToString(), 0);
|
|
await SaveConfig("System.EmailVerification", _systemConfig.EmailVerificationRequired.ToString(), 0);
|
|
|
|
Snackbar.Add("تنظیمات سیستم با موفقیت ذخیره شد", Severity.Success);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Snackbar.Add($"خطا در ذخیره: {ex.Message}", Severity.Error);
|
|
}
|
|
}
|
|
|
|
private async Task SaveVatConfig()
|
|
{
|
|
try
|
|
{
|
|
await SaveConfig("DefaultVatPercentage", _vatConfig.DefaultVatPercentage.ToString(), 0);
|
|
Snackbar.Add("تنظیمات VAT با موفقیت ذخیره شد", Severity.Success);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Snackbar.Add($"خطا در ذخیره تنظیمات VAT: {ex.Message}", Severity.Error);
|
|
}
|
|
}
|
|
|
|
private async Task SaveConfig(string key, string value, int scope)
|
|
{
|
|
var request = new CreateOrUpdateConfigurationRequest
|
|
{
|
|
Key = key,
|
|
Value = value,
|
|
Scope = scope
|
|
};
|
|
|
|
await ConfigurationClient.CreateOrUpdateConfigurationAsync(request);
|
|
}
|
|
|
|
private string GetStringConfig(string key, string defaultValue)
|
|
{
|
|
return _configurations.TryGetValue(key, out var value) ? value : defaultValue;
|
|
}
|
|
|
|
private int GetIntConfig(string key, int defaultValue)
|
|
{
|
|
return _configurations.TryGetValue(key, out var value) && int.TryParse(value, out var result) ? result : defaultValue;
|
|
}
|
|
|
|
private decimal GetDecimalConfig(string key, decimal defaultValue)
|
|
{
|
|
return _configurations.TryGetValue(key, out var value) && decimal.TryParse(value, out var result) ? result : defaultValue;
|
|
}
|
|
|
|
private double GetDoubleConfig(string key, double defaultValue)
|
|
{
|
|
return _configurations.TryGetValue(key, out var value) && double.TryParse(value, out var result) ? result : defaultValue;
|
|
}
|
|
|
|
private bool GetBoolConfig(string key, bool defaultValue)
|
|
{
|
|
return _configurations.TryGetValue(key, out var value) && bool.TryParse(value, out var result) ? result : defaultValue;
|
|
}
|
|
|
|
private void ResetCommissionConfig() => _commissionConfig = new CommissionConfig();
|
|
private void ResetNetworkConfig() => _networkConfig = new NetworkConfig();
|
|
private void ResetClubConfig() => _clubConfig = new ClubConfig();
|
|
private void ResetSystemConfig() => _systemConfig = new SystemConfig();
|
|
|
|
private class CommissionConfig
|
|
{
|
|
public decimal MinBalanceForPayout { get; set; }
|
|
public decimal MaxWithdrawalAmount { get; set; }
|
|
public double CommissionPercentage { get; set; }
|
|
public double WeeklyPoolPercentage { get; set; }
|
|
public string CalculationDay { get; set; } = "Saturday";
|
|
public TimeSpan? CalculationTime { get; set; }
|
|
public bool AutoCalculationEnabled { get; set; }
|
|
public bool AutoPayoutEnabled { get; set; }
|
|
}
|
|
|
|
private class NetworkConfig
|
|
{
|
|
public int MaxTreeDepth { get; set; }
|
|
public int MaxDirectChildren { get; set; }
|
|
public decimal MinimumPurchaseForActivation { get; set; }
|
|
public int BalanceExpirationDays { get; set; }
|
|
public bool BinaryTreeEnabled { get; set; }
|
|
public bool AutoPlacementEnabled { get; set; }
|
|
public bool SpilloverEnabled { get; set; }
|
|
}
|
|
|
|
private class ClubConfig
|
|
{
|
|
public decimal MonthlyFee { get; set; }
|
|
public int GracePeriodDays { get; set; }
|
|
public int MembershipDurationMonths { get; set; }
|
|
public decimal MinimumPurchaseForClub { get; set; }
|
|
public bool AutoRenewalEnabled { get; set; }
|
|
public bool EmailNotificationsEnabled { get; set; }
|
|
public bool SmsNotificationsEnabled { get; set; }
|
|
}
|
|
|
|
private class SystemConfig
|
|
{
|
|
public string SystemName { get; set; } = "";
|
|
public string SupportEmail { get; set; } = "";
|
|
public string SupportPhone { get; set; } = "";
|
|
public int SessionTimeoutMinutes { get; set; }
|
|
public int MaxLoginAttempts { get; set; }
|
|
public int LockoutDurationMinutes { get; set; }
|
|
public bool MaintenanceMode { get; set; }
|
|
public bool TwoFactorAuthEnabled { get; set; }
|
|
public bool EmailVerificationRequired { get; set; }
|
|
}
|
|
|
|
private class VatConfig
|
|
{
|
|
public int DefaultVatPercentage { get; set; }
|
|
}
|
|
}
|