feat(club-membership): enhance club membership history queries and responses
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 17m54s
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 17m54s
- Added filtering capabilities to GetClubMembershipHistoryQuery, allowing optional filters for UserId, ClubMembershipId, Action, and date range. - Updated GetClubMembershipHistoryQueryHandler to utilize the new filter structure. - Enhanced GetAllClubMembershipsQueryHandler to include LastPackage details in the response. - Introduced new properties in GetAllClubMembershipsResponseModel for PackageId and PackageName. - Updated Protobuf definitions to reflect changes in club membership history queries and responses. - Refactored mapping configurations to accommodate new DTOs and filters.
This commit is contained in:
+5
@@ -1,4 +1,5 @@
|
|||||||
using CMSMicroservice.Application.Common.Exceptions;
|
using CMSMicroservice.Application.Common.Exceptions;
|
||||||
|
using CMSMicroservice.Application.Common.Helpers;
|
||||||
using CMSMicroservice.Application.Common.Interfaces;
|
using CMSMicroservice.Application.Common.Interfaces;
|
||||||
using CMSMicroservice.Application.Common.Models;
|
using CMSMicroservice.Application.Common.Models;
|
||||||
using CMSMicroservice.Domain.Common;
|
using CMSMicroservice.Domain.Common;
|
||||||
@@ -272,6 +273,7 @@ public class ActivateClubMembershipCommandHandler : IRequestHandler<ActivateClub
|
|||||||
foreach (var prevCycle in previousCycles)
|
foreach (var prevCycle in previousCycles)
|
||||||
{
|
{
|
||||||
prevCycle.IsCurrentCycle = false;
|
prevCycle.IsCurrentCycle = false;
|
||||||
|
ClubMembershipCycleHistoryWriter.WriteCycleClosed(_context, prevCycle, reason: "شروع دوره جدید");
|
||||||
}
|
}
|
||||||
|
|
||||||
var maxCycleNumber = await _context.ClubMembershipCycles
|
var maxCycleNumber = await _context.ClubMembershipCycles
|
||||||
@@ -293,6 +295,9 @@ public class ActivateClubMembershipCommandHandler : IRequestHandler<ActivateClub
|
|||||||
_context.ClubMembershipCycles.Add(newCycle);
|
_context.ClubMembershipCycles.Add(newCycle);
|
||||||
await _context.SaveChangesAsync(cancellationToken);
|
await _context.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
|
ClubMembershipCycleHistoryWriter.WriteCycleStarted(_context, newCycle, reason: "فعالسازی عضویت باشگاه");
|
||||||
|
await _context.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
_logger.LogInformation(
|
_logger.LogInformation(
|
||||||
"Created ClubMembershipCycle #{CycleNumber} for UserId {UserId}, MembershipId {MembershipId}",
|
"Created ClubMembershipCycle #{CycleNumber} for UserId {UserId}, MembershipId {MembershipId}",
|
||||||
newCycle.CycleNumber,
|
newCycle.CycleNumber,
|
||||||
|
|||||||
+4
-1
@@ -13,6 +13,7 @@ public class GetAllClubMembershipsQueryHandler : IRequestHandler<GetAllClubMembe
|
|||||||
{
|
{
|
||||||
var query = _context.ClubMemberships
|
var query = _context.ClubMemberships
|
||||||
.Include(x => x.User)
|
.Include(x => x.User)
|
||||||
|
.Include(x => x.LastPackage)
|
||||||
.ApplyOrder(sortBy: request.SortBy)
|
.ApplyOrder(sortBy: request.SortBy)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.AsQueryable();
|
.AsQueryable();
|
||||||
@@ -35,8 +36,10 @@ public class GetAllClubMembershipsQueryHandler : IRequestHandler<GetAllClubMembe
|
|||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
UserId = x.UserId,
|
UserId = x.UserId,
|
||||||
UserName = x.User != null ? $"{x.User.FirstName} {x.User.LastName}" : string.Empty,
|
UserName = x.User != null ? $"{x.User.FirstName} {x.User.LastName}" : string.Empty,
|
||||||
|
PackageId = x.LastPackageId ?? 0,
|
||||||
|
PackageName = x.LastPackage != null ? x.LastPackage.Title : string.Empty,
|
||||||
IsActive = x.IsActive,
|
IsActive = x.IsActive,
|
||||||
ActivatedAt = x.ActivatedAt,
|
ActivatedAt = x.LastActivationDate ?? x.ActivatedAt,
|
||||||
InitialContribution = x.InitialContribution,
|
InitialContribution = x.InitialContribution,
|
||||||
TotalEarned = x.TotalEarned,
|
TotalEarned = x.TotalEarned,
|
||||||
Created = x.Created,
|
Created = x.Created,
|
||||||
|
|||||||
+2
@@ -11,6 +11,8 @@ public class GetAllClubMembershipsResponseModel
|
|||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public long UserId { get; set; }
|
public long UserId { get; set; }
|
||||||
public string UserName { get; set; } = string.Empty;
|
public string UserName { get; set; } = string.Empty;
|
||||||
|
public long PackageId { get; set; }
|
||||||
|
public string PackageName { get; set; } = string.Empty;
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
public DateTime? ActivatedAt { get; set; }
|
public DateTime? ActivatedAt { get; set; }
|
||||||
public long InitialContribution { get; set; }
|
public long InitialContribution { get; set; }
|
||||||
|
|||||||
+10
-20
@@ -1,27 +1,17 @@
|
|||||||
namespace CMSMicroservice.Application.ClubMembershipCQ.Queries.GetClubMembershipHistory;
|
namespace CMSMicroservice.Application.ClubMembershipCQ.Queries.GetClubMembershipHistory;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Query برای دریافت تاریخچه تغییرات عضویت باشگاه
|
|
||||||
/// </summary>
|
|
||||||
public record GetClubMembershipHistoryQuery : IRequest<GetClubMembershipHistoryResponseDto>
|
public record GetClubMembershipHistoryQuery : IRequest<GetClubMembershipHistoryResponseDto>
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// شناسه عضویت (اختیاری)
|
|
||||||
/// </summary>
|
|
||||||
public long? MembershipId { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// شناسه کاربر (اختیاری)
|
|
||||||
/// </summary>
|
|
||||||
public long? UserId { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// موقعیت صفحهبندی
|
|
||||||
/// </summary>
|
|
||||||
public PaginationState? PaginationState { get; init; }
|
public PaginationState? PaginationState { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// مرتبسازی بر اساس
|
|
||||||
/// </summary>
|
|
||||||
public string? SortBy { get; init; }
|
public string? SortBy { get; init; }
|
||||||
|
public GetClubMembershipHistoryFilter? Filter { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetClubMembershipHistoryFilter
|
||||||
|
{
|
||||||
|
public long? UserId { get; set; }
|
||||||
|
public long? ClubMembershipId { get; set; }
|
||||||
|
public ClubMembershipAction? Action { get; set; }
|
||||||
|
public DateTime? CreatedFrom { get; set; }
|
||||||
|
public DateTime? CreatedTo { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-8
@@ -12,20 +12,30 @@ public class GetClubMembershipHistoryQueryHandler : IRequestHandler<GetClubMembe
|
|||||||
public async Task<GetClubMembershipHistoryResponseDto> Handle(GetClubMembershipHistoryQuery request, CancellationToken cancellationToken)
|
public async Task<GetClubMembershipHistoryResponseDto> Handle(GetClubMembershipHistoryQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var query = _context.ClubMembershipHistories
|
var query = _context.ClubMembershipHistories
|
||||||
|
.Include(x => x.ClubMembership)
|
||||||
|
.ThenInclude(m => m!.User)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.AsQueryable();
|
.AsQueryable();
|
||||||
|
|
||||||
if (request.MembershipId.HasValue)
|
if (request.Filter != null)
|
||||||
{
|
{
|
||||||
query = query.Where(x => x.ClubMembershipId == request.MembershipId.Value);
|
if (request.Filter.ClubMembershipId.HasValue)
|
||||||
|
query = query.Where(x => x.ClubMembershipId == request.Filter.ClubMembershipId.Value);
|
||||||
|
|
||||||
|
if (request.Filter.UserId.HasValue)
|
||||||
|
query = query.Where(x => x.UserId == request.Filter.UserId.Value);
|
||||||
|
|
||||||
|
if (request.Filter.Action.HasValue)
|
||||||
|
query = query.Where(x => x.Action == request.Filter.Action.Value);
|
||||||
|
|
||||||
|
if (request.Filter.CreatedFrom.HasValue)
|
||||||
|
query = query.Where(x => x.Created >= request.Filter.CreatedFrom.Value);
|
||||||
|
|
||||||
|
if (request.Filter.CreatedTo.HasValue)
|
||||||
|
query = query.Where(x => x.Created <= request.Filter.CreatedTo.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.UserId.HasValue)
|
query = query.ApplyOrder(sortBy: request.SortBy ?? "-Created");
|
||||||
{
|
|
||||||
query = query.Where(x => x.UserId == request.UserId.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
query = query.ApplyOrder(sortBy: request.SortBy ?? "Created"); // پیشفرض: جدیدترین اول
|
|
||||||
|
|
||||||
var meta = await query.GetMetaData(request.PaginationState, cancellationToken);
|
var meta = await query.GetMetaData(request.PaginationState, cancellationToken);
|
||||||
|
|
||||||
@@ -36,6 +46,9 @@ public class GetClubMembershipHistoryQueryHandler : IRequestHandler<GetClubMembe
|
|||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
ClubMembershipId = x.ClubMembershipId,
|
ClubMembershipId = x.ClubMembershipId,
|
||||||
UserId = x.UserId,
|
UserId = x.UserId,
|
||||||
|
UserName = x.ClubMembership != null && x.ClubMembership.User != null
|
||||||
|
? $"{x.ClubMembership.User.FirstName} {x.ClubMembership.User.LastName}"
|
||||||
|
: string.Empty,
|
||||||
OldIsActive = x.OldIsActive,
|
OldIsActive = x.OldIsActive,
|
||||||
NewIsActive = x.NewIsActive,
|
NewIsActive = x.NewIsActive,
|
||||||
OldInitialContribution = x.OldInitialContribution,
|
OldInitialContribution = x.OldInitialContribution,
|
||||||
|
|||||||
+1
-26
@@ -4,31 +4,6 @@ public class GetClubMembershipHistoryQueryValidator : AbstractValidator<GetClubM
|
|||||||
{
|
{
|
||||||
public GetClubMembershipHistoryQueryValidator()
|
public GetClubMembershipHistoryQueryValidator()
|
||||||
{
|
{
|
||||||
RuleFor(x => x.MembershipId)
|
// Admin report: filters are all optional
|
||||||
.GreaterThan(0)
|
|
||||||
.WithMessage("شناسه عضویت معتبر نیست")
|
|
||||||
.When(x => x.MembershipId.HasValue);
|
|
||||||
|
|
||||||
RuleFor(x => x.UserId)
|
|
||||||
.GreaterThan(0)
|
|
||||||
.WithMessage("شناسه کاربر معتبر نیست")
|
|
||||||
.When(x => x.UserId.HasValue);
|
|
||||||
|
|
||||||
RuleFor(x => x)
|
|
||||||
.Must(x => x.MembershipId.HasValue || x.UserId.HasValue)
|
|
||||||
.WithMessage("حداقل یکی از MembershipId یا UserId باید مقداردهی شود");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
|
||||||
{
|
|
||||||
var result = await ValidateAsync(
|
|
||||||
ValidationContext<GetClubMembershipHistoryQuery>.CreateWithOptions(
|
|
||||||
(GetClubMembershipHistoryQuery)model,
|
|
||||||
x => x.IncludeProperties(propertyName)));
|
|
||||||
|
|
||||||
if (result.IsValid)
|
|
||||||
return Array.Empty<string>();
|
|
||||||
|
|
||||||
return result.Errors.Select(e => e.ErrorMessage);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -11,6 +11,7 @@ public class GetClubMembershipHistoryResponseModel
|
|||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public long ClubMembershipId { get; set; }
|
public long ClubMembershipId { get; set; }
|
||||||
public long UserId { get; set; }
|
public long UserId { get; set; }
|
||||||
|
public string UserName { get; set; } = string.Empty;
|
||||||
public bool OldIsActive { get; set; }
|
public bool OldIsActive { get; set; }
|
||||||
public bool NewIsActive { get; set; }
|
public bool NewIsActive { get; set; }
|
||||||
public long? OldInitialContribution { get; set; }
|
public long? OldInitialContribution { get; set; }
|
||||||
|
|||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
using CMSMicroservice.Domain.Entities.Club;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Application.ClubMembershipCycleCQ.Queries.GetAllClubMembershipCycleByFilter;
|
||||||
|
|
||||||
|
public static class ClubMembershipCycleFilterExtensions
|
||||||
|
{
|
||||||
|
public static IQueryable<ClubMembershipCycle> ApplyClubMembershipCycleFilter(
|
||||||
|
this IQueryable<ClubMembershipCycle> query,
|
||||||
|
GetAllClubMembershipCycleByFilterFilter? filter)
|
||||||
|
{
|
||||||
|
if (filter == null) return query;
|
||||||
|
|
||||||
|
if (filter.UserId.HasValue)
|
||||||
|
query = query.Where(x => x.UserId == filter.UserId.Value);
|
||||||
|
|
||||||
|
if (filter.IsCurrentCycle.HasValue)
|
||||||
|
query = query.Where(x => x.IsCurrentCycle == filter.IsCurrentCycle.Value);
|
||||||
|
|
||||||
|
if (filter.PackageId.HasValue)
|
||||||
|
query = query.Where(x => x.PackageId == filter.PackageId.Value);
|
||||||
|
|
||||||
|
if (filter.CycleNumber.HasValue)
|
||||||
|
query = query.Where(x => x.CycleNumber == filter.CycleNumber.Value);
|
||||||
|
|
||||||
|
if (filter.PurchaseMethod.HasValue)
|
||||||
|
query = query.Where(x => x.PurchaseMethod == filter.PurchaseMethod.Value);
|
||||||
|
|
||||||
|
if (filter.MagicState.HasValue)
|
||||||
|
{
|
||||||
|
query = filter.MagicState.Value switch
|
||||||
|
{
|
||||||
|
1 => query.Where(x => x.MagicStartedAt != null && x.MagicCompletedAt == null),
|
||||||
|
2 => query.Where(x => x.MagicCompletedAt != null),
|
||||||
|
_ => query.Where(x => x.MagicStartedAt == null && x.MagicCompletedAt == null)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.PackagePurchasedFrom.HasValue)
|
||||||
|
query = query.Where(x => x.PackagePurchasedAt >= filter.PackagePurchasedFrom.Value);
|
||||||
|
|
||||||
|
if (filter.PackagePurchasedTo.HasValue)
|
||||||
|
query = query.Where(x => x.PackagePurchasedAt <= filter.PackagePurchasedTo.Value);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
}
|
||||||
+47
@@ -0,0 +1,47 @@
|
|||||||
|
using CMSMicroservice.Domain.Enums;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Application.ClubMembershipCycleCQ.Queries.GetAllClubMembershipCycleByFilter;
|
||||||
|
|
||||||
|
public record GetAllClubMembershipCycleByFilterQuery : IRequest<GetAllClubMembershipCycleByFilterResponseDto>
|
||||||
|
{
|
||||||
|
public PaginationState? PaginationState { get; init; }
|
||||||
|
public string? SortBy { get; init; }
|
||||||
|
public GetAllClubMembershipCycleByFilterFilter? Filter { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAllClubMembershipCycleByFilterFilter
|
||||||
|
{
|
||||||
|
public long? UserId { get; set; }
|
||||||
|
public bool? IsCurrentCycle { get; set; }
|
||||||
|
public long? PackageId { get; set; }
|
||||||
|
public int? CycleNumber { get; set; }
|
||||||
|
public PackagePurchaseMethod? PurchaseMethod { get; set; }
|
||||||
|
/// <summary>0=none, 1=active magic, 2=completed magic</summary>
|
||||||
|
public int? MagicState { get; set; }
|
||||||
|
public DateTime? PackagePurchasedFrom { get; set; }
|
||||||
|
public DateTime? PackagePurchasedTo { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAllClubMembershipCycleByFilterResponseDto
|
||||||
|
{
|
||||||
|
public MetaData MetaData { get; set; }
|
||||||
|
public List<GetAllClubMembershipCycleByFilterResponseModel>? Models { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAllClubMembershipCycleByFilterResponseModel
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public long UserId { get; set; }
|
||||||
|
public string UserName { get; set; } = string.Empty;
|
||||||
|
public long ClubMembershipId { get; set; }
|
||||||
|
public int CycleNumber { get; set; }
|
||||||
|
public long PackageId { get; set; }
|
||||||
|
public string PackageName { get; set; } = string.Empty;
|
||||||
|
public long PackageAmount { get; set; }
|
||||||
|
public PackagePurchaseMethod PurchaseMethod { get; set; }
|
||||||
|
public DateTime PackagePurchasedAt { get; set; }
|
||||||
|
public DateTime? MagicStartedAt { get; set; }
|
||||||
|
public DateTime? MagicCompletedAt { get; set; }
|
||||||
|
public bool IsCurrentCycle { get; set; }
|
||||||
|
public DateTimeOffset Created { get; set; }
|
||||||
|
}
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
namespace CMSMicroservice.Application.ClubMembershipCycleCQ.Queries.GetAllClubMembershipCycleByFilter;
|
||||||
|
|
||||||
|
public class GetAllClubMembershipCycleByFilterQueryHandler
|
||||||
|
: IRequestHandler<GetAllClubMembershipCycleByFilterQuery, GetAllClubMembershipCycleByFilterResponseDto>
|
||||||
|
{
|
||||||
|
private readonly IApplicationDbContext _context;
|
||||||
|
|
||||||
|
public GetAllClubMembershipCycleByFilterQueryHandler(IApplicationDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<GetAllClubMembershipCycleByFilterResponseDto> Handle(
|
||||||
|
GetAllClubMembershipCycleByFilterQuery request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var query = _context.ClubMembershipCycles
|
||||||
|
.Include(x => x.User)
|
||||||
|
.Include(x => x.Package)
|
||||||
|
.AsNoTracking()
|
||||||
|
.ApplyClubMembershipCycleFilter(request.Filter)
|
||||||
|
.ApplyOrder(sortBy: request.SortBy ?? "-PackagePurchasedAt");
|
||||||
|
|
||||||
|
return new GetAllClubMembershipCycleByFilterResponseDto
|
||||||
|
{
|
||||||
|
MetaData = await query.GetMetaData(request.PaginationState, cancellationToken),
|
||||||
|
Models = await query
|
||||||
|
.PaginatedListAsync(paginationState: request.PaginationState)
|
||||||
|
.Select(x => new GetAllClubMembershipCycleByFilterResponseModel
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
UserId = x.UserId,
|
||||||
|
UserName = x.User != null ? $"{x.User.FirstName} {x.User.LastName}" : string.Empty,
|
||||||
|
ClubMembershipId = x.ClubMembershipId,
|
||||||
|
CycleNumber = x.CycleNumber,
|
||||||
|
PackageId = x.PackageId,
|
||||||
|
PackageName = x.Package != null ? x.Package.Title : string.Empty,
|
||||||
|
PackageAmount = x.PackageAmount,
|
||||||
|
PurchaseMethod = x.PurchaseMethod,
|
||||||
|
PackagePurchasedAt = x.PackagePurchasedAt,
|
||||||
|
MagicStartedAt = x.MagicStartedAt,
|
||||||
|
MagicCompletedAt = x.MagicCompletedAt,
|
||||||
|
IsCurrentCycle = x.IsCurrentCycle,
|
||||||
|
Created = x.Created
|
||||||
|
})
|
||||||
|
.ToListAsync(cancellationToken)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
namespace CMSMicroservice.Application.ClubMembershipCycleCQ.Queries.GetClubMembershipCycleSummary;
|
||||||
|
|
||||||
|
public record GetClubMembershipCycleSummaryQuery : IRequest<GetClubMembershipCycleSummaryResponseDto>
|
||||||
|
{
|
||||||
|
public GetAllClubMembershipCycleByFilter.GetAllClubMembershipCycleByFilterFilter? Filter { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetClubMembershipCycleSummaryResponseDto
|
||||||
|
{
|
||||||
|
public long TotalCount { get; set; }
|
||||||
|
public long CurrentCycleCount { get; set; }
|
||||||
|
public long MagicActiveCount { get; set; }
|
||||||
|
}
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
using CMSMicroservice.Application.ClubMembershipCycleCQ.Queries.GetAllClubMembershipCycleByFilter;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Application.ClubMembershipCycleCQ.Queries.GetClubMembershipCycleSummary;
|
||||||
|
|
||||||
|
public class GetClubMembershipCycleSummaryQueryHandler
|
||||||
|
: IRequestHandler<GetClubMembershipCycleSummaryQuery, GetClubMembershipCycleSummaryResponseDto>
|
||||||
|
{
|
||||||
|
private readonly IApplicationDbContext _context;
|
||||||
|
|
||||||
|
public GetClubMembershipCycleSummaryQueryHandler(IApplicationDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<GetClubMembershipCycleSummaryResponseDto> Handle(
|
||||||
|
GetClubMembershipCycleSummaryQuery request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var query = _context.ClubMembershipCycles
|
||||||
|
.AsNoTracking()
|
||||||
|
.ApplyClubMembershipCycleFilter(request.Filter);
|
||||||
|
|
||||||
|
var totalCount = await query.LongCountAsync(cancellationToken);
|
||||||
|
var currentCycleCount = await query.LongCountAsync(x => x.IsCurrentCycle, cancellationToken);
|
||||||
|
var magicActiveCount = await query.LongCountAsync(
|
||||||
|
x => x.MagicStartedAt != null && x.MagicCompletedAt == null,
|
||||||
|
cancellationToken);
|
||||||
|
|
||||||
|
return new GetClubMembershipCycleSummaryResponseDto
|
||||||
|
{
|
||||||
|
TotalCount = totalCount,
|
||||||
|
CurrentCycleCount = currentCycleCount,
|
||||||
|
MagicActiveCount = magicActiveCount
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
using CMSMicroservice.Domain.Entities.History;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Application.ClubMembershipCycleHistoryCQ.Queries.GetAllClubMembershipCycleHistoryByFilter;
|
||||||
|
|
||||||
|
public static class ClubMembershipCycleHistoryFilterExtensions
|
||||||
|
{
|
||||||
|
public static IQueryable<ClubMembershipCycleHistory> ApplyClubMembershipCycleHistoryFilter(
|
||||||
|
this IQueryable<ClubMembershipCycleHistory> query,
|
||||||
|
GetAllClubMembershipCycleHistoryByFilterFilter? filter)
|
||||||
|
{
|
||||||
|
if (filter == null) return query;
|
||||||
|
|
||||||
|
if (filter.UserId.HasValue)
|
||||||
|
query = query.Where(x => x.UserId == filter.UserId.Value);
|
||||||
|
|
||||||
|
if (filter.ClubMembershipCycleId.HasValue)
|
||||||
|
query = query.Where(x => x.ClubMembershipCycleId == filter.ClubMembershipCycleId.Value);
|
||||||
|
|
||||||
|
if (filter.CycleNumber.HasValue)
|
||||||
|
query = query.Where(x => x.CycleNumber == filter.CycleNumber.Value);
|
||||||
|
|
||||||
|
if (filter.Action.HasValue)
|
||||||
|
query = query.Where(x => x.Action == filter.Action.Value);
|
||||||
|
|
||||||
|
if (filter.CreatedFrom.HasValue)
|
||||||
|
query = query.Where(x => x.Created >= filter.CreatedFrom.Value);
|
||||||
|
|
||||||
|
if (filter.CreatedTo.HasValue)
|
||||||
|
query = query.Where(x => x.Created <= filter.CreatedTo.Value);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
}
|
||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
using CMSMicroservice.Domain.Enums;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Application.ClubMembershipCycleHistoryCQ.Queries.GetAllClubMembershipCycleHistoryByFilter;
|
||||||
|
|
||||||
|
public record GetAllClubMembershipCycleHistoryByFilterQuery : IRequest<GetAllClubMembershipCycleHistoryByFilterResponseDto>
|
||||||
|
{
|
||||||
|
public PaginationState? PaginationState { get; init; }
|
||||||
|
public string? SortBy { get; init; }
|
||||||
|
public GetAllClubMembershipCycleHistoryByFilterFilter? Filter { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAllClubMembershipCycleHistoryByFilterFilter
|
||||||
|
{
|
||||||
|
public long? UserId { get; set; }
|
||||||
|
public long? ClubMembershipCycleId { get; set; }
|
||||||
|
public int? CycleNumber { get; set; }
|
||||||
|
public ClubMembershipCycleAction? Action { get; set; }
|
||||||
|
public DateTime? CreatedFrom { get; set; }
|
||||||
|
public DateTime? CreatedTo { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAllClubMembershipCycleHistoryByFilterResponseDto
|
||||||
|
{
|
||||||
|
public MetaData MetaData { get; set; }
|
||||||
|
public List<GetAllClubMembershipCycleHistoryByFilterResponseModel>? Models { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAllClubMembershipCycleHistoryByFilterResponseModel
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public long ClubMembershipCycleId { get; set; }
|
||||||
|
public long UserId { get; set; }
|
||||||
|
public string UserName { get; set; } = string.Empty;
|
||||||
|
public int CycleNumber { get; set; }
|
||||||
|
public bool OldIsCurrentCycle { get; set; }
|
||||||
|
public bool NewIsCurrentCycle { get; set; }
|
||||||
|
public DateTime? OldMagicStartedAt { get; set; }
|
||||||
|
public DateTime? NewMagicStartedAt { get; set; }
|
||||||
|
public DateTime? OldMagicCompletedAt { get; set; }
|
||||||
|
public DateTime? NewMagicCompletedAt { get; set; }
|
||||||
|
public ClubMembershipCycleAction Action { get; set; }
|
||||||
|
public string? PerformedBy { get; set; }
|
||||||
|
public string? Reason { get; set; }
|
||||||
|
public DateTimeOffset Created { get; set; }
|
||||||
|
}
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
namespace CMSMicroservice.Application.ClubMembershipCycleHistoryCQ.Queries.GetAllClubMembershipCycleHistoryByFilter;
|
||||||
|
|
||||||
|
public class GetAllClubMembershipCycleHistoryByFilterQueryHandler
|
||||||
|
: IRequestHandler<GetAllClubMembershipCycleHistoryByFilterQuery, GetAllClubMembershipCycleHistoryByFilterResponseDto>
|
||||||
|
{
|
||||||
|
private readonly IApplicationDbContext _context;
|
||||||
|
|
||||||
|
public GetAllClubMembershipCycleHistoryByFilterQueryHandler(IApplicationDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<GetAllClubMembershipCycleHistoryByFilterResponseDto> Handle(
|
||||||
|
GetAllClubMembershipCycleHistoryByFilterQuery request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var query = _context.ClubMembershipCycleHistories
|
||||||
|
.Include(x => x.ClubMembershipCycle)
|
||||||
|
.ThenInclude(c => c!.User)
|
||||||
|
.AsNoTracking()
|
||||||
|
.ApplyClubMembershipCycleHistoryFilter(request.Filter)
|
||||||
|
.ApplyOrder(sortBy: request.SortBy ?? "-Created");
|
||||||
|
|
||||||
|
return new GetAllClubMembershipCycleHistoryByFilterResponseDto
|
||||||
|
{
|
||||||
|
MetaData = await query.GetMetaData(request.PaginationState, cancellationToken),
|
||||||
|
Models = await query
|
||||||
|
.PaginatedListAsync(paginationState: request.PaginationState)
|
||||||
|
.Select(x => new GetAllClubMembershipCycleHistoryByFilterResponseModel
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
ClubMembershipCycleId = x.ClubMembershipCycleId,
|
||||||
|
UserId = x.UserId,
|
||||||
|
UserName = x.ClubMembershipCycle != null && x.ClubMembershipCycle.User != null
|
||||||
|
? $"{x.ClubMembershipCycle.User.FirstName} {x.ClubMembershipCycle.User.LastName}"
|
||||||
|
: string.Empty,
|
||||||
|
CycleNumber = x.CycleNumber,
|
||||||
|
OldIsCurrentCycle = x.OldIsCurrentCycle,
|
||||||
|
NewIsCurrentCycle = x.NewIsCurrentCycle,
|
||||||
|
OldMagicStartedAt = x.OldMagicStartedAt,
|
||||||
|
NewMagicStartedAt = x.NewMagicStartedAt,
|
||||||
|
OldMagicCompletedAt = x.OldMagicCompletedAt,
|
||||||
|
NewMagicCompletedAt = x.NewMagicCompletedAt,
|
||||||
|
Action = x.Action,
|
||||||
|
PerformedBy = x.PerformedBy,
|
||||||
|
Reason = x.Reason,
|
||||||
|
Created = x.Created
|
||||||
|
})
|
||||||
|
.ToListAsync(cancellationToken)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
using CMSMicroservice.Domain.Entities.Club;
|
||||||
|
using CMSMicroservice.Domain.Entities.History;
|
||||||
|
using CMSMicroservice.Domain.Enums;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Application.Common.Helpers;
|
||||||
|
|
||||||
|
public static class ClubMembershipCycleHistoryWriter
|
||||||
|
{
|
||||||
|
public static void WriteCycleStarted(
|
||||||
|
IApplicationDbContext context,
|
||||||
|
ClubMembershipCycle cycle,
|
||||||
|
string? performedBy = "System",
|
||||||
|
string? reason = null)
|
||||||
|
{
|
||||||
|
context.ClubMembershipCycleHistories.Add(new ClubMembershipCycleHistory
|
||||||
|
{
|
||||||
|
ClubMembershipCycleId = cycle.Id,
|
||||||
|
UserId = cycle.UserId,
|
||||||
|
CycleNumber = cycle.CycleNumber,
|
||||||
|
OldIsCurrentCycle = false,
|
||||||
|
NewIsCurrentCycle = cycle.IsCurrentCycle,
|
||||||
|
OldMagicStartedAt = null,
|
||||||
|
NewMagicStartedAt = cycle.MagicStartedAt,
|
||||||
|
OldMagicCompletedAt = null,
|
||||||
|
NewMagicCompletedAt = cycle.MagicCompletedAt,
|
||||||
|
Action = ClubMembershipCycleAction.Started,
|
||||||
|
PerformedBy = performedBy,
|
||||||
|
Reason = reason
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteCycleClosed(
|
||||||
|
IApplicationDbContext context,
|
||||||
|
ClubMembershipCycle cycle,
|
||||||
|
string? performedBy = "System",
|
||||||
|
string? reason = null)
|
||||||
|
{
|
||||||
|
context.ClubMembershipCycleHistories.Add(new ClubMembershipCycleHistory
|
||||||
|
{
|
||||||
|
ClubMembershipCycleId = cycle.Id,
|
||||||
|
UserId = cycle.UserId,
|
||||||
|
CycleNumber = cycle.CycleNumber,
|
||||||
|
OldIsCurrentCycle = true,
|
||||||
|
NewIsCurrentCycle = false,
|
||||||
|
OldMagicStartedAt = cycle.MagicStartedAt,
|
||||||
|
NewMagicStartedAt = cycle.MagicStartedAt,
|
||||||
|
OldMagicCompletedAt = cycle.MagicCompletedAt,
|
||||||
|
NewMagicCompletedAt = cycle.MagicCompletedAt,
|
||||||
|
Action = ClubMembershipCycleAction.Completed,
|
||||||
|
PerformedBy = performedBy,
|
||||||
|
Reason = reason ?? "دوره جدید جایگزین شد"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
namespace CMSMicroservice.Application.PaymentTransactionCQ.Queries.GetAllPaymentTransactionByFilter;
|
||||||
|
|
||||||
|
public record GetAllPaymentTransactionByFilterQuery : IRequest<GetAllPaymentTransactionByFilterResponseDto>
|
||||||
|
{
|
||||||
|
public PaginationState? PaginationState { get; init; }
|
||||||
|
public string? SortBy { get; init; }
|
||||||
|
public GetAllPaymentTransactionByFilterFilter? Filter { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAllPaymentTransactionByFilterFilter
|
||||||
|
{
|
||||||
|
public long? UserId { get; set; }
|
||||||
|
public string? Mobile { get; set; }
|
||||||
|
public string? GatewayProvider { get; set; }
|
||||||
|
public bool? PaymentStatus { get; set; }
|
||||||
|
public string? Authority { get; set; }
|
||||||
|
public string? RefId { get; set; }
|
||||||
|
public string? OrderId { get; set; }
|
||||||
|
public DateTime? CreatedFrom { get; set; }
|
||||||
|
public DateTime? CreatedTo { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAllPaymentTransactionByFilterResponseDto
|
||||||
|
{
|
||||||
|
public MetaData MetaData { get; set; }
|
||||||
|
public List<GetAllPaymentTransactionByFilterResponseModel>? Models { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAllPaymentTransactionByFilterResponseModel
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public long? UserId { get; set; }
|
||||||
|
public string? Mobile { get; set; }
|
||||||
|
public string GatewayProvider { get; set; } = string.Empty;
|
||||||
|
public long Amount { get; set; }
|
||||||
|
public string? Authority { get; set; }
|
||||||
|
public bool PaymentStatus { get; set; }
|
||||||
|
public int? VerificationStatusCode { get; set; }
|
||||||
|
public string? VerificationStatusMessage { get; set; }
|
||||||
|
public string? RefId { get; set; }
|
||||||
|
public string? CardPan { get; set; }
|
||||||
|
public string? OrderId { get; set; }
|
||||||
|
public long? TransactionId { get; set; }
|
||||||
|
public string? Description { get; set; }
|
||||||
|
public DateTimeOffset Created { get; set; }
|
||||||
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
namespace CMSMicroservice.Application.PaymentTransactionCQ.Queries.GetAllPaymentTransactionByFilter;
|
||||||
|
|
||||||
|
public class GetAllPaymentTransactionByFilterQueryHandler
|
||||||
|
: IRequestHandler<GetAllPaymentTransactionByFilterQuery, GetAllPaymentTransactionByFilterResponseDto>
|
||||||
|
{
|
||||||
|
private readonly IApplicationDbContext _context;
|
||||||
|
|
||||||
|
public GetAllPaymentTransactionByFilterQueryHandler(IApplicationDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<GetAllPaymentTransactionByFilterResponseDto> Handle(
|
||||||
|
GetAllPaymentTransactionByFilterQuery request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var query = _context.PaymentTransactions
|
||||||
|
.AsNoTracking()
|
||||||
|
.ApplyPaymentTransactionFilter(request.Filter)
|
||||||
|
.ApplyOrder(sortBy: request.SortBy ?? "-Created");
|
||||||
|
|
||||||
|
return new GetAllPaymentTransactionByFilterResponseDto
|
||||||
|
{
|
||||||
|
MetaData = await query.GetMetaData(request.PaginationState, cancellationToken),
|
||||||
|
Models = await query
|
||||||
|
.PaginatedListAsync(paginationState: request.PaginationState)
|
||||||
|
.Select(x => new GetAllPaymentTransactionByFilterResponseModel
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
UserId = x.UserId,
|
||||||
|
Mobile = x.Mobile,
|
||||||
|
GatewayProvider = x.GatewayProvider,
|
||||||
|
Amount = x.Amount,
|
||||||
|
Authority = x.Authority,
|
||||||
|
PaymentStatus = x.PaymentStatus,
|
||||||
|
VerificationStatusCode = x.VerificationStatusCode,
|
||||||
|
VerificationStatusMessage = x.VerificationStatusMessage,
|
||||||
|
RefId = x.RefId,
|
||||||
|
CardPan = x.CardPan,
|
||||||
|
OrderId = x.OrderId,
|
||||||
|
TransactionId = x.TransactionId,
|
||||||
|
Description = x.Description,
|
||||||
|
Created = x.Created
|
||||||
|
})
|
||||||
|
.ToListAsync(cancellationToken)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
using CMSMicroservice.Domain.Entities.Payment;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Application.PaymentTransactionCQ.Queries.GetAllPaymentTransactionByFilter;
|
||||||
|
|
||||||
|
public static class PaymentTransactionFilterExtensions
|
||||||
|
{
|
||||||
|
public static IQueryable<PaymentTransaction> ApplyPaymentTransactionFilter(
|
||||||
|
this IQueryable<PaymentTransaction> query,
|
||||||
|
GetAllPaymentTransactionByFilterFilter? filter)
|
||||||
|
{
|
||||||
|
if (filter == null) return query;
|
||||||
|
|
||||||
|
if (filter.UserId.HasValue)
|
||||||
|
query = query.Where(x => x.UserId == filter.UserId.Value);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(filter.Mobile))
|
||||||
|
query = query.Where(x => x.Mobile != null && x.Mobile.Contains(filter.Mobile));
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(filter.GatewayProvider))
|
||||||
|
query = query.Where(x => x.GatewayProvider == filter.GatewayProvider);
|
||||||
|
|
||||||
|
if (filter.PaymentStatus.HasValue)
|
||||||
|
query = query.Where(x => x.PaymentStatus == filter.PaymentStatus.Value);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(filter.Authority))
|
||||||
|
query = query.Where(x => x.Authority != null && x.Authority.Contains(filter.Authority));
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(filter.RefId))
|
||||||
|
query = query.Where(x => x.RefId != null && x.RefId.Contains(filter.RefId));
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(filter.OrderId))
|
||||||
|
query = query.Where(x => x.OrderId != null && x.OrderId.Contains(filter.OrderId));
|
||||||
|
|
||||||
|
if (filter.CreatedFrom.HasValue)
|
||||||
|
query = query.Where(x => x.Created >= filter.CreatedFrom.Value);
|
||||||
|
|
||||||
|
if (filter.CreatedTo.HasValue)
|
||||||
|
query = query.Where(x => x.Created <= filter.CreatedTo.Value);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
namespace CMSMicroservice.Application.PaymentTransactionCQ.Queries.GetPaymentTransactionSummary;
|
||||||
|
|
||||||
|
public record GetPaymentTransactionSummaryQuery : IRequest<GetPaymentTransactionSummaryResponseDto>
|
||||||
|
{
|
||||||
|
public GetAllPaymentTransactionByFilter.GetAllPaymentTransactionByFilterFilter? Filter { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetPaymentTransactionSummaryResponseDto
|
||||||
|
{
|
||||||
|
public long TotalCount { get; set; }
|
||||||
|
public long TotalAmount { get; set; }
|
||||||
|
public long SuccessfulCount { get; set; }
|
||||||
|
public long PendingCount { get; set; }
|
||||||
|
}
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
using CMSMicroservice.Application.PaymentTransactionCQ.Queries.GetAllPaymentTransactionByFilter;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Application.PaymentTransactionCQ.Queries.GetPaymentTransactionSummary;
|
||||||
|
|
||||||
|
public class GetPaymentTransactionSummaryQueryHandler
|
||||||
|
: IRequestHandler<GetPaymentTransactionSummaryQuery, GetPaymentTransactionSummaryResponseDto>
|
||||||
|
{
|
||||||
|
private readonly IApplicationDbContext _context;
|
||||||
|
|
||||||
|
public GetPaymentTransactionSummaryQueryHandler(IApplicationDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<GetPaymentTransactionSummaryResponseDto> Handle(
|
||||||
|
GetPaymentTransactionSummaryQuery request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var query = _context.PaymentTransactions
|
||||||
|
.AsNoTracking()
|
||||||
|
.ApplyPaymentTransactionFilter(request.Filter);
|
||||||
|
|
||||||
|
var totalCount = await query.LongCountAsync(cancellationToken);
|
||||||
|
var totalAmount = totalCount > 0 ? await query.SumAsync(x => x.Amount, cancellationToken) : 0;
|
||||||
|
var successfulCount = await query.LongCountAsync(x => x.PaymentStatus, cancellationToken);
|
||||||
|
var pendingCount = await query.LongCountAsync(x => !x.PaymentStatus, cancellationToken);
|
||||||
|
|
||||||
|
return new GetPaymentTransactionSummaryResponseDto
|
||||||
|
{
|
||||||
|
TotalCount = totalCount,
|
||||||
|
TotalAmount = totalAmount,
|
||||||
|
SuccessfulCount = successfulCount,
|
||||||
|
PendingCount = pendingCount
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
using CMSMicroservice.Domain.Enums;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetAllUserPackagePurchaseByFilter;
|
||||||
|
|
||||||
|
public record GetAllUserPackagePurchaseByFilterQuery : IRequest<GetAllUserPackagePurchaseByFilterResponseDto>
|
||||||
|
{
|
||||||
|
public PaginationState? PaginationState { get; init; }
|
||||||
|
public string? SortBy { get; init; }
|
||||||
|
public GetAllUserPackagePurchaseByFilterFilter? Filter { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAllUserPackagePurchaseByFilterFilter
|
||||||
|
{
|
||||||
|
public long? UserId { get; set; }
|
||||||
|
public long? PackageId { get; set; }
|
||||||
|
public PackagePurchaseMethod? PurchaseMethod { get; set; }
|
||||||
|
public DateTime? PurchasedFrom { get; set; }
|
||||||
|
public DateTime? PurchasedTo { get; set; }
|
||||||
|
public long? MinAmount { get; set; }
|
||||||
|
public long? MaxAmount { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAllUserPackagePurchaseByFilterResponseDto
|
||||||
|
{
|
||||||
|
public MetaData MetaData { get; set; }
|
||||||
|
public List<GetAllUserPackagePurchaseByFilterResponseModel>? Models { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAllUserPackagePurchaseByFilterResponseModel
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public long UserId { get; set; }
|
||||||
|
public string UserName { get; set; } = string.Empty;
|
||||||
|
public string UserMobile { get; set; } = string.Empty;
|
||||||
|
public long PackageId { get; set; }
|
||||||
|
public string PackageName { get; set; } = string.Empty;
|
||||||
|
public PackagePurchaseMethod PurchaseMethod { get; set; }
|
||||||
|
public DateTime PurchasedAt { get; set; }
|
||||||
|
public long Amount { get; set; }
|
||||||
|
public long? OrderId { get; set; }
|
||||||
|
public long? TransactionId { get; set; }
|
||||||
|
public DateTimeOffset Created { get; set; }
|
||||||
|
}
|
||||||
+47
@@ -0,0 +1,47 @@
|
|||||||
|
namespace CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetAllUserPackagePurchaseByFilter;
|
||||||
|
|
||||||
|
public class GetAllUserPackagePurchaseByFilterQueryHandler
|
||||||
|
: IRequestHandler<GetAllUserPackagePurchaseByFilterQuery, GetAllUserPackagePurchaseByFilterResponseDto>
|
||||||
|
{
|
||||||
|
private readonly IApplicationDbContext _context;
|
||||||
|
|
||||||
|
public GetAllUserPackagePurchaseByFilterQueryHandler(IApplicationDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<GetAllUserPackagePurchaseByFilterResponseDto> Handle(
|
||||||
|
GetAllUserPackagePurchaseByFilterQuery request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var query = _context.UserPackagePurchases
|
||||||
|
.Include(x => x.User)
|
||||||
|
.Include(x => x.Package)
|
||||||
|
.AsNoTracking()
|
||||||
|
.ApplyUserPackagePurchaseFilter(request.Filter)
|
||||||
|
.ApplyOrder(sortBy: request.SortBy ?? "-PurchasedAt");
|
||||||
|
|
||||||
|
return new GetAllUserPackagePurchaseByFilterResponseDto
|
||||||
|
{
|
||||||
|
MetaData = await query.GetMetaData(request.PaginationState, cancellationToken),
|
||||||
|
Models = await query
|
||||||
|
.PaginatedListAsync(paginationState: request.PaginationState)
|
||||||
|
.Select(x => new GetAllUserPackagePurchaseByFilterResponseModel
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
UserId = x.UserId,
|
||||||
|
UserName = x.User != null ? $"{x.User.FirstName} {x.User.LastName}" : string.Empty,
|
||||||
|
UserMobile = x.User != null ? x.User.Mobile : string.Empty,
|
||||||
|
PackageId = x.PackageId,
|
||||||
|
PackageName = x.Package != null ? x.Package.Title : string.Empty,
|
||||||
|
PurchaseMethod = x.PurchaseMethod,
|
||||||
|
PurchasedAt = x.PurchasedAt,
|
||||||
|
Amount = x.Amount,
|
||||||
|
OrderId = x.OrderId,
|
||||||
|
TransactionId = x.TransactionId,
|
||||||
|
Created = x.Created
|
||||||
|
})
|
||||||
|
.ToListAsync(cancellationToken)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
using CMSMicroservice.Domain.Entities;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetAllUserPackagePurchaseByFilter;
|
||||||
|
|
||||||
|
public static class UserPackagePurchaseFilterExtensions
|
||||||
|
{
|
||||||
|
public static IQueryable<UserPackagePurchase> ApplyUserPackagePurchaseFilter(
|
||||||
|
this IQueryable<UserPackagePurchase> query,
|
||||||
|
GetAllUserPackagePurchaseByFilterFilter? filter)
|
||||||
|
{
|
||||||
|
if (filter == null) return query;
|
||||||
|
|
||||||
|
if (filter.UserId.HasValue)
|
||||||
|
query = query.Where(x => x.UserId == filter.UserId.Value);
|
||||||
|
|
||||||
|
if (filter.PackageId.HasValue)
|
||||||
|
query = query.Where(x => x.PackageId == filter.PackageId.Value);
|
||||||
|
|
||||||
|
if (filter.PurchaseMethod.HasValue)
|
||||||
|
query = query.Where(x => x.PurchaseMethod == filter.PurchaseMethod.Value);
|
||||||
|
|
||||||
|
if (filter.PurchasedFrom.HasValue)
|
||||||
|
query = query.Where(x => x.PurchasedAt >= filter.PurchasedFrom.Value);
|
||||||
|
|
||||||
|
if (filter.PurchasedTo.HasValue)
|
||||||
|
query = query.Where(x => x.PurchasedAt <= filter.PurchasedTo.Value);
|
||||||
|
|
||||||
|
if (filter.MinAmount.HasValue)
|
||||||
|
query = query.Where(x => x.Amount >= filter.MinAmount.Value);
|
||||||
|
|
||||||
|
if (filter.MaxAmount.HasValue)
|
||||||
|
query = query.Where(x => x.Amount <= filter.MaxAmount.Value);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
namespace CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetUserPackagePurchaseSummary;
|
||||||
|
|
||||||
|
public record GetUserPackagePurchaseSummaryQuery : IRequest<GetUserPackagePurchaseSummaryResponseDto>
|
||||||
|
{
|
||||||
|
public GetAllUserPackagePurchaseByFilter.GetAllUserPackagePurchaseByFilterFilter? Filter { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetUserPackagePurchaseSummaryResponseDto
|
||||||
|
{
|
||||||
|
public long TotalCount { get; set; }
|
||||||
|
public long TotalAmount { get; set; }
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
using CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetAllUserPackagePurchaseByFilter;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetUserPackagePurchaseSummary;
|
||||||
|
|
||||||
|
public class GetUserPackagePurchaseSummaryQueryHandler
|
||||||
|
: IRequestHandler<GetUserPackagePurchaseSummaryQuery, GetUserPackagePurchaseSummaryResponseDto>
|
||||||
|
{
|
||||||
|
private readonly IApplicationDbContext _context;
|
||||||
|
|
||||||
|
public GetUserPackagePurchaseSummaryQueryHandler(IApplicationDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<GetUserPackagePurchaseSummaryResponseDto> Handle(
|
||||||
|
GetUserPackagePurchaseSummaryQuery request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var query = _context.UserPackagePurchases
|
||||||
|
.AsNoTracking()
|
||||||
|
.ApplyUserPackagePurchaseFilter(request.Filter);
|
||||||
|
|
||||||
|
var totalCount = await query.LongCountAsync(cancellationToken);
|
||||||
|
var totalAmount = totalCount > 0 ? await query.SumAsync(x => x.Amount, cancellationToken) : 0;
|
||||||
|
|
||||||
|
return new GetUserPackagePurchaseSummaryResponseDto
|
||||||
|
{
|
||||||
|
TotalCount = totalCount,
|
||||||
|
TotalAmount = totalAmount
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>0.0.200</Version>
|
<Version>0.0.201</Version>
|
||||||
<DebugType>None</DebugType>
|
<DebugType>None</DebugType>
|
||||||
<DebugSymbols>False</DebugSymbols>
|
<DebugSymbols>False</DebugSymbols>
|
||||||
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
||||||
@@ -74,6 +74,11 @@
|
|||||||
<Protobuf Include="Protos\sitepagesettings.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
<Protobuf Include="Protos\sitepagesettings.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||||
<!-- Image Resolver Service -->
|
<!-- Image Resolver Service -->
|
||||||
<Protobuf Include="Protos\imageresolver.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
<Protobuf Include="Protos\imageresolver.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||||
|
<!-- Admin Report APIs -->
|
||||||
|
<Protobuf Include="Protos\paymenttransaction.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||||
|
<Protobuf Include="Protos\userpackagepurchase.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||||
|
<Protobuf Include="Protos\clubmembershipcycle.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||||
|
<Protobuf Include="Protos\clubmembershipcyclehistory.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PushToFoursatNuget" AfterTargets="Pack" Condition="'$(CI)' != 'true'">
|
<Target Name="PushToFoursatNuget" AfterTargets="Pack" Condition="'$(CI)' != 'true'">
|
||||||
|
|||||||
@@ -164,11 +164,19 @@ message ClubMembershipModel
|
|||||||
|
|
||||||
// GetHistory Query
|
// GetHistory Query
|
||||||
message GetClubMembershipHistoryRequest
|
message GetClubMembershipHistoryRequest
|
||||||
|
{
|
||||||
|
messages.PaginationState pagination_state = 1;
|
||||||
|
google.protobuf.StringValue sort_by = 2;
|
||||||
|
GetClubMembershipHistoryFilter filter = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetClubMembershipHistoryFilter
|
||||||
{
|
{
|
||||||
google.protobuf.Int64Value user_id = 1;
|
google.protobuf.Int64Value user_id = 1;
|
||||||
google.protobuf.Int64Value package_id = 2;
|
google.protobuf.Int64Value club_membership_id = 2;
|
||||||
int32 page_index = 3;
|
google.protobuf.Int32Value action = 3;
|
||||||
int32 page_size = 4;
|
google.protobuf.Timestamp created_from = 4;
|
||||||
|
google.protobuf.Timestamp created_to = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetClubMembershipHistoryResponse
|
message GetClubMembershipHistoryResponse
|
||||||
@@ -182,16 +190,15 @@ message ClubMembershipHistoryModel
|
|||||||
int64 id = 1;
|
int64 id = 1;
|
||||||
int64 club_membership_id = 2;
|
int64 club_membership_id = 2;
|
||||||
int64 user_id = 3;
|
int64 user_id = 3;
|
||||||
google.protobuf.Int64Value old_package_id = 4;
|
string user_name = 4;
|
||||||
google.protobuf.Int64Value new_package_id = 5;
|
bool old_is_active = 5;
|
||||||
google.protobuf.Timestamp old_activated_at = 6;
|
bool new_is_active = 6;
|
||||||
google.protobuf.Timestamp new_activated_at = 7;
|
google.protobuf.Int64Value old_initial_contribution = 7;
|
||||||
google.protobuf.Timestamp old_expires_at = 8;
|
google.protobuf.Int64Value new_initial_contribution = 8;
|
||||||
google.protobuf.Timestamp new_expires_at = 9;
|
int32 action = 9; // ClubMembershipAction enum
|
||||||
int32 action = 10; // ClubMembershipAction enum
|
string performed_by = 10;
|
||||||
string performed_by = 11;
|
string reason = 11;
|
||||||
string reason = 12;
|
google.protobuf.Timestamp created_at = 12;
|
||||||
google.protobuf.Timestamp created = 13;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetClubStatistics Query
|
// GetClubStatistics Query
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package clubmembershipcycle;
|
||||||
|
|
||||||
|
import "public_messages.proto";
|
||||||
|
import "google/protobuf/wrappers.proto";
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
import "google/api/annotations.proto";
|
||||||
|
|
||||||
|
option csharp_namespace = "CMSMicroservice.Protobuf.Protos.ClubMembershipCycle";
|
||||||
|
|
||||||
|
service ClubMembershipCycleContract
|
||||||
|
{
|
||||||
|
rpc GetAllClubMembershipCycleByFilter(GetAllClubMembershipCycleByFilterRequest) returns (GetAllClubMembershipCycleByFilterResponse){
|
||||||
|
option (google.api.http) = {
|
||||||
|
get: "/ClubMembershipCycle/GetAllByFilter"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
rpc GetClubMembershipCycleSummary(GetClubMembershipCycleSummaryRequest) returns (GetClubMembershipCycleSummaryResponse){
|
||||||
|
option (google.api.http) = {
|
||||||
|
get: "/ClubMembershipCycle/GetSummary"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetAllClubMembershipCycleByFilterRequest
|
||||||
|
{
|
||||||
|
messages.PaginationState pagination_state = 1;
|
||||||
|
google.protobuf.StringValue sort_by = 2;
|
||||||
|
GetAllClubMembershipCycleByFilterFilter filter = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetAllClubMembershipCycleByFilterFilter
|
||||||
|
{
|
||||||
|
google.protobuf.Int64Value user_id = 1;
|
||||||
|
google.protobuf.BoolValue is_current_cycle = 2;
|
||||||
|
google.protobuf.Int64Value package_id = 3;
|
||||||
|
google.protobuf.Int32Value cycle_number = 4;
|
||||||
|
google.protobuf.Int32Value purchase_method = 5;
|
||||||
|
google.protobuf.Int32Value magic_state = 6; // 0=none, 1=active, 2=completed
|
||||||
|
google.protobuf.Timestamp package_purchased_from = 7;
|
||||||
|
google.protobuf.Timestamp package_purchased_to = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetAllClubMembershipCycleByFilterResponse
|
||||||
|
{
|
||||||
|
messages.MetaData meta_data = 1;
|
||||||
|
repeated ClubMembershipCycleModel models = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ClubMembershipCycleModel
|
||||||
|
{
|
||||||
|
int64 id = 1;
|
||||||
|
int64 user_id = 2;
|
||||||
|
string user_name = 3;
|
||||||
|
int64 club_membership_id = 4;
|
||||||
|
int32 cycle_number = 5;
|
||||||
|
int64 package_id = 6;
|
||||||
|
string package_name = 7;
|
||||||
|
int64 package_amount = 8;
|
||||||
|
int32 purchase_method = 9;
|
||||||
|
google.protobuf.Timestamp package_purchased_at = 10;
|
||||||
|
google.protobuf.Timestamp magic_started_at = 11;
|
||||||
|
google.protobuf.Timestamp magic_completed_at = 12;
|
||||||
|
bool is_current_cycle = 13;
|
||||||
|
google.protobuf.Timestamp created_at = 14;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetClubMembershipCycleSummaryRequest
|
||||||
|
{
|
||||||
|
GetAllClubMembershipCycleByFilterFilter filter = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetClubMembershipCycleSummaryResponse
|
||||||
|
{
|
||||||
|
int64 total_count = 1;
|
||||||
|
int64 current_cycle_count = 2;
|
||||||
|
int64 magic_active_count = 3;
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package clubmembershipcyclehistory;
|
||||||
|
|
||||||
|
import "public_messages.proto";
|
||||||
|
import "google/protobuf/wrappers.proto";
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
import "google/api/annotations.proto";
|
||||||
|
|
||||||
|
option csharp_namespace = "CMSMicroservice.Protobuf.Protos.ClubMembershipCycleHistory";
|
||||||
|
|
||||||
|
service ClubMembershipCycleHistoryContract
|
||||||
|
{
|
||||||
|
rpc GetAllClubMembershipCycleHistoryByFilter(GetAllClubMembershipCycleHistoryByFilterRequest) returns (GetAllClubMembershipCycleHistoryByFilterResponse){
|
||||||
|
option (google.api.http) = {
|
||||||
|
get: "/ClubMembershipCycleHistory/GetAllByFilter"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetAllClubMembershipCycleHistoryByFilterRequest
|
||||||
|
{
|
||||||
|
messages.PaginationState pagination_state = 1;
|
||||||
|
google.protobuf.StringValue sort_by = 2;
|
||||||
|
GetAllClubMembershipCycleHistoryByFilterFilter filter = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetAllClubMembershipCycleHistoryByFilterFilter
|
||||||
|
{
|
||||||
|
google.protobuf.Int64Value user_id = 1;
|
||||||
|
google.protobuf.Int64Value club_membership_cycle_id = 2;
|
||||||
|
google.protobuf.Int32Value cycle_number = 3;
|
||||||
|
google.protobuf.Int32Value action = 4;
|
||||||
|
google.protobuf.Timestamp created_from = 5;
|
||||||
|
google.protobuf.Timestamp created_to = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetAllClubMembershipCycleHistoryByFilterResponse
|
||||||
|
{
|
||||||
|
messages.MetaData meta_data = 1;
|
||||||
|
repeated ClubMembershipCycleHistoryModel models = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ClubMembershipCycleHistoryModel
|
||||||
|
{
|
||||||
|
int64 id = 1;
|
||||||
|
int64 club_membership_cycle_id = 2;
|
||||||
|
int64 user_id = 3;
|
||||||
|
string user_name = 4;
|
||||||
|
int32 cycle_number = 5;
|
||||||
|
bool old_is_current_cycle = 6;
|
||||||
|
bool new_is_current_cycle = 7;
|
||||||
|
google.protobuf.Timestamp old_magic_started_at = 8;
|
||||||
|
google.protobuf.Timestamp new_magic_started_at = 9;
|
||||||
|
google.protobuf.Timestamp old_magic_completed_at = 10;
|
||||||
|
google.protobuf.Timestamp new_magic_completed_at = 11;
|
||||||
|
int32 action = 12;
|
||||||
|
string performed_by = 13;
|
||||||
|
string reason = 14;
|
||||||
|
google.protobuf.Timestamp created_at = 15;
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package paymenttransaction;
|
||||||
|
|
||||||
|
import "public_messages.proto";
|
||||||
|
import "google/protobuf/wrappers.proto";
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
import "google/api/annotations.proto";
|
||||||
|
|
||||||
|
option csharp_namespace = "CMSMicroservice.Protobuf.Protos.PaymentTransaction";
|
||||||
|
|
||||||
|
service PaymentTransactionContract
|
||||||
|
{
|
||||||
|
rpc GetAllPaymentTransactionByFilter(GetAllPaymentTransactionByFilterRequest) returns (GetAllPaymentTransactionByFilterResponse){
|
||||||
|
option (google.api.http) = {
|
||||||
|
get: "/PaymentTransaction/GetAllByFilter"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
rpc GetPaymentTransactionSummary(GetPaymentTransactionSummaryRequest) returns (GetPaymentTransactionSummaryResponse){
|
||||||
|
option (google.api.http) = {
|
||||||
|
get: "/PaymentTransaction/GetSummary"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetAllPaymentTransactionByFilterRequest
|
||||||
|
{
|
||||||
|
messages.PaginationState pagination_state = 1;
|
||||||
|
google.protobuf.StringValue sort_by = 2;
|
||||||
|
GetAllPaymentTransactionByFilterFilter filter = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetAllPaymentTransactionByFilterFilter
|
||||||
|
{
|
||||||
|
google.protobuf.Int64Value user_id = 1;
|
||||||
|
google.protobuf.StringValue mobile = 2;
|
||||||
|
google.protobuf.StringValue gateway_provider = 3;
|
||||||
|
google.protobuf.BoolValue payment_status = 4;
|
||||||
|
google.protobuf.StringValue authority = 5;
|
||||||
|
google.protobuf.StringValue ref_id = 6;
|
||||||
|
google.protobuf.StringValue order_id = 7;
|
||||||
|
google.protobuf.Timestamp created_from = 8;
|
||||||
|
google.protobuf.Timestamp created_to = 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetAllPaymentTransactionByFilterResponse
|
||||||
|
{
|
||||||
|
messages.MetaData meta_data = 1;
|
||||||
|
repeated PaymentTransactionModel models = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message PaymentTransactionModel
|
||||||
|
{
|
||||||
|
int64 id = 1;
|
||||||
|
int64 user_id = 2;
|
||||||
|
string mobile = 3;
|
||||||
|
string gateway_provider = 4;
|
||||||
|
int64 amount = 5;
|
||||||
|
string authority = 6;
|
||||||
|
bool payment_status = 7;
|
||||||
|
google.protobuf.Int32Value verification_status_code = 8;
|
||||||
|
string verification_status_message = 9;
|
||||||
|
string ref_id = 10;
|
||||||
|
string card_pan = 11;
|
||||||
|
string order_id = 12;
|
||||||
|
google.protobuf.Int64Value transaction_id = 13;
|
||||||
|
string description = 14;
|
||||||
|
google.protobuf.Timestamp created_at = 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetPaymentTransactionSummaryRequest
|
||||||
|
{
|
||||||
|
GetAllPaymentTransactionByFilterFilter filter = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetPaymentTransactionSummaryResponse
|
||||||
|
{
|
||||||
|
int64 total_count = 1;
|
||||||
|
int64 total_amount = 2;
|
||||||
|
int64 successful_count = 3;
|
||||||
|
int64 pending_count = 4;
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package userpackagepurchase;
|
||||||
|
|
||||||
|
import "public_messages.proto";
|
||||||
|
import "google/protobuf/wrappers.proto";
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
import "google/api/annotations.proto";
|
||||||
|
|
||||||
|
option csharp_namespace = "CMSMicroservice.Protobuf.Protos.UserPackagePurchase";
|
||||||
|
|
||||||
|
service UserPackagePurchaseContract
|
||||||
|
{
|
||||||
|
rpc GetAllUserPackagePurchaseByFilter(GetAllUserPackagePurchaseByFilterRequest) returns (GetAllUserPackagePurchaseByFilterResponse){
|
||||||
|
option (google.api.http) = {
|
||||||
|
get: "/UserPackagePurchase/GetAllByFilter"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
rpc GetUserPackagePurchaseSummary(GetUserPackagePurchaseSummaryRequest) returns (GetUserPackagePurchaseSummaryResponse){
|
||||||
|
option (google.api.http) = {
|
||||||
|
get: "/UserPackagePurchase/GetSummary"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetAllUserPackagePurchaseByFilterRequest
|
||||||
|
{
|
||||||
|
messages.PaginationState pagination_state = 1;
|
||||||
|
google.protobuf.StringValue sort_by = 2;
|
||||||
|
GetAllUserPackagePurchaseByFilterFilter filter = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetAllUserPackagePurchaseByFilterFilter
|
||||||
|
{
|
||||||
|
google.protobuf.Int64Value user_id = 1;
|
||||||
|
google.protobuf.Int64Value package_id = 2;
|
||||||
|
google.protobuf.Int32Value purchase_method = 3;
|
||||||
|
google.protobuf.Timestamp purchased_from = 4;
|
||||||
|
google.protobuf.Timestamp purchased_to = 5;
|
||||||
|
google.protobuf.Int64Value min_amount = 6;
|
||||||
|
google.protobuf.Int64Value max_amount = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetAllUserPackagePurchaseByFilterResponse
|
||||||
|
{
|
||||||
|
messages.MetaData meta_data = 1;
|
||||||
|
repeated UserPackagePurchaseModel models = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message UserPackagePurchaseModel
|
||||||
|
{
|
||||||
|
int64 id = 1;
|
||||||
|
int64 user_id = 2;
|
||||||
|
string user_name = 3;
|
||||||
|
string user_mobile = 4;
|
||||||
|
int64 package_id = 5;
|
||||||
|
string package_name = 6;
|
||||||
|
int32 purchase_method = 7;
|
||||||
|
google.protobuf.Timestamp purchased_at = 8;
|
||||||
|
int64 amount = 9;
|
||||||
|
google.protobuf.Int64Value order_id = 10;
|
||||||
|
google.protobuf.Int64Value transaction_id = 11;
|
||||||
|
google.protobuf.Timestamp created_at = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetUserPackagePurchaseSummaryRequest
|
||||||
|
{
|
||||||
|
GetAllUserPackagePurchaseByFilterFilter filter = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetUserPackagePurchaseSummaryResponse
|
||||||
|
{
|
||||||
|
int64 total_count = 1;
|
||||||
|
int64 total_amount = 2;
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
using CMSMicroservice.Application.ClubMembershipCycleHistoryCQ.Queries.GetAllClubMembershipCycleHistoryByFilter;
|
||||||
|
using CMSMicroservice.Protobuf.Protos.ClubMembershipCycleHistory;
|
||||||
|
using Google.Protobuf.WellKnownTypes;
|
||||||
|
using Mapster;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.WebApi.Common.Mappings;
|
||||||
|
|
||||||
|
public class ClubMembershipCycleHistoryProfile : IRegister
|
||||||
|
{
|
||||||
|
public void Register(TypeAdapterConfig config)
|
||||||
|
{
|
||||||
|
config.NewConfig<GetAllClubMembershipCycleHistoryByFilterRequest, GetAllClubMembershipCycleHistoryByFilterQuery>()
|
||||||
|
.MapWith(src => new GetAllClubMembershipCycleHistoryByFilterQuery
|
||||||
|
{
|
||||||
|
PaginationState = MapPagination(src.PaginationState),
|
||||||
|
SortBy = src.HasSortBy ? src.SortBy : null,
|
||||||
|
Filter = MapFilter(src.Filter)
|
||||||
|
});
|
||||||
|
|
||||||
|
config.NewConfig<GetAllClubMembershipCycleHistoryByFilterResponseDto, GetAllClubMembershipCycleHistoryByFilterResponse>()
|
||||||
|
.MapWith(src => new GetAllClubMembershipCycleHistoryByFilterResponse
|
||||||
|
{
|
||||||
|
MetaData = MapMeta(src.MetaData),
|
||||||
|
Models = { src.Models?.Select(MapModel) ?? [] }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static GetAllClubMembershipCycleHistoryByFilterFilter? MapFilter(GetAllClubMembershipCycleHistoryByFilterFilter? src)
|
||||||
|
{
|
||||||
|
if (src == null) return null;
|
||||||
|
return new GetAllClubMembershipCycleHistoryByFilterFilter
|
||||||
|
{
|
||||||
|
UserId = src.HasUserId ? src.UserId : null,
|
||||||
|
ClubMembershipCycleId = src.HasClubMembershipCycleId ? src.ClubMembershipCycleId : null,
|
||||||
|
CycleNumber = src.HasCycleNumber ? src.CycleNumber : null,
|
||||||
|
Action = src.HasAction ? (Domain.Enums.ClubMembershipCycleAction)src.Action : null,
|
||||||
|
CreatedFrom = src.CreatedFrom?.ToDateTime(),
|
||||||
|
CreatedTo = src.CreatedTo?.ToDateTime()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ClubMembershipCycleHistoryModel MapModel(GetAllClubMembershipCycleHistoryByFilterResponseModel m) =>
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Id = m.Id,
|
||||||
|
ClubMembershipCycleId = m.ClubMembershipCycleId,
|
||||||
|
UserId = m.UserId,
|
||||||
|
UserName = m.UserName,
|
||||||
|
CycleNumber = m.CycleNumber,
|
||||||
|
OldIsCurrentCycle = m.OldIsCurrentCycle,
|
||||||
|
NewIsCurrentCycle = m.NewIsCurrentCycle,
|
||||||
|
OldMagicStartedAt = m.OldMagicStartedAt.HasValue
|
||||||
|
? Timestamp.FromDateTime(DateTime.SpecifyKind(m.OldMagicStartedAt.Value, DateTimeKind.Utc)) : null,
|
||||||
|
NewMagicStartedAt = m.NewMagicStartedAt.HasValue
|
||||||
|
? Timestamp.FromDateTime(DateTime.SpecifyKind(m.NewMagicStartedAt.Value, DateTimeKind.Utc)) : null,
|
||||||
|
OldMagicCompletedAt = m.OldMagicCompletedAt.HasValue
|
||||||
|
? Timestamp.FromDateTime(DateTime.SpecifyKind(m.OldMagicCompletedAt.Value, DateTimeKind.Utc)) : null,
|
||||||
|
NewMagicCompletedAt = m.NewMagicCompletedAt.HasValue
|
||||||
|
? Timestamp.FromDateTime(DateTime.SpecifyKind(m.NewMagicCompletedAt.Value, DateTimeKind.Utc)) : null,
|
||||||
|
Action = (int)m.Action,
|
||||||
|
PerformedBy = m.PerformedBy ?? string.Empty,
|
||||||
|
Reason = m.Reason ?? string.Empty,
|
||||||
|
CreatedAt = Timestamp.FromDateTimeOffset(m.Created)
|
||||||
|
};
|
||||||
|
|
||||||
|
private static Application.Common.Models.PaginationState? MapPagination(CMSMicroservice.Protobuf.Protos.PaginationState? ps) =>
|
||||||
|
ps == null ? null : new Application.Common.Models.PaginationState
|
||||||
|
{
|
||||||
|
PageNumber = ps.PageNumber > 0 ? ps.PageNumber : 1,
|
||||||
|
PageSize = ps.PageSize > 0 ? ps.PageSize : 20
|
||||||
|
};
|
||||||
|
|
||||||
|
private static CMSMicroservice.Protobuf.Protos.MetaData MapMeta(Application.Common.Models.MetaData meta) =>
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
CurrentPage = meta.CurrentPage,
|
||||||
|
PageSize = meta.PageSize,
|
||||||
|
TotalCount = meta.TotalCount,
|
||||||
|
TotalPage = meta.TotalPage
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
using CMSMicroservice.Application.ClubMembershipCycleCQ.Queries.GetAllClubMembershipCycleByFilter;
|
||||||
|
using CMSMicroservice.Application.ClubMembershipCycleCQ.Queries.GetClubMembershipCycleSummary;
|
||||||
|
using CMSMicroservice.Protobuf.Protos.ClubMembershipCycle;
|
||||||
|
using Google.Protobuf.WellKnownTypes;
|
||||||
|
using Mapster;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.WebApi.Common.Mappings;
|
||||||
|
|
||||||
|
public class ClubMembershipCycleProfile : IRegister
|
||||||
|
{
|
||||||
|
public void Register(TypeAdapterConfig config)
|
||||||
|
{
|
||||||
|
config.NewConfig<GetAllClubMembershipCycleByFilterRequest, GetAllClubMembershipCycleByFilterQuery>()
|
||||||
|
.MapWith(src => new GetAllClubMembershipCycleByFilterQuery
|
||||||
|
{
|
||||||
|
PaginationState = MapPagination(src.PaginationState),
|
||||||
|
SortBy = src.HasSortBy ? src.SortBy : null,
|
||||||
|
Filter = MapFilter(src.Filter)
|
||||||
|
});
|
||||||
|
|
||||||
|
config.NewConfig<GetAllClubMembershipCycleByFilterResponseDto, GetAllClubMembershipCycleByFilterResponse>()
|
||||||
|
.MapWith(src => new GetAllClubMembershipCycleByFilterResponse
|
||||||
|
{
|
||||||
|
MetaData = MapMeta(src.MetaData),
|
||||||
|
Models = { src.Models?.Select(MapModel) ?? [] }
|
||||||
|
});
|
||||||
|
|
||||||
|
config.NewConfig<GetClubMembershipCycleSummaryRequest, GetClubMembershipCycleSummaryQuery>()
|
||||||
|
.MapWith(src => new GetClubMembershipCycleSummaryQuery { Filter = MapFilter(src.Filter) });
|
||||||
|
|
||||||
|
config.NewConfig<GetClubMembershipCycleSummaryResponseDto, GetClubMembershipCycleSummaryResponse>()
|
||||||
|
.MapWith(src => new GetClubMembershipCycleSummaryResponse
|
||||||
|
{
|
||||||
|
TotalCount = src.TotalCount,
|
||||||
|
CurrentCycleCount = src.CurrentCycleCount,
|
||||||
|
MagicActiveCount = src.MagicActiveCount
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static GetAllClubMembershipCycleByFilterFilter? MapFilter(GetAllClubMembershipCycleByFilterFilter? src)
|
||||||
|
{
|
||||||
|
if (src == null) return null;
|
||||||
|
return new GetAllClubMembershipCycleByFilterFilter
|
||||||
|
{
|
||||||
|
UserId = src.HasUserId ? src.UserId : null,
|
||||||
|
IsCurrentCycle = src.HasIsCurrentCycle ? src.IsCurrentCycle : null,
|
||||||
|
PackageId = src.HasPackageId ? src.PackageId : null,
|
||||||
|
CycleNumber = src.HasCycleNumber ? src.CycleNumber : null,
|
||||||
|
PurchaseMethod = src.HasPurchaseMethod ? (Domain.Enums.PackagePurchaseMethod)src.PurchaseMethod : null,
|
||||||
|
MagicState = src.HasMagicState ? src.MagicState : null,
|
||||||
|
PackagePurchasedFrom = src.PackagePurchasedFrom?.ToDateTime(),
|
||||||
|
PackagePurchasedTo = src.PackagePurchasedTo?.ToDateTime()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ClubMembershipCycleModel MapModel(GetAllClubMembershipCycleByFilterResponseModel m) =>
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Id = m.Id,
|
||||||
|
UserId = m.UserId,
|
||||||
|
UserName = m.UserName,
|
||||||
|
ClubMembershipId = m.ClubMembershipId,
|
||||||
|
CycleNumber = m.CycleNumber,
|
||||||
|
PackageId = m.PackageId,
|
||||||
|
PackageName = m.PackageName,
|
||||||
|
PackageAmount = m.PackageAmount,
|
||||||
|
PurchaseMethod = (int)m.PurchaseMethod,
|
||||||
|
PackagePurchasedAt = Timestamp.FromDateTime(DateTime.SpecifyKind(m.PackagePurchasedAt, DateTimeKind.Utc)),
|
||||||
|
MagicStartedAt = m.MagicStartedAt.HasValue
|
||||||
|
? Timestamp.FromDateTime(DateTime.SpecifyKind(m.MagicStartedAt.Value, DateTimeKind.Utc)) : null,
|
||||||
|
MagicCompletedAt = m.MagicCompletedAt.HasValue
|
||||||
|
? Timestamp.FromDateTime(DateTime.SpecifyKind(m.MagicCompletedAt.Value, DateTimeKind.Utc)) : null,
|
||||||
|
IsCurrentCycle = m.IsCurrentCycle,
|
||||||
|
CreatedAt = Timestamp.FromDateTimeOffset(m.Created)
|
||||||
|
};
|
||||||
|
|
||||||
|
private static Application.Common.Models.PaginationState? MapPagination(CMSMicroservice.Protobuf.Protos.PaginationState? ps) =>
|
||||||
|
ps == null ? null : new Application.Common.Models.PaginationState
|
||||||
|
{
|
||||||
|
PageNumber = ps.PageNumber > 0 ? ps.PageNumber : 1,
|
||||||
|
PageSize = ps.PageSize > 0 ? ps.PageSize : 20
|
||||||
|
};
|
||||||
|
|
||||||
|
private static CMSMicroservice.Protobuf.Protos.MetaData MapMeta(Application.Common.Models.MetaData meta) =>
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
CurrentPage = meta.CurrentPage,
|
||||||
|
PageSize = meta.PageSize,
|
||||||
|
TotalCount = meta.TotalCount,
|
||||||
|
TotalPage = meta.TotalPage
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using CMSMicroservice.Application.ClubMembershipCQ.Queries.GetAllClubMemberships;
|
using CMSMicroservice.Application.ClubMembershipCQ.Queries.GetAllClubMemberships;
|
||||||
using CMSMicroservice.Application.ClubMembershipCQ.Queries.GetClubMembership;
|
using CMSMicroservice.Application.ClubMembershipCQ.Queries.GetClubMembership;
|
||||||
|
using CMSMicroservice.Application.ClubMembershipCQ.Queries.GetClubMembershipHistory;
|
||||||
using CMSMicroservice.Application.ClubMembershipCQ.Queries.GetClubStatistics;
|
using CMSMicroservice.Application.ClubMembershipCQ.Queries.GetClubStatistics;
|
||||||
using CMSMicroservice.Protobuf.Protos.ClubMembership;
|
using CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||||
using Google.Protobuf.WellKnownTypes;
|
using Google.Protobuf.WellKnownTypes;
|
||||||
@@ -112,6 +113,55 @@ public class ClubMembershipProfile : IRegister
|
|||||||
NetChange = t.NetChange
|
NetChange = t.NetChange
|
||||||
}) }
|
}) }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// GetClubMembershipHistory
|
||||||
|
config.NewConfig<GetClubMembershipHistoryRequest, GetClubMembershipHistoryQuery>()
|
||||||
|
.MapWith(src => new GetClubMembershipHistoryQuery
|
||||||
|
{
|
||||||
|
PaginationState = src.PaginationState != null
|
||||||
|
? new Application.Common.Models.PaginationState
|
||||||
|
{
|
||||||
|
PageNumber = src.PaginationState.PageNumber > 0 ? src.PaginationState.PageNumber : 1,
|
||||||
|
PageSize = src.PaginationState.PageSize > 0 ? src.PaginationState.PageSize : 20
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
SortBy = src.HasSortBy ? src.SortBy : null,
|
||||||
|
Filter = src.Filter != null ? new GetClubMembershipHistoryFilter
|
||||||
|
{
|
||||||
|
UserId = src.Filter.HasUserId ? src.Filter.UserId : null,
|
||||||
|
ClubMembershipId = src.Filter.HasClubMembershipId ? src.Filter.ClubMembershipId : null,
|
||||||
|
Action = src.Filter.HasAction ? (Domain.Enums.ClubMembershipAction)src.Filter.Action : null,
|
||||||
|
CreatedFrom = src.Filter.CreatedFrom?.ToDateTime(),
|
||||||
|
CreatedTo = src.Filter.CreatedTo?.ToDateTime()
|
||||||
|
} : null
|
||||||
|
});
|
||||||
|
|
||||||
|
config.NewConfig<GetClubMembershipHistoryResponseDto, GetClubMembershipHistoryResponse>()
|
||||||
|
.MapWith(src => new GetClubMembershipHistoryResponse
|
||||||
|
{
|
||||||
|
MetaData = new CMSMicroservice.Protobuf.Protos.MetaData
|
||||||
|
{
|
||||||
|
CurrentPage = src.MetaData.CurrentPage,
|
||||||
|
PageSize = src.MetaData.PageSize,
|
||||||
|
TotalCount = src.MetaData.TotalCount,
|
||||||
|
TotalPage = src.MetaData.TotalPage
|
||||||
|
},
|
||||||
|
Models = { src.Models.Select(m => new ClubMembershipHistoryModel
|
||||||
|
{
|
||||||
|
Id = m.Id,
|
||||||
|
ClubMembershipId = m.ClubMembershipId,
|
||||||
|
UserId = m.UserId,
|
||||||
|
UserName = m.UserName ?? string.Empty,
|
||||||
|
OldIsActive = m.OldIsActive,
|
||||||
|
NewIsActive = m.NewIsActive,
|
||||||
|
OldInitialContribution = m.OldInitialContribution,
|
||||||
|
NewInitialContribution = m.NewInitialContribution,
|
||||||
|
Action = (int)m.Action,
|
||||||
|
PerformedBy = m.PerformedBy ?? string.Empty,
|
||||||
|
Reason = m.Reason ?? string.Empty,
|
||||||
|
CreatedAt = Timestamp.FromDateTimeOffset(m.Created)
|
||||||
|
}) }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ClubMembershipModel MapToModel(GetAllClubMembershipsResponseModel src)
|
private static ClubMembershipModel MapToModel(GetAllClubMembershipsResponseModel src)
|
||||||
@@ -121,15 +171,15 @@ public class ClubMembershipProfile : IRegister
|
|||||||
Id = src.Id,
|
Id = src.Id,
|
||||||
UserId = src.UserId,
|
UserId = src.UserId,
|
||||||
UserName = src.UserName ?? string.Empty,
|
UserName = src.UserName ?? string.Empty,
|
||||||
PackageId = 0, // Not available in current entity
|
PackageId = src.PackageId,
|
||||||
PackageName = string.Empty, // Not available in current entity
|
PackageName = src.PackageName ?? string.Empty,
|
||||||
ActivationCode = string.Empty, // Not available in current entity
|
ActivationCode = string.Empty,
|
||||||
ActivatedAt = src.ActivatedAt.HasValue
|
ActivatedAt = src.ActivatedAt.HasValue
|
||||||
? Timestamp.FromDateTime(DateTime.SpecifyKind(src.ActivatedAt.Value, DateTimeKind.Utc))
|
? Timestamp.FromDateTime(DateTime.SpecifyKind(src.ActivatedAt.Value, DateTimeKind.Utc))
|
||||||
: null,
|
: null,
|
||||||
ExpiresAt = null, // Not available in current entity
|
ExpiresAt = null,
|
||||||
IsActive = src.IsActive,
|
IsActive = src.IsActive,
|
||||||
IsExpired = false, // Calculate based on ExpiresAt if available
|
IsExpired = false,
|
||||||
Created = Timestamp.FromDateTime(src.Created.UtcDateTime)
|
Created = Timestamp.FromDateTime(src.Created.UtcDateTime)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
using CMSMicroservice.Application.PaymentTransactionCQ.Queries.GetAllPaymentTransactionByFilter;
|
||||||
|
using CMSMicroservice.Application.PaymentTransactionCQ.Queries.GetPaymentTransactionSummary;
|
||||||
|
using CMSMicroservice.Protobuf.Protos.PaymentTransaction;
|
||||||
|
using Google.Protobuf.WellKnownTypes;
|
||||||
|
using Mapster;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.WebApi.Common.Mappings;
|
||||||
|
|
||||||
|
public class PaymentTransactionProfile : IRegister
|
||||||
|
{
|
||||||
|
public void Register(TypeAdapterConfig config)
|
||||||
|
{
|
||||||
|
config.NewConfig<GetAllPaymentTransactionByFilterRequest, GetAllPaymentTransactionByFilterQuery>()
|
||||||
|
.MapWith(MapListQuery);
|
||||||
|
|
||||||
|
config.NewConfig<GetAllPaymentTransactionByFilterResponseDto, GetAllPaymentTransactionByFilterResponse>()
|
||||||
|
.MapWith(MapListResponse);
|
||||||
|
|
||||||
|
config.NewConfig<GetPaymentTransactionSummaryRequest, GetPaymentTransactionSummaryQuery>()
|
||||||
|
.MapWith(src => new GetPaymentTransactionSummaryQuery
|
||||||
|
{
|
||||||
|
Filter = MapFilter(src.Filter)
|
||||||
|
});
|
||||||
|
|
||||||
|
config.NewConfig<GetPaymentTransactionSummaryResponseDto, GetPaymentTransactionSummaryResponse>()
|
||||||
|
.MapWith(src => new GetPaymentTransactionSummaryResponse
|
||||||
|
{
|
||||||
|
TotalCount = src.TotalCount,
|
||||||
|
TotalAmount = src.TotalAmount,
|
||||||
|
SuccessfulCount = src.SuccessfulCount,
|
||||||
|
PendingCount = src.PendingCount
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static GetAllPaymentTransactionByFilterQuery MapListQuery(GetAllPaymentTransactionByFilterRequest src) =>
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
PaginationState = MapPagination(src.PaginationState),
|
||||||
|
SortBy = src.HasSortBy ? src.SortBy : null,
|
||||||
|
Filter = MapFilter(src.Filter)
|
||||||
|
};
|
||||||
|
|
||||||
|
private static GetAllPaymentTransactionByFilterResponse MapListResponse(GetAllPaymentTransactionByFilterResponseDto src) =>
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
MetaData = MapMeta(src.MetaData),
|
||||||
|
Models = { src.Models?.Select(MapModel) ?? [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
private static GetAllPaymentTransactionByFilterFilter? MapFilter(GetAllPaymentTransactionByFilterFilter? src)
|
||||||
|
{
|
||||||
|
if (src == null) return null;
|
||||||
|
return new GetAllPaymentTransactionByFilterFilter
|
||||||
|
{
|
||||||
|
UserId = src.HasUserId ? src.UserId : null,
|
||||||
|
Mobile = src.HasMobile ? src.Mobile : null,
|
||||||
|
GatewayProvider = src.HasGatewayProvider ? src.GatewayProvider : null,
|
||||||
|
PaymentStatus = src.HasPaymentStatus ? src.PaymentStatus : null,
|
||||||
|
Authority = src.HasAuthority ? src.Authority : null,
|
||||||
|
RefId = src.HasRefId ? src.RefId : null,
|
||||||
|
OrderId = src.HasOrderId ? src.OrderId : null,
|
||||||
|
CreatedFrom = src.CreatedFrom?.ToDateTime(),
|
||||||
|
CreatedTo = src.CreatedTo?.ToDateTime()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PaymentTransactionModel MapModel(GetAllPaymentTransactionByFilterResponseModel m) =>
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Id = m.Id,
|
||||||
|
UserId = m.UserId ?? 0,
|
||||||
|
Mobile = m.Mobile ?? string.Empty,
|
||||||
|
GatewayProvider = m.GatewayProvider,
|
||||||
|
Amount = m.Amount,
|
||||||
|
Authority = m.Authority ?? string.Empty,
|
||||||
|
PaymentStatus = m.PaymentStatus,
|
||||||
|
VerificationStatusCode = m.VerificationStatusCode,
|
||||||
|
VerificationStatusMessage = m.VerificationStatusMessage ?? string.Empty,
|
||||||
|
RefId = m.RefId ?? string.Empty,
|
||||||
|
CardPan = m.CardPan ?? string.Empty,
|
||||||
|
OrderId = m.OrderId ?? string.Empty,
|
||||||
|
TransactionId = m.TransactionId,
|
||||||
|
Description = m.Description ?? string.Empty,
|
||||||
|
CreatedAt = Timestamp.FromDateTimeOffset(m.Created)
|
||||||
|
};
|
||||||
|
|
||||||
|
private static Application.Common.Models.PaginationState? MapPagination(CMSMicroservice.Protobuf.Protos.PaginationState? ps) =>
|
||||||
|
ps == null ? null : new Application.Common.Models.PaginationState
|
||||||
|
{
|
||||||
|
PageNumber = ps.PageNumber > 0 ? ps.PageNumber : 1,
|
||||||
|
PageSize = ps.PageSize > 0 ? ps.PageSize : 20
|
||||||
|
};
|
||||||
|
|
||||||
|
private static CMSMicroservice.Protobuf.Protos.MetaData MapMeta(Application.Common.Models.MetaData meta) =>
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
CurrentPage = meta.CurrentPage,
|
||||||
|
PageSize = meta.PageSize,
|
||||||
|
TotalCount = meta.TotalCount,
|
||||||
|
TotalPage = meta.TotalPage
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
using CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetAllUserPackagePurchaseByFilter;
|
||||||
|
using CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetUserPackagePurchaseSummary;
|
||||||
|
using CMSMicroservice.Protobuf.Protos.UserPackagePurchase;
|
||||||
|
using Google.Protobuf.WellKnownTypes;
|
||||||
|
using Mapster;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.WebApi.Common.Mappings;
|
||||||
|
|
||||||
|
public class UserPackagePurchaseProfile : IRegister
|
||||||
|
{
|
||||||
|
public void Register(TypeAdapterConfig config)
|
||||||
|
{
|
||||||
|
config.NewConfig<GetAllUserPackagePurchaseByFilterRequest, GetAllUserPackagePurchaseByFilterQuery>()
|
||||||
|
.MapWith(src => new GetAllUserPackagePurchaseByFilterQuery
|
||||||
|
{
|
||||||
|
PaginationState = MapPagination(src.PaginationState),
|
||||||
|
SortBy = src.HasSortBy ? src.SortBy : null,
|
||||||
|
Filter = MapFilter(src.Filter)
|
||||||
|
});
|
||||||
|
|
||||||
|
config.NewConfig<GetAllUserPackagePurchaseByFilterResponseDto, GetAllUserPackagePurchaseByFilterResponse>()
|
||||||
|
.MapWith(src => new GetAllUserPackagePurchaseByFilterResponse
|
||||||
|
{
|
||||||
|
MetaData = MapMeta(src.MetaData),
|
||||||
|
Models = { src.Models?.Select(m => new UserPackagePurchaseModel
|
||||||
|
{
|
||||||
|
Id = m.Id,
|
||||||
|
UserId = m.UserId,
|
||||||
|
UserName = m.UserName,
|
||||||
|
UserMobile = m.UserMobile,
|
||||||
|
PackageId = m.PackageId,
|
||||||
|
PackageName = m.PackageName,
|
||||||
|
PurchaseMethod = (int)m.PurchaseMethod,
|
||||||
|
PurchasedAt = Timestamp.FromDateTime(DateTime.SpecifyKind(m.PurchasedAt, DateTimeKind.Utc)),
|
||||||
|
Amount = m.Amount,
|
||||||
|
OrderId = m.OrderId,
|
||||||
|
TransactionId = m.TransactionId,
|
||||||
|
CreatedAt = Timestamp.FromDateTimeOffset(m.Created)
|
||||||
|
}) ?? [] }
|
||||||
|
});
|
||||||
|
|
||||||
|
config.NewConfig<GetUserPackagePurchaseSummaryRequest, GetUserPackagePurchaseSummaryQuery>()
|
||||||
|
.MapWith(src => new GetUserPackagePurchaseSummaryQuery { Filter = MapFilter(src.Filter) });
|
||||||
|
|
||||||
|
config.NewConfig<GetUserPackagePurchaseSummaryResponseDto, GetUserPackagePurchaseSummaryResponse>()
|
||||||
|
.MapWith(src => new GetUserPackagePurchaseSummaryResponse
|
||||||
|
{
|
||||||
|
TotalCount = src.TotalCount,
|
||||||
|
TotalAmount = src.TotalAmount
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static GetAllUserPackagePurchaseByFilterFilter? MapFilter(GetAllUserPackagePurchaseByFilterFilter? src)
|
||||||
|
{
|
||||||
|
if (src == null) return null;
|
||||||
|
return new GetAllUserPackagePurchaseByFilterFilter
|
||||||
|
{
|
||||||
|
UserId = src.HasUserId ? src.UserId : null,
|
||||||
|
PackageId = src.HasPackageId ? src.PackageId : null,
|
||||||
|
PurchaseMethod = src.HasPurchaseMethod ? (Domain.Enums.PackagePurchaseMethod)src.PurchaseMethod : null,
|
||||||
|
PurchasedFrom = src.PurchasedFrom?.ToDateTime(),
|
||||||
|
PurchasedTo = src.PurchasedTo?.ToDateTime(),
|
||||||
|
MinAmount = src.HasMinAmount ? src.MinAmount : null,
|
||||||
|
MaxAmount = src.HasMaxAmount ? src.MaxAmount : null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Application.Common.Models.PaginationState? MapPagination(CMSMicroservice.Protobuf.Protos.PaginationState? ps) =>
|
||||||
|
ps == null ? null : new Application.Common.Models.PaginationState
|
||||||
|
{
|
||||||
|
PageNumber = ps.PageNumber > 0 ? ps.PageNumber : 1,
|
||||||
|
PageSize = ps.PageSize > 0 ? ps.PageSize : 20
|
||||||
|
};
|
||||||
|
|
||||||
|
private static CMSMicroservice.Protobuf.Protos.MetaData MapMeta(Application.Common.Models.MetaData meta) =>
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
CurrentPage = meta.CurrentPage,
|
||||||
|
PageSize = meta.PageSize,
|
||||||
|
TotalCount = meta.TotalCount,
|
||||||
|
TotalPage = meta.TotalPage
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using CMSMicroservice.Protobuf.Protos.ClubMembershipCycleHistory;
|
||||||
|
using CMSMicroservice.WebApi.Common.Services;
|
||||||
|
using CMSMicroservice.Application.ClubMembershipCycleHistoryCQ.Queries.GetAllClubMembershipCycleHistoryByFilter;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.WebApi.Services;
|
||||||
|
|
||||||
|
public class ClubMembershipCycleHistoryService : ClubMembershipCycleHistoryContract.ClubMembershipCycleHistoryContractBase
|
||||||
|
{
|
||||||
|
private readonly IDispatchRequestToCQRS _dispatch;
|
||||||
|
|
||||||
|
public ClubMembershipCycleHistoryService(IDispatchRequestToCQRS dispatch) => _dispatch = dispatch;
|
||||||
|
|
||||||
|
public override Task<GetAllClubMembershipCycleHistoryByFilterResponse> GetAllClubMembershipCycleHistoryByFilter(
|
||||||
|
GetAllClubMembershipCycleHistoryByFilterRequest request, ServerCallContext context) =>
|
||||||
|
_dispatch.Handle<GetAllClubMembershipCycleHistoryByFilterRequest, GetAllClubMembershipCycleHistoryByFilterQuery, GetAllClubMembershipCycleHistoryByFilterResponse>(request, context);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using CMSMicroservice.Protobuf.Protos.ClubMembershipCycle;
|
||||||
|
using CMSMicroservice.WebApi.Common.Services;
|
||||||
|
using CMSMicroservice.Application.ClubMembershipCycleCQ.Queries.GetAllClubMembershipCycleByFilter;
|
||||||
|
using CMSMicroservice.Application.ClubMembershipCycleCQ.Queries.GetClubMembershipCycleSummary;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.WebApi.Services;
|
||||||
|
|
||||||
|
public class ClubMembershipCycleService : ClubMembershipCycleContract.ClubMembershipCycleContractBase
|
||||||
|
{
|
||||||
|
private readonly IDispatchRequestToCQRS _dispatch;
|
||||||
|
|
||||||
|
public ClubMembershipCycleService(IDispatchRequestToCQRS dispatch) => _dispatch = dispatch;
|
||||||
|
|
||||||
|
public override Task<GetAllClubMembershipCycleByFilterResponse> GetAllClubMembershipCycleByFilter(
|
||||||
|
GetAllClubMembershipCycleByFilterRequest request, ServerCallContext context) =>
|
||||||
|
_dispatch.Handle<GetAllClubMembershipCycleByFilterRequest, GetAllClubMembershipCycleByFilterQuery, GetAllClubMembershipCycleByFilterResponse>(request, context);
|
||||||
|
|
||||||
|
public override Task<GetClubMembershipCycleSummaryResponse> GetClubMembershipCycleSummary(
|
||||||
|
GetClubMembershipCycleSummaryRequest request, ServerCallContext context) =>
|
||||||
|
_dispatch.Handle<GetClubMembershipCycleSummaryRequest, GetClubMembershipCycleSummaryQuery, GetClubMembershipCycleSummaryResponse>(request, context);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using CMSMicroservice.Protobuf.Protos.PaymentTransaction;
|
||||||
|
using CMSMicroservice.WebApi.Common.Services;
|
||||||
|
using CMSMicroservice.Application.PaymentTransactionCQ.Queries.GetAllPaymentTransactionByFilter;
|
||||||
|
using CMSMicroservice.Application.PaymentTransactionCQ.Queries.GetPaymentTransactionSummary;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.WebApi.Services;
|
||||||
|
|
||||||
|
public class PaymentTransactionService : PaymentTransactionContract.PaymentTransactionContractBase
|
||||||
|
{
|
||||||
|
private readonly IDispatchRequestToCQRS _dispatch;
|
||||||
|
|
||||||
|
public PaymentTransactionService(IDispatchRequestToCQRS dispatch) => _dispatch = dispatch;
|
||||||
|
|
||||||
|
public override Task<GetAllPaymentTransactionByFilterResponse> GetAllPaymentTransactionByFilter(
|
||||||
|
GetAllPaymentTransactionByFilterRequest request, ServerCallContext context) =>
|
||||||
|
_dispatch.Handle<GetAllPaymentTransactionByFilterRequest, GetAllPaymentTransactionByFilterQuery, GetAllPaymentTransactionByFilterResponse>(request, context);
|
||||||
|
|
||||||
|
public override Task<GetPaymentTransactionSummaryResponse> GetPaymentTransactionSummary(
|
||||||
|
GetPaymentTransactionSummaryRequest request, ServerCallContext context) =>
|
||||||
|
_dispatch.Handle<GetPaymentTransactionSummaryRequest, GetPaymentTransactionSummaryQuery, GetPaymentTransactionSummaryResponse>(request, context);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using CMSMicroservice.Protobuf.Protos.UserPackagePurchase;
|
||||||
|
using CMSMicroservice.WebApi.Common.Services;
|
||||||
|
using CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetAllUserPackagePurchaseByFilter;
|
||||||
|
using CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetUserPackagePurchaseSummary;
|
||||||
|
|
||||||
|
namespace CMSMicroservice.WebApi.Services;
|
||||||
|
|
||||||
|
public class UserPackagePurchaseService : UserPackagePurchaseContract.UserPackagePurchaseContractBase
|
||||||
|
{
|
||||||
|
private readonly IDispatchRequestToCQRS _dispatch;
|
||||||
|
|
||||||
|
public UserPackagePurchaseService(IDispatchRequestToCQRS dispatch) => _dispatch = dispatch;
|
||||||
|
|
||||||
|
public override Task<GetAllUserPackagePurchaseByFilterResponse> GetAllUserPackagePurchaseByFilter(
|
||||||
|
GetAllUserPackagePurchaseByFilterRequest request, ServerCallContext context) =>
|
||||||
|
_dispatch.Handle<GetAllUserPackagePurchaseByFilterRequest, GetAllUserPackagePurchaseByFilterQuery, GetAllUserPackagePurchaseByFilterResponse>(request, context);
|
||||||
|
|
||||||
|
public override Task<GetUserPackagePurchaseSummaryResponse> GetUserPackagePurchaseSummary(
|
||||||
|
GetUserPackagePurchaseSummaryRequest request, ServerCallContext context) =>
|
||||||
|
_dispatch.Handle<GetUserPackagePurchaseSummaryRequest, GetUserPackagePurchaseSummaryQuery, GetUserPackagePurchaseSummaryResponse>(request, context);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user