diff --git a/src/CMSMicroservice.Infrastructure/GlobalUsings.cs b/src/CMSMicroservice.Infrastructure/GlobalUsings.cs index 95a993b..56f4c82 100644 --- a/src/CMSMicroservice.Infrastructure/GlobalUsings.cs +++ b/src/CMSMicroservice.Infrastructure/GlobalUsings.cs @@ -1,4 +1,13 @@ +global using System; +global using System.Linq; global using System.Threading; global using System.Threading.Tasks; -global using System; -global using System.Linq; \ No newline at end of file + +// Domain Usings +global using CMSMicroservice.Domain.Entities; +global using CMSMicroservice.Domain.Entities.Club; +global using CMSMicroservice.Domain.Entities.Network; +global using CMSMicroservice.Domain.Entities.Commission; +global using CMSMicroservice.Domain.Entities.Configuration; +global using CMSMicroservice.Domain.Entities.History; +global using CMSMicroservice.Domain.Enums; \ No newline at end of file diff --git a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs index bb9c431..10ea581 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs @@ -60,4 +60,25 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext public DbSet UserOrders => Set(); public DbSet UserWallets => Set(); public DbSet UserWalletChangeLogs => Set(); + + // ============= Network Club System DbSets ============= + + // Configuration + public DbSet SystemConfigurations => Set(); + public DbSet SystemConfigurationHistories => Set(); + + // Club Management + public DbSet ClubMemberships => Set(); + public DbSet ClubFeatures => Set(); + public DbSet UserClubFeatures => Set(); + public DbSet ClubMembershipHistories => Set(); + + // Network + public DbSet NetworkWeeklyBalances => Set(); + public DbSet NetworkMembershipHistories => Set(); + + // Commission + public DbSet WeeklyCommissionPools => Set(); + public DbSet UserCommissionPayouts => Set(); + public DbSet CommissionPayoutHistories => Set(); } diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ClubFeatureConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ClubFeatureConfiguration.cs new file mode 100644 index 0000000..eb89490 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ClubFeatureConfiguration.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +/// +/// فیچرهای باشگاه مشتریان +/// +public class ClubFeatureConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasQueryFilter(p => !p.IsDeleted); + builder.Ignore(entity => entity.DomainEvents); + + builder.HasKey(entity => entity.Id); + builder.Property(entity => entity.Id).UseIdentityColumn(); + + builder.Property(entity => entity.Title).IsRequired().HasMaxLength(200); + builder.Property(entity => entity.Description).IsRequired(false).HasMaxLength(1000); + builder.Property(entity => entity.IsActive).IsRequired(); + builder.Property(entity => entity.RequiredPoints).IsRequired(false); + builder.Property(entity => entity.SortOrder).IsRequired(); + + // Index برای IsActive و SortOrder + builder.HasIndex(e => new { e.IsActive, e.SortOrder }) + .HasDatabaseName("IX_ClubFeature_IsActive_SortOrder"); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ClubMembershipConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ClubMembershipConfiguration.cs new file mode 100644 index 0000000..ebd6605 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ClubMembershipConfiguration.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +/// +/// عضویت باشگاه مشتریان +/// +public class ClubMembershipConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasQueryFilter(p => !p.IsDeleted); + builder.Ignore(entity => entity.DomainEvents); + + builder.HasKey(entity => entity.Id); + builder.Property(entity => entity.Id).UseIdentityColumn(); + + builder.Property(entity => entity.UserId).IsRequired(); + builder.Property(entity => entity.IsActive).IsRequired(); + builder.Property(entity => entity.ActivatedAt).IsRequired(false); + builder.Property(entity => entity.InitialContribution).IsRequired(); + builder.Property(entity => entity.TotalEarned).IsRequired(); + + // رابطه یک‌به‌یک با User + builder.HasOne(entity => entity.User) + .WithOne(u => u.ClubMembership) + .HasForeignKey(entity => entity.UserId) + .OnDelete(DeleteBehavior.Restrict); + + // Index برای UserId (یونیک برای یک‌به‌یک) + builder.HasIndex(e => e.UserId) + .IsUnique() + .HasDatabaseName("IX_ClubMembership_UserId"); + + // Index برای IsActive + builder.HasIndex(e => e.IsActive) + .HasDatabaseName("IX_ClubMembership_IsActive"); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ClubMembershipHistoryConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ClubMembershipHistoryConfiguration.cs new file mode 100644 index 0000000..23aa2f7 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ClubMembershipHistoryConfiguration.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +/// +/// تاریخچه تغییرات عضویت باشگاه +/// +public class ClubMembershipHistoryConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasQueryFilter(p => !p.IsDeleted); + builder.Ignore(entity => entity.DomainEvents); + + builder.HasKey(entity => entity.Id); + builder.Property(entity => entity.Id).UseIdentityColumn(); + + builder.Property(entity => entity.ClubMembershipId).IsRequired(); + builder.Property(entity => entity.UserId).IsRequired(); + builder.Property(entity => entity.OldIsActive).IsRequired(); + builder.Property(entity => entity.NewIsActive).IsRequired(); + builder.Property(entity => entity.OldInitialContribution).IsRequired(false); + builder.Property(entity => entity.NewInitialContribution).IsRequired(false); + builder.Property(entity => entity.Action).IsRequired(); + builder.Property(entity => entity.Reason).IsRequired(false).HasMaxLength(500); + builder.Property(entity => entity.PerformedBy).IsRequired(false).HasMaxLength(100); + + // رابطه با ClubMembership + builder.HasOne(entity => entity.ClubMembership) + .WithMany(cm => cm.ClubMembershipHistories) + .HasForeignKey(entity => entity.ClubMembershipId) + .OnDelete(DeleteBehavior.Restrict); + + // Index برای UserId و Created (برای تاریخچه) + builder.HasIndex(e => new { e.UserId, e.Created }) + .HasDatabaseName("IX_ClubMembershipHistory_UserId_Created"); + + // Index برای ClubMembershipId + builder.HasIndex(e => e.ClubMembershipId) + .HasDatabaseName("IX_ClubMembershipHistory_ClubMembershipId"); + + // Index برای Action + builder.HasIndex(e => e.Action) + .HasDatabaseName("IX_ClubMembershipHistory_Action"); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/CommissionPayoutHistoryConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/CommissionPayoutHistoryConfiguration.cs new file mode 100644 index 0000000..f72bb1f --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/CommissionPayoutHistoryConfiguration.cs @@ -0,0 +1,52 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +/// +/// تاریخچه تغییرات پرداخت کمیسیون +/// +public class CommissionPayoutHistoryConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasQueryFilter(p => !p.IsDeleted); + builder.Ignore(entity => entity.DomainEvents); + + builder.HasKey(entity => entity.Id); + builder.Property(entity => entity.Id).UseIdentityColumn(); + + builder.Property(entity => entity.UserCommissionPayoutId).IsRequired(); + builder.Property(entity => entity.UserId).IsRequired(); + builder.Property(entity => entity.WeekNumber).IsRequired().HasMaxLength(20); + builder.Property(entity => entity.AmountBefore).IsRequired(); + builder.Property(entity => entity.AmountAfter).IsRequired(); + builder.Property(entity => entity.OldStatus).IsRequired(); + builder.Property(entity => entity.NewStatus).IsRequired(); + builder.Property(entity => entity.Action).IsRequired(); + builder.Property(entity => entity.PerformedBy).IsRequired(false).HasMaxLength(100); + builder.Property(entity => entity.Reason).IsRequired(false).HasMaxLength(500); + + // رابطه با UserCommissionPayout + builder.HasOne(entity => entity.UserCommissionPayout) + .WithMany(ucp => ucp.CommissionPayoutHistories) + .HasForeignKey(entity => entity.UserCommissionPayoutId) + .OnDelete(DeleteBehavior.Restrict); + + // Index برای UserId و Created + builder.HasIndex(e => new { e.UserId, e.Created }) + .HasDatabaseName("IX_CommissionPayoutHistory_UserId_Created"); + + // Index برای UserCommissionPayoutId + builder.HasIndex(e => e.UserCommissionPayoutId) + .HasDatabaseName("IX_CommissionPayoutHistory_PayoutId"); + + // Index برای WeekNumber + builder.HasIndex(e => e.WeekNumber) + .HasDatabaseName("IX_CommissionPayoutHistory_WeekNumber"); + + // Index برای Action + builder.HasIndex(e => e.Action) + .HasDatabaseName("IX_CommissionPayoutHistory_Action"); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/NetworkMembershipHistoryConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/NetworkMembershipHistoryConfiguration.cs new file mode 100644 index 0000000..7dae415 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/NetworkMembershipHistoryConfiguration.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +/// +/// تاریخچه جابجایی در شبکه باینری +/// +public class NetworkMembershipHistoryConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasQueryFilter(p => !p.IsDeleted); + builder.Ignore(entity => entity.DomainEvents); + + builder.HasKey(entity => entity.Id); + builder.Property(entity => entity.Id).UseIdentityColumn(); + + builder.Property(entity => entity.UserId).IsRequired(); + builder.Property(entity => entity.OldParentId).IsRequired(false); + builder.Property(entity => entity.NewParentId).IsRequired(false); + builder.Property(entity => entity.OldLegPosition).IsRequired(false); + builder.Property(entity => entity.NewLegPosition).IsRequired(false); + builder.Property(entity => entity.Action).IsRequired(); + builder.Property(entity => entity.Reason).IsRequired(false).HasMaxLength(500); + builder.Property(entity => entity.PerformedBy).IsRequired(false).HasMaxLength(100); + + // Index برای UserId و Created + builder.HasIndex(e => new { e.UserId, e.Created }) + .HasDatabaseName("IX_NetworkMembershipHistory_UserId_Created"); + + // Index برای Action + builder.HasIndex(e => e.Action) + .HasDatabaseName("IX_NetworkMembershipHistory_Action"); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/NetworkWeeklyBalanceConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/NetworkWeeklyBalanceConfiguration.cs new file mode 100644 index 0000000..66301a5 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/NetworkWeeklyBalanceConfiguration.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +/// +/// تعادل‌های هفتگی شبکه باینری +/// +public class NetworkWeeklyBalanceConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasQueryFilter(p => !p.IsDeleted); + builder.Ignore(entity => entity.DomainEvents); + + builder.HasKey(entity => entity.Id); + builder.Property(entity => entity.Id).UseIdentityColumn(); + + builder.Property(entity => entity.UserId).IsRequired(); + builder.Property(entity => entity.WeekNumber).IsRequired().HasMaxLength(20); + builder.Property(entity => entity.LeftLegBalances).IsRequired(); + builder.Property(entity => entity.RightLegBalances).IsRequired(); + builder.Property(entity => entity.TotalBalances).IsRequired(); + builder.Property(entity => entity.WeeklyPoolContribution).IsRequired(); + builder.Property(entity => entity.CalculatedAt).IsRequired(false); + builder.Property(entity => entity.IsExpired).IsRequired(); + + // رابطه با User + builder.HasOne(entity => entity.User) + .WithMany(u => u.NetworkWeeklyBalances) + .HasForeignKey(entity => entity.UserId) + .OnDelete(DeleteBehavior.Restrict); + + // Composite Index برای UserId و WeekNumber + builder.HasIndex(e => new { e.UserId, e.WeekNumber }) + .IsUnique() + .HasDatabaseName("IX_NetworkWeeklyBalance_UserId_WeekNumber"); + + // Index برای WeekNumber + builder.HasIndex(e => e.WeekNumber) + .HasDatabaseName("IX_NetworkWeeklyBalance_WeekNumber"); + + // Index برای IsExpired + builder.HasIndex(e => e.IsExpired) + .HasDatabaseName("IX_NetworkWeeklyBalance_IsExpired"); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductsConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductsConfiguration.cs index 63f98db..c15cbde 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductsConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ProductsConfiguration.cs @@ -23,6 +23,14 @@ public class ProductsConfiguration : IEntityTypeConfiguration builder.Property(entity => entity.SaleCount).IsRequired(true); builder.Property(entity => entity.ViewCount).IsRequired(true); builder.Property(entity => entity.RemainingCount).IsRequired(true); + + // ============= Club Shop Fields ============= + builder.Property(entity => entity.IsClubExclusive).IsRequired(true); + builder.Property(entity => entity.ClubDiscountPercent).IsRequired(true); + + // Index برای IsClubExclusive + builder.HasIndex(e => e.IsClubExclusive) + .HasDatabaseName("IX_Products_IsClubExclusive"); } } diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/SystemConfigurationConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/SystemConfigurationConfiguration.cs new file mode 100644 index 0000000..8d8f111 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/SystemConfigurationConfiguration.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +/// +/// تنظیمات پویای سیستم +/// +public class SystemConfigurationConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasQueryFilter(p => !p.IsDeleted); + builder.Ignore(entity => entity.DomainEvents); + + builder.HasKey(entity => entity.Id); + builder.Property(entity => entity.Id).UseIdentityColumn(); + + builder.Property(entity => entity.Scope).IsRequired(); + builder.Property(entity => entity.Key).IsRequired().HasMaxLength(200); + builder.Property(entity => entity.Value).IsRequired().HasMaxLength(1000); + builder.Property(entity => entity.DataType).IsRequired(false).HasMaxLength(50); + builder.Property(entity => entity.Description).IsRequired(false).HasMaxLength(500); + builder.Property(entity => entity.IsActive).IsRequired(); + + // Composite Index برای جستجوی سریع + builder.HasIndex(e => new { e.Scope, e.Key }) + .IsUnique() + .HasDatabaseName("IX_SystemConfiguration_Scope_Key"); + + // Index برای IsActive + builder.HasIndex(e => e.IsActive) + .HasDatabaseName("IX_SystemConfiguration_IsActive"); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/SystemConfigurationHistoryConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/SystemConfigurationHistoryConfiguration.cs new file mode 100644 index 0000000..cfec350 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/SystemConfigurationHistoryConfiguration.cs @@ -0,0 +1,41 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +/// +/// تاریخچه تغییرات تنظیمات سیستم +/// +public class SystemConfigurationHistoryConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasQueryFilter(p => !p.IsDeleted); + builder.Ignore(entity => entity.DomainEvents); + + builder.HasKey(entity => entity.Id); + builder.Property(entity => entity.Id).UseIdentityColumn(); + + builder.Property(entity => entity.ConfigurationId).IsRequired(); + builder.Property(entity => entity.Scope).IsRequired(); + builder.Property(entity => entity.Key).IsRequired().HasMaxLength(200); + builder.Property(entity => entity.OldValue).IsRequired().HasMaxLength(1000); + builder.Property(entity => entity.NewValue).IsRequired().HasMaxLength(1000); + builder.Property(entity => entity.Reason).IsRequired(false).HasMaxLength(500); + builder.Property(entity => entity.PerformedBy).IsRequired(false).HasMaxLength(100); + + // رابطه با SystemConfiguration + builder.HasOne(entity => entity.Configuration) + .WithMany(sc => sc.SystemConfigurationHistories) + .HasForeignKey(entity => entity.ConfigurationId) + .OnDelete(DeleteBehavior.Restrict); + + // Index برای ConfigurationId و Created + builder.HasIndex(e => new { e.ConfigurationId, e.Created }) + .HasDatabaseName("IX_SystemConfigurationHistory_ConfigId_Created"); + + // Index برای Scope و Key + builder.HasIndex(e => new { e.Scope, e.Key }) + .HasDatabaseName("IX_SystemConfigurationHistory_Scope_Key"); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserClubFeatureConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserClubFeatureConfiguration.cs new file mode 100644 index 0000000..8d1e333 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserClubFeatureConfiguration.cs @@ -0,0 +1,52 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +/// +/// جدول واسط کاربر-فیچر +/// +public class UserClubFeatureConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasQueryFilter(p => !p.IsDeleted); + builder.Ignore(entity => entity.DomainEvents); + + builder.HasKey(entity => entity.Id); + builder.Property(entity => entity.Id).UseIdentityColumn(); + + builder.Property(entity => entity.UserId).IsRequired(); + builder.Property(entity => entity.ClubMembershipId).IsRequired(); + builder.Property(entity => entity.ClubFeatureId).IsRequired(); + builder.Property(entity => entity.GrantedAt).IsRequired(); + builder.Property(entity => entity.Notes).IsRequired(false).HasMaxLength(500); + + // رابطه با User + builder.HasOne(entity => entity.User) + .WithMany(u => u.UserClubFeatures) + .HasForeignKey(entity => entity.UserId) + .OnDelete(DeleteBehavior.Restrict); + + // رابطه با ClubMembership + builder.HasOne(entity => entity.ClubMembership) + .WithMany(cm => cm.UserClubFeatures) + .HasForeignKey(entity => entity.ClubMembershipId) + .OnDelete(DeleteBehavior.Restrict); + + // رابطه با ClubFeature + builder.HasOne(entity => entity.ClubFeature) + .WithMany(cf => cf.UserClubFeatures) + .HasForeignKey(entity => entity.ClubFeatureId) + .OnDelete(DeleteBehavior.Restrict); + + // Composite Index برای جلوگیری از تکرار + builder.HasIndex(e => new { e.UserId, e.ClubFeatureId }) + .IsUnique() + .HasDatabaseName("IX_UserClubFeature_UserId_ClubFeatureId"); + + // Index برای ClubMembershipId + builder.HasIndex(e => e.ClubMembershipId) + .HasDatabaseName("IX_UserClubFeature_ClubMembershipId"); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserCommissionPayoutConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserCommissionPayoutConfiguration.cs new file mode 100644 index 0000000..1833872 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserCommissionPayoutConfiguration.cs @@ -0,0 +1,60 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +/// +/// پرداخت کمیسیون به کاربران +/// +public class UserCommissionPayoutConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasQueryFilter(p => !p.IsDeleted); + builder.Ignore(entity => entity.DomainEvents); + + builder.HasKey(entity => entity.Id); + builder.Property(entity => entity.Id).UseIdentityColumn(); + + builder.Property(entity => entity.UserId).IsRequired(); + builder.Property(entity => entity.WeekNumber).IsRequired().HasMaxLength(20); + builder.Property(entity => entity.WeeklyPoolId).IsRequired(); + builder.Property(entity => entity.BalancesEarned).IsRequired(); + builder.Property(entity => entity.ValuePerBalance).IsRequired(); + builder.Property(entity => entity.TotalAmount).IsRequired(); + builder.Property(entity => entity.Status).IsRequired(); + builder.Property(entity => entity.PaidAt).IsRequired(false); + builder.Property(entity => entity.WithdrawalMethod).IsRequired(false); + builder.Property(entity => entity.IbanNumber).IsRequired(false).HasMaxLength(26); + builder.Property(entity => entity.WithdrawnAt).IsRequired(false); + + // رابطه با User + builder.HasOne(entity => entity.User) + .WithMany(u => u.CommissionPayouts) + .HasForeignKey(entity => entity.UserId) + .OnDelete(DeleteBehavior.Restrict); + + // رابطه با WeeklyCommissionPool + builder.HasOne(entity => entity.WeeklyPool) + .WithMany(wp => wp.UserCommissionPayouts) + .HasForeignKey(entity => entity.WeeklyPoolId) + .OnDelete(DeleteBehavior.Restrict); + + // Composite Index برای UserId و WeekNumber + builder.HasIndex(e => new { e.UserId, e.WeekNumber }) + .IsUnique() + .HasDatabaseName("IX_UserCommissionPayout_UserId_WeekNumber"); + + // Index برای WeeklyPoolId + builder.HasIndex(e => e.WeeklyPoolId) + .HasDatabaseName("IX_UserCommissionPayout_WeeklyPoolId"); + + // Index برای Status + builder.HasIndex(e => e.Status) + .HasDatabaseName("IX_UserCommissionPayout_Status"); + + // Index برای WeekNumber + builder.HasIndex(e => e.WeekNumber) + .HasDatabaseName("IX_UserCommissionPayout_WeekNumber"); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserConfiguration.cs index 54ab59e..d39edba 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserConfiguration.cs @@ -31,6 +31,27 @@ public class UserConfiguration : IEntityTypeConfiguration builder.Property(entity => entity.PushNotifications).IsRequired(true); builder.Property(entity => entity.BirthDate).IsRequired(false); builder.Property(entity => entity.HashPassword).IsRequired(false); + + // ============= Network Club System Fields ============= + + builder.Property(entity => entity.NetworkParentId).IsRequired(false); + builder.Property(entity => entity.LegPosition).IsRequired(false); + + // رابطه با والد در شبکه باینری + builder + .HasOne(entity => entity.NetworkParent) + .WithMany(entity => entity.NetworkChildren) + .HasForeignKey(entity => entity.NetworkParentId) + .IsRequired(false) + .OnDelete(DeleteBehavior.Restrict); + + // Index برای NetworkParentId + builder.HasIndex(e => e.NetworkParentId) + .HasDatabaseName("IX_User_NetworkParentId"); + + // Index برای LegPosition + builder.HasIndex(e => e.LegPosition) + .HasDatabaseName("IX_User_LegPosition"); } } diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserWalletConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserWalletConfiguration.cs index 9a7dda4..a39b681 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserWalletConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/UserWalletConfiguration.cs @@ -18,6 +18,7 @@ public class UserWalletConfiguration : IEntityTypeConfiguration .IsRequired(true); builder.Property(entity => entity.Balance).IsRequired(true); builder.Property(entity => entity.NetworkBalance).IsRequired(true); + builder.Property(entity => entity.DiscountBalance).IsRequired(true); } } diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/WeeklyCommissionPoolConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/WeeklyCommissionPoolConfiguration.cs new file mode 100644 index 0000000..7d8217f --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/WeeklyCommissionPoolConfiguration.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations; + +/// +/// استخر کارمزد هفتگی +/// +public class WeeklyCommissionPoolConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasQueryFilter(p => !p.IsDeleted); + builder.Ignore(entity => entity.DomainEvents); + + builder.HasKey(entity => entity.Id); + builder.Property(entity => entity.Id).UseIdentityColumn(); + + builder.Property(entity => entity.WeekNumber).IsRequired().HasMaxLength(20); + builder.Property(entity => entity.TotalPoolAmount).IsRequired(); + builder.Property(entity => entity.TotalBalances).IsRequired(); + builder.Property(entity => entity.ValuePerBalance).IsRequired(); + builder.Property(entity => entity.IsCalculated).IsRequired(); + builder.Property(entity => entity.CalculatedAt).IsRequired(false); + + // Index یونیک برای WeekNumber + builder.HasIndex(e => e.WeekNumber) + .IsUnique() + .HasDatabaseName("IX_WeeklyCommissionPool_WeekNumber"); + + // Index برای IsCalculated + builder.HasIndex(e => e.IsCalculated) + .HasDatabaseName("IX_WeeklyCommissionPool_IsCalculated"); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251129002222_AddNetworkClubSystemV2.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251129002222_AddNetworkClubSystemV2.Designer.cs new file mode 100644 index 0000000..c88bad4 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251129002222_AddNetworkClubSystemV2.Designer.cs @@ -0,0 +1,2175 @@ +// +using System; +using CMSMicroservice.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20251129002222_AddNetworkClubSystemV2")] + partial class AddNetworkClubSystemV2 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("CMS") + .HasAnnotation("ProductVersion", "9.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("Categorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RequiredPoints") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("IsActive", "SortOrder") + .HasDatabaseName("IX_ClubFeature_IsActive_SortOrder"); + + b.ToTable("ClubFeatures", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubMembership", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActivatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("InitialContribution") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalEarned") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("IsActive") + .HasDatabaseName("IX_ClubMembership_IsActive"); + + b.HasIndex("UserId") + .IsUnique() + .HasDatabaseName("IX_ClubMembership_UserId"); + + b.ToTable("ClubMemberships", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.UserClubFeature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubFeatureId") + .HasColumnType("bigint"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GrantedAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ClubFeatureId"); + + b.HasIndex("ClubMembershipId") + .HasDatabaseName("IX_UserClubFeature_ClubMembershipId"); + + b.HasIndex("UserId", "ClubFeatureId") + .IsUnique() + .HasDatabaseName("IX_UserClubFeature_UserId_ClubFeatureId"); + + b.ToTable("UserClubFeatures", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.UserCommissionPayout", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BalancesEarned") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IbanNumber") + .HasMaxLength(26) + .HasColumnType("nvarchar(26)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaidAt") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("WeeklyPoolId") + .HasColumnType("bigint"); + + b.Property("WithdrawalMethod") + .HasColumnType("int"); + + b.Property("WithdrawnAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Status") + .HasDatabaseName("IX_UserCommissionPayout_Status"); + + b.HasIndex("WeekNumber") + .HasDatabaseName("IX_UserCommissionPayout_WeekNumber"); + + b.HasIndex("WeeklyPoolId") + .HasDatabaseName("IX_UserCommissionPayout_WeeklyPoolId"); + + b.HasIndex("UserId", "WeekNumber") + .IsUnique() + .HasDatabaseName("IX_UserCommissionPayout_UserId_WeekNumber"); + + b.ToTable("UserCommissionPayouts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.WeeklyCommissionPool", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsCalculated") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("TotalPoolAmount") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("IsCalculated") + .HasDatabaseName("IX_WeeklyCommissionPool_IsCalculated"); + + b.HasIndex("WeekNumber") + .IsUnique() + .HasDatabaseName("IX_WeeklyCommissionPool_WeekNumber"); + + b.ToTable("WeeklyCommissionPools", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DataType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Scope") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.HasKey("Id"); + + b.HasIndex("IsActive") + .HasDatabaseName("IX_SystemConfiguration_IsActive"); + + b.HasIndex("Scope", "Key") + .IsUnique() + .HasDatabaseName("IX_SystemConfiguration_Scope_Key"); + + b.ToTable("SystemConfigurations", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Contract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HtmlContent") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Contracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsChangePrice") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UnitDiscount") + .HasColumnType("int"); + + b.Property("UnitDiscountPrice") + .HasColumnType("bigint"); + + b.Property("UnitPrice") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("FactorDetailss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewInitialContribution") + .HasColumnType("bigint"); + + b.Property("NewIsActive") + .HasColumnType("bit"); + + b.Property("OldInitialContribution") + .HasColumnType("bigint"); + + b.Property("OldIsActive") + .HasColumnType("bit"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Action") + .HasDatabaseName("IX_ClubMembershipHistory_Action"); + + b.HasIndex("ClubMembershipId") + .HasDatabaseName("IX_ClubMembershipHistory_ClubMembershipId"); + + b.HasIndex("UserId", "Created") + .HasDatabaseName("IX_ClubMembershipHistory_UserId_Created"); + + b.ToTable("ClubMembershipHistories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.CommissionPayoutHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("AmountAfter") + .HasColumnType("bigint"); + + b.Property("AmountBefore") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewStatus") + .HasColumnType("int"); + + b.Property("OldStatus") + .HasColumnType("int"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserCommissionPayoutId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Action") + .HasDatabaseName("IX_CommissionPayoutHistory_Action"); + + b.HasIndex("UserCommissionPayoutId") + .HasDatabaseName("IX_CommissionPayoutHistory_PayoutId"); + + b.HasIndex("WeekNumber") + .HasDatabaseName("IX_CommissionPayoutHistory_WeekNumber"); + + b.HasIndex("UserId", "Created") + .HasDatabaseName("IX_CommissionPayoutHistory_UserId_Created"); + + b.ToTable("CommissionPayoutHistories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.NetworkMembershipHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewLegPosition") + .HasColumnType("int"); + + b.Property("NewParentId") + .HasColumnType("bigint"); + + b.Property("OldLegPosition") + .HasColumnType("int"); + + b.Property("OldParentId") + .HasColumnType("bigint"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Action") + .HasDatabaseName("IX_NetworkMembershipHistory_Action"); + + b.HasIndex("UserId", "Created") + .HasDatabaseName("IX_NetworkMembershipHistory_UserId_Created"); + + b.ToTable("NetworkMembershipHistories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.SystemConfigurationHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConfigurationId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OldValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Scope") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ConfigurationId", "Created") + .HasDatabaseName("IX_SystemConfigurationHistory_ConfigId_Created"); + + b.HasIndex("Scope", "Key") + .HasDatabaseName("IX_SystemConfigurationHistory_Scope_Key"); + + b.ToTable("SystemConfigurationHistories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Network.NetworkWeeklyBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExpired") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LeftLegBalances") + .HasColumnType("int"); + + b.Property("RightLegBalances") + .HasColumnType("int"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("WeeklyPoolContribution") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("IsExpired") + .HasDatabaseName("IX_NetworkWeeklyBalance_IsExpired"); + + b.HasIndex("WeekNumber") + .HasDatabaseName("IX_NetworkWeeklyBalance_WeekNumber"); + + b.HasIndex("UserId", "WeekNumber") + .IsUnique() + .HasDatabaseName("IX_NetworkWeeklyBalance_UserId_WeekNumber"); + + b.ToTable("NetworkWeeklyBalances", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.OtpToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Attempts") + .HasColumnType("int"); + + b.Property("CodeHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsUsed") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Purpose") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("OtpTokens", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Packages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("ProductImageId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("ProductImageId"); + + b.ToTable("ProductGalleryss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImageThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ProductImagess", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubDiscountPercent") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Discount") + .HasColumnType("int"); + + b.Property("FullInformation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsClubExclusive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Rate") + .HasColumnType("int"); + + b.Property("RemainingCount") + .HasColumnType("int"); + + b.Property("SaleCount") + .HasColumnType("int"); + + b.Property("ShortInfomation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ViewCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IsClubExclusive") + .HasDatabaseName("IX_Products_IsClubExclusive"); + + b.ToTable("Productss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("ProductId"); + + b.ToTable("PruductCategorys", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("TagId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("TagId"); + + b.ToTable("PruductTags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Roles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Tags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("RefId") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Transactionss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AvatarPath") + .HasColumnType("nvarchar(max)"); + + b.Property("BirthDate") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailNotifications") + .HasColumnType("bit"); + + b.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property("HashPassword") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsMobileVerified") + .HasColumnType("bit"); + + b.Property("IsRulesAccepted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .HasColumnType("nvarchar(max)"); + + b.Property("LegPosition") + .HasColumnType("int"); + + b.Property("Mobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MobileVerifiedAt") + .HasColumnType("datetime2"); + + b.Property("NationalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkParentId") + .HasColumnType("bigint"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("PushNotifications") + .HasColumnType("bit"); + + b.Property("ReferralCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RulesAcceptedAt") + .HasColumnType("datetime2"); + + b.Property("SmsNotifications") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("LegPosition") + .HasDatabaseName("IX_User_LegPosition"); + + b.HasIndex("NetworkParentId") + .HasDatabaseName("IX_User_NetworkParentId"); + + b.HasIndex("ParentId"); + + b.ToTable("Users", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CityId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserCartss", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("SignGuid") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SignedPdfFile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("UserId"); + + b.ToTable("UserContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("DeliveryStatus") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PaymentDate") + .HasColumnType("datetime2"); + + b.Property("PaymentMethod") + .HasColumnType("int"); + + b.Property("PaymentStatus") + .HasColumnType("int"); + + b.Property("TrackingCode") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserAddressId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("PackageId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("UserOrders", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NetworkBalance") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserWallets", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChangeNerworkValue") + .HasColumnType("bigint"); + + b.Property("ChangeValue") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentBalance") + .HasColumnType("bigint"); + + b.Property("CurrentNetworkBalance") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsIncrease") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RefrenceId") + .HasColumnType("bigint"); + + b.Property("WalletId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("WalletId"); + + b.ToTable("UserWalletChangeLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Parent") + .WithMany("Categorys") + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubMembership", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithOne("ClubMembership") + .HasForeignKey("CMSMicroservice.Domain.Entities.Club.ClubMembership", "UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.UserClubFeature", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Club.ClubFeature", "ClubFeature") + .WithMany("UserClubFeatures") + .HasForeignKey("ClubFeatureId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Club.ClubMembership", "ClubMembership") + .WithMany("UserClubFeatures") + .HasForeignKey("ClubMembershipId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserClubFeatures") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ClubFeature"); + + b.Navigation("ClubMembership"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.UserCommissionPayout", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("CommissionPayouts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Commission.WeeklyCommissionPool", "WeeklyPool") + .WithMany("UserCommissionPayouts") + .HasForeignKey("WeeklyPoolId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("User"); + + b.Navigation("WeeklyPool"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany("FactorDetailss") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("FactorDetailss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Club.ClubMembership", "ClubMembership") + .WithMany("ClubMembershipHistories") + .HasForeignKey("ClubMembershipId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ClubMembership"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.CommissionPayoutHistory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Commission.UserCommissionPayout", "UserCommissionPayout") + .WithMany("CommissionPayoutHistories") + .HasForeignKey("UserCommissionPayoutId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("UserCommissionPayout"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.SystemConfigurationHistory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", "Configuration") + .WithMany("SystemConfigurationHistories") + .HasForeignKey("ConfigurationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Configuration"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Network.NetworkWeeklyBalance", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("NetworkWeeklyBalances") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.ProductImages", "ProductImage") + .WithMany("ProductGalleryss") + .HasForeignKey("ProductImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("ProductImage"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Category") + .WithMany("PruductCategorys") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductCategorys") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PruductTag", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("PruductTags") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Tag", "Tag") + .WithMany("PruductTags") + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Tag"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "NetworkParent") + .WithMany("NetworkChildren") + .HasForeignKey("NetworkParentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "Parent") + .WithMany("Users") + .HasForeignKey("ParentId"); + + b.Navigation("NetworkParent"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserAddresss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCarts", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") + .WithMany("UserCartss") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserCartss") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Contract", "Contract") + .WithMany("UserContracts") + .HasForeignKey("ContractId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contract"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany("UserOrders") + .HasForeignKey("PackageId"); + + b.HasOne("CMSMicroservice.Domain.Entities.Transactions", "Transaction") + .WithMany("UserOrders") + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress") + .WithMany("UserOrders") + .HasForeignKey("UserAddressId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserOrders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + + b.Navigation("UserAddress"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserWallets") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWalletChangeLog", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserWallet", "Wallet") + .WithMany("UserWalletChangeLogs") + .HasForeignKey("WalletId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Wallet"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.Navigation("Categorys"); + + b.Navigation("PruductCategorys"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b => + { + b.Navigation("UserClubFeatures"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubMembership", b => + { + b.Navigation("ClubMembershipHistories"); + + b.Navigation("UserClubFeatures"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.UserCommissionPayout", b => + { + b.Navigation("CommissionPayoutHistories"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.WeeklyCommissionPool", b => + { + b.Navigation("UserCommissionPayouts"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b => + { + b.Navigation("SystemConfigurationHistories"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Contract", b => + { + b.Navigation("UserContracts"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImages", b => + { + b.Navigation("ProductGalleryss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Products", b => + { + b.Navigation("FactorDetailss"); + + b.Navigation("ProductGalleryss"); + + b.Navigation("PruductCategorys"); + + b.Navigation("PruductTags"); + + b.Navigation("UserCartss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Navigation("PruductTags"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transactions", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Navigation("ClubMembership"); + + b.Navigation("CommissionPayouts"); + + b.Navigation("NetworkChildren"); + + b.Navigation("NetworkWeeklyBalances"); + + b.Navigation("UserAddresss"); + + b.Navigation("UserCartss"); + + b.Navigation("UserClubFeatures"); + + b.Navigation("UserContracts"); + + b.Navigation("UserOrders"); + + b.Navigation("UserRoles"); + + b.Navigation("UserWallets"); + + b.Navigation("Users"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Navigation("FactorDetailss"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Navigation("UserWalletChangeLogs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251129002222_AddNetworkClubSystemV2.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251129002222_AddNetworkClubSystemV2.cs new file mode 100644 index 0000000..b25f84c --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251129002222_AddNetworkClubSystemV2.cs @@ -0,0 +1,696 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + /// + public partial class AddNetworkClubSystemV2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "DiscountBalance", + schema: "CMS", + table: "UserWallets", + type: "bigint", + nullable: false, + defaultValue: 0L); + + migrationBuilder.AddColumn( + name: "LegPosition", + schema: "CMS", + table: "Users", + type: "int", + nullable: true); + + migrationBuilder.AddColumn( + name: "NetworkParentId", + schema: "CMS", + table: "Users", + type: "bigint", + nullable: true); + + migrationBuilder.AddColumn( + name: "ClubDiscountPercent", + schema: "CMS", + table: "Productss", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "IsClubExclusive", + schema: "CMS", + table: "Productss", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.CreateTable( + name: "ClubFeatures", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Title = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + IsActive = table.Column(type: "bit", nullable: false), + RequiredPoints = table.Column(type: "int", nullable: true), + SortOrder = table.Column(type: "int", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ClubFeatures", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ClubMemberships", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "bigint", nullable: false), + IsActive = table.Column(type: "bit", nullable: false), + ActivatedAt = table.Column(type: "datetime2", nullable: true), + InitialContribution = table.Column(type: "bigint", nullable: false), + TotalEarned = table.Column(type: "bigint", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ClubMemberships", x => x.Id); + table.ForeignKey( + name: "FK_ClubMemberships_Users_UserId", + column: x => x.UserId, + principalSchema: "CMS", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "NetworkMembershipHistories", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "bigint", nullable: false), + OldParentId = table.Column(type: "bigint", nullable: true), + NewParentId = table.Column(type: "bigint", nullable: true), + OldLegPosition = table.Column(type: "int", nullable: true), + NewLegPosition = table.Column(type: "int", nullable: true), + Action = table.Column(type: "int", nullable: false), + Reason = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + PerformedBy = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_NetworkMembershipHistories", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "NetworkWeeklyBalances", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "bigint", nullable: false), + WeekNumber = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: false), + LeftLegBalances = table.Column(type: "int", nullable: false), + RightLegBalances = table.Column(type: "int", nullable: false), + TotalBalances = table.Column(type: "int", nullable: false), + WeeklyPoolContribution = table.Column(type: "bigint", nullable: false), + CalculatedAt = table.Column(type: "datetime2", nullable: true), + IsExpired = table.Column(type: "bit", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_NetworkWeeklyBalances", x => x.Id); + table.ForeignKey( + name: "FK_NetworkWeeklyBalances_Users_UserId", + column: x => x.UserId, + principalSchema: "CMS", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "SystemConfigurations", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Scope = table.Column(type: "int", nullable: false), + Key = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + Value = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false), + DataType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + Description = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + IsActive = table.Column(type: "bit", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SystemConfigurations", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "WeeklyCommissionPools", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + WeekNumber = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: false), + TotalPoolAmount = table.Column(type: "bigint", nullable: false), + TotalBalances = table.Column(type: "int", nullable: false), + ValuePerBalance = table.Column(type: "bigint", nullable: false), + IsCalculated = table.Column(type: "bit", nullable: false), + CalculatedAt = table.Column(type: "datetime2", nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_WeeklyCommissionPools", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ClubMembershipHistories", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ClubMembershipId = table.Column(type: "bigint", nullable: false), + UserId = table.Column(type: "bigint", nullable: false), + OldIsActive = table.Column(type: "bit", nullable: false), + NewIsActive = table.Column(type: "bit", nullable: false), + OldInitialContribution = table.Column(type: "bigint", nullable: true), + NewInitialContribution = table.Column(type: "bigint", nullable: true), + Action = table.Column(type: "int", nullable: false), + Reason = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + PerformedBy = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ClubMembershipHistories", x => x.Id); + table.ForeignKey( + name: "FK_ClubMembershipHistories_ClubMemberships_ClubMembershipId", + column: x => x.ClubMembershipId, + principalSchema: "CMS", + principalTable: "ClubMemberships", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "UserClubFeatures", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "bigint", nullable: false), + ClubMembershipId = table.Column(type: "bigint", nullable: false), + ClubFeatureId = table.Column(type: "bigint", nullable: false), + GrantedAt = table.Column(type: "datetime2", nullable: false), + Notes = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserClubFeatures", x => x.Id); + table.ForeignKey( + name: "FK_UserClubFeatures_ClubFeatures_ClubFeatureId", + column: x => x.ClubFeatureId, + principalSchema: "CMS", + principalTable: "ClubFeatures", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_UserClubFeatures_ClubMemberships_ClubMembershipId", + column: x => x.ClubMembershipId, + principalSchema: "CMS", + principalTable: "ClubMemberships", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_UserClubFeatures_Users_UserId", + column: x => x.UserId, + principalSchema: "CMS", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "SystemConfigurationHistories", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ConfigurationId = table.Column(type: "bigint", nullable: false), + Scope = table.Column(type: "int", nullable: false), + Key = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + OldValue = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false), + NewValue = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false), + Reason = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + PerformedBy = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SystemConfigurationHistories", x => x.Id); + table.ForeignKey( + name: "FK_SystemConfigurationHistories_SystemConfigurations_ConfigurationId", + column: x => x.ConfigurationId, + principalSchema: "CMS", + principalTable: "SystemConfigurations", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "UserCommissionPayouts", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "bigint", nullable: false), + WeekNumber = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: false), + WeeklyPoolId = table.Column(type: "bigint", nullable: false), + BalancesEarned = table.Column(type: "int", nullable: false), + ValuePerBalance = table.Column(type: "bigint", nullable: false), + TotalAmount = table.Column(type: "bigint", nullable: false), + Status = table.Column(type: "int", nullable: false), + PaidAt = table.Column(type: "datetime2", nullable: true), + WithdrawalMethod = table.Column(type: "int", nullable: true), + IbanNumber = table.Column(type: "nvarchar(26)", maxLength: 26, nullable: true), + WithdrawnAt = table.Column(type: "datetime2", nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserCommissionPayouts", x => x.Id); + table.ForeignKey( + name: "FK_UserCommissionPayouts_Users_UserId", + column: x => x.UserId, + principalSchema: "CMS", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_UserCommissionPayouts_WeeklyCommissionPools_WeeklyPoolId", + column: x => x.WeeklyPoolId, + principalSchema: "CMS", + principalTable: "WeeklyCommissionPools", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "CommissionPayoutHistories", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserCommissionPayoutId = table.Column(type: "bigint", nullable: false), + UserId = table.Column(type: "bigint", nullable: false), + WeekNumber = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: false), + AmountBefore = table.Column(type: "bigint", nullable: false), + AmountAfter = table.Column(type: "bigint", nullable: false), + OldStatus = table.Column(type: "int", nullable: false), + NewStatus = table.Column(type: "int", nullable: false), + Action = table.Column(type: "int", nullable: false), + PerformedBy = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Reason = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CommissionPayoutHistories", x => x.Id); + table.ForeignKey( + name: "FK_CommissionPayoutHistories_UserCommissionPayouts_UserCommissionPayoutId", + column: x => x.UserCommissionPayoutId, + principalSchema: "CMS", + principalTable: "UserCommissionPayouts", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_User_LegPosition", + schema: "CMS", + table: "Users", + column: "LegPosition"); + + migrationBuilder.CreateIndex( + name: "IX_User_NetworkParentId", + schema: "CMS", + table: "Users", + column: "NetworkParentId"); + + migrationBuilder.CreateIndex( + name: "IX_Products_IsClubExclusive", + schema: "CMS", + table: "Productss", + column: "IsClubExclusive"); + + migrationBuilder.CreateIndex( + name: "IX_ClubFeature_IsActive_SortOrder", + schema: "CMS", + table: "ClubFeatures", + columns: new[] { "IsActive", "SortOrder" }); + + migrationBuilder.CreateIndex( + name: "IX_ClubMembershipHistory_Action", + schema: "CMS", + table: "ClubMembershipHistories", + column: "Action"); + + migrationBuilder.CreateIndex( + name: "IX_ClubMembershipHistory_ClubMembershipId", + schema: "CMS", + table: "ClubMembershipHistories", + column: "ClubMembershipId"); + + migrationBuilder.CreateIndex( + name: "IX_ClubMembershipHistory_UserId_Created", + schema: "CMS", + table: "ClubMembershipHistories", + columns: new[] { "UserId", "Created" }); + + migrationBuilder.CreateIndex( + name: "IX_ClubMembership_IsActive", + schema: "CMS", + table: "ClubMemberships", + column: "IsActive"); + + migrationBuilder.CreateIndex( + name: "IX_ClubMembership_UserId", + schema: "CMS", + table: "ClubMemberships", + column: "UserId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_CommissionPayoutHistory_Action", + schema: "CMS", + table: "CommissionPayoutHistories", + column: "Action"); + + migrationBuilder.CreateIndex( + name: "IX_CommissionPayoutHistory_PayoutId", + schema: "CMS", + table: "CommissionPayoutHistories", + column: "UserCommissionPayoutId"); + + migrationBuilder.CreateIndex( + name: "IX_CommissionPayoutHistory_UserId_Created", + schema: "CMS", + table: "CommissionPayoutHistories", + columns: new[] { "UserId", "Created" }); + + migrationBuilder.CreateIndex( + name: "IX_CommissionPayoutHistory_WeekNumber", + schema: "CMS", + table: "CommissionPayoutHistories", + column: "WeekNumber"); + + migrationBuilder.CreateIndex( + name: "IX_NetworkMembershipHistory_Action", + schema: "CMS", + table: "NetworkMembershipHistories", + column: "Action"); + + migrationBuilder.CreateIndex( + name: "IX_NetworkMembershipHistory_UserId_Created", + schema: "CMS", + table: "NetworkMembershipHistories", + columns: new[] { "UserId", "Created" }); + + migrationBuilder.CreateIndex( + name: "IX_NetworkWeeklyBalance_IsExpired", + schema: "CMS", + table: "NetworkWeeklyBalances", + column: "IsExpired"); + + migrationBuilder.CreateIndex( + name: "IX_NetworkWeeklyBalance_UserId_WeekNumber", + schema: "CMS", + table: "NetworkWeeklyBalances", + columns: new[] { "UserId", "WeekNumber" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_NetworkWeeklyBalance_WeekNumber", + schema: "CMS", + table: "NetworkWeeklyBalances", + column: "WeekNumber"); + + migrationBuilder.CreateIndex( + name: "IX_SystemConfigurationHistory_ConfigId_Created", + schema: "CMS", + table: "SystemConfigurationHistories", + columns: new[] { "ConfigurationId", "Created" }); + + migrationBuilder.CreateIndex( + name: "IX_SystemConfigurationHistory_Scope_Key", + schema: "CMS", + table: "SystemConfigurationHistories", + columns: new[] { "Scope", "Key" }); + + migrationBuilder.CreateIndex( + name: "IX_SystemConfiguration_IsActive", + schema: "CMS", + table: "SystemConfigurations", + column: "IsActive"); + + migrationBuilder.CreateIndex( + name: "IX_SystemConfiguration_Scope_Key", + schema: "CMS", + table: "SystemConfigurations", + columns: new[] { "Scope", "Key" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_UserClubFeature_ClubMembershipId", + schema: "CMS", + table: "UserClubFeatures", + column: "ClubMembershipId"); + + migrationBuilder.CreateIndex( + name: "IX_UserClubFeature_UserId_ClubFeatureId", + schema: "CMS", + table: "UserClubFeatures", + columns: new[] { "UserId", "ClubFeatureId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_UserClubFeatures_ClubFeatureId", + schema: "CMS", + table: "UserClubFeatures", + column: "ClubFeatureId"); + + migrationBuilder.CreateIndex( + name: "IX_UserCommissionPayout_Status", + schema: "CMS", + table: "UserCommissionPayouts", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_UserCommissionPayout_UserId_WeekNumber", + schema: "CMS", + table: "UserCommissionPayouts", + columns: new[] { "UserId", "WeekNumber" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_UserCommissionPayout_WeeklyPoolId", + schema: "CMS", + table: "UserCommissionPayouts", + column: "WeeklyPoolId"); + + migrationBuilder.CreateIndex( + name: "IX_UserCommissionPayout_WeekNumber", + schema: "CMS", + table: "UserCommissionPayouts", + column: "WeekNumber"); + + migrationBuilder.CreateIndex( + name: "IX_WeeklyCommissionPool_IsCalculated", + schema: "CMS", + table: "WeeklyCommissionPools", + column: "IsCalculated"); + + migrationBuilder.CreateIndex( + name: "IX_WeeklyCommissionPool_WeekNumber", + schema: "CMS", + table: "WeeklyCommissionPools", + column: "WeekNumber", + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_Users_Users_NetworkParentId", + schema: "CMS", + table: "Users", + column: "NetworkParentId", + principalSchema: "CMS", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Users_Users_NetworkParentId", + schema: "CMS", + table: "Users"); + + migrationBuilder.DropTable( + name: "ClubMembershipHistories", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "CommissionPayoutHistories", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "NetworkMembershipHistories", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "NetworkWeeklyBalances", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "SystemConfigurationHistories", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "UserClubFeatures", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "UserCommissionPayouts", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "SystemConfigurations", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "ClubFeatures", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "ClubMemberships", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "WeeklyCommissionPools", + schema: "CMS"); + + migrationBuilder.DropIndex( + name: "IX_User_LegPosition", + schema: "CMS", + table: "Users"); + + migrationBuilder.DropIndex( + name: "IX_User_NetworkParentId", + schema: "CMS", + table: "Users"); + + migrationBuilder.DropIndex( + name: "IX_Products_IsClubExclusive", + schema: "CMS", + table: "Productss"); + + migrationBuilder.DropColumn( + name: "DiscountBalance", + schema: "CMS", + table: "UserWallets"); + + migrationBuilder.DropColumn( + name: "LegPosition", + schema: "CMS", + table: "Users"); + + migrationBuilder.DropColumn( + name: "NetworkParentId", + schema: "CMS", + table: "Users"); + + migrationBuilder.DropColumn( + name: "ClubDiscountPercent", + schema: "CMS", + table: "Productss"); + + migrationBuilder.DropColumn( + name: "IsClubExclusive", + schema: "CMS", + table: "Productss"); + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs index d9bd124..ccaa819 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs @@ -76,6 +76,349 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("Categorys", "CMS"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("RequiredPoints") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("IsActive", "SortOrder") + .HasDatabaseName("IX_ClubFeature_IsActive_SortOrder"); + + b.ToTable("ClubFeatures", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubMembership", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActivatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("InitialContribution") + .HasColumnType("bigint"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalEarned") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("IsActive") + .HasDatabaseName("IX_ClubMembership_IsActive"); + + b.HasIndex("UserId") + .IsUnique() + .HasDatabaseName("IX_ClubMembership_UserId"); + + b.ToTable("ClubMemberships", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.UserClubFeature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClubFeatureId") + .HasColumnType("bigint"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("GrantedAt") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ClubFeatureId"); + + b.HasIndex("ClubMembershipId") + .HasDatabaseName("IX_UserClubFeature_ClubMembershipId"); + + b.HasIndex("UserId", "ClubFeatureId") + .IsUnique() + .HasDatabaseName("IX_UserClubFeature_UserId_ClubFeatureId"); + + b.ToTable("UserClubFeatures", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.UserCommissionPayout", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BalancesEarned") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IbanNumber") + .HasMaxLength(26) + .HasColumnType("nvarchar(26)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PaidAt") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("WeeklyPoolId") + .HasColumnType("bigint"); + + b.Property("WithdrawalMethod") + .HasColumnType("int"); + + b.Property("WithdrawnAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Status") + .HasDatabaseName("IX_UserCommissionPayout_Status"); + + b.HasIndex("WeekNumber") + .HasDatabaseName("IX_UserCommissionPayout_WeekNumber"); + + b.HasIndex("WeeklyPoolId") + .HasDatabaseName("IX_UserCommissionPayout_WeeklyPoolId"); + + b.HasIndex("UserId", "WeekNumber") + .IsUnique() + .HasDatabaseName("IX_UserCommissionPayout_UserId_WeekNumber"); + + b.ToTable("UserCommissionPayouts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.WeeklyCommissionPool", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsCalculated") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("TotalPoolAmount") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("IsCalculated") + .HasDatabaseName("IX_WeeklyCommissionPool_IsCalculated"); + + b.HasIndex("WeekNumber") + .IsUnique() + .HasDatabaseName("IX_WeeklyCommissionPool_WeekNumber"); + + b.ToTable("WeeklyCommissionPools", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DataType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Scope") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.HasKey("Id"); + + b.HasIndex("IsActive") + .HasDatabaseName("IX_SystemConfiguration_IsActive"); + + b.HasIndex("Scope", "Key") + .IsUnique() + .HasDatabaseName("IX_SystemConfiguration_Scope_Key"); + + b.ToTable("SystemConfigurations", "CMS"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Contract", b => { b.Property("Id") @@ -172,6 +515,333 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("FactorDetailss", "CMS"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("ClubMembershipId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewInitialContribution") + .HasColumnType("bigint"); + + b.Property("NewIsActive") + .HasColumnType("bit"); + + b.Property("OldInitialContribution") + .HasColumnType("bigint"); + + b.Property("OldIsActive") + .HasColumnType("bit"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Action") + .HasDatabaseName("IX_ClubMembershipHistory_Action"); + + b.HasIndex("ClubMembershipId") + .HasDatabaseName("IX_ClubMembershipHistory_ClubMembershipId"); + + b.HasIndex("UserId", "Created") + .HasDatabaseName("IX_ClubMembershipHistory_UserId_Created"); + + b.ToTable("ClubMembershipHistories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.CommissionPayoutHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("AmountAfter") + .HasColumnType("bigint"); + + b.Property("AmountBefore") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewStatus") + .HasColumnType("int"); + + b.Property("OldStatus") + .HasColumnType("int"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserCommissionPayoutId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Action") + .HasDatabaseName("IX_CommissionPayoutHistory_Action"); + + b.HasIndex("UserCommissionPayoutId") + .HasDatabaseName("IX_CommissionPayoutHistory_PayoutId"); + + b.HasIndex("WeekNumber") + .HasDatabaseName("IX_CommissionPayoutHistory_WeekNumber"); + + b.HasIndex("UserId", "Created") + .HasDatabaseName("IX_CommissionPayoutHistory_UserId_Created"); + + b.ToTable("CommissionPayoutHistories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.NetworkMembershipHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewLegPosition") + .HasColumnType("int"); + + b.Property("NewParentId") + .HasColumnType("bigint"); + + b.Property("OldLegPosition") + .HasColumnType("int"); + + b.Property("OldParentId") + .HasColumnType("bigint"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Action") + .HasDatabaseName("IX_NetworkMembershipHistory_Action"); + + b.HasIndex("UserId", "Created") + .HasDatabaseName("IX_NetworkMembershipHistory_UserId_Created"); + + b.ToTable("NetworkMembershipHistories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.SystemConfigurationHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConfigurationId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NewValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OldValue") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Scope") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ConfigurationId", "Created") + .HasDatabaseName("IX_SystemConfigurationHistory_ConfigId_Created"); + + b.HasIndex("Scope", "Key") + .HasDatabaseName("IX_SystemConfigurationHistory_Scope_Key"); + + b.ToTable("SystemConfigurationHistories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Network.NetworkWeeklyBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CalculatedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExpired") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LeftLegBalances") + .HasColumnType("int"); + + b.Property("RightLegBalances") + .HasColumnType("int"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("WeeklyPoolContribution") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("IsExpired") + .HasDatabaseName("IX_NetworkWeeklyBalance_IsExpired"); + + b.HasIndex("WeekNumber") + .HasDatabaseName("IX_NetworkWeeklyBalance_WeekNumber"); + + b.HasIndex("UserId", "WeekNumber") + .IsUnique() + .HasDatabaseName("IX_NetworkWeeklyBalance_UserId_WeekNumber"); + + b.ToTable("NetworkWeeklyBalances", "CMS"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.OtpToken", b => { b.Property("Id") @@ -350,6 +1020,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + b.Property("ClubDiscountPercent") + .HasColumnType("int"); + b.Property("Created") .HasColumnType("datetime2"); @@ -371,6 +1044,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("IsClubExclusive") + .HasColumnType("bit"); + b.Property("IsDeleted") .HasColumnType("bit"); @@ -409,6 +1085,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.HasKey("Id"); + b.HasIndex("IsClubExclusive") + .HasDatabaseName("IX_Products_IsClubExclusive"); + b.ToTable("Productss", "CMS"); }); @@ -663,6 +1342,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Property("LastName") .HasColumnType("nvarchar(max)"); + b.Property("LegPosition") + .HasColumnType("int"); + b.Property("Mobile") .IsRequired() .HasColumnType("nvarchar(max)"); @@ -673,6 +1355,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Property("NationalCode") .HasColumnType("nvarchar(max)"); + b.Property("NetworkParentId") + .HasColumnType("bigint"); + b.Property("ParentId") .HasColumnType("bigint"); @@ -691,6 +1376,12 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.HasKey("Id"); + b.HasIndex("LegPosition") + .HasDatabaseName("IX_User_LegPosition"); + + b.HasIndex("NetworkParentId") + .HasDatabaseName("IX_User_NetworkParentId"); + b.HasIndex("ParentId"); b.ToTable("Users", "CMS"); @@ -958,6 +1649,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Property("CreatedBy") .HasColumnType("nvarchar(max)"); + b.Property("DiscountBalance") + .HasColumnType("bigint"); + b.Property("IsDeleted") .HasColumnType("bit"); @@ -1040,6 +1734,63 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("Parent"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubMembership", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithOne("ClubMembership") + .HasForeignKey("CMSMicroservice.Domain.Entities.Club.ClubMembership", "UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.UserClubFeature", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Club.ClubFeature", "ClubFeature") + .WithMany("UserClubFeatures") + .HasForeignKey("ClubFeatureId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Club.ClubMembership", "ClubMembership") + .WithMany("UserClubFeatures") + .HasForeignKey("ClubMembershipId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserClubFeatures") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ClubFeature"); + + b.Navigation("ClubMembership"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.UserCommissionPayout", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("CommissionPayouts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Commission.WeeklyCommissionPool", "WeeklyPool") + .WithMany("UserCommissionPayouts") + .HasForeignKey("WeeklyPoolId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("User"); + + b.Navigation("WeeklyPool"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => { b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") @@ -1059,6 +1810,50 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("Product"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.ClubMembershipHistory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Club.ClubMembership", "ClubMembership") + .WithMany("ClubMembershipHistories") + .HasForeignKey("ClubMembershipId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ClubMembership"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.CommissionPayoutHistory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Commission.UserCommissionPayout", "UserCommissionPayout") + .WithMany("CommissionPayoutHistories") + .HasForeignKey("UserCommissionPayoutId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("UserCommissionPayout"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.History.SystemConfigurationHistory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", "Configuration") + .WithMany("SystemConfigurationHistories") + .HasForeignKey("ConfigurationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Configuration"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Network.NetworkWeeklyBalance", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("NetworkWeeklyBalances") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("User"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallerys", b => { b.HasOne("CMSMicroservice.Domain.Entities.Products", "Product") @@ -1118,10 +1913,17 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => { + b.HasOne("CMSMicroservice.Domain.Entities.User", "NetworkParent") + .WithMany("NetworkChildren") + .HasForeignKey("NetworkParentId") + .OnDelete(DeleteBehavior.Restrict); + b.HasOne("CMSMicroservice.Domain.Entities.User", "Parent") .WithMany("Users") .HasForeignKey("ParentId"); + b.Navigation("NetworkParent"); + b.Navigation("Parent"); }); @@ -1253,6 +2055,33 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("PruductCategorys"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubFeature", b => + { + b.Navigation("UserClubFeatures"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Club.ClubMembership", b => + { + b.Navigation("ClubMembershipHistories"); + + b.Navigation("UserClubFeatures"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.UserCommissionPayout", b => + { + b.Navigation("CommissionPayoutHistories"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.WeeklyCommissionPool", b => + { + b.Navigation("UserCommissionPayouts"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b => + { + b.Navigation("SystemConfigurationHistories"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Contract", b => { b.Navigation("UserContracts"); @@ -1298,10 +2127,20 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => { + b.Navigation("ClubMembership"); + + b.Navigation("CommissionPayouts"); + + b.Navigation("NetworkChildren"); + + b.Navigation("NetworkWeeklyBalances"); + b.Navigation("UserAddresss"); b.Navigation("UserCartss"); + b.Navigation("UserClubFeatures"); + b.Navigation("UserContracts"); b.Navigation("UserOrders");