feat: Enhance network membership and withdrawal processing with user tracking and logging
This commit is contained in:
@@ -47,104 +47,95 @@ public class ApplicationDbContextInitialiser
|
||||
}
|
||||
public async Task TrySeedAsync()
|
||||
{
|
||||
// Seed default System Configurations for Network-Club-Commission System
|
||||
if (!_context.SystemConfigurations.Any())
|
||||
// Seed / upsert default System Configurations for Network-Club-Commission System
|
||||
var desiredConfigurations = new List<SystemConfiguration>
|
||||
{
|
||||
var defaultConfigurations = new List<SystemConfiguration>
|
||||
// Network Configuration
|
||||
new SystemConfiguration
|
||||
{
|
||||
// Network Configuration
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "Network.MaxDepth",
|
||||
Value = "10",
|
||||
Description = "حداکثر عمق شبکه باینری",
|
||||
Scope = ConfigurationScope.Network,
|
||||
IsActive = true
|
||||
},
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "Network.AllowOrphanNodes",
|
||||
Value = "false",
|
||||
Description = "اجازه حذف والدین که فرزند دارند",
|
||||
Scope = ConfigurationScope.Network,
|
||||
IsActive = true
|
||||
},
|
||||
|
||||
// Club Configuration
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "Club.DefaultMembershipDurationMonths",
|
||||
Value = "12",
|
||||
Description = "مدت زمان پیشفرض عضویت باشگاه (ماه)",
|
||||
Scope = ConfigurationScope.Club,
|
||||
IsActive = true
|
||||
},
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "Club.MinimumActivationAmount",
|
||||
Value = "1000000",
|
||||
Description = "حداقل مبلغ برای فعالسازی عضویت (ریال)",
|
||||
Scope = ConfigurationScope.Club,
|
||||
IsActive = true
|
||||
},
|
||||
|
||||
// Commission Configuration
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "Commission.WeeklyPoolContributionPercent",
|
||||
Value = "10",
|
||||
Description = "درصد مشارکت در استخر هفتگی از تعادل کل",
|
||||
Scope = ConfigurationScope.Commission,
|
||||
IsActive = true
|
||||
},
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "Commission.MinimumPayoutAmount",
|
||||
Value = "100000",
|
||||
Description = "حداقل مبلغ برای پرداخت کمیسیون (ریال)",
|
||||
Scope = ConfigurationScope.Commission,
|
||||
IsActive = true
|
||||
},
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "Commission.CashWithdrawalEnabled",
|
||||
Value = "true",
|
||||
Description = "امکان برداشت نقدی فعال باشد",
|
||||
Scope = ConfigurationScope.Commission,
|
||||
IsActive = true
|
||||
},
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "Commission.DiamondWithdrawalEnabled",
|
||||
Value = "true",
|
||||
Description = "امکان تبدیل به الماس فعال باشد",
|
||||
Scope = ConfigurationScope.Commission,
|
||||
IsActive = true
|
||||
},
|
||||
|
||||
// System Configuration
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "System.MaintenanceMode",
|
||||
Value = "false",
|
||||
Description = "حالت تعمیر و نگهداری سیستم",
|
||||
Scope = ConfigurationScope.System,
|
||||
IsActive = true
|
||||
},
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "System.EnableAuditLog",
|
||||
Value = "true",
|
||||
Description = "فعالسازی لاگ تغییرات",
|
||||
Scope = ConfigurationScope.System,
|
||||
IsActive = true
|
||||
}
|
||||
};
|
||||
Key = "Network.MaxNetworkDepth",
|
||||
Value = "15",
|
||||
Description = "حداکثر عمق شبکه باینری",
|
||||
Scope = ConfigurationScope.Network,
|
||||
IsActive = true
|
||||
},
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "Network.MaxChildrenPerLeg",
|
||||
Value = "1",
|
||||
Description = "حداکثر تعداد فرزند مستقیم در هر پا",
|
||||
Scope = ConfigurationScope.Network,
|
||||
IsActive = true
|
||||
},
|
||||
|
||||
await _context.SystemConfigurations.AddRangeAsync(defaultConfigurations);
|
||||
// Commission Configuration
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "Commission.MaxWeeklyBalancesPerUser",
|
||||
Value = "300",
|
||||
Description = "سقف امتیاز/تعادل هفتگی برای هر کاربر",
|
||||
Scope = ConfigurationScope.Commission,
|
||||
IsActive = true
|
||||
},
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "Commission.MinWithdrawalAmount",
|
||||
Value = "1000000",
|
||||
Description = "حداقل مبلغ برداشت (ریال)",
|
||||
Scope = ConfigurationScope.Commission,
|
||||
IsActive = true
|
||||
},
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "Commission.DefaultInitialContribution",
|
||||
Value = "25000000",
|
||||
Description = "مبلغ پیشفرض مشارکت/هزینه فعالسازی",
|
||||
Scope = ConfigurationScope.Commission,
|
||||
IsActive = true
|
||||
},
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "Commission.WeeklyPoolContributionPercent",
|
||||
Value = "20",
|
||||
Description = "درصد مشارکت در استخر هفتگی از کل فعالسازیهای جدید شبکه (20%)",
|
||||
Scope = ConfigurationScope.Commission,
|
||||
IsActive = true
|
||||
},
|
||||
|
||||
// Club Configuration
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "Club.ActivationFee",
|
||||
Value = "25000000",
|
||||
Description = "هزینه فعالسازی عضویت باشگاه (ریال)",
|
||||
Scope = ConfigurationScope.Club,
|
||||
IsActive = true
|
||||
},
|
||||
|
||||
// System Configuration
|
||||
new SystemConfiguration
|
||||
{
|
||||
Key = "System.EnableAuditLog",
|
||||
Value = "true",
|
||||
Description = "فعالسازی لاگ تغییرات",
|
||||
Scope = ConfigurationScope.System,
|
||||
IsActive = true
|
||||
}
|
||||
};
|
||||
|
||||
var existingKeys = _context.SystemConfigurations
|
||||
.Select(c => c.Key)
|
||||
.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var newConfigs = desiredConfigurations
|
||||
.Where(c => !existingKeys.Contains(c.Key))
|
||||
.ToList();
|
||||
|
||||
if (newConfigs.Any())
|
||||
{
|
||||
await _context.SystemConfigurations.AddRangeAsync(newConfigs);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
_logger.LogInformation("Seeded {Count} default system configurations", defaultConfigurations.Count);
|
||||
_logger.LogInformation("Seeded {Count} default system configurations", newConfigs.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user