feat: Complete Phase 8 - Migration & Seed Data
Database Migration: - Applied migration 20251129002222_AddNetworkClubSystemV2 - Created 11 new tables: * SystemConfigurations * SystemConfigurationHistories * ClubMemberships * ClubMembershipHistories * ClubFeatures * UserClubFeatures * NetworkWeeklyBalances * WeeklyCommissionPools * UserCommissionPayouts * CommissionPayoutHistories * NetworkMembershipHistories - Updated existing tables: * Users: Added NetworkParentId, LegPosition * UserWallets: Added DiscountBalance * Products: Added IsClubExclusive, ClubDiscountPercent Seed Data: - Added 10 default SystemConfigurations: * Network settings (MaxDepth, AllowOrphanNodes) * Club settings (DefaultDuration, MinimumActivation) * Commission settings (PoolPercent, MinimumPayout, WithdrawalMethods) * System settings (MaintenanceMode, AuditLog) Migration Status: ✅ Applied successfully Database Schema: ✅ Verified Build Status: ✅ Success (0 errors)
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using CMSMicroservice.Domain.Entities.Configuration;
|
||||||
|
using CMSMicroservice.Domain.Enums;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace CMSMicroservice.Infrastructure.Persistence;
|
namespace CMSMicroservice.Infrastructure.Persistence;
|
||||||
|
|
||||||
@@ -44,6 +47,104 @@ public class ApplicationDbContextInitialiser
|
|||||||
}
|
}
|
||||||
public async Task TrySeedAsync()
|
public async Task TrySeedAsync()
|
||||||
{
|
{
|
||||||
|
// Seed default System Configurations for Network-Club-Commission System
|
||||||
|
if (!_context.SystemConfigurations.Any())
|
||||||
|
{
|
||||||
|
var defaultConfigurations = new List<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
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
await _context.SystemConfigurations.AddRangeAsync(defaultConfigurations);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
_logger.LogInformation("Seeded {Count} default system configurations", defaultConfigurations.Count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user