feat: Add EF configurations and migration for network-club system
EF Core Configurations (11 files): - SystemConfigurationConfiguration with Scope+Key composite index - ClubMembershipConfiguration with one-to-one User relationship - ClubFeatureConfiguration with IsActive+SortOrder index - UserClubFeatureConfiguration with composite unique index - NetworkWeeklyBalanceConfiguration with UserId+WeekNumber index - WeeklyCommissionPoolConfiguration with unique WeekNumber - UserCommissionPayoutConfiguration with multiple indexes - ClubMembershipHistoryConfiguration for audit trail - NetworkMembershipHistoryConfiguration for audit trail - CommissionPayoutHistoryConfiguration for audit trail - SystemConfigurationHistoryConfiguration for audit trail Configuration Updates: - UserConfiguration: Add NetworkParentId, LegPosition with indexes - UserWalletConfiguration: Add DiscountBalance field - ProductsConfiguration: Add IsClubExclusive, ClubDiscountPercent with index Infrastructure Updates: - ApplicationDbContext: Add 11 new DbSets for network-club entities - GlobalUsings: Add Domain entity namespaces Migration: - AddNetworkClubSystemV2: Complete database schema for network-club system
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
|
||||
|
||||
/// <summary>
|
||||
/// پرداخت کمیسیون به کاربران
|
||||
/// </summary>
|
||||
public class UserCommissionPayoutConfiguration : IEntityTypeConfiguration<UserCommissionPayout>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<UserCommissionPayout> 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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user