diff --git a/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs b/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs index 95da562..bc6c049 100644 --- a/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs +++ b/src/CMSMicroservice.Application/Common/Interfaces/IApplicationDbContext.cs @@ -51,6 +51,7 @@ public interface IApplicationDbContext DbSet DiscountProducts { get; } DbSet DiscountCategories { get; } DbSet DiscountProductCategories { get; } + DbSet DiscountProductImages { get; } DbSet DiscountShoppingCarts { get; } DbSet DiscountOrders { get; } DbSet DiscountOrderDetails { get; } diff --git a/src/CMSMicroservice.Application/Common/Services/VatCalculator.cs b/src/CMSMicroservice.Application/Common/Services/VatCalculator.cs new file mode 100644 index 0000000..92e2cc9 --- /dev/null +++ b/src/CMSMicroservice.Application/Common/Services/VatCalculator.cs @@ -0,0 +1,83 @@ +namespace CMSMicroservice.Application.Common.Services; + +/// +/// سرویس محاسبه مالیات بر ارزش افزوده (VAT) +/// +public static class VatCalculator +{ + /// + /// نرخ VAT ایران - 9 درصد + /// + public const decimal VAT_RATE = 0.09m; + + /// + /// نرخ VAT به صورت درصد (9) + /// + public const int VAT_PERCENT = 9; + + /// + /// محاسبه VAT از مبلغ خالص + /// + /// مبلغ خالص (بدون مالیات) + /// مبلغ VAT + public static long CalculateVat(long netAmount) + { + return (long)(netAmount * VAT_RATE); + } + + /// + /// محاسبه مبلغ ناخالص (شامل VAT) از مبلغ خالص + /// + /// مبلغ خالص + /// مبلغ ناخالص (خالص + VAT) + public static long CalculateGrossAmount(long netAmount) + { + return netAmount + CalculateVat(netAmount); + } + + /// + /// استخراج مبلغ خالص از مبلغ ناخالص + /// + /// مبلغ ناخالص (شامل VAT) + /// مبلغ خالص + public static long ExtractNetAmount(long grossAmount) + { + return (long)(grossAmount / (1 + VAT_RATE)); + } + + /// + /// استخراج VAT از مبلغ ناخالص + /// + /// مبلغ ناخالص (شامل VAT) + /// مبلغ VAT + public static long ExtractVatFromGross(long grossAmount) + { + return grossAmount - ExtractNetAmount(grossAmount); + } + + /// + /// جزئیات محاسبه VAT + /// + public record VatBreakdown( + long NetAmount, + long VatAmount, + long GrossAmount, + decimal VatRate + ); + + /// + /// محاسبه کامل جزئیات VAT + /// + /// مبلغ خالص + /// جزئیات کامل VAT + public static VatBreakdown CalculateBreakdown(long netAmount) + { + var vatAmount = CalculateVat(netAmount); + return new VatBreakdown( + NetAmount: netAmount, + VatAmount: vatAmount, + GrossAmount: netAmount + vatAmount, + VatRate: VAT_RATE + ); + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddDiscountProductImage/AddDiscountProductImageCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddDiscountProductImage/AddDiscountProductImageCommand.cs new file mode 100644 index 0000000..2888f40 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddDiscountProductImage/AddDiscountProductImageCommand.cs @@ -0,0 +1,12 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.AddDiscountProductImage; + +public class AddDiscountProductImageCommand : IRequest +{ + public long DiscountProductId { get; set; } + public string ImagePath { get; set; } = string.Empty; + public string ThumbnailPath { get; set; } = string.Empty; + public string? Title { get; set; } + public string? AltText { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddDiscountProductImage/AddDiscountProductImageCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddDiscountProductImage/AddDiscountProductImageCommandHandler.cs new file mode 100644 index 0000000..43dc131 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/AddDiscountProductImage/AddDiscountProductImageCommandHandler.cs @@ -0,0 +1,47 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Entities.DiscountShop; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.AddDiscountProductImage; + +public class AddDiscountProductImageCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public AddDiscountProductImageCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(AddDiscountProductImageCommand request, CancellationToken cancellationToken) + { + // Verify product exists + var productExists = await _context.DiscountProducts + .AnyAsync(p => p.Id == request.DiscountProductId, cancellationToken); + + if (!productExists) + throw new InvalidOperationException($"DiscountProduct with Id {request.DiscountProductId} not found."); + + // Get the max sort order for this product + var maxSortOrder = await _context.DiscountProductImages + .Where(i => i.DiscountProductId == request.DiscountProductId) + .MaxAsync(i => (int?)i.SortOrder, cancellationToken) ?? 0; + + var image = new DiscountProductImage + { + DiscountProductId = request.DiscountProductId, + ImagePath = request.ImagePath, + ThumbnailPath = request.ThumbnailPath, + Title = request.Title, + AltText = request.AltText, + SortOrder = maxSortOrder + 1, + IsActive = true + }; + + _context.DiscountProductImages.Add(image); + await _context.SaveChangesAsync(cancellationToken); + + return image.Id; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountProductImage/DeleteDiscountProductImageCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountProductImage/DeleteDiscountProductImageCommand.cs new file mode 100644 index 0000000..a498f36 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountProductImage/DeleteDiscountProductImageCommand.cs @@ -0,0 +1,8 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.DeleteDiscountProductImage; + +public class DeleteDiscountProductImageCommand : IRequest +{ + public long Id { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountProductImage/DeleteDiscountProductImageCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountProductImage/DeleteDiscountProductImageCommandHandler.cs new file mode 100644 index 0000000..7e784c5 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/DeleteDiscountProductImage/DeleteDiscountProductImageCommandHandler.cs @@ -0,0 +1,41 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.DeleteDiscountProductImage; + +public class DeleteDiscountProductImageCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public DeleteDiscountProductImageCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(DeleteDiscountProductImageCommand request, CancellationToken cancellationToken) + { + var image = await _context.DiscountProductImages + .FirstOrDefaultAsync(i => i.Id == request.Id, cancellationToken); + + if (image == null) + return false; + + _context.DiscountProductImages.Remove(image); + await _context.SaveChangesAsync(cancellationToken); + + // Reorder remaining images for this product + var remainingImages = await _context.DiscountProductImages + .Where(i => i.DiscountProductId == image.DiscountProductId) + .OrderBy(i => i.SortOrder) + .ToListAsync(cancellationToken); + + for (int i = 0; i < remainingImages.Count; i++) + { + remainingImages[i].SortOrder = i + 1; + } + + await _context.SaveChangesAsync(cancellationToken); + return true; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/PlaceOrder/PlaceOrderCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/PlaceOrder/PlaceOrderCommandHandler.cs index 7032a20..0158d50 100644 --- a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/PlaceOrder/PlaceOrderCommandHandler.cs +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/PlaceOrder/PlaceOrderCommandHandler.cs @@ -1,4 +1,5 @@ using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Application.Common.Services; using CMSMicroservice.Domain.Entities.DiscountShop; using CMSMicroservice.Domain.Entities.Payment; using CMSMicroservice.Domain.Enums; @@ -109,9 +110,10 @@ public class PlaceOrderCommandHandler : IRequestHandler +{ + public long DiscountProductId { get; set; } + public List ImageIds { get; set; } = new(); +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/ReorderDiscountProductImages/ReorderDiscountProductImagesCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/ReorderDiscountProductImages/ReorderDiscountProductImagesCommandHandler.cs new file mode 100644 index 0000000..b5d2800 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/ReorderDiscountProductImages/ReorderDiscountProductImagesCommandHandler.cs @@ -0,0 +1,43 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.ReorderDiscountProductImages; + +public class ReorderDiscountProductImagesCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public ReorderDiscountProductImagesCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(ReorderDiscountProductImagesCommand request, CancellationToken cancellationToken) + { + var images = await _context.DiscountProductImages + .Where(i => i.DiscountProductId == request.DiscountProductId) + .ToListAsync(cancellationToken); + + if (!images.Any()) + return false; + + // Validate all image IDs belong to this product + var imageIdSet = images.Select(i => i.Id).ToHashSet(); + if (!request.ImageIds.All(id => imageIdSet.Contains(id))) + return false; + + // Update sort order based on the new order + for (int i = 0; i < request.ImageIds.Count; i++) + { + var image = images.FirstOrDefault(img => img.Id == request.ImageIds[i]); + if (image != null) + { + image.SortOrder = i + 1; + } + } + + await _context.SaveChangesAsync(cancellationToken); + return true; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProductImage/UpdateDiscountProductImageCommand.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProductImage/UpdateDiscountProductImageCommand.cs new file mode 100644 index 0000000..7efb3bc --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProductImage/UpdateDiscountProductImageCommand.cs @@ -0,0 +1,13 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateDiscountProductImage; + +public class UpdateDiscountProductImageCommand : IRequest +{ + public long Id { get; set; } + public string ImagePath { get; set; } = string.Empty; + public string ThumbnailPath { get; set; } = string.Empty; + public string? Title { get; set; } + public string? AltText { get; set; } + public bool IsActive { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProductImage/UpdateDiscountProductImageCommandHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProductImage/UpdateDiscountProductImageCommandHandler.cs new file mode 100644 index 0000000..09d931e --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Commands/UpdateDiscountProductImage/UpdateDiscountProductImageCommandHandler.cs @@ -0,0 +1,33 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateDiscountProductImage; + +public class UpdateDiscountProductImageCommandHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public UpdateDiscountProductImageCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(UpdateDiscountProductImageCommand request, CancellationToken cancellationToken) + { + var image = await _context.DiscountProductImages + .FirstOrDefaultAsync(i => i.Id == request.Id, cancellationToken); + + if (image == null) + return false; + + image.ImagePath = request.ImagePath; + image.ThumbnailPath = request.ThumbnailPath; + image.Title = request.Title; + image.AltText = request.AltText; + image.IsActive = request.IsActive; + + await _context.SaveChangesAsync(cancellationToken); + return true; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetAllDiscountOrders/GetAllDiscountOrdersQuery.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetAllDiscountOrders/GetAllDiscountOrdersQuery.cs new file mode 100644 index 0000000..4b447f8 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetAllDiscountOrders/GetAllDiscountOrdersQuery.cs @@ -0,0 +1,102 @@ +using CMSMicroservice.Application.Common.Models; +using CMSMicroservice.Domain.Enums; +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetAllDiscountOrders; + +/// +/// کوئری دریافت همه سفارشات فروشگاه تخفیفی برای ادمین +/// +public class GetAllDiscountOrdersQuery : IRequest +{ + public PaginationState? PaginationQuery { get; set; } + + /// + /// فیلتر بر اساس شناسه کاربر + /// + public long? UserId { get; set; } + + /// + /// فیلتر بر اساس وضعیت پرداخت + /// + public PaymentStatus? PaymentStatus { get; set; } + + /// + /// فیلتر بر اساس وضعیت ارسال + /// + public DeliveryStatus? DeliveryStatus { get; set; } + + /// + /// جستجو بر اساس موبایل کاربر + /// + public string? UserMobile { get; set; } + + /// + /// جستجو بر اساس کد رهگیری + /// + public string? TrackingCode { get; set; } + + /// + /// فیلتر از تاریخ + /// + public DateTime? FromDate { get; set; } + + /// + /// فیلتر تا تاریخ + /// + public DateTime? ToDate { get; set; } + + /// + /// حداقل مبلغ سفارش + /// + public long? MinAmount { get; set; } + + /// + /// حداکثر مبلغ سفارش + /// + public long? MaxAmount { get; set; } +} + +public class GetAllDiscountOrdersResponseDto +{ + public MetaData MetaData { get; set; } = new(); + public List Models { get; set; } = new(); +} + +public class AdminOrderDto +{ + public long Id { get; set; } + + // اطلاعات کاربر + public long UserId { get; set; } + public string UserFullName { get; set; } = string.Empty; + public string UserMobile { get; set; } = string.Empty; + + // مبالغ + public long TotalAmount { get; set; } + public long DiscountBalanceUsed { get; set; } + public long GatewayAmountPaid { get; set; } + public long VatAmount { get; set; } + + // وضعیت ها + public PaymentStatus PaymentStatus { get; set; } + public DateTime? PaymentDate { get; set; } + public DeliveryStatus DeliveryStatus { get; set; } + public DateTime? DeliveryDate { get; set; } + + // آدرس تحویل + public string? ShippingAddress { get; set; } + public string? ReceiverName { get; set; } + public string? ReceiverMobile { get; set; } + + // رهگیری + public string? TrackingCode { get; set; } + public string? AdminNote { get; set; } + + // تاریخ ها + public DateTime Created { get; set; } + public DateTime? LastModified { get; set; } + + // تعداد آیتم ها + public int ItemsCount { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetAllDiscountOrders/GetAllDiscountOrdersQueryHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetAllDiscountOrders/GetAllDiscountOrdersQueryHandler.cs new file mode 100644 index 0000000..fac1fde --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetAllDiscountOrders/GetAllDiscountOrdersQueryHandler.cs @@ -0,0 +1,124 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Application.Common.Models; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetAllDiscountOrders; + +public class GetAllDiscountOrdersQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + + public GetAllDiscountOrdersQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(GetAllDiscountOrdersQuery request, CancellationToken cancellationToken) + { + var query = _context.DiscountOrders + .Include(o => o.User) + .Include(o => o.UserAddress) + .AsQueryable(); + + // فیلتر بر اساس شناسه کاربر + if (request.UserId.HasValue) + { + query = query.Where(o => o.UserId == request.UserId.Value); + } + + // فیلتر بر اساس وضعیت پرداخت + if (request.PaymentStatus.HasValue) + { + query = query.Where(o => o.PaymentStatus == request.PaymentStatus.Value); + } + + // فیلتر بر اساس وضعیت ارسال + if (request.DeliveryStatus.HasValue) + { + query = query.Where(o => o.DeliveryStatus == request.DeliveryStatus.Value); + } + + // جستجو بر اساس موبایل کاربر + if (!string.IsNullOrWhiteSpace(request.UserMobile)) + { + query = query.Where(o => o.User.Mobile.Contains(request.UserMobile)); + } + + // جستجو بر اساس کد رهگیری + if (!string.IsNullOrWhiteSpace(request.TrackingCode)) + { + query = query.Where(o => o.TrackingCode != null && o.TrackingCode.Contains(request.TrackingCode)); + } + + // فیلتر از تاریخ + if (request.FromDate.HasValue) + { + query = query.Where(o => o.Created >= request.FromDate.Value); + } + + // فیلتر تا تاریخ + if (request.ToDate.HasValue) + { + query = query.Where(o => o.Created <= request.ToDate.Value); + } + + // فیلتر حداقل مبلغ + if (request.MinAmount.HasValue) + { + query = query.Where(o => o.TotalAmount >= request.MinAmount.Value); + } + + // فیلتر حداکثر مبلغ + if (request.MaxAmount.HasValue) + { + query = query.Where(o => o.TotalAmount <= request.MaxAmount.Value); + } + + var totalCount = await query.CountAsync(cancellationToken); + + // Apply pagination + var pagination = request.PaginationQuery ?? new PaginationState { PageNumber = 1, PageSize = 20 }; + + var orders = await query + .OrderByDescending(o => o.Created) + .Skip((pagination.PageNumber - 1) * pagination.PageSize) + .Take(pagination.PageSize) + .Select(o => new AdminOrderDto + { + Id = o.Id, + UserId = o.UserId, + UserFullName = (o.User.FirstName ?? "") + " " + (o.User.LastName ?? ""), + UserMobile = o.User.Mobile, + TotalAmount = o.TotalAmount, + DiscountBalanceUsed = o.DiscountBalanceUsed, + GatewayAmountPaid = o.GatewayAmountPaid, + VatAmount = o.VatAmount, + PaymentStatus = o.PaymentStatus, + PaymentDate = o.PaymentDate, + DeliveryStatus = o.DeliveryStatus, + DeliveryDate = null, // TODO: Add DeliveryDate to DiscountOrder if needed + ShippingAddress = o.UserAddress.Address, + ReceiverName = o.UserAddress.Title, + ReceiverMobile = o.User.Mobile, + TrackingCode = o.TrackingCode, + AdminNote = o.DeliveryDescription, + Created = o.Created, + LastModified = o.LastModified, + ItemsCount = o.OrderDetails.Count + }) + .ToListAsync(cancellationToken); + + return new GetAllDiscountOrdersResponseDto + { + MetaData = new MetaData + { + TotalCount = totalCount, + PageSize = pagination.PageSize, + CurrentPage = pagination.PageNumber, + TotalPage = (int)Math.Ceiling(totalCount / (double)pagination.PageSize) + }, + Models = orders + }; + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProductImages/GetDiscountProductImagesQuery.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProductImages/GetDiscountProductImagesQuery.cs new file mode 100644 index 0000000..4dccbfb --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProductImages/GetDiscountProductImagesQuery.cs @@ -0,0 +1,21 @@ +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountProductImages; + +public class GetDiscountProductImagesQuery : IRequest> +{ + public long DiscountProductId { get; set; } + public bool OnlyActive { get; set; } = true; +} + +public class DiscountProductImageDto +{ + public long Id { get; set; } + public long DiscountProductId { get; set; } + public string ImagePath { get; set; } = string.Empty; + public string ThumbnailPath { get; set; } = string.Empty; + public string? Title { get; set; } + public string? AltText { get; set; } + public int SortOrder { get; set; } + public bool IsActive { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProductImages/GetDiscountProductImagesQueryHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProductImages/GetDiscountProductImagesQueryHandler.cs new file mode 100644 index 0000000..5a6399d --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountProductImages/GetDiscountProductImagesQueryHandler.cs @@ -0,0 +1,39 @@ +using CMSMicroservice.Application.Common.Interfaces; +using MediatR; +using Microsoft.EntityFrameworkCore; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountProductImages; + +public class GetDiscountProductImagesQueryHandler : IRequestHandler> +{ + private readonly IApplicationDbContext _context; + + public GetDiscountProductImagesQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task> Handle(GetDiscountProductImagesQuery request, CancellationToken cancellationToken) + { + var query = _context.DiscountProductImages + .Where(i => i.DiscountProductId == request.DiscountProductId); + + if (request.OnlyActive) + query = query.Where(i => i.IsActive); + + return await query + .OrderBy(i => i.SortOrder) + .Select(i => new DiscountProductImageDto + { + Id = i.Id, + DiscountProductId = i.DiscountProductId, + ImagePath = i.ImagePath, + ThumbnailPath = i.ThumbnailPath, + Title = i.Title, + AltText = i.AltText, + SortOrder = i.SortOrder, + IsActive = i.IsActive + }) + .ToListAsync(cancellationToken); + } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountSalesReport/GetDiscountSalesReportQuery.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountSalesReport/GetDiscountSalesReportQuery.cs new file mode 100644 index 0000000..ba322a9 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountSalesReport/GetDiscountSalesReportQuery.cs @@ -0,0 +1,166 @@ +using CMSMicroservice.Application.Common.Models; +using MediatR; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountSalesReport; + +/// +/// کوئری گزارش فروش فروشگاه تخفیفی +/// +public class GetDiscountSalesReportQuery : IRequest +{ + /// + /// از تاریخ + /// + public DateTime? FromDate { get; set; } + + /// + /// تا تاریخ + /// + public DateTime? ToDate { get; set; } + + /// + /// نوع گزارش + /// + public SalesReportType ReportType { get; set; } = SalesReportType.Summary; +} + +public enum SalesReportType +{ + /// + /// خلاصه کلی + /// + Summary, + + /// + /// روزانه + /// + Daily, + + /// + /// هفتگی + /// + Weekly, + + /// + /// ماهانه + /// + Monthly +} + +public class DiscountSalesReportDto +{ + // خلاصه کلی + public SalesSummary Summary { get; set; } = new(); + + // جزئیات زمانی (برای گزارش‌های روزانه، هفتگی، ماهانه) + public List Periods { get; set; } = new(); + + // پرفروش‌ترین محصولات + public List TopProducts { get; set; } = new(); +} + +public class SalesSummary +{ + /// + /// تعداد کل سفارشات + /// + public int TotalOrders { get; set; } + + /// + /// تعداد سفارشات موفق (پرداخت شده) + /// + public int CompletedOrders { get; set; } + + /// + /// تعداد سفارشات در انتظار پرداخت + /// + public int PendingOrders { get; set; } + + /// + /// تعداد سفارشات لغو شده + /// + public int CancelledOrders { get; set; } + + /// + /// جمع کل فروش (TotalAmount) + /// + public long TotalSalesAmount { get; set; } + + /// + /// جمع تخفیف استفاده شده (DiscountBalanceUsed) + /// + public long TotalDiscountUsed { get; set; } + + /// + /// جمع پرداخت از درگاه (GatewayAmountPaid) + /// + public long TotalGatewayPaid { get; set; } + + /// + /// جمع VAT + /// + public long TotalVatAmount { get; set; } + + /// + /// میانگین ارزش سفارش + /// + public long AverageOrderValue { get; set; } + + /// + /// تعداد کاربران یکتا + /// + public int UniqueCustomers { get; set; } + + /// + /// تعداد کل محصولات فروخته شده + /// + public int TotalProductsSold { get; set; } +} + +public class SalesPeriodDto +{ + /// + /// نام دوره (مثل: 1403/10/11 یا هفته 41) + /// + public string PeriodLabel { get; set; } = string.Empty; + + /// + /// تاریخ شروع دوره + /// + public DateTime PeriodStart { get; set; } + + /// + /// تاریخ پایان دوره + /// + public DateTime PeriodEnd { get; set; } + + /// + /// تعداد سفارشات + /// + public int OrdersCount { get; set; } + + /// + /// جمع فروش + /// + public long TotalAmount { get; set; } + + /// + /// جمع تخفیف + /// + public long DiscountUsed { get; set; } + + /// + /// جمع پرداخت درگاه + /// + public long GatewayPaid { get; set; } +} + +public class TopSellingProductDto +{ + public long ProductId { get; set; } + public string ProductTitle { get; set; } = string.Empty; + public string? ImagePath { get; set; } + public int QuantitySold { get; set; } + public long TotalRevenue { get; set; } + public int OrdersCount { get; set; } +} diff --git a/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountSalesReport/GetDiscountSalesReportQueryHandler.cs b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountSalesReport/GetDiscountSalesReportQueryHandler.cs new file mode 100644 index 0000000..4c319a7 --- /dev/null +++ b/src/CMSMicroservice.Application/DiscountShopCQ/Queries/GetDiscountSalesReport/GetDiscountSalesReportQueryHandler.cs @@ -0,0 +1,193 @@ +using CMSMicroservice.Application.Common.Interfaces; +using CMSMicroservice.Domain.Enums; +using MediatR; +using Microsoft.EntityFrameworkCore; +using System.Globalization; + +namespace CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountSalesReport; + +public class GetDiscountSalesReportQueryHandler : IRequestHandler +{ + private readonly IApplicationDbContext _context; + private static readonly PersianCalendar PersianCalendar = new(); + + public GetDiscountSalesReportQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(GetDiscountSalesReportQuery request, CancellationToken cancellationToken) + { + var result = new DiscountSalesReportDto(); + + // Base query for orders + var ordersQuery = _context.DiscountOrders.AsQueryable(); + + // Apply date filters + if (request.FromDate.HasValue) + { + ordersQuery = ordersQuery.Where(o => o.Created >= request.FromDate.Value); + } + + if (request.ToDate.HasValue) + { + ordersQuery = ordersQuery.Where(o => o.Created <= request.ToDate.Value); + } + + // Get all matching orders for summary + var orders = await ordersQuery.ToListAsync(cancellationToken); + var completedOrders = orders.Where(o => o.PaymentStatus == PaymentStatus.Success).ToList(); + + // Calculate summary + result.Summary = new SalesSummary + { + TotalOrders = orders.Count, + CompletedOrders = completedOrders.Count, + PendingOrders = orders.Count(o => o.PaymentStatus == PaymentStatus.Pending), + CancelledOrders = orders.Count(o => o.PaymentStatus == PaymentStatus.Reject), + TotalSalesAmount = completedOrders.Sum(o => o.TotalAmount), + TotalDiscountUsed = completedOrders.Sum(o => o.DiscountBalanceUsed), + TotalGatewayPaid = completedOrders.Sum(o => o.GatewayAmountPaid), + TotalVatAmount = completedOrders.Sum(o => o.VatAmount), + AverageOrderValue = completedOrders.Any() ? (long)completedOrders.Average(o => o.TotalAmount) : 0, + UniqueCustomers = orders.Select(o => o.UserId).Distinct().Count() + }; + + // Get total products sold + var orderIds = completedOrders.Select(o => o.Id).ToList(); + result.Summary.TotalProductsSold = await _context.DiscountOrderDetails + .Where(d => orderIds.Contains(d.DiscountOrderId)) + .SumAsync(d => d.Count, cancellationToken); + + // Generate period-based reports + if (request.ReportType != SalesReportType.Summary && completedOrders.Any()) + { + result.Periods = GeneratePeriodReport(completedOrders, request.ReportType); + } + + // Get top selling products + result.TopProducts = await GetTopSellingProducts(orderIds, cancellationToken); + + return result; + } + + private List GeneratePeriodReport(List orders, SalesReportType reportType) + { + var periods = new List(); + + var groupedOrders = reportType switch + { + SalesReportType.Daily => orders.GroupBy(o => o.Created.Date), + SalesReportType.Weekly => orders.GroupBy(o => GetStartOfWeek(o.Created)), + SalesReportType.Monthly => orders.GroupBy(o => new DateTime(o.Created.Year, o.Created.Month, 1)), + _ => orders.GroupBy(o => o.Created.Date) + }; + + foreach (var group in groupedOrders.OrderBy(g => g.Key)) + { + var periodStart = group.Key; + var periodEnd = reportType switch + { + SalesReportType.Daily => periodStart.AddDays(1).AddSeconds(-1), + SalesReportType.Weekly => periodStart.AddDays(7).AddSeconds(-1), + SalesReportType.Monthly => periodStart.AddMonths(1).AddSeconds(-1), + _ => periodStart.AddDays(1).AddSeconds(-1) + }; + + periods.Add(new SalesPeriodDto + { + PeriodLabel = GetPersianPeriodLabel(periodStart, reportType), + PeriodStart = periodStart, + PeriodEnd = periodEnd, + OrdersCount = group.Count(), + TotalAmount = group.Sum(o => o.TotalAmount), + DiscountUsed = group.Sum(o => o.DiscountBalanceUsed), + GatewayPaid = group.Sum(o => o.GatewayAmountPaid) + }); + } + + return periods; + } + + private async Task> GetTopSellingProducts(List orderIds, CancellationToken cancellationToken) + { + if (!orderIds.Any()) + return new List(); + + var topProducts = await _context.DiscountOrderDetails + .Where(d => orderIds.Contains(d.DiscountOrderId)) + .GroupBy(d => d.ProductId) + .Select(g => new + { + ProductId = g.Key, + QuantitySold = g.Sum(d => d.Count), + TotalRevenue = g.Sum(d => d.FinalPrice), + OrdersCount = g.Select(d => d.DiscountOrderId).Distinct().Count() + }) + .OrderByDescending(x => x.QuantitySold) + .Take(10) + .ToListAsync(cancellationToken); + + var productIds = topProducts.Select(p => p.ProductId).ToList(); + var products = await _context.DiscountProducts + .Where(p => productIds.Contains(p.Id)) + .Select(p => new { p.Id, p.Title, p.ThumbnailPath }) + .ToListAsync(cancellationToken); + + return topProducts.Select(tp => new TopSellingProductDto + { + ProductId = tp.ProductId, + ProductTitle = products.FirstOrDefault(p => p.Id == tp.ProductId)?.Title ?? "نامشخص", + ImagePath = products.FirstOrDefault(p => p.Id == tp.ProductId)?.ThumbnailPath, + QuantitySold = tp.QuantitySold, + TotalRevenue = tp.TotalRevenue, + OrdersCount = tp.OrdersCount + }).ToList(); + } + + private static DateTime GetStartOfWeek(DateTime date) + { + // شروع هفته از شنبه (Saturday = 6 in DayOfWeek) + var diff = ((int)date.DayOfWeek + 1) % 7; // Saturday = 0 + return date.AddDays(-diff).Date; + } + + private static string GetPersianPeriodLabel(DateTime date, SalesReportType reportType) + { + var persianYear = PersianCalendar.GetYear(date); + var persianMonth = PersianCalendar.GetMonth(date); + var persianDay = PersianCalendar.GetDayOfMonth(date); + + return reportType switch + { + SalesReportType.Daily => $"{persianYear}/{persianMonth:D2}/{persianDay:D2}", + SalesReportType.Weekly => $"هفته {GetPersianWeekOfYear(date)} - {persianYear}", + SalesReportType.Monthly => $"{GetPersianMonthName(persianMonth)} {persianYear}", + _ => $"{persianYear}/{persianMonth:D2}/{persianDay:D2}" + }; + } + + private static int GetPersianWeekOfYear(DateTime date) + { + var firstDayOfYear = PersianCalendar.ToDateTime(PersianCalendar.GetYear(date), 1, 1, 0, 0, 0, 0); + var daysSinceStart = (date - firstDayOfYear).Days; + return (daysSinceStart / 7) + 1; + } + + private static string GetPersianMonthName(int month) => month switch + { + 1 => "فروردین", + 2 => "اردیبهشت", + 3 => "خرداد", + 4 => "تیر", + 5 => "مرداد", + 6 => "شهریور", + 7 => "مهر", + 8 => "آبان", + 9 => "آذر", + 10 => "دی", + 11 => "بهمن", + 12 => "اسفند", + _ => "نامشخص" + }; +} diff --git a/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountProduct.cs b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountProduct.cs index 5985d1b..85f314c 100644 --- a/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountProduct.cs +++ b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountProduct.cs @@ -83,4 +83,9 @@ public class DiscountProduct : BaseAuditableEntity /// دسته‌بندی‌های این محصول /// public virtual ICollection ProductCategories { get; set; } + + /// + /// تصاویر گالری محصول + /// + public virtual ICollection Images { get; set; } } diff --git a/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountProductImage.cs b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountProductImage.cs new file mode 100644 index 0000000..e8e19e0 --- /dev/null +++ b/src/CMSMicroservice.Domain/Entities/DiscountShop/DiscountProductImage.cs @@ -0,0 +1,47 @@ +namespace CMSMicroservice.Domain.Entities.DiscountShop; + +/// +/// تصویر گالری محصول تخفیفی +/// +public class DiscountProductImage : BaseAuditableEntity +{ + /// + /// شناسه محصول + /// + public long DiscountProductId { get; set; } + + /// + /// محصول + /// + public virtual DiscountProduct DiscountProduct { get; set; } = null!; + + /// + /// عنوان تصویر + /// + public string? Title { get; set; } + + /// + /// متن جایگزین (Alt) + /// + public string? AltText { get; set; } + + /// + /// مسیر تصویر اصلی + /// + public string ImagePath { get; set; } = string.Empty; + + /// + /// مسیر تصویر کوچک + /// + public string? ThumbnailPath { get; set; } + + /// + /// ترتیب نمایش + /// + public int SortOrder { get; set; } + + /// + /// آیا فعال است؟ + /// + public bool IsActive { get; set; } = true; +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs index e44cc12..ee49e54 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/ApplicationDbContext.cs @@ -110,6 +110,7 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext public DbSet DiscountProducts => Set(); public DbSet DiscountCategories => Set(); public DbSet DiscountProductCategories => Set(); + public DbSet DiscountProductImages => Set(); public DbSet DiscountShoppingCarts => Set(); public DbSet DiscountOrders => Set(); public DbSet DiscountOrderDetails => Set(); diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountProductImageConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountProductImageConfiguration.cs new file mode 100644 index 0000000..2d34b72 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/DiscountShop/DiscountProductImageConfiguration.cs @@ -0,0 +1,36 @@ +using CMSMicroservice.Domain.Entities.DiscountShop; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CMSMicroservice.Infrastructure.Persistence.Configurations.DiscountShop; + +public class DiscountProductImageConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("DiscountProductImages"); + + builder.HasKey(x => x.Id); + + builder.Property(x => x.Title) + .HasMaxLength(200); + + builder.Property(x => x.AltText) + .HasMaxLength(500); + + builder.Property(x => x.ImagePath) + .IsRequired() + .HasMaxLength(500); + + builder.Property(x => x.ThumbnailPath) + .HasMaxLength(500); + + builder.HasOne(x => x.DiscountProduct) + .WithMany(p => p.Images) + .HasForeignKey(x => x.DiscountProductId) + .OnDelete(DeleteBehavior.Cascade); + + builder.HasIndex(x => x.DiscountProductId); + builder.HasIndex(x => new { x.DiscountProductId, x.SortOrder }); + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251231190505_AddDiscountProductImages.Designer.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251231190505_AddDiscountProductImages.Designer.cs new file mode 100644 index 0000000..7804568 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251231190505_AddDiscountProductImages.Designer.cs @@ -0,0 +1,3632 @@ +// +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("20251231190505_AddDiscountProductImages")] + partial class AddDiscountProductImages + { + /// + 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.DiscountProductImage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AltText") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountProductId") + .HasColumnType("bigint"); + + b.Property("ImagePath") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + 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("ThumbnailPath") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("DiscountProductId"); + + b.HasIndex("DiscountProductId", "SortOrder"); + + b.ToTable("DiscountProductImages", "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.DiscountProductImage", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "DiscountProduct") + .WithMany("Images") + .HasForeignKey("DiscountProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DiscountProduct"); + }); + + 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("Images"); + + 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/20251231190505_AddDiscountProductImages.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251231190505_AddDiscountProductImages.cs new file mode 100644 index 0000000..7029023 --- /dev/null +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251231190505_AddDiscountProductImages.cs @@ -0,0 +1,67 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CMSMicroservice.Infrastructure.Persistence.Migrations +{ + /// + public partial class AddDiscountProductImages : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "DiscountProductImages", + schema: "CMS", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DiscountProductId = table.Column(type: "bigint", nullable: false), + Title = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + AltText = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + ImagePath = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), + ThumbnailPath = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + SortOrder = table.Column(type: "int", nullable: false), + IsActive = table.Column(type: "bit", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DiscountProductImages", x => x.Id); + table.ForeignKey( + name: "FK_DiscountProductImages_DiscountProducts_DiscountProductId", + column: x => x.DiscountProductId, + principalSchema: "CMS", + principalTable: "DiscountProducts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_DiscountProductImages_DiscountProductId", + schema: "CMS", + table: "DiscountProductImages", + column: "DiscountProductId"); + + migrationBuilder.CreateIndex( + name: "IX_DiscountProductImages_DiscountProductId_SortOrder", + schema: "CMS", + table: "DiscountProductImages", + columns: new[] { "DiscountProductId", "SortOrder" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "DiscountProductImages", + schema: "CMS"); + } + } +} diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs index 988662b..c165802 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs @@ -902,6 +902,64 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.ToTable("DiscountProductCategories", "CMS"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProductImage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AltText") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("DiscountProductId") + .HasColumnType("bigint"); + + b.Property("ImagePath") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + 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("ThumbnailPath") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("DiscountProductId"); + + b.HasIndex("DiscountProductId", "SortOrder"); + + b.ToTable("DiscountProductImages", "CMS"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountShoppingCart", b => { b.Property("Id") @@ -3026,6 +3084,17 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations b.Navigation("Product"); }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProductImage", b => + { + b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "DiscountProduct") + .WithMany("Images") + .HasForeignKey("DiscountProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DiscountProduct"); + }); + modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountShoppingCart", b => { b.HasOne("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", "Product") @@ -3439,6 +3508,8 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations modelBuilder.Entity("CMSMicroservice.Domain.Entities.DiscountShop.DiscountProduct", b => { + b.Navigation("Images"); + b.Navigation("OrderDetails"); b.Navigation("ProductCategories"); diff --git a/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj b/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj index 4e605f0..f63d02a 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.162 + 0.0.164 None False False diff --git a/src/CMSMicroservice.Protobuf/Protos/discountorder.proto b/src/CMSMicroservice.Protobuf/Protos/discountorder.proto index e84b4ff..7d66400 100644 --- a/src/CMSMicroservice.Protobuf/Protos/discountorder.proto +++ b/src/CMSMicroservice.Protobuf/Protos/discountorder.proto @@ -40,6 +40,20 @@ service DiscountOrderContract get: "/GetUserOrders" }; }; + + // Admin: Get All Discount Orders with filters + rpc GetAllDiscountOrders(GetAllDiscountOrdersRequest) returns (GetAllDiscountOrdersResponse){ + option (google.api.http) = { + get: "/GetAllDiscountOrders" + }; + }; + + // Admin: Get Sales Report + rpc GetDiscountSalesReport(GetDiscountSalesReportRequest) returns (GetDiscountSalesReportResponse){ + option (google.api.http) = { + get: "/GetDiscountSalesReport" + }; + }; } // Place Order (Initial Step - Create Order) @@ -175,3 +189,118 @@ message OrderSummaryDto int32 items_count = 9; google.protobuf.Timestamp created = 10; } + +// ===== Admin: Get All Discount Orders ===== + +message GetAllDiscountOrdersRequest +{ + google.protobuf.Int64Value user_id = 1; + google.protobuf.Int32Value payment_status = 2; + google.protobuf.Int32Value delivery_status = 3; + google.protobuf.StringValue user_mobile = 4; + google.protobuf.StringValue tracking_code = 5; + google.protobuf.Timestamp from_date = 6; + google.protobuf.Timestamp to_date = 7; + google.protobuf.Int64Value min_amount = 8; + google.protobuf.Int64Value max_amount = 9; + int32 page_number = 10; + int32 page_size = 11; +} + +message GetAllDiscountOrdersResponse +{ + messages.MetaData meta_data = 1; + repeated AdminOrderDto models = 2; +} + +message AdminOrderDto +{ + int64 id = 1; + int64 user_id = 2; + string user_full_name = 3; + string user_mobile = 4; + int64 total_amount = 5; + int64 discount_balance_used = 6; + int64 gateway_amount_paid = 7; + int64 vat_amount = 8; + PaymentStatus payment_status = 9; + google.protobuf.Timestamp payment_date = 10; + DeliveryStatus delivery_status = 11; + google.protobuf.Timestamp delivery_date = 12; + google.protobuf.StringValue shipping_address = 13; + google.protobuf.StringValue receiver_name = 14; + google.protobuf.StringValue receiver_mobile = 15; + google.protobuf.StringValue tracking_code = 16; + google.protobuf.StringValue admin_note = 17; + google.protobuf.Timestamp created = 18; + google.protobuf.Timestamp last_modified = 19; + int32 items_count = 20; +} + +enum PaymentStatus +{ + PAYMENT_PENDING = 0; + PAYMENT_COMPLETED = 1; + PAYMENT_FAILED = 2; + PAYMENT_REFUNDED = 3; +} + +// ===== Sales Report Messages ===== + +enum SalesReportType +{ + REPORT_SUMMARY = 0; + REPORT_DAILY = 1; + REPORT_WEEKLY = 2; + REPORT_MONTHLY = 3; +} + +message GetDiscountSalesReportRequest +{ + google.protobuf.Timestamp from_date = 1; + google.protobuf.Timestamp to_date = 2; + SalesReportType report_type = 3; +} + +message GetDiscountSalesReportResponse +{ + SalesSummary summary = 1; + repeated SalesPeriodDto periods = 2; + repeated TopSellingProductDto top_products = 3; +} + +message SalesSummary +{ + int32 total_orders = 1; + int32 completed_orders = 2; + int32 pending_orders = 3; + int32 cancelled_orders = 4; + int64 total_sales_amount = 5; + int64 total_discount_used = 6; + int64 total_gateway_paid = 7; + int64 total_vat_amount = 8; + int64 average_order_value = 9; + int32 unique_customers = 10; + int32 total_products_sold = 11; +} + +message SalesPeriodDto +{ + string period_label = 1; + google.protobuf.Timestamp period_start = 2; + google.protobuf.Timestamp period_end = 3; + int32 orders_count = 4; + int64 total_amount = 5; + int64 discount_used = 6; + int64 gateway_paid = 7; +} + +message TopSellingProductDto +{ + int64 product_id = 1; + string product_title = 2; + google.protobuf.StringValue image_path = 3; + int32 quantity_sold = 4; + int64 total_revenue = 5; + int32 orders_count = 6; +} diff --git a/src/CMSMicroservice.Protobuf/Protos/discountproduct.proto b/src/CMSMicroservice.Protobuf/Protos/discountproduct.proto index 1e3048c..7edb97c 100644 --- a/src/CMSMicroservice.Protobuf/Protos/discountproduct.proto +++ b/src/CMSMicroservice.Protobuf/Protos/discountproduct.proto @@ -40,6 +40,37 @@ service DiscountProductContract get: "/GetDiscountProducts" }; }; + + // Product Image Gallery Operations + rpc AddDiscountProductImage(AddDiscountProductImageRequest) returns (AddDiscountProductImageResponse){ + option (google.api.http) = { + post: "/AddDiscountProductImage" + body: "*" + }; + }; + rpc UpdateDiscountProductImage(UpdateDiscountProductImageRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + put: "/UpdateDiscountProductImage" + body: "*" + }; + }; + rpc DeleteDiscountProductImage(DeleteDiscountProductImageRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + delete: "/DeleteDiscountProductImage" + body: "*" + }; + }; + rpc ReorderDiscountProductImages(ReorderDiscountProductImagesRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + put: "/ReorderDiscountProductImages" + body: "*" + }; + }; + rpc GetDiscountProductImages(GetDiscountProductImagesRequest) returns (GetDiscountProductImagesResponse){ + option (google.api.http) = { + get: "/GetDiscountProductImages" + }; + }; } // Create Product @@ -150,3 +181,68 @@ message DiscountProductDto bool is_active = 10; google.protobuf.Timestamp created = 11; } + +// ===== Product Image Gallery Messages ===== + +// Add Product Image +message AddDiscountProductImageRequest +{ + int64 discount_product_id = 1; + string image_path = 2; + string thumbnail_path = 3; + google.protobuf.StringValue title = 4; + google.protobuf.StringValue alt_text = 5; +} + +message AddDiscountProductImageResponse +{ + int64 image_id = 1; +} + +// Update Product Image +message UpdateDiscountProductImageRequest +{ + int64 id = 1; + string image_path = 2; + string thumbnail_path = 3; + google.protobuf.StringValue title = 4; + google.protobuf.StringValue alt_text = 5; + bool is_active = 6; +} + +// Delete Product Image +message DeleteDiscountProductImageRequest +{ + int64 id = 1; +} + +// Reorder Product Images +message ReorderDiscountProductImagesRequest +{ + int64 discount_product_id = 1; + repeated int64 image_ids = 2; +} + +// Get Product Images +message GetDiscountProductImagesRequest +{ + int64 discount_product_id = 1; + bool only_active = 2; +} + +message GetDiscountProductImagesResponse +{ + repeated DiscountProductImageDto images = 1; +} + +message DiscountProductImageDto +{ + int64 id = 1; + int64 discount_product_id = 2; + string image_path = 3; + string thumbnail_path = 4; + google.protobuf.StringValue title = 5; + google.protobuf.StringValue alt_text = 6; + int32 sort_order = 7; + bool is_active = 8; +} diff --git a/src/CMSMicroservice.WebApi/Services/DiscountOrderService.cs b/src/CMSMicroservice.WebApi/Services/DiscountOrderService.cs index 23c1857..d2df7d5 100644 --- a/src/CMSMicroservice.WebApi/Services/DiscountOrderService.cs +++ b/src/CMSMicroservice.WebApi/Services/DiscountOrderService.cs @@ -5,6 +5,8 @@ using CMSMicroservice.Application.DiscountShopCQ.Commands.CompleteOrderPayment; using CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateOrderStatus; using CMSMicroservice.Application.DiscountShopCQ.Queries.GetOrderById; using CMSMicroservice.Application.DiscountShopCQ.Queries.GetUserOrders; +using CMSMicroservice.Application.DiscountShopCQ.Queries.GetAllDiscountOrders; +using CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountSalesReport; namespace CMSMicroservice.WebApi.Services; @@ -41,4 +43,14 @@ public class DiscountOrderService : DiscountOrderContract.DiscountOrderContractB { return await _dispatchRequestToCQRS.Handle(request, context); } + + public override async Task GetAllDiscountOrders(GetAllDiscountOrdersRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetDiscountSalesReport(GetDiscountSalesReportRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } } diff --git a/src/CMSMicroservice.WebApi/Services/DiscountProductService.cs b/src/CMSMicroservice.WebApi/Services/DiscountProductService.cs index 236fbb7..6f5c6ae 100644 --- a/src/CMSMicroservice.WebApi/Services/DiscountProductService.cs +++ b/src/CMSMicroservice.WebApi/Services/DiscountProductService.cs @@ -3,8 +3,13 @@ using CMSMicroservice.WebApi.Common.Services; using CMSMicroservice.Application.DiscountShopCQ.Commands.CreateDiscountProduct; using CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateDiscountProduct; using CMSMicroservice.Application.DiscountShopCQ.Commands.DeleteDiscountProduct; +using CMSMicroservice.Application.DiscountShopCQ.Commands.AddDiscountProductImage; +using CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateDiscountProductImage; +using CMSMicroservice.Application.DiscountShopCQ.Commands.DeleteDiscountProductImage; +using CMSMicroservice.Application.DiscountShopCQ.Commands.ReorderDiscountProductImages; using CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountProductById; using CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountProducts; +using CMSMicroservice.Application.DiscountShopCQ.Queries.GetDiscountProductImages; namespace CMSMicroservice.WebApi.Services; @@ -41,4 +46,30 @@ public class DiscountProductService : DiscountProductContract.DiscountProductCon { return await _dispatchRequestToCQRS.Handle(request, context); } + + // Product Image Gallery Operations + public override async Task AddDiscountProductImage(AddDiscountProductImageRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task UpdateDiscountProductImage(UpdateDiscountProductImageRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task DeleteDiscountProductImage(DeleteDiscountProductImageRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task ReorderDiscountProductImages(ReorderDiscountProductImagesRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetDiscountProductImages(GetDiscountProductImagesRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } }