diff --git a/src/CMSMicroservice.Application/ClubMembershipCQ/Commands/AcceptClubMembershipContract/AcceptClubMembershipContractCommandHandler.cs b/src/CMSMicroservice.Application/ClubMembershipCQ/Commands/AcceptClubMembershipContract/AcceptClubMembershipContractCommandHandler.cs index 2067b07..07821fd 100644 --- a/src/CMSMicroservice.Application/ClubMembershipCQ/Commands/AcceptClubMembershipContract/AcceptClubMembershipContractCommandHandler.cs +++ b/src/CMSMicroservice.Application/ClubMembershipCQ/Commands/AcceptClubMembershipContract/AcceptClubMembershipContractCommandHandler.cs @@ -1,5 +1,6 @@ using CMSMicroservice.Application.Common.Exceptions; using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Common; using CMSMicroservice.Domain.Entities; using CMSMicroservice.Domain.Entities.Club; using CMSMicroservice.Domain.Entities.Commission; @@ -126,38 +127,14 @@ public class AcceptClubMembershipContractCommandHandler }; await _context.UserContracts.AddAsync(userContract, cancellationToken); - // 6. دریافت مقادیر از تنظیمات سیستم - var giftValueConfig = await _context.SystemConfigurations - .FirstOrDefaultAsync( - c => c.Key == "Club.MembershipGiftValue" && c.IsActive, - cancellationToken - ); + // 6. دریافت مقادیر از SystemConstants (استاتیک) + long giftValue = SystemConstants.ClubMembershipGiftValue; + long activationFeeValue = SystemConstants.ClubActivationFee; - var activationFeeConfig = await _context.SystemConfigurations - .FirstOrDefaultAsync( - c => c.Key == "Club.ActivationFee" && c.IsActive, - cancellationToken - ); - - long giftValue = 28_000_000; // مقدار پیش‌فرض - if (giftValueConfig != null && long.TryParse(giftValueConfig.Value, out var configValue)) - { - giftValue = configValue; - _logger.LogInformation( - "Using Club.MembershipGiftValue from configuration: {GiftValue}", - giftValue - ); - } - - long activationFeeValue = 25_200_000; // مقدار پیش‌فرض - if (activationFeeConfig != null && long.TryParse(activationFeeConfig.Value, out var activationFeeConfigValue)) - { - activationFeeValue = activationFeeConfigValue; - _logger.LogInformation( - "Using Club.ActivationFee from configuration: {activationFeeValue}", - activationFeeValue - ); - } + _logger.LogInformation( + "Using Club.MembershipGiftValue: {GiftValue}, Club.ActivationFee: {ActivationFee}", + giftValue, activationFeeValue + ); // 7. فعال‌سازی باشگاه مشتریان ClubMembership clubMembership; diff --git a/src/CMSMicroservice.Application/ClubMembershipCQ/Commands/ActivateClubMembership/ActivateClubMembershipCommandHandler.cs b/src/CMSMicroservice.Application/ClubMembershipCQ/Commands/ActivateClubMembership/ActivateClubMembershipCommandHandler.cs index 57fef67..d890d98 100644 --- a/src/CMSMicroservice.Application/ClubMembershipCQ/Commands/ActivateClubMembership/ActivateClubMembershipCommandHandler.cs +++ b/src/CMSMicroservice.Application/ClubMembershipCQ/Commands/ActivateClubMembership/ActivateClubMembershipCommandHandler.cs @@ -1,6 +1,7 @@ using CMSMicroservice.Application.Common.Exceptions; using CMSMicroservice.Application.Common.Interfaces; using CMSMicroservice.Application.Common.Models; +using CMSMicroservice.Domain.Common; using CMSMicroservice.Domain.Entities; using CMSMicroservice.Domain.Entities.Club; using CMSMicroservice.Domain.Entities.Commission; @@ -75,7 +76,7 @@ public class ActivateClubMembershipCommandHandler : IRequestHandler c.UserId == user.Id, cancellationToken); - // 6.1. دریافت مبلغ هدیه از تنظیمات - var giftValueConfig = await _context.SystemConfigurations - .FirstOrDefaultAsync( - c => c.Key == "Club.MembershipGiftValue" && c.IsActive, - cancellationToken - ); + // 6.1. دریافت مبلغ هدیه و هزینه فعالسازی از SystemConstants + long giftValue = SystemConstants.ClubMembershipGiftValue; + long activationFeeValue = SystemConstants.ClubActivationFee; - var activationFeeConfig = await _context.SystemConfigurations - .FirstOrDefaultAsync( - c => c.Key == "Club.ActivationFee" && c.IsActive, - cancellationToken - ); - - long giftValue = 28_000_000; // مقدار پیش‌فرض - if (giftValueConfig != null && long.TryParse(giftValueConfig.Value, out var configValue)) - { - giftValue = configValue; - _logger.LogInformation( - "Using Club.MembershipGiftValue from configuration: {GiftValue}", - giftValue - ); - } - else - { - _logger.LogWarning( - "Club.MembershipGiftValue not found in configuration, using default: {GiftValue}", - giftValue - ); - } - long activationFeeValue = 25_200_000; // مقدار پیش‌فرض - if (activationFeeConfig != null && long.TryParse(activationFeeConfig.Value, out var activationFeeConfigValue)) - { - activationFeeValue = activationFeeConfigValue; - _logger.LogInformation( - "Using Club.ActivationFee from configuration: {activationFeeValue}", - activationFeeValue - ); - } - else - { - _logger.LogWarning( - "Club.ActivationFee not found in configuration, using default: {activationFeeValue}", - activationFeeValue - ); - } + _logger.LogInformation( + "Using Club.MembershipGiftValue: {GiftValue}, Club.ActivationFee: {ActivationFee}", + giftValue, activationFeeValue + ); ClubMembership entity; bool isNewMembership = existingMembership == null; diff --git a/src/CMSMicroservice.Application/CommissionCQ/Commands/CalculateWeeklyBalances/CalculateWeeklyBalancesCommandHandler.cs b/src/CMSMicroservice.Application/CommissionCQ/Commands/CalculateWeeklyBalances/CalculateWeeklyBalancesCommandHandler.cs index 7535301..ac83d4d 100644 --- a/src/CMSMicroservice.Application/CommissionCQ/Commands/CalculateWeeklyBalances/CalculateWeeklyBalancesCommandHandler.cs +++ b/src/CMSMicroservice.Application/CommissionCQ/Commands/CalculateWeeklyBalances/CalculateWeeklyBalancesCommandHandler.cs @@ -1,3 +1,5 @@ +using CMSMicroservice.Domain.Common; + namespace CMSMicroservice.Application.CommissionCQ.Commands.CalculateWeeklyBalances; public class CalculateWeeklyBalancesCommandHandler : IRequestHandler @@ -74,21 +76,11 @@ public class CalculateWeeklyBalancesCommandHandler : IRequestHandler(); var calculatedAt = DateTime.Now; - // خواندن یکباره Configuration ها (بهینه‌سازی - به جای N query) - var configs = await _context.SystemConfigurations - .Where(x => x.IsActive && ( - x.Key == "Club.ActivationFee" || - x.Key == "Commission.WeeklyPoolContributionPercent" || - x.Key == "Commission.MaxWeeklyBalancesPerLeg" || - x.Key == "Commission.MaxNetworkLevel")) - .ToDictionaryAsync(x => x.Key, x => x.Value, cancellationToken); - - // var activationFee = long.Parse(configs.GetValueOrDefault("Club.ActivationFee", "25000000")); - // var poolPercent = decimal.Parse(configs.GetValueOrDefault("Commission.WeeklyPoolContributionPercent", "20")) / 100m; + // استفاده از SystemConstants (استاتیک - بدون کوئری به دیتابیس) // سقف تعادل هفتگی برای هر دست (نه کل) - 300 برای چپ + 300 برای راست = حداکثر 600 تعادل - var maxBalancesPerLeg = int.Parse(configs.GetValueOrDefault("Commission.MaxWeeklyBalancesPerLeg", "300")); + var maxBalancesPerLeg = SystemConstants.CommissionMaxWeeklyBalancesPerLeg; // حداکثر عمق شبکه برای شمارش اعضا (15 لول) - var maxNetworkLevel = int.Parse(configs.GetValueOrDefault("Commission.MaxNetworkLevel", "15")); + var maxNetworkLevel = SystemConstants.CommissionMaxNetworkLevel; foreach (var user in usersInNetwork.OrderBy(o=>o.Id)) { diff --git a/src/CMSMicroservice.Application/CommissionCQ/Commands/ProcessUserPayouts/ProcessUserPayoutsCommandHandler.cs b/src/CMSMicroservice.Application/CommissionCQ/Commands/ProcessUserPayouts/ProcessUserPayoutsCommandHandler.cs index f53aba1..2051122 100644 --- a/src/CMSMicroservice.Application/CommissionCQ/Commands/ProcessUserPayouts/ProcessUserPayoutsCommandHandler.cs +++ b/src/CMSMicroservice.Application/CommissionCQ/Commands/ProcessUserPayouts/ProcessUserPayoutsCommandHandler.cs @@ -1,3 +1,5 @@ +using CMSMicroservice.Domain.Common; + namespace CMSMicroservice.Application.CommissionCQ.Commands.ProcessUserPayouts; public class ProcessUserPayoutsCommandHandler : IRequestHandler @@ -47,12 +49,8 @@ public class ProcessUserPayoutsCommandHandler : IRequestHandler x.Key == "Commission.MaxNetworkLevel" && x.IsActive) - .Select(x => x.Value) - .FirstOrDefaultAsync(cancellationToken); - var maxNetworkLevel = int.Parse(maxNetworkLevelConfig ?? "15"); + // ⭐ خواندن MaxNetworkLevel از SystemConstants (استاتیک) + var maxNetworkLevel = SystemConstants.CommissionMaxNetworkLevel; // دریافت همه تعادل‌های هفتگی (شامل صفرها هم برای محاسبه زیرمجموعه) var allWeeklyBalances = await _context.NetworkWeeklyBalances diff --git a/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs b/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs index 9b01342..95da562 100644 --- a/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs +++ b/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs @@ -31,8 +31,6 @@ public interface IApplicationDbContext DbSet UserPackagePurchases { get; } DbSet UserWallets { get; } DbSet UserWalletChangeLogs { get; } - DbSet SystemConfigurations { get; } - DbSet SystemConfigurationHistories { get; } DbSet ManualPayments { get; } DbSet PublicMessages { get; } DbSet ClubMemberships { get; } diff --git a/src/CMSMicroservice.Application/Common/Interfaces/IKavenegarService.cs b/src/CMSMicroservice.Application/Common/Interfaces/IKavenegarService.cs new file mode 100644 index 0000000..a8982bc --- /dev/null +++ b/src/CMSMicroservice.Application/Common/Interfaces/IKavenegarService.cs @@ -0,0 +1,17 @@ +namespace CMSMicroservice.Application.Common.Interfaces; + +/// +/// سرویس ارسال SMS با کاوه‌نگار +/// +public interface IKavenegarService +{ + /// + /// ارسال پیامک ساده + /// + Task SendAsync(string mobile, string message); + + /// + /// ارسال پیامک با قالب (VerifyLookup) + /// + Task VerifyLookupAsync(string mobile, string token, string template = "Afrino"); +} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/DeactivateConfiguration/DeactivateConfigurationCommand.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Commands/DeactivateConfiguration/DeactivateConfigurationCommand.cs deleted file mode 100644 index 589e7a9..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/DeactivateConfiguration/DeactivateConfigurationCommand.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Commands.DeactivateConfiguration; - -/// -/// Command برای غیرفعال کردن یک Configuration -/// -public record DeactivateConfigurationCommand : IRequest -{ - /// - /// شناسه Configuration - /// - public long ConfigurationId { get; init; } - - /// - /// دلیل غیرفعال‌سازی - /// - public string? Reason { get; init; } -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/DeactivateConfiguration/DeactivateConfigurationCommandHandler.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Commands/DeactivateConfiguration/DeactivateConfigurationCommandHandler.cs deleted file mode 100644 index 6d32fb5..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/DeactivateConfiguration/DeactivateConfigurationCommandHandler.cs +++ /dev/null @@ -1,51 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Commands.DeactivateConfiguration; - -public class DeactivateConfigurationCommandHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - private readonly ICurrentUserService _currentUser; - - public DeactivateConfigurationCommandHandler( - IApplicationDbContext context, - ICurrentUserService currentUser) - { - _context = context; - _currentUser = currentUser; - } - - public async Task Handle(DeactivateConfigurationCommand request, CancellationToken cancellationToken) - { - var entity = await _context.SystemConfigurations - .FirstOrDefaultAsync(x => x.Id == request.ConfigurationId, cancellationToken) - ?? throw new NotFoundException(nameof(SystemConfiguration), request.ConfigurationId); - - // اگر از قبل غیرفعال است، خطا ندهیم - if (!entity.IsActive) - { - return Unit.Value; - } - - var oldValue = entity.Value; - entity.IsActive = false; - - _context.SystemConfigurations.Update(entity); - await _context.SaveChangesAsync(cancellationToken); - - // ثبت تاریخچه - var history = new SystemConfigurationHistory - { - ConfigurationId = entity.Id, - Scope = entity.Scope, - Key = entity.Key, - OldValue = oldValue, - NewValue = entity.Value, - Reason = request.Reason ?? "Configuration deactivated", - PerformedBy = _currentUser.GetPerformedBy() - }; - - await _context.SystemConfigurationHistories.AddAsync(history, cancellationToken); - await _context.SaveChangesAsync(cancellationToken); - - return Unit.Value; - } -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/DeactivateConfiguration/DeactivateConfigurationCommandValidator.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Commands/DeactivateConfiguration/DeactivateConfigurationCommandValidator.cs deleted file mode 100644 index 74a0d8a..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/DeactivateConfiguration/DeactivateConfigurationCommandValidator.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Commands.DeactivateConfiguration; - -public class DeactivateConfigurationCommandValidator : AbstractValidator -{ - public DeactivateConfigurationCommandValidator() - { - RuleFor(x => x.ConfigurationId) - .GreaterThan(0) - .WithMessage("شناسه Configuration معتبر نیست"); - - RuleFor(x => x.Reason) - .MaximumLength(500) - .WithMessage("دلیل غیرفعال‌سازی نمی‌تواند بیشتر از 500 کاراکتر باشد") - .When(x => !string.IsNullOrEmpty(x.Reason)); - } - - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync( - ValidationContext.CreateWithOptions( - (DeactivateConfigurationCommand)model, - x => x.IncludeProperties(propertyName))); - - if (result.IsValid) - return Array.Empty(); - - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SeedVATConfiguration/SeedVATConfigurationCommand.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SeedVATConfiguration/SeedVATConfigurationCommand.cs deleted file mode 100644 index 5b3b1ac..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SeedVATConfiguration/SeedVATConfigurationCommand.cs +++ /dev/null @@ -1,77 +0,0 @@ -using CMSMicroservice.Application.Common.Interfaces; -using CMSMicroservice.Domain.Enums; -using MediatR; -using Microsoft.Extensions.Logging; - -namespace CMSMicroservice.Application.ConfigurationCQ.Commands.SeedVATConfiguration; - -/// -/// Seed initial VAT configuration -/// نرخ مالیات پیش‌فرض ۹٪ -/// -public class SeedVATConfigurationCommand : IRequest -{ -} - -public class SeedVATConfigurationCommandHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - private readonly ILogger _logger; - - public SeedVATConfigurationCommandHandler( - IApplicationDbContext context, - ILogger logger) - { - _context = context; - _logger = logger; - } - - public async Task Handle(SeedVATConfigurationCommand request, CancellationToken cancellationToken) - { - var configs = new[] - { - new - { - Scope = ConfigurationScope.VAT, - Key = "Rate", - Value = "0.09", - Description = "نرخ مالیات بر ارزش افزوده (۹٪)" - }, - new - { - Scope = ConfigurationScope.VAT, - Key = "IsEnabled", - Value = "true", - Description = "فعال/غیرفعال بودن محاسبه مالیات" - } - }; - - foreach (var config in configs) - { - var exists = _context.SystemConfigurations - .Any(x => x.Scope == config.Scope && x.Key == config.Key); - - if (!exists) - { - _context.SystemConfigurations.Add(new Domain.Entities.Configuration.SystemConfiguration - { - Scope = config.Scope, - Key = config.Key, - Value = config.Value, - Description = config.Description - }); - - _logger.LogInformation( - "VAT configuration seeded: {Scope}.{Key} = {Value}", - config.Scope, - config.Key, - config.Value - ); - } - } - - await _context.SaveChangesAsync(cancellationToken); - - return Unit.Value; - } -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SetConfigurationValue/SetConfigurationValueCommand.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SetConfigurationValue/SetConfigurationValueCommand.cs deleted file mode 100644 index 0189024..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SetConfigurationValue/SetConfigurationValueCommand.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Commands.SetConfigurationValue; - -/// -/// Command برای تنظیم یا به‌روزرسانی یک Configuration -/// -public record SetConfigurationValueCommand : IRequest -{ - /// - /// محدوده تنظیمات (System, Network, Club, Commission) - /// - public ConfigurationScope Scope { get; init; } - - /// - /// کلید یکتا برای تنظیمات - /// - public string Key { get; init; } - - /// - /// مقدار تنظیمات (JSON format) - /// - public string Value { get; init; } - - /// - /// توضیحات تنظیمات - /// - public string? Description { get; init; } - - /// - /// دلیل تغییر (برای History) - /// - public string? ChangeReason { get; init; } -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SetConfigurationValue/SetConfigurationValueCommandHandler.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SetConfigurationValue/SetConfigurationValueCommandHandler.cs deleted file mode 100644 index de23699..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SetConfigurationValue/SetConfigurationValueCommandHandler.cs +++ /dev/null @@ -1,78 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Commands.SetConfigurationValue; - -public class SetConfigurationValueCommandHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - private readonly ICurrentUserService _currentUser; - - public SetConfigurationValueCommandHandler( - IApplicationDbContext context, - ICurrentUserService currentUser) - { - _context = context; - _currentUser = currentUser; - } - - public async Task Handle(SetConfigurationValueCommand request, CancellationToken cancellationToken) - { - // بررسی وجود Configuration با همین Scope و Key - var existingConfig = await _context.SystemConfigurations - .FirstOrDefaultAsync(x => - x.Scope == request.Scope && - x.Key == request.Key, - cancellationToken); - - SystemConfiguration entity; - bool isNewRecord = existingConfig == null; - string oldValue = null; - - if (isNewRecord) - { - // ایجاد Configuration جدید - entity = new SystemConfiguration - { - Scope = request.Scope, - Key = request.Key, - Value = request.Value, - Description = request.Description, - IsActive = true - }; - - await _context.SystemConfigurations.AddAsync(entity, cancellationToken); - } - else - { - // به‌روزرسانی Configuration موجود - entity = existingConfig; - oldValue = entity.Value; - - entity.Value = request.Value; - - if (!string.IsNullOrEmpty(request.Description)) - { - entity.Description = request.Description; - } - - _context.SystemConfigurations.Update(entity); - } - - await _context.SaveChangesAsync(cancellationToken); - - // ثبت تاریخچه - var history = new SystemConfigurationHistory - { - ConfigurationId = entity.Id, - Scope = entity.Scope, - Key = entity.Key, - OldValue = oldValue, - NewValue = entity.Value, - Reason = request.ChangeReason ?? (isNewRecord ? "Initial creation" : "Value updated"), - PerformedBy = "System" // TODO: باید از Current User گرفته شود - }; - - await _context.SystemConfigurationHistories.AddAsync(history, cancellationToken); - await _context.SaveChangesAsync(cancellationToken); - - return entity.Id; - } -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SetConfigurationValue/SetConfigurationValueCommandValidator.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SetConfigurationValue/SetConfigurationValueCommandValidator.cs deleted file mode 100644 index b648bd8..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Commands/SetConfigurationValue/SetConfigurationValueCommandValidator.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Commands.SetConfigurationValue; - -public class SetConfigurationValueCommandValidator : AbstractValidator -{ - public SetConfigurationValueCommandValidator() - { - RuleFor(x => x.Scope) - .IsInEnum() - .WithMessage("محدوده تنظیمات معتبر نیست"); - - RuleFor(x => x.Key) - .NotEmpty() - .WithMessage("کلید تنظیمات الزامی است") - .MaximumLength(100) - .WithMessage("کلید تنظیمات نمی‌تواند بیشتر از 100 کاراکتر باشد") - .Matches(@"^[a-zA-Z0-9_\.]+$") - .WithMessage("کلید تنظیمات فقط می‌تواند شامل حروف انگلیسی، اعداد، نقطه و آندرلاین باشد"); - - RuleFor(x => x.Value) - .NotEmpty() - .WithMessage("مقدار تنظیمات الزامی است") - .MaximumLength(2000) - .WithMessage("مقدار تنظیمات نمی‌تواند بیشتر از 2000 کاراکتر باشد"); - - RuleFor(x => x.Description) - .MaximumLength(500) - .WithMessage("توضیحات نمی‌تواند بیشتر از 500 کاراکتر باشد") - .When(x => !string.IsNullOrEmpty(x.Description)); - - RuleFor(x => x.ChangeReason) - .MaximumLength(500) - .WithMessage("دلیل تغییر نمی‌تواند بیشتر از 500 کاراکتر باشد") - .When(x => !string.IsNullOrEmpty(x.ChangeReason)); - } - - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync( - ValidationContext.CreateWithOptions( - (SetConfigurationValueCommand)model, - x => x.IncludeProperties(propertyName))); - - if (result.IsValid) - return Array.Empty(); - - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetAllConfigurations/GetAllConfigurationsQuery.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetAllConfigurations/GetAllConfigurationsQuery.cs deleted file mode 100644 index a7cb564..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetAllConfigurations/GetAllConfigurationsQuery.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Queries.GetAllConfigurations; - -/// -/// Query برای دریافت لیست تمام Configuration ها با فیلتر -/// -public record GetAllConfigurationsQuery : IRequest -{ - /// - /// موقعیت صفحه‌بندی - /// - public PaginationState? PaginationState { get; init; } - - /// - /// مرتب‌سازی بر اساس - /// - public string? SortBy { get; init; } - - /// - /// فیلتر - /// - public GetAllConfigurationsFilter? Filter { get; init; } -} - -public class GetAllConfigurationsFilter -{ - /// - /// فیلتر بر اساس محدوده - /// - public ConfigurationScope? Scope { get; set; } - - /// - /// جستجو در کلید - /// - public string? KeyContains { get; set; } - - /// - /// فقط Configuration های فعال - /// - public bool? IsActive { get; set; } -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetAllConfigurations/GetAllConfigurationsQueryHandler.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetAllConfigurations/GetAllConfigurationsQueryHandler.cs deleted file mode 100644 index ba54924..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetAllConfigurations/GetAllConfigurationsQueryHandler.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Queries.GetAllConfigurations; - -public class GetAllConfigurationsQueryHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public GetAllConfigurationsQueryHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(GetAllConfigurationsQuery request, CancellationToken cancellationToken) - { - var query = _context.SystemConfigurations - .ApplyOrder(sortBy: request.SortBy) - .AsNoTracking() - .AsQueryable(); - - if (request.Filter is not null) - { - query = query - .Where(x => request.Filter.Scope == null || x.Scope == request.Filter.Scope) - .Where(x => request.Filter.KeyContains == null || x.Key.Contains(request.Filter.KeyContains)) - .Where(x => request.Filter.IsActive == null || x.IsActive == request.Filter.IsActive); - } - - var meta = await query.GetMetaData(request.PaginationState, cancellationToken); - - var models = await query - .PaginatedListAsync(paginationState: request.PaginationState) - .Select(x => new GetAllConfigurationsResponseModel - { - Id = x.Id, - Scope = x.Scope, - Key = x.Key, - Value = x.Value, - Description = x.Description, - IsActive = x.IsActive, - Created = x.Created, - LastModified = x.LastModified - }) - .ToListAsync(cancellationToken); - - return new GetAllConfigurationsResponseDto - { - MetaData = meta, - Models = models - }; - } -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetAllConfigurations/GetAllConfigurationsQueryValidator.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetAllConfigurations/GetAllConfigurationsQueryValidator.cs deleted file mode 100644 index f4fe276..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetAllConfigurations/GetAllConfigurationsQueryValidator.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Queries.GetAllConfigurations; - -public class GetAllConfigurationsQueryValidator : AbstractValidator -{ - public GetAllConfigurationsQueryValidator() - { - RuleFor(x => x.Filter.Scope) - .IsInEnum() - .WithMessage("محدوده تنظیمات معتبر نیست") - .When(x => x.Filter?.Scope != null); - } - - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync( - ValidationContext.CreateWithOptions( - (GetAllConfigurationsQuery)model, - x => x.IncludeProperties(propertyName))); - - if (result.IsValid) - return Array.Empty(); - - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetAllConfigurations/GetAllConfigurationsResponseDto.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetAllConfigurations/GetAllConfigurationsResponseDto.cs deleted file mode 100644 index 052d7d3..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetAllConfigurations/GetAllConfigurationsResponseDto.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Queries.GetAllConfigurations; - -public class GetAllConfigurationsResponseDto -{ - public MetaData MetaData { get; set; } - public List Models { get; set; } -} - -public class GetAllConfigurationsResponseModel -{ - public long Id { get; set; } - public ConfigurationScope Scope { get; set; } - public string Key { get; set; } - public string Value { get; set; } - public string? Description { get; set; } - public bool IsActive { get; set; } - public DateTimeOffset Created { get; set; } - public DateTimeOffset? LastModified { get; set; } -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationByKey/ConfigurationDto.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationByKey/ConfigurationDto.cs deleted file mode 100644 index 0796d8b..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationByKey/ConfigurationDto.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Queries.GetConfigurationByKey; - -/// -/// DTO برای نمایش اطلاعات Configuration -/// -public class ConfigurationDto -{ - public long Id { get; set; } - public ConfigurationScope Scope { get; set; } - public string Key { get; set; } - public string Value { get; set; } - public string? Description { get; set; } - public bool IsActive { get; set; } - public DateTimeOffset Created { get; set; } - public DateTimeOffset? LastModified { get; set; } -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationByKey/GetConfigurationByKeyQuery.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationByKey/GetConfigurationByKeyQuery.cs deleted file mode 100644 index 9f273f3..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationByKey/GetConfigurationByKeyQuery.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Queries.GetConfigurationByKey; - -/// -/// Query برای دریافت یک Configuration بر اساس Scope و Key -/// -public record GetConfigurationByKeyQuery : IRequest -{ - /// - /// محدوده تنظیمات - /// - public ConfigurationScope Scope { get; init; } - - /// - /// کلید تنظیمات - /// - public string Key { get; init; } -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationByKey/GetConfigurationByKeyQueryHandler.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationByKey/GetConfigurationByKeyQueryHandler.cs deleted file mode 100644 index 7a9e7e8..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationByKey/GetConfigurationByKeyQueryHandler.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Queries.GetConfigurationByKey; - -public class GetConfigurationByKeyQueryHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public GetConfigurationByKeyQueryHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(GetConfigurationByKeyQuery request, CancellationToken cancellationToken) - { - var config = await _context.SystemConfigurations - .AsNoTracking() - .Where(x => x.Scope == request.Scope && x.Key == request.Key) - .FirstOrDefaultAsync(cancellationToken); - - if (config == null) - return null; - - return new ConfigurationDto - { - Id = config.Id, - Scope = config.Scope, - Key = config.Key, - Value = config.Value, - Description = config.Description, - IsActive = config.IsActive, - Created = config.Created, - LastModified = config.LastModified - }; - } -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationByKey/GetConfigurationByKeyQueryValidator.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationByKey/GetConfigurationByKeyQueryValidator.cs deleted file mode 100644 index f743d22..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationByKey/GetConfigurationByKeyQueryValidator.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Queries.GetConfigurationByKey; - -public class GetConfigurationByKeyQueryValidator : AbstractValidator -{ - public GetConfigurationByKeyQueryValidator() - { - RuleFor(x => x.Scope) - .IsInEnum() - .WithMessage("محدوده تنظیمات معتبر نیست"); - - RuleFor(x => x.Key) - .NotEmpty() - .WithMessage("کلید تنظیمات الزامی است"); - } - - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync( - ValidationContext.CreateWithOptions( - (GetConfigurationByKeyQuery)model, - x => x.IncludeProperties(propertyName))); - - if (result.IsValid) - return Array.Empty(); - - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationHistory/GetConfigurationHistoryQuery.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationHistory/GetConfigurationHistoryQuery.cs deleted file mode 100644 index 44d9274..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationHistory/GetConfigurationHistoryQuery.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Queries.GetConfigurationHistory; - -/// -/// Query برای دریافت تاریخچه تغییرات یک Configuration -/// -public record GetConfigurationHistoryQuery : IRequest -{ - /// - /// شناسه Configuration - /// - public long ConfigurationId { get; init; } - - /// - /// موقعیت صفحه‌بندی - /// - public PaginationState? PaginationState { get; init; } - - /// - /// مرتب‌سازی بر اساس - /// - public string? SortBy { get; init; } -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationHistory/GetConfigurationHistoryQueryHandler.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationHistory/GetConfigurationHistoryQueryHandler.cs deleted file mode 100644 index c1b5e0f..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationHistory/GetConfigurationHistoryQueryHandler.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Queries.GetConfigurationHistory; - -public class GetConfigurationHistoryQueryHandler : IRequestHandler -{ - private readonly IApplicationDbContext _context; - - public GetConfigurationHistoryQueryHandler(IApplicationDbContext context) - { - _context = context; - } - - public async Task Handle(GetConfigurationHistoryQuery request, CancellationToken cancellationToken) - { - // بررسی وجود Configuration - var configExists = await _context.SystemConfigurations - .AnyAsync(x => x.Id == request.ConfigurationId, cancellationToken); - - if (!configExists) - { - throw new NotFoundException(nameof(SystemConfiguration), request.ConfigurationId); - } - - var query = _context.SystemConfigurationHistories - .Where(x => x.ConfigurationId == request.ConfigurationId) - .ApplyOrder(sortBy: request.SortBy ?? "Created") // پیش‌فرض: جدیدترین اول - .AsNoTracking() - .AsQueryable(); - - var meta = await query.GetMetaData(request.PaginationState, cancellationToken); - - var models = await query - .PaginatedListAsync(paginationState: request.PaginationState) - .Select(x => new GetConfigurationHistoryResponseModel - { - Id = x.Id, - ConfigurationId = x.ConfigurationId, - Scope = x.Scope, - Key = x.Key, - OldValue = x.OldValue, - NewValue = x.NewValue, - ChangeReason = x.Reason, - ChangedBy = x.PerformedBy, - Created = x.Created - }) - .ToListAsync(cancellationToken); - - return new GetConfigurationHistoryResponseDto - { - MetaData = meta, - Models = models - }; - } -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationHistory/GetConfigurationHistoryQueryValidator.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationHistory/GetConfigurationHistoryQueryValidator.cs deleted file mode 100644 index 8c71a50..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationHistory/GetConfigurationHistoryQueryValidator.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Queries.GetConfigurationHistory; - -public class GetConfigurationHistoryQueryValidator : AbstractValidator -{ - public GetConfigurationHistoryQueryValidator() - { - RuleFor(x => x.ConfigurationId) - .GreaterThan(0) - .WithMessage("شناسه Configuration معتبر نیست"); - } - - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync( - ValidationContext.CreateWithOptions( - (GetConfigurationHistoryQuery)model, - x => x.IncludeProperties(propertyName))); - - if (result.IsValid) - return Array.Empty(); - - return result.Errors.Select(e => e.ErrorMessage); - }; -} diff --git a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationHistory/GetConfigurationHistoryResponseDto.cs b/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationHistory/GetConfigurationHistoryResponseDto.cs deleted file mode 100644 index 48f795e..0000000 --- a/src/CMSMicroservice.Application/ConfigurationCQ/Queries/GetConfigurationHistory/GetConfigurationHistoryResponseDto.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace CMSMicroservice.Application.ConfigurationCQ.Queries.GetConfigurationHistory; - -public class GetConfigurationHistoryResponseDto -{ - public MetaData MetaData { get; set; } - public List Models { get; set; } -} - -public class GetConfigurationHistoryResponseModel -{ - public long Id { get; set; } - public long ConfigurationId { get; set; } - public ConfigurationScope Scope { get; set; } - public string Key { get; set; } - public string? OldValue { get; set; } - public string NewValue { get; set; } - public string ChangeReason { get; set; } - public string ChangedBy { get; set; } - public DateTimeOffset Created { get; set; } -} diff --git a/src/CMSMicroservice.Application/DayaLoanCQ/Commands/CheckDayaLoanStatus/CheckDayaLoanStatusCommandHandler.cs b/src/CMSMicroservice.Application/DayaLoanCQ/Commands/CheckDayaLoanStatus/CheckDayaLoanStatusCommandHandler.cs index 6fb89c6..0f2b57c 100644 --- a/src/CMSMicroservice.Application/DayaLoanCQ/Commands/CheckDayaLoanStatus/CheckDayaLoanStatusCommandHandler.cs +++ b/src/CMSMicroservice.Application/DayaLoanCQ/Commands/CheckDayaLoanStatus/CheckDayaLoanStatusCommandHandler.cs @@ -1,5 +1,6 @@ using CMSMicroservice.Domain.Events; using CMSMicroservice.Domain.Enums; +using CMSMicroservice.Domain.Common; using CMSMicroservice.Application.DayaLoanCQ.Services; using Microsoft.Extensions.Logging; @@ -10,11 +11,6 @@ public class CheckDayaLoanStatusCommandHandler : IRequestHandler _logger; - - /// - /// مبلغ وام دایا - 56 میلیون ریال - /// - private const long DAYA_LOAN_AMOUNT = 56_000_000; public CheckDayaLoanStatusCommandHandler( IApplicationDbContext context, @@ -69,7 +65,7 @@ public class CheckDayaLoanStatusCommandHandler : IRequestHandler - /// مبلغ کیف پول عادی (56 میلیون) + /// مبلغ کیف پول عادی /// - public long WalletAmount { get; init; } = 56_000_000; + public long WalletAmount { get; init; } = SystemConstants.DayaLoanAmount; /// - /// مبلغ کیف پول قفل شده (56 میلیون) + /// مبلغ کیف پول قفل شده /// - public long LockedWalletAmount { get; init; } = 56_000_000; + public long LockedWalletAmount { get; init; } = SystemConstants.DayaLoanAmount; /// - /// مبلغ کیف پول تخفیف (56 میلیون) + /// مبلغ کیف پول تخفیف (دو برابر) /// - public long DiscountWalletAmount { get; init; } = 56_000_000; + public long DiscountWalletAmount { get; init; } = SystemConstants.DayaLoanAmount * 2; } diff --git a/src/CMSMicroservice.Application/DayaLoanCQ/Commands/ProcessDayaLoanApproval/ProcessDayaLoanApprovalCommandHandler.cs b/src/CMSMicroservice.Application/DayaLoanCQ/Commands/ProcessDayaLoanApproval/ProcessDayaLoanApprovalCommandHandler.cs index 08958fd..1fb410d 100644 --- a/src/CMSMicroservice.Application/DayaLoanCQ/Commands/ProcessDayaLoanApproval/ProcessDayaLoanApprovalCommandHandler.cs +++ b/src/CMSMicroservice.Application/DayaLoanCQ/Commands/ProcessDayaLoanApproval/ProcessDayaLoanApprovalCommandHandler.cs @@ -76,22 +76,7 @@ public class ProcessDayaLoanApprovalCommandHandler : IRequestHandler p.Title.Contains("طلایی") || p.Title.Contains("Golden"), cancellationToken); + .FirstOrDefaultAsync(p => p.Id==4, cancellationToken); if (goldenPackage != null) { diff --git a/src/CMSMicroservice.Application/PackageCQ/Commands/InitiateBasePackagePayment/InitiateBasePackagePaymentCommandHandler.cs b/src/CMSMicroservice.Application/PackageCQ/Commands/InitiateBasePackagePayment/InitiateBasePackagePaymentCommandHandler.cs index fbc87cc..b921ab1 100644 --- a/src/CMSMicroservice.Application/PackageCQ/Commands/InitiateBasePackagePayment/InitiateBasePackagePaymentCommandHandler.cs +++ b/src/CMSMicroservice.Application/PackageCQ/Commands/InitiateBasePackagePayment/InitiateBasePackagePaymentCommandHandler.cs @@ -2,6 +2,7 @@ using CMSMicroservice.Application.Common.Exceptions; using CMSMicroservice.Application.Common.Interfaces; using CMSMicroservice.Domain.Entities; using CMSMicroservice.Domain.Enums; +using CMSMicroservice.Domain.Common; using MediatR; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; @@ -19,11 +20,6 @@ public class InitiateBasePackagePaymentCommandHandler : IRequestHandler _logger; - /// - /// مبلغ پکیج پایه (56 میلیون تومان) - /// - private const long BasePackageAmount = 56_000_000; - /// /// شناسه پکیج پایه در دیتابیس /// @@ -97,7 +93,7 @@ public class InitiateBasePackagePaymentCommandHandler : IRequestHandler _logger; - - /// - /// مبلغ پکیج پایه (56 میلیون تومان) - /// - private const long BasePackageAmount = 56_000_000; public VerifyBasePackagePaymentCommandHandler( IApplicationDbContext context, @@ -136,8 +132,8 @@ public class VerifyBasePackagePaymentCommandHandler : IRequestHandler {NewBalance}, DiscountBalance: {OldDiscount} -> {NewDiscount}", @@ -157,11 +153,11 @@ public class VerifyBasePackagePaymentCommandHandler : IRequestHandler f.Scope == ConfigurationScope.VAT && f.Key == "IsEnabled")?.Value ?? - "0"; - if (vatIsEnable=="1") + + // استفاده از SystemConstants برای VAT + if (SystemConstants.ShopVATEnabled) { - _vatRate = float.Parse( - _context.SystemConfigurations - .FirstOrDefault(f => f.Scope == ConfigurationScope.VAT && f.Key == "Shop.VAT")?.Value ?? - throw new InvalidOperationException()); + _vatRate = (float)SystemConstants.ShopVAT; finalAmount = AddVAT(user.UserCarts.Sum(s => s.Count * s.Product.Price)); _logger.LogInformation( "Calculating final amount with VAT. Base Amount: {BaseAmount}, VAT Rate: {VATRate}, Final Amount: {FinalAmount}", @@ -147,7 +143,7 @@ public class { ProductId = s.ProductId, Count = s.Count, - UnitPrice =vatIsEnable=="1" ?AddVAT(s.Product.Price): s.Product.Price, + UnitPrice = SystemConstants.ShopVATEnabled ? AddVAT(s.Product.Price) : s.Product.Price, OrderId = newOrder.Id }); await _context.FactorDetails.AddRangeAsync(factorDetailsList, cancellationToken); @@ -183,25 +179,15 @@ public class { try { - // بررسی فعال بودن VAT - var vatEnabledConfig = await _context.SystemConfigurations - .FirstOrDefaultAsync(x => x.Scope == ConfigurationScope.VAT && x.Key == "IsEnabled", cancellationToken); - - if (vatEnabledConfig == null || !bool.TryParse(vatEnabledConfig.Value, out var isEnabled) || !isEnabled) + // بررسی فعال بودن VAT از SystemConstants + if (!SystemConstants.ShopVATEnabled) { _logger.LogInformation("VAT is disabled. Skipping VAT calculation for order {OrderId}", orderId); return false; } - // دریافت نرخ VAT - var vatRateConfig = await _context.SystemConfigurations - .FirstOrDefaultAsync(x => x.Scope == ConfigurationScope.VAT && x.Key == "Shop.VAT", cancellationToken); - - if (vatRateConfig == null || !decimal.TryParse(vatRateConfig.Value, out var vatRate)) - { - _logger.LogWarning("VAT Rate configuration not found or invalid. Using default 0.09"); - vatRate = 0.09m; - } + // دریافت نرخ VAT از SystemConstants + var vatRate = SystemConstants.ShopVAT; // محاسبه مالیات var vatAmount = (long)(orderAmount * vatRate); diff --git a/src/CMSMicroservice.Domain/Common/SystemConstants.cs b/src/CMSMicroservice.Domain/Common/SystemConstants.cs new file mode 100644 index 0000000..34c35b1 --- /dev/null +++ b/src/CMSMicroservice.Domain/Common/SystemConstants.cs @@ -0,0 +1,176 @@ +namespace CMSMicroservice.Domain.Common; + +/// +/// تنظیمات ثابت سیستم - Static و در مموری +/// این مقادیر هرگز تغییر نمی‌کنند و نیازی به جدول ندارند +/// +public static class SystemConstants +{ + #region Network Settings + + /// + /// اجازه حذف والدین که فرزند دارند + /// + public const bool NetworkAllowOrphanNodes = false; + + /// + /// حداکثر تعداد فرزند مستقیم در هر پا + /// + public const int NetworkMaxChildrenPerLeg = 1; + + #endregion + + #region Club Settings + + /// + /// مبلغ هدیه حق عضویت باشگاه (ریال) - این مبلغ از کیف پول کم نمی‌شود + /// + public const long ClubMembershipGiftValue = 25_200_000; + + /// + /// هزینه فعال‌سازی عضویت باشگاه (ریال) + /// + public const long ClubActivationFee = 25_200_000; + + #endregion + + #region Package Settings + + /// + /// مبلغ پکیج طلایی / پایه (ریال) - 56 میلیون تومان + /// شامل: هدیه باشگاه + هزینه فعال‌سازی + مزایای دیگر + /// + public const long BasePackageAmount = 56_000_000; + + /// + /// مبلغ وام دایا (ریال) - همان مبلغ پکیج طلایی + /// + public const long DayaLoanAmount = 56_000_000; + + #endregion + + #region Commission Settings + + /// + /// امکان برداشت نقدی فعال باشد + /// + public const bool CommissionCashWithdrawalEnabled = true; + + /// + /// حداقل مبلغ برداشت (ریال) + /// + public const long CommissionMinWithdrawalAmount = 1_000_000; + + /// + /// سقف تعادل هفتگی برای هر دست (چپ یا راست) - حداکثر کل = 600 + /// + public const int CommissionMaxWeeklyBalancesPerLeg = 300; + + /// + /// حداکثر عمق شبکه برای محاسبه کمیسیون (تعداد لول زیرمجموعه) + /// + public const int CommissionMaxNetworkLevel = 15; + + /// + /// روش محاسبه (ORM یا SP) + /// + public const string CommissionCalculationStrategy = "SP"; + + #endregion + + #region System Settings + + /// + /// حالت تعمیر و نگهداری سیستم + /// + public const bool SystemMaintenanceMode = false; + + /// + /// فعال‌سازی لاگ تغییرات + /// + public const bool SystemEnableAuditLog = true; + + #endregion + + #region Shop Settings + + /// + /// مالیات بر ارزش افزوده (10%) + /// + public const decimal ShopVAT = 0.1m; + + /// + /// مالیات فعال است؟ + /// + public const bool ShopVATEnabled = true; + + #endregion + + #region Helper Methods + + /// + /// دریافت مقدار به صورت دیکشنری برای نمایش در Admin Panel + /// + public static Dictionary GetAllAsDict() + { + return new Dictionary + { + // Network + ["Network.AllowOrphanNodes"] = NetworkAllowOrphanNodes, + ["Network.MaxChildrenPerLeg"] = NetworkMaxChildrenPerLeg, + + // Club + ["Club.MembershipGiftValue"] = ClubMembershipGiftValue, + ["Club.ActivationFee"] = ClubActivationFee, + + // Commission + ["Commission.CashWithdrawalEnabled"] = CommissionCashWithdrawalEnabled, + ["Commission.MinWithdrawalAmount"] = CommissionMinWithdrawalAmount, + ["Commission.MaxWeeklyBalancesPerLeg"] = CommissionMaxWeeklyBalancesPerLeg, + ["Commission.MaxNetworkLevel"] = CommissionMaxNetworkLevel, + ["Commission.CalculationStrategy"] = CommissionCalculationStrategy, + + // System + ["System.MaintenanceMode"] = SystemMaintenanceMode, + ["System.EnableAuditLog"] = SystemEnableAuditLog, + + // Shop + ["Shop.VAT"] = ShopVAT, + ["Shop.VATEnabled"] = ShopVATEnabled + }; + } + + /// + /// دریافت لیست تنظیمات با توضیحات + /// + public static List<(string Key, object Value, string Description)> GetAllWithDescriptions() + { + return new List<(string Key, object Value, string Description)> + { + // Network + ("Network.AllowOrphanNodes", NetworkAllowOrphanNodes, "اجازه حذف والدین که فرزند دارند"), + ("Network.MaxChildrenPerLeg", NetworkMaxChildrenPerLeg, "حداکثر تعداد فرزند مستقیم در هر پا"), + + // Club + ("Club.MembershipGiftValue", ClubMembershipGiftValue, "مبلغ هدیه حق عضویت باشگاه (ریال)"), + ("Club.ActivationFee", ClubActivationFee, "هزینه فعال‌سازی عضویت باشگاه (ریال)"), + + // Commission + ("Commission.CashWithdrawalEnabled", CommissionCashWithdrawalEnabled, "امکان برداشت نقدی فعال باشد"), + ("Commission.MinWithdrawalAmount", CommissionMinWithdrawalAmount, "حداقل مبلغ برداشت (ریال)"), + ("Commission.MaxWeeklyBalancesPerLeg", CommissionMaxWeeklyBalancesPerLeg, "سقف تعادل هفتگی برای هر دست"), + ("Commission.MaxNetworkLevel", CommissionMaxNetworkLevel, "حداکثر عمق شبکه برای محاسبه کمیسیون"), + ("Commission.CalculationStrategy", CommissionCalculationStrategy, "روش محاسبه (ORM/SP)"), + + // System + ("System.MaintenanceMode", SystemMaintenanceMode, "حالت تعمیر و نگهداری سیستم"), + ("System.EnableAuditLog", SystemEnableAuditLog, "فعال‌سازی لاگ تغییرات"), + + // Shop + ("Shop.VAT", ShopVAT, "مالیات بر ارزش افزوده"), + ("Shop.VATEnabled", ShopVATEnabled, "مالیات فعال است؟") + }; + } + + #endregion +} diff --git a/src/CMSMicroservice.Domain/Entities/Configuration/SystemConfiguration.cs b/src/CMSMicroservice.Domain/Entities/Configuration/SystemConfiguration.cs deleted file mode 100644 index 3281388..0000000 --- a/src/CMSMicroservice.Domain/Entities/Configuration/SystemConfiguration.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace CMSMicroservice.Domain.Entities.Configuration; - -/// -/// تنظیمات پویای سیستم - قابل تغییر بدون Deployment -/// -public class SystemConfiguration : BaseAuditableEntity -{ - /// - /// محدوده تنظیمات (System, Network, Club, Commission) - /// - public ConfigurationScope Scope { get; set; } - - /// - /// کلید تنظیم (مثلاً "MaxWeeklyBalancesPerUser") - /// - public string Key { get; set; } - - /// - /// مقدار به‌صورت رشته (تفسیر در Application Layer) - /// - public string Value { get; set; } - - /// - /// نوع داده برای Validation و UI (Int/Decimal/Bool/String/Json) - /// - public string? DataType { get; set; } - - /// - /// توضیحات برای ادمین - /// - public string? Description { get; set; } - - /// - /// فعال یا غیرفعال - /// - public bool IsActive { get; set; } - - /// - /// SystemConfigurationHistory Collection Navigation Reference - /// - public virtual ICollection? SystemConfigurationHistories { get; set; } -} diff --git a/src/CMSMicroservice.Domain/Entities/History/SystemConfigurationHistory.cs b/src/CMSMicroservice.Domain/Entities/History/SystemConfigurationHistory.cs deleted file mode 100644 index e7f980c..0000000 --- a/src/CMSMicroservice.Domain/Entities/History/SystemConfigurationHistory.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace CMSMicroservice.Domain.Entities.History; - -/// -/// تاریخچه تغییرات تنظیمات سیستم (برای Audit) -/// -public class SystemConfigurationHistory : BaseAuditableEntity -{ - /// - /// شناسه تنظیم - /// - public long ConfigurationId { get; set; } - - /// - /// SystemConfiguration Navigation Property - /// - public virtual SystemConfiguration? Configuration { get; set; } - - /// - /// محدوده تنظیمات - /// - public ConfigurationScope Scope { get; set; } - - /// - /// کلید تنظیم - /// - public string Key { get; set; } - - /// - /// مقدار قبل از تغییر - /// - public string OldValue { get; set; } - - /// - /// مقدار بعد از تغییر - /// - public string NewValue { get; set; } - - /// - /// دلیل تغییر (اختیاری) - /// - public string? Reason { get; set; } - - /// - /// چه کسی انجام داده (UserId یا "System") - /// - public string? PerformedBy { get; set; } -} diff --git a/src/CMSMicroservice.Domain/Enums/ConfigurationScope.cs b/src/CMSMicroservice.Domain/Enums/ConfigurationScope.cs deleted file mode 100644 index 71b7127..0000000 --- a/src/CMSMicroservice.Domain/Enums/ConfigurationScope.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace CMSMicroservice.Domain.Enums; - -/// -/// محدوده تنظیمات سیستم (Scope) -/// -public enum ConfigurationScope -{ - /// - /// تنظیمات کلی سیستم - /// - System = 0, - - /// - /// تنظیمات شبکه باینری - /// - Network = 1, - - /// - /// تنظیمات باشگاه مشتریان - /// - Club = 2, - - /// - /// تنظیمات کمیسیون - /// - Commission = 3, - - /// - /// تنظیمات مالیات بر ارزش افزوده - /// - VAT = 4 -} diff --git a/src/CMSMicroservice.Infrastructure/ConfigureServices.cs b/src/CMSMicroservice.Infrastructure/ConfigureServices.cs index 496a87e..4a7ed35 100644 --- a/src/CMSMicroservice.Infrastructure/ConfigureServices.cs +++ b/src/CMSMicroservice.Infrastructure/ConfigureServices.cs @@ -34,6 +34,7 @@ public static class ConfigureServices services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); // Daya Loan API Service - قابل تغییر بین Mock و Real var useMockDayaApi = configuration.GetValue("DayaApi:UseMock", false); diff --git a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs index 2ccc451..e44cc12 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs @@ -84,9 +84,7 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext // ============= Network Club System DbSets ============= - // Configuration - public DbSet SystemConfigurations => Set(); - public DbSet SystemConfigurationHistories => Set(); + // App Version public DbSet AppVersions => Set(); // Club Management diff --git a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContextInitialiser.cs b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContextInitialiser.cs index b7ca4d8..eef582f 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContextInitialiser.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContextInitialiser.cs @@ -1,12 +1,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; -using CMSMicroservice.Domain.Entities.Configuration; -using CMSMicroservice.Domain.Enums; -using System.Collections.Generic; namespace CMSMicroservice.Infrastructure.Persistence; -public class ApplicationDbContextInitialiser +public class ApplicationDbContextInitialiser { private readonly ApplicationDbContext _context; private readonly ILogger _logger; @@ -32,6 +29,7 @@ public class ApplicationDbContextInitialiser throw; } } + public async Task SeedAsync() { try @@ -44,113 +42,12 @@ public class ApplicationDbContextInitialiser throw; } } - public async Task TrySeedAsync() + + public Task TrySeedAsync() { - // Seed / upsert default System Configurations for Network-Club-Commission System - var desiredConfigurations = new List - { - // Network Configuration - new SystemConfiguration - { - Key = "Network.MaxNetworkDepth", - Value = "15", - Description = "حداکثر عمق شبکه باینری", - Scope = ConfigurationScope.Network, - IsActive = true - }, - new SystemConfiguration - { - Key = "Network.MaxChildrenPerLeg", - Value = "1", - Description = "حداکثر تعداد فرزند مستقیم در هر پا", - Scope = ConfigurationScope.Network, - IsActive = true - }, - - // Commission Configuration - new SystemConfiguration - { - Key = "Commission.MaxWeeklyBalancesPerLeg", - Value = "300", - Description = "سقف تعادل هفتگی برای هر دست (چپ یا راست) - حداکثر کل = 600", - Scope = ConfigurationScope.Commission, - IsActive = true - }, - new SystemConfiguration - { - Key = "Commission.MaxNetworkLevel", - Value = "15", - Description = "حداکثر عمق شبکه برای محاسبه کمیسیون (تعداد لول زیرمجموعه)", - Scope = ConfigurationScope.Commission, - IsActive = true - }, - new SystemConfiguration - { - Key = "Commission.MinWithdrawalAmount", - Value = "1000000", - Description = "حداقل مبلغ برداشت (ریال)", - Scope = ConfigurationScope.Commission, - IsActive = true - }, - new SystemConfiguration - { - Key = "Commission.DefaultInitialContribution", - Value = "25000000", - Description = "مبلغ پیش‌فرض مشارکت/هزینه فعال‌سازی", - Scope = ConfigurationScope.Commission, - IsActive = true - }, - new SystemConfiguration - { - Key = "Commission.WeeklyPoolContributionPercent", - Value = "20", - Description = "درصد مشارکت در استخر هفتگی از کل فعال‌سازی‌های جدید شبکه (20%)", - Scope = ConfigurationScope.Commission, - IsActive = true - }, - - // Club Configuration - new SystemConfiguration - { - Key = "Club.ActivationFee", - Value = "25000000", - Description = "هزینه فعال‌سازی عضویت باشگاه (ریال)", - Scope = ConfigurationScope.Club, - IsActive = true - }, - new SystemConfiguration - { - Key = "Club.MembershipGiftValue", - Value = "25200000", - Description = "مبلغ هدیه حق عضویت باشگاه (ریال) - این مبلغ از کیف پول کم نمی‌شود", - Scope = ConfigurationScope.Club, - IsActive = true - }, - - // System Configuration - new SystemConfiguration - { - Key = "System.EnableAuditLog", - Value = "true", - Description = "فعال‌سازی لاگ تغییرات", - Scope = ConfigurationScope.System, - IsActive = true - } - }; - - var existingKeys = _context.SystemConfigurations - .Select(c => c.Key) - .ToHashSet(StringComparer.OrdinalIgnoreCase); - - var newConfigs = desiredConfigurations - .Where(c => !existingKeys.Contains(c.Key)) - .ToList(); - - if (newConfigs.Any()) - { - await _context.SystemConfigurations.AddRangeAsync(newConfigs); - await _context.SaveChangesAsync(); - _logger.LogInformation("Seeded {Count} default system configurations", newConfigs.Count); - } + // SystemConfigurations دیگه در دیتابیس نیست + // مقادیر کانفیگ حالا در SystemConstants.cs به صورت const تعریف شدن + _logger.LogInformation("Database seeding completed. System configurations are now defined as compile-time constants in SystemConstants.cs"); + return Task.CompletedTask; } } diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/SystemConfigurationConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/SystemConfigurationConfiguration.cs deleted file mode 100644 index 8d8f111..0000000 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/SystemConfigurationConfiguration.cs +++ /dev/null @@ -1,35 +0,0 @@ -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 deleted file mode 100644 index cfec350..0000000 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/SystemConfigurationHistoryConfiguration.cs +++ /dev/null @@ -1,41 +0,0 @@ -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/Migrations/20251226051932_RemoveSystemConfigurationsTables.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251226051932_RemoveSystemConfigurationsTables.Designer.cs new file mode 100644 index 0000000..b5b2df4 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251226051932_RemoveSystemConfigurationsTables.Designer.cs @@ -0,0 +1,3561 @@ +// +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("20251226051932_RemoveSystemConfigurationsTables")] + partial class RemoveSystemConfigurationsTables + { + /// + 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("Categories", "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("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("GiftValue") + .HasColumnType("bigint"); + + 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("PurchaseMethod") + .HasColumnType("int"); + + 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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + 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("BankReferenceId") + .HasColumnType("nvarchar(max)"); + + b.Property("BankTrackingCode") + .HasColumnType("nvarchar(max)"); + + 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("PaymentFailureReason") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedAt") + .HasColumnType("datetime2"); + + b.Property("ProcessedBy") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("ValuePerBalance") + .HasColumnType("bigint"); + + b.Property("WeekDefinitionId") + .HasColumnType("bigint"); + + 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("WeekDefinitionId"); + + b.HasIndex("WeeklyPoolId") + .HasDatabaseName("IX_UserCommissionPayout_WeeklyPoolId"); + + b.HasIndex("UserId", "WeekDefinitionId") + .IsUnique() + .HasDatabaseName("IX_UserCommissionPayout_UserId_WeekDefinitionId"); + + 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("WeekDefinitionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("IsCalculated") + .HasDatabaseName("IX_WeeklyCommissionPool_IsCalculated"); + + b.HasIndex("WeekDefinitionId") + .IsUnique() + .HasDatabaseName("IX_WeeklyCommissionPool_WeekDefinitionId"); + + b.ToTable("WeeklyCommissionPools", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.WorkerExecutionLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CompletedAt") + .HasColumnType("datetime2"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("DurationMs") + .HasColumnType("bigint"); + + b.Property("ErrorCount") + .HasColumnType("int"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ErrorStackTrace") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutionId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedCount") + .HasColumnType("int"); + + b.Property("StartedAt") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("WeekDefinitionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("StartedAt"); + + b.HasIndex("Status"); + + b.HasIndex("WeekDefinitionId"); + + b.ToTable("WorkerExecutionLogs", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.AppVersion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AppName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentVersion") + .IsRequired() + .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("MinRequiredVersion") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ReleaseNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("RequiresFullCacheClear") + .HasColumnType("bit"); + + b.Property("UpdateMessage") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AppVersions", "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.DayaLoanContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ContractNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsProcessed") + .HasColumnType("bit"); + + b.Property("LastCheckDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("NationalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessedDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.ToTable("DayaLoanContracts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", 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("ImagePath") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentCategoryId") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("ParentCategoryId"); + + b.ToTable("DiscountCategories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrder", 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("DeliveryDescription") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("DeliveryStatus") + .HasColumnType("int"); + + b.Property("DiscountBalanceUsed") + .HasColumnType("bigint"); + + b.Property("GatewayAmountPaid") + .HasColumnType("bigint"); + + 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("TotalAmount") + .HasColumnType("bigint"); + + b.Property("TrackingCode") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserAddressId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("VatAmount") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("DiscountOrders", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrderDetail", 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("DiscountAmount") + .HasColumnType("bigint"); + + b.Property("DiscountOrderId") + .HasColumnType("bigint"); + + b.Property("DiscountPercentUsed") + .HasColumnType("int"); + + b.Property("FinalPrice") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("bigint"); + + b.Property("UnitPrice") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DiscountOrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("DiscountOrderDetails", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", 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("FullInformation") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ImagePath") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("MaxDiscountPercent") + .HasColumnType("int"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Rate") + .HasColumnType("int"); + + b.Property("RemainingCount") + .HasColumnType("int"); + + b.Property("SaleCount") + .HasColumnType("int"); + + b.Property("ShortInfomation") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ViewCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("DiscountProducts", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProductCategory", 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", "CategoryId") + .IsUnique(); + + b.ToTable("DiscountProductCategories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountShoppingCart", 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", "ProductId") + .IsUnique(); + + b.ToTable("DiscountShoppingCarts", "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("FactorDetails", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Geography.City", 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("ExternalId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Latitude") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Longitude") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Native") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)") + .HasDefaultValue(""); + + b.Property("StateId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("StateId") + .HasDatabaseName("IX_Cities_StateId"); + + b.ToTable("Cities", "GMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Geography.Country", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Capital") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CurrencyName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CurrencySymbol") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Emoji") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("EmojiU") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ExternalId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("Iso2") + .IsRequired() + .HasMaxLength(2) + .HasColumnType("nvarchar(2)"); + + b.Property("Iso3") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Latitude") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Longitude") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Native") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("NumericCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("PhoneCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Region") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Subregion") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Tld") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("Id"); + + b.ToTable("Countries", "GMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Geography.State", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CountryId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ExternalId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Latitude") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Longitude") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Native") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)") + .HasDefaultValue(""); + + b.Property("StateCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("CountryId") + .HasDatabaseName("IX_States_CountryId"); + + b.ToTable("States", "GMS"); + }); + + 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("WeekDefinitionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Action") + .HasDatabaseName("IX_CommissionPayoutHistory_Action"); + + b.HasIndex("UserCommissionPayoutId") + .HasDatabaseName("IX_CommissionPayoutHistory_PayoutId"); + + b.HasIndex("WeekDefinitionId") + .HasDatabaseName("IX_CommissionPayoutHistory_WeekDefinitionId"); + + 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.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("FlushedPerSide") + .HasColumnType("int"); + + 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("LeftLegCarryover") + .HasColumnType("int"); + + b.Property("LeftLegNewMembers") + .HasColumnType("int"); + + b.Property("LeftLegRemainder") + .HasColumnType("int"); + + b.Property("LeftLegTotal") + .HasColumnType("int"); + + b.Property("RightLegBalances") + .HasColumnType("int"); + + b.Property("RightLegCarryover") + .HasColumnType("int"); + + b.Property("RightLegNewMembers") + .HasColumnType("int"); + + b.Property("RightLegRemainder") + .HasColumnType("int"); + + b.Property("RightLegTotal") + .HasColumnType("int"); + + b.Property("SubordinateBalances") + .HasColumnType("int"); + + b.Property("TotalBalances") + .HasColumnType("int"); + + b.Property("TotalFlushed") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeekDefinitionId") + .HasColumnType("bigint"); + + b.Property("WeeklyPoolContribution") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("IsExpired") + .HasDatabaseName("IX_NetworkWeeklyBalance_IsExpired"); + + b.HasIndex("WeekDefinitionId") + .HasDatabaseName("IX_NetworkWeeklyBalance_WeekDefinitionId"); + + b.HasIndex("UserId", "WeekDefinitionId") + .IsUnique() + .HasDatabaseName("IX_NetworkWeeklyBalance_UserId_WeekDefinitionId"); + + b.ToTable("NetworkWeeklyBalances", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Order.OrderVAT", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BaseAmount") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsPaid") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("PaidAt") + .HasColumnType("datetime2"); + + b.Property("TotalAmount") + .HasColumnType("bigint"); + + b.Property("VATAmount") + .HasColumnType("bigint"); + + b.Property("VATRate") + .HasColumnType("decimal(5,4)"); + + b.HasKey("Id"); + + b.HasIndex("Created") + .HasDatabaseName("IX_OrderVATs_Created"); + + b.HasIndex("IsPaid") + .HasDatabaseName("IX_OrderVATs_IsPaid"); + + b.HasIndex("OrderId") + .IsUnique() + .HasDatabaseName("IX_OrderVATs_OrderId"); + + b.ToTable("OrderVATs", "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.Payment.ManualPayment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("ApprovedAt") + .HasColumnType("datetime2"); + + b.Property("ApprovedBy") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferenceNumber") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("RejectionReason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RequestedBy") + .HasColumnType("bigint"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ApprovedBy"); + + b.HasIndex("Created"); + + b.HasIndex("RequestedBy"); + + b.HasIndex("Status"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId"); + + b.HasIndex("UserId", "Status"); + + b.ToTable("ManualPayments", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Product", 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("Products", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductCategory", 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("ProductCategories", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallery", 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("ProductGalleries", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImage", 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("ProductImages", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductTag", 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("ProductTags", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.PublicMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ArchivedAt") + .HasColumnType("datetime2"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedByUserId") + .HasColumnType("bigint"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsArchived") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LinkText") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LinkUrl") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("PublishedAt") + .HasColumnType("datetime2"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("StartsAt") + .HasColumnType("datetime2"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("ViewCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId") + .HasDatabaseName("IX_PublicMessages_CreatedByUserId"); + + b.HasIndex("ExpiresAt") + .HasDatabaseName("IX_PublicMessages_ExpiresAt"); + + b.HasIndex("IsActive") + .HasDatabaseName("IX_PublicMessages_IsActive"); + + b.HasIndex("Priority") + .HasDatabaseName("IX_PublicMessages_Priority"); + + b.HasIndex("StartsAt") + .HasDatabaseName("IX_PublicMessages_StartsAt"); + + b.HasIndex("Type") + .HasDatabaseName("IX_PublicMessages_Type"); + + b.HasIndex("IsActive", "ExpiresAt") + .HasDatabaseName("IX_PublicMessages_IsActive_ExpiresAt"); + + b.ToTable("PublicMessages", "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.Transaction", 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("Transactions", "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("DayaCreditReceivedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailNotifications") + .HasColumnType("bit"); + + b.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property("HasReceivedDayaCredit") + .HasColumnType("bit"); + + 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("PackagePurchaseMethod") + .HasColumnType("int"); + + 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.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("UserAddresses", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCart", 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("UserCarts", "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("HasVAT") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderVATId") + .HasColumnType("bigint"); + + 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("OrderVATId"); + + b.HasIndex("PackageId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("UserOrders", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", 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("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("bigint"); + + b.Property("PackageId") + .HasColumnType("bigint"); + + b.Property("PurchaseMethod") + .HasColumnType("int"); + + b.Property("PurchasedAt") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("PackageId") + .HasDatabaseName("IX_UserPackagePurchase_PackageId"); + + b.HasIndex("PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_PurchasedAt"); + + b.HasIndex("TransactionId"); + + b.HasIndex("UserId") + .HasDatabaseName("IX_UserPackagePurchase_UserId"); + + b.HasIndex("UserId", "PurchasedAt") + .HasDatabaseName("IX_UserPackagePurchase_UserId_PurchasedAt"); + + b.ToTable("UserPackagePurchases", "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("ChangeDiscountValue") + .HasColumnType("bigint"); + + 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("CurrentDiscountBalance") + .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.WeekDefinition", 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("DisplayName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("GregorianWeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("GregorianYear") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("PersianWeekNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PersianYear") + .HasColumnType("int"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("WeekOrder") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("GregorianWeekNumber") + .IsUnique() + .HasDatabaseName("IX_WeekDefinition_GregorianWeekNumber"); + + b.HasIndex("GregorianYear") + .HasDatabaseName("IX_WeekDefinition_GregorianYear"); + + b.HasIndex("PersianWeekNumber") + .HasDatabaseName("IX_WeekDefinition_PersianWeekNumber"); + + b.HasIndex("PersianYear") + .HasDatabaseName("IX_WeekDefinition_PersianYear"); + + b.HasIndex("StartDate") + .HasDatabaseName("IX_WeekDefinition_StartDate"); + + b.ToTable("WeekDefinitions", "CMS"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Category", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Parent") + .WithMany("Categories") + .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.WeekDefinition", "WeekDefinition") + .WithMany("UserCommissionPayouts") + .HasForeignKey("WeekDefinitionId") + .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("WeekDefinition"); + + b.Navigation("WeeklyPool"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.WeeklyCommissionPool", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.WeekDefinition", "WeekDefinition") + .WithMany("WeeklyCommissionPools") + .HasForeignKey("WeekDefinitionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("WeekDefinition"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Commission.WorkerExecutionLog", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.WeekDefinition", "WeekDefinition") + .WithMany("WorkerExecutionLogs") + .HasForeignKey("WeekDefinitionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("WeekDefinition"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DayaLoanContract", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "Transaction") + .WithMany() + .HasForeignKey("TransactionId"); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DayaLoanContracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", "ParentCategory") + .WithMany("ChildCategories") + .HasForeignKey("ParentCategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ParentCategory"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrder", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress") + .WithMany() + .HasForeignKey("UserAddressId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DiscountOrders") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + + b.Navigation("UserAddress"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrderDetail", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrder", "DiscountOrder") + .WithMany("OrderDetails") + .HasForeignKey("DiscountOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "Product") + .WithMany("OrderDetails") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("DiscountOrder"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProductCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", "Category") + .WithMany("ProductCategories") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "Product") + .WithMany("ProductCategories") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountShoppingCart", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "Product") + .WithMany("ShoppingCarts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("DiscountShoppingCarts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.FactorDetails", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany("FactorDetails") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("FactorDetails") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Geography.City", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Geography.State", "State") + .WithMany("Cities") + .HasForeignKey("StateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("State"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Geography.State", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Geography.Country", "Country") + .WithMany("States") + .HasForeignKey("CountryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Country"); + }); + + 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.HasOne("CMSMicroservice.Domain.Entities.WeekDefinition", "WeekDefinition") + .WithMany("CommissionPayoutHistories") + .HasForeignKey("WeekDefinitionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("UserCommissionPayout"); + + b.Navigation("WeekDefinition"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Network.NetworkWeeklyBalance", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("NetworkWeeklyBalances") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.WeekDefinition", "WeekDefinition") + .WithMany("NetworkWeeklyBalances") + .HasForeignKey("WeekDefinitionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("User"); + + b.Navigation("WeekDefinition"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Order.OrderVAT", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithOne() + .HasForeignKey("CMSMicroservice.Domain.Entities.Order.OrderVAT", "OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Payment.ManualPayment", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductCategory", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Category", "Category") + .WithMany("ProductCategories") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("ProductCategories") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductGallery", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("ProductGalleries") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.ProductImage", "ProductImage") + .WithMany("ProductGalleries") + .HasForeignKey("ProductImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("ProductImage"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductTag", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("ProductTags") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Tag", "Tag") + .WithMany("ProductTags") + .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.Navigation("NetworkParent"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserAddresses") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserCart", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.Product", "Product") + .WithMany("UserCarts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany("UserCarts") + .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.Order.OrderVAT", "OrderVAT") + .WithMany() + .HasForeignKey("OrderVATId"); + + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany("UserOrders") + .HasForeignKey("PackageId"); + + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "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("OrderVAT"); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + + b.Navigation("UserAddress"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserPackagePurchase", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.UserOrder", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package") + .WithMany() + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CMSMicroservice.Domain.Entities.Transaction", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CMSMicroservice.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Package"); + + b.Navigation("Transaction"); + + b.Navigation("User"); + }); + + 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("Categories"); + + b.Navigation("ProductCategories"); + }); + + 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.Contract", b => + { + b.Navigation("UserContracts"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountCategory", b => + { + b.Navigation("ChildCategories"); + + b.Navigation("ProductCategories"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountOrder", b => + { + b.Navigation("OrderDetails"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", b => + { + b.Navigation("OrderDetails"); + + b.Navigation("ProductCategories"); + + b.Navigation("ShoppingCarts"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Geography.Country", b => + { + b.Navigation("States"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Geography.State", b => + { + b.Navigation("Cities"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Product", b => + { + b.Navigation("FactorDetails"); + + b.Navigation("ProductCategories"); + + b.Navigation("ProductGalleries"); + + b.Navigation("ProductTags"); + + b.Navigation("UserCarts"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.ProductImage", b => + { + b.Navigation("ProductGalleries"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Tag", b => + { + b.Navigation("ProductTags"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.Transaction", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b => + { + b.Navigation("ClubMembership"); + + b.Navigation("CommissionPayouts"); + + b.Navigation("DayaLoanContracts"); + + b.Navigation("DiscountOrders"); + + b.Navigation("DiscountShoppingCarts"); + + b.Navigation("NetworkChildren"); + + b.Navigation("NetworkWeeklyBalances"); + + b.Navigation("UserAddresses"); + + b.Navigation("UserCarts"); + + b.Navigation("UserClubFeatures"); + + b.Navigation("UserContracts"); + + b.Navigation("UserOrders"); + + b.Navigation("UserRoles"); + + b.Navigation("UserWallets"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b => + { + b.Navigation("UserOrders"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b => + { + b.Navigation("FactorDetails"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserWallet", b => + { + b.Navigation("UserWalletChangeLogs"); + }); + + modelBuilder.Entity("CMSMicroservice.Domain.Entities.WeekDefinition", b => + { + b.Navigation("CommissionPayoutHistories"); + + b.Navigation("NetworkWeeklyBalances"); + + b.Navigation("UserCommissionPayouts"); + + b.Navigation("WeeklyCommissionPools"); + + b.Navigation("WorkerExecutionLogs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251226051932_RemoveSystemConfigurationsTables.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251226051932_RemoveSystemConfigurationsTables.cs new file mode 100644 index 0000000..e59d6fa --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251226051932_RemoveSystemConfigurationsTables.cs @@ -0,0 +1,108 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + /// + public partial class RemoveSystemConfigurationsTables : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "SystemConfigurationHistories", + schema: "CMS"); + + migrationBuilder.DropTable( + name: "SystemConfigurations", + schema: "CMS"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "SystemConfigurations", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + 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), + IsDeleted = table.Column(type: "bit", nullable: false), + Key = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + Scope = table.Column(type: "int", nullable: false), + Value = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SystemConfigurations", x => x.Id); + }); + + 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), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false), + Key = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + NewValue = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false), + OldValue = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false), + PerformedBy = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Reason = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + Scope = table.Column(type: "int", 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.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); + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs index 6045d30..988662b 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs @@ -503,65 +503,6 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("AppVersions", "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") @@ -1504,69 +1445,6 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations 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") @@ -3238,17 +3116,6 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("WeekDefinition"); }); - 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") @@ -3553,11 +3420,6 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("UserCommissionPayouts"); }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.Configuration.SystemConfiguration", b => - { - b.Navigation("SystemConfigurationHistories"); - }); - modelBuilder.Entity("CMSMicroservice.Domain.Entities.Contract", b => { b.Navigation("UserContracts"); diff --git a/src/CMSMicroservice.Infrastructure/Persistence/StoredProcedures/sp_CalculateWeeklyBalances.sql b/src/CMSMicroservice.Infrastructure/Persistence/StoredProcedures/sp_CalculateWeeklyBalances.sql index c6803d3..1472b57 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/StoredProcedures/sp_CalculateWeeklyBalances.sql +++ b/src/CMSMicroservice.Infrastructure/Persistence/StoredProcedures/sp_CalculateWeeklyBalances.sql @@ -65,19 +65,11 @@ BEGIN AND IsActive = 1; -- ============================================= - -- 4. خواندن Configuration ها + -- 4. مقادیر ثابت (Hardcoded - از SystemConstants) -- ============================================= - SELECT @MaxBalancesPerLeg = CAST(Value AS INT) - FROM CMS.SystemConfigurations - WHERE [Key] = 'Commission.MaxWeeklyBalancesPerLeg' AND IsActive = 1; - - SELECT @MaxNetworkLevel = CAST(Value AS INT) - FROM CMS.SystemConfigurations - WHERE [Key] = 'Commission.MaxNetworkLevel' AND IsActive = 1; - - -- مقادیر پیش‌فرض - SET @MaxBalancesPerLeg = ISNULL(@MaxBalancesPerLeg, 300); - SET @MaxNetworkLevel = ISNULL(@MaxNetworkLevel, 15); + -- این مقادیر ثابت هستند و تغییر نمی‌کنند + SET @MaxBalancesPerLeg = 300; -- سقف تعادل هر پا + SET @MaxNetworkLevel = 15; -- حداکثر عمق شبکه -- ============================================= -- 5. ایجاد جدول موقت برای نتایج diff --git a/src/CMSMicroservice.Infrastructure/Services/Commission/CommissionCalculationStrategyFactory.cs b/src/CMSMicroservice.Infrastructure/Services/Commission/CommissionCalculationStrategyFactory.cs index c32479e..5cd3398 100644 --- a/src/CMSMicroservice.Infrastructure/Services/Commission/CommissionCalculationStrategyFactory.cs +++ b/src/CMSMicroservice.Infrastructure/Services/Commission/CommissionCalculationStrategyFactory.cs @@ -1,4 +1,5 @@ using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Common; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; @@ -13,13 +14,6 @@ public class CommissionCalculationStrategyFactory : ICommissionCalculationStrate private readonly IWeekDefinitionRepository _weekRepository; private readonly IServiceProvider _serviceProvider; - /// - /// کلید Config برای انتخاب استراتژی - /// مقدار: "ORM" یا "SP" - /// پیش‌فرض: "ORM" - /// - private const string ConfigKey = "Commission.CalculationStrategy"; - public CommissionCalculationStrategyFactory( IApplicationDbContext context, IWeekDefinitionRepository weekRepository, @@ -31,13 +25,10 @@ public class CommissionCalculationStrategyFactory : ICommissionCalculationStrate } /// - public async Task CreateStrategyAsync(CancellationToken cancellationToken = default) + public Task CreateStrategyAsync(CancellationToken cancellationToken = default) { - // خواندن Config از دیتابیس - var config = await _context.SystemConfigurations - .FirstOrDefaultAsync(x => x.Key == ConfigKey && x.IsActive, cancellationToken); - - var strategyValue = config?.Value?.ToUpperInvariant() ?? "ORM"; + // خواندن Config از SystemConstants (استاتیک) + var strategyValue = SystemConstants.CommissionCalculationStrategy.ToUpperInvariant(); var strategyType = strategyValue switch { @@ -45,7 +36,7 @@ public class CommissionCalculationStrategyFactory : ICommissionCalculationStrate _ => CommissionCalculationStrategyType.Orm }; - return CreateStrategy(strategyType); + return Task.FromResult(CreateStrategy(strategyType)); } /// diff --git a/src/CMSMicroservice.Infrastructure/Services/Commission/OrmCommissionCalculationStrategy.cs b/src/CMSMicroservice.Infrastructure/Services/Commission/OrmCommissionCalculationStrategy.cs index 5e5eb08..ea6f36b 100644 --- a/src/CMSMicroservice.Infrastructure/Services/Commission/OrmCommissionCalculationStrategy.cs +++ b/src/CMSMicroservice.Infrastructure/Services/Commission/OrmCommissionCalculationStrategy.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Common; using CMSMicroservice.Domain.Entities.Club; using CMSMicroservice.Domain.Entities.Commission; using CMSMicroservice.Domain.Entities.Network; @@ -87,15 +88,9 @@ public class OrmCommissionCalculationStrategy : ICommissionCalculationStrategy var balancesList = new List(); var calculatedAt = DateTime.Now; - // خواندن یکباره Configuration ها - var configs = await _context.SystemConfigurations - .Where(x => x.IsActive && ( - x.Key == "Commission.MaxWeeklyBalancesPerLeg" || - x.Key == "Commission.MaxNetworkLevel")) - .ToDictionaryAsync(x => x.Key, x => x.Value, cancellationToken); - - var maxBalancesPerLeg = int.Parse(configs.GetValueOrDefault("Commission.MaxWeeklyBalancesPerLeg", "300")); - var maxNetworkLevel = int.Parse(configs.GetValueOrDefault("Commission.MaxNetworkLevel", "15")); + // استفاده از SystemConstants به جای دیتابیس + var maxBalancesPerLeg = SystemConstants.CommissionMaxWeeklyBalancesPerLeg; + var maxNetworkLevel = SystemConstants.CommissionMaxNetworkLevel; foreach (var user in usersInNetwork.OrderBy(o => o.Id)) { diff --git a/src/CMSMicroservice.Infrastructure/Services/KavenegarService.cs b/src/CMSMicroservice.Infrastructure/Services/KavenegarService.cs new file mode 100644 index 0000000..f666a0e --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Services/KavenegarService.cs @@ -0,0 +1,109 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Infrastructure.Configuration; +using Kavenegar; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace CMSMicroservice.Infrastructure.Services; + +/// +/// پیاده‌سازی سرویس ارسال SMS با کاوه‌نگار +/// +public class KavenegarService : IKavenegarService +{ + private readonly KavenegarApi? _kavenegarApi; + private readonly SmsSettings _smsSettings; + private readonly ILogger _logger; + + public KavenegarService( + IOptions smsSettings, + ILogger logger) + { + _smsSettings = smsSettings.Value; + _logger = logger; + + // Initialize Kavenegar API + if (_smsSettings.Enabled && !string.IsNullOrEmpty(_smsSettings.KavenegarApiKey)) + { + try + { + _kavenegarApi = new KavenegarApi(_smsSettings.KavenegarApiKey); + } + catch (Exception ex) + { + _logger.LogError(ex, "❌ Failed to initialize Kavenegar API"); + } + } + } + + /// + public async Task SendAsync(string mobile, string message) + { + if (!_smsSettings.Enabled) + { + _logger.LogInformation("SMS is disabled. Skipping send to {Mobile}", mobile); + return; + } + + if (_kavenegarApi == null) + { + _logger.LogWarning("⚠️ Kavenegar API not initialized, cannot send SMS"); + return; + } + + try + { + // Kavenegar Send is synchronous + await Task.Run(() => + { + var result = _kavenegarApi.Send( + sender: _smsSettings.Sender, + receptor: mobile, + message: message); + + _logger.LogInformation("📱 SMS sent successfully to {Mobile}, MessageId: {MessageId}", mobile, result.Messageid); + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "❌ Kavenegar error sending SMS to {Mobile}: {Message}", mobile, ex.Message); + throw; + } + } + + /// + public async Task VerifyLookupAsync(string mobile, string token, string template = "Afrino") + { + if (!_smsSettings.Enabled) + { + _logger.LogInformation("SMS is disabled. Skipping VerifyLookup to {Mobile}", mobile); + return; + } + + if (_kavenegarApi == null) + { + _logger.LogWarning("⚠️ Kavenegar API not initialized, cannot send VerifyLookup"); + return; + } + + try + { + // Kavenegar VerifyLookup is synchronous + await Task.Run(() => + { + var result = _kavenegarApi.VerifyLookup( + receptor: mobile, + token: token, + template: template); + + _logger.LogInformation("📱 VerifyLookup SMS sent successfully to {Mobile} with template {Template}, MessageId: {MessageId}", + mobile, template, result.Messageid); + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "❌ Kavenegar error sending VerifyLookup to {Mobile}: {Message}", mobile, ex.Message); + throw; + } + } +} diff --git a/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj b/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj index 3f14563..e397d3f 100644 --- a/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj +++ b/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj @@ -3,7 +3,7 @@ net9.0 enable enable - 0.0.159 + 0.0.161 None False False diff --git a/src/CMSMicroservice.WebApi/Services/ConfigurationService.cs b/src/CMSMicroservice.WebApi/Services/ConfigurationService.cs deleted file mode 100644 index 146848a..0000000 --- a/src/CMSMicroservice.WebApi/Services/ConfigurationService.cs +++ /dev/null @@ -1,44 +0,0 @@ -using CMSMicroservice.Protobuf.Protos.Configuration; -using CMSMicroservice.WebApi.Common.Services; -using CMSMicroservice.Application.ConfigurationCQ.Commands.SetConfigurationValue; -using CMSMicroservice.Application.ConfigurationCQ.Commands.DeactivateConfiguration; -using CMSMicroservice.Application.ConfigurationCQ.Queries.GetConfigurationByKey; -using CMSMicroservice.Application.ConfigurationCQ.Queries.GetAllConfigurations; -using CMSMicroservice.Application.ConfigurationCQ.Queries.GetConfigurationHistory; - -namespace CMSMicroservice.WebApi.Services; - -public class ConfigurationService : ConfigurationContract.ConfigurationContractBase -{ - private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; - - public ConfigurationService(IDispatchRequestToCQRS dispatchRequestToCQRS) - { - _dispatchRequestToCQRS = dispatchRequestToCQRS; - } - - public override async Task CreateOrUpdateConfiguration(CreateOrUpdateConfigurationRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - - public override async Task DeactivateConfiguration(DeactivateConfigurationRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - - public override async Task GetConfigurationByKey(GetConfigurationByKeyRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - - public override async Task GetAllConfigurations(GetAllConfigurationsRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } - - public override async Task GetConfigurationHistory(GetConfigurationHistoryRequest request, ServerCallContext context) - { - return await _dispatchRequestToCQRS.Handle(request, context); - } -} diff --git a/src/CMSMicroservice.WebApi/Workers/DayaLoanCheckWorker.cs b/src/CMSMicroservice.WebApi/Workers/DayaLoanCheckWorker.cs index 5ef1dab..517ff63 100644 --- a/src/CMSMicroservice.WebApi/Workers/DayaLoanCheckWorker.cs +++ b/src/CMSMicroservice.WebApi/Workers/DayaLoanCheckWorker.cs @@ -84,7 +84,8 @@ public class DayaLoanCheckWorker var processCommand = new ProcessDayaLoanApprovalCommand { UserId = user.Id, - ContractNumber = result.ContractNumber + ContractNumber = result.ContractNumber, + LockedWalletAmount = 0, // TODO: not needed for now }; var processResult = await _mediator.Send(processCommand); diff --git a/src/CMSMicroservice.WebApi/appsettings.json b/src/CMSMicroservice.WebApi/appsettings.json index 351bd60..8c19306 100644 --- a/src/CMSMicroservice.WebApi/appsettings.json +++ b/src/CMSMicroservice.WebApi/appsettings.json @@ -37,8 +37,8 @@ "Sms": { "Enabled": true, "Provider": "Kavenegar", - "KavenegarApiKey": "YOUR_KAVENEGAR_API_KEY", - "Sender": "10008663" + "KavenegarApiKey": "497263626F32626A48685A6137524C4F78575A766E4C74694A556B79317648424964655030682B554545413D", + "Sender": "1000001110100" }, "DayaPayment": { "BaseUrl": "https://api.daya.ir",