feat: update protobuf versions and enhance club membership and commission queries
Build and Deploy / build (push) Successful in 1m41s
Build and Deploy / build (push) Successful in 1m41s
This commit is contained in:
@@ -1,29 +1,124 @@
|
||||
using BackOffice.BFF.Application.ClubMembershipCQ.Queries.GetAllClubMembers;
|
||||
using BackOffice.BFF.Application.ClubMembershipCQ.Queries.GetClubStatistics;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using BffProtos = Foursat.BackOffice.BFF.ClubMembership.Protos;
|
||||
using CmsProtos = CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||
|
||||
namespace BackOffice.BFF.WebApi.Common.Mappings;
|
||||
|
||||
public class ClubMembershipProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
// GetAllClubMembersResponseDto -> GetAllClubMembershipsResponse
|
||||
// config.NewConfig<GetAllClubMembersResponseDto, GetAllClubMembershipsResponse>()
|
||||
// .MapWith(src => new GetAllClubMembershipsResponse
|
||||
// {
|
||||
// Members = { src.Members.Select(m => new ClubMemberModel
|
||||
// {
|
||||
// Id = m.Id,
|
||||
// UserId = m.UserId,
|
||||
// UserName = m.UserName ?? string.Empty,
|
||||
// ActivationDate = Timestamp.FromDateTime(DateTime.SpecifyKind(m.ActivationDate, DateTimeKind.Utc)),
|
||||
// InitialContribution = m.InitialContribution,
|
||||
// CurrentBalance = m.CurrentBalance,
|
||||
// TotalEarnings = m.TotalEarnings,
|
||||
// IsActive = m.IsActive,
|
||||
// ClubLevel = m.ClubLevel,
|
||||
// ClubLevelDisplay = m.ClubLevelDisplay ?? string.Empty
|
||||
// }) },
|
||||
// TotalCount = src.TotalCount,
|
||||
// PageNumber = src.PageNumber,
|
||||
// PageSize = src.PageSize
|
||||
// });
|
||||
// =====================
|
||||
// GetAllClubMemberships
|
||||
// =====================
|
||||
|
||||
// BFF Proto Request -> Query
|
||||
config.NewConfig<BffProtos.GetAllClubMembershipsRequest, GetAllClubMembersQuery>()
|
||||
.MapWith(src => new GetAllClubMembersQuery
|
||||
{
|
||||
IsActive = src.IsActive,
|
||||
PageNumber = src.PageIndex > 0 ? src.PageIndex : 1,
|
||||
PageSize = src.PageSize > 0 ? src.PageSize : 20
|
||||
});
|
||||
|
||||
// Query -> CMS Proto Request
|
||||
config.NewConfig<GetAllClubMembersQuery, CmsProtos.GetAllClubMembershipsRequest>()
|
||||
.MapWith(src => new CmsProtos.GetAllClubMembershipsRequest
|
||||
{
|
||||
IsActive = src.IsActive,
|
||||
PageIndex = src.PageNumber,
|
||||
PageSize = src.PageSize
|
||||
});
|
||||
|
||||
// CMS Proto Response -> DTO
|
||||
config.NewConfig<CmsProtos.GetAllClubMembershipsResponse, GetAllClubMembersResponseDto>()
|
||||
.MapWith(src => new GetAllClubMembersResponseDto
|
||||
{
|
||||
TotalCount = (int)(src.MetaData != null ? src.MetaData.TotalCount : 0),
|
||||
PageNumber = (int)(src.MetaData != null ? src.MetaData.CurrentPage : 1),
|
||||
PageSize = (int)(src.MetaData != null ? src.MetaData.PageSize : 20),
|
||||
Members = src.Models.Select(m => new ClubMemberDto
|
||||
{
|
||||
Id = m.Id,
|
||||
UserId = m.UserId,
|
||||
UserName = m.UserName ?? string.Empty,
|
||||
ActivationDate = m.ActivatedAt != null ? m.ActivatedAt.ToDateTime() : DateTime.MinValue,
|
||||
IsActive = m.IsActive
|
||||
}).ToList()
|
||||
});
|
||||
|
||||
// DTO -> BFF Proto Response
|
||||
config.NewConfig<GetAllClubMembersResponseDto, BffProtos.GetAllClubMembershipsResponse>()
|
||||
.MapWith(src => new BffProtos.GetAllClubMembershipsResponse
|
||||
{
|
||||
MetaData = new BackOffice.BFF.Protobuf.Common.MetaData
|
||||
{
|
||||
CurrentPage = src.PageNumber,
|
||||
PageSize = src.PageSize,
|
||||
TotalCount = src.TotalCount,
|
||||
TotalPage = (int)Math.Ceiling((double)src.TotalCount / src.PageSize)
|
||||
},
|
||||
Models = { src.Members.Select(m => new BffProtos.ClubMembershipModel
|
||||
{
|
||||
Id = m.Id,
|
||||
UserId = m.UserId,
|
||||
UserName = m.UserName ?? string.Empty,
|
||||
PackageId = 0,
|
||||
PackageName = string.Empty,
|
||||
ActivationCode = string.Empty,
|
||||
ActivatedAt = Timestamp.FromDateTime(DateTime.SpecifyKind(m.ActivationDate, DateTimeKind.Utc)),
|
||||
ExpiresAt = null,
|
||||
IsActive = m.IsActive,
|
||||
IsExpired = false,
|
||||
Created = Timestamp.FromDateTime(DateTime.SpecifyKind(m.ActivationDate, DateTimeKind.Utc))
|
||||
}) }
|
||||
});
|
||||
|
||||
// =====================
|
||||
// GetClubStatistics
|
||||
// =====================
|
||||
|
||||
// BFF Proto Request -> Query
|
||||
config.NewConfig<BffProtos.GetClubStatisticsRequest, GetClubStatisticsQuery>()
|
||||
.MapWith(src => new GetClubStatisticsQuery());
|
||||
|
||||
// CMS Proto Response -> DTO
|
||||
config.NewConfig<CmsProtos.GetClubStatisticsResponse, GetClubStatisticsResponseDto>()
|
||||
.MapWith(src => new GetClubStatisticsResponseDto
|
||||
{
|
||||
TotalMemberships = src.TotalMembers,
|
||||
ActiveMemberships = src.ActiveMembers,
|
||||
InactiveMemberships = src.InactiveMembers,
|
||||
ActivePercentage = src.ActivePercentage,
|
||||
TotalRevenue = src.TotalRevenue,
|
||||
AverageDurationDays = src.AverageMembershipDurationDays,
|
||||
MonthlyTrends = src.MonthlyTrend.Select(t => new MonthlyMembershipTrendModel
|
||||
{
|
||||
Month = t.Month,
|
||||
NewMemberships = t.Activations,
|
||||
ExpiredMemberships = t.Expirations
|
||||
}).ToList()
|
||||
});
|
||||
|
||||
// DTO -> BFF Proto Response
|
||||
config.NewConfig<GetClubStatisticsResponseDto, BffProtos.GetClubStatisticsResponse>()
|
||||
.MapWith(src => new BffProtos.GetClubStatisticsResponse
|
||||
{
|
||||
TotalMembers = src.TotalMemberships,
|
||||
ActiveMembers = src.ActiveMemberships,
|
||||
InactiveMembers = src.InactiveMemberships,
|
||||
ActivePercentage = src.ActivePercentage,
|
||||
TotalRevenue = (long)src.TotalRevenue,
|
||||
AverageMembershipDurationDays = src.AverageDurationDays,
|
||||
MonthlyTrend = { src.MonthlyTrends.Select(t => new BffProtos.MonthlyMembershipTrend
|
||||
{
|
||||
Month = t.Month,
|
||||
Activations = t.NewMemberships,
|
||||
Expirations = t.ExpiredMemberships,
|
||||
NetChange = t.NewMemberships - t.ExpiredMemberships
|
||||
}) }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,18 +27,35 @@ public class CommissionProfile : IRegister
|
||||
? new BackOffice.BFF.Application.CommissionCQ.Queries.GetUserPayouts.GetUserPayoutsFilter
|
||||
{
|
||||
UserId = src.Filter.UserId,
|
||||
WeekNumber = src.Filter.WeekNumber,
|
||||
WeekDefinitionId = src.Filter.WeekDefinitionId,
|
||||
Status = src.Filter.Status
|
||||
}
|
||||
: null
|
||||
});
|
||||
|
||||
// GetUserWeeklyBalancesRequest -> GetUserWeeklyBalancesQuery
|
||||
config.NewConfig<GetUserWeeklyBalancesRequest, GetUserWeeklyBalancesQuery>()
|
||||
.MapWith(src => new GetUserWeeklyBalancesQuery
|
||||
{
|
||||
PaginationState = new BackOffice.BFF.Application.Common.Models.PaginationState
|
||||
{
|
||||
PageNumber = src.PageIndex > 0 ? src.PageIndex : 1,
|
||||
PageSize = src.PageSize > 0 ? src.PageSize : 10
|
||||
},
|
||||
Filter = new GetUserWeeklyBalancesFilter
|
||||
{
|
||||
UserId = src.UserId,
|
||||
WeekDefinitionId = src.WeekDefinitionId,
|
||||
OnlyActive = src.OnlyActive
|
||||
}
|
||||
});
|
||||
|
||||
// GetWeeklyPoolResponseDto -> GetWeeklyCommissionPoolResponse
|
||||
config.NewConfig<GetWeeklyPoolResponseDto, GetWeeklyCommissionPoolResponse>()
|
||||
.MapWith(src => new GetWeeklyCommissionPoolResponse
|
||||
{
|
||||
Id = src.Id,
|
||||
WeekNumber = src.WeekNumber ?? string.Empty,
|
||||
WeekDefinitionId = src.WeekDefinitionId,
|
||||
TotalBalances = (int)src.TotalBalances,
|
||||
TotalPoolAmount = src.TotalPoolAmount,
|
||||
|
||||
@@ -94,7 +111,8 @@ public class CommissionProfile : IRegister
|
||||
Models = { src.Models.Select(m => new WeeklyCommissionPoolModel
|
||||
{
|
||||
Id = m.Id,
|
||||
WeekNumber = m.WeekNumber ?? string.Empty,
|
||||
WeekDefinitionId = m.WeekDefinitionId,
|
||||
WeekDisplayName = m.WeekDisplayName ?? string.Empty,
|
||||
TotalPoolAmount = m.TotalPoolAmount,
|
||||
TotalBalances = m.TotalBalances,
|
||||
ValuePerBalance = m.ValuePerBalance,
|
||||
@@ -121,7 +139,8 @@ public class CommissionProfile : IRegister
|
||||
{
|
||||
Id = m.Id,
|
||||
UserId = m.UserId,
|
||||
WeekNumber = m.WeekNumber ?? string.Empty,
|
||||
WeekDefinitionId = m.WeekDefinitionId,
|
||||
WeekDisplayName = m.WeekDisplayName ?? string.Empty,
|
||||
LeftLegBalances = m.LeftLegBalances,
|
||||
RightLegBalances = m.RightLegBalances,
|
||||
TotalBalances = m.TotalBalances,
|
||||
@@ -204,7 +223,8 @@ public class CommissionProfile : IRegister
|
||||
{
|
||||
return new WeekInfo
|
||||
{
|
||||
WeekNumber = dto.WeekNumber,
|
||||
WeekDefinitionId = dto.WeekDefinitionId,
|
||||
DisplayName = dto.DisplayName,
|
||||
StartDate = Timestamp.FromDateTime(dto.StartDate.ToUniversalTime()),
|
||||
EndDate = Timestamp.FromDateTime(dto.EndDate.ToUniversalTime()),
|
||||
IsCalculated = dto.IsCalculated,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkTree;
|
||||
using BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetUserNetworkInfo;
|
||||
using BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkHistory;
|
||||
using BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkStatistics;
|
||||
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
|
||||
|
||||
namespace BackOffice.BFF.WebApi.Common.Mappings;
|
||||
@@ -9,6 +10,10 @@ public class NetworkMembershipProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
// GetNetworkStatisticsRequest -> GetNetworkStatisticsQuery
|
||||
config.NewConfig<GetNetworkStatisticsRequest, GetNetworkStatisticsQuery>()
|
||||
.MapWith(src => new GetNetworkStatisticsQuery());
|
||||
|
||||
// GetNetworkTreeResponseDto -> GetNetworkTreeResponse
|
||||
config.NewConfig<GetNetworkTreeResponseDto, GetNetworkTreeResponse>()
|
||||
.MapWith(src => new GetNetworkTreeResponse
|
||||
@@ -28,7 +33,7 @@ public class NetworkMembershipProfile : IRegister
|
||||
? Timestamp.FromDateTime(DateTime.SpecifyKind(n.ClubActivatedAt.Value, DateTimeKind.Utc))
|
||||
: null,
|
||||
IsClubActive = n.IsClubActive,
|
||||
ActivationWeekNumber = n.ActivationWeekNumber,
|
||||
ActivationWeekDefinitionId = n.ActivationWeekDefinitionId,
|
||||
IsActivatedInTargetWeek =n.IsActivatedInTargetWeek,
|
||||
UserCreated = n.UserCreated.HasValue
|
||||
? Timestamp.FromDateTime(DateTime.SpecifyKind(n.UserCreated.Value, DateTimeKind.Utc))
|
||||
@@ -53,7 +58,7 @@ public class NetworkMembershipProfile : IRegister
|
||||
? Timestamp.FromDateTime(DateTime.SpecifyKind(src.ClubActivatedAt.Value, DateTimeKind.Utc))
|
||||
: null,
|
||||
IsClubActive = src.IsClubActive,
|
||||
ActivationWeekNumber = src.ActivationWeekNumber,
|
||||
ActivationWeekDefinitionId = src.ActivationWeekDefinitionId,
|
||||
UserCreated = src.UserCreated.HasValue
|
||||
? Timestamp.FromDateTime(DateTime.SpecifyKind(src.UserCreated.Value, DateTimeKind.Utc))
|
||||
: null
|
||||
@@ -142,5 +147,38 @@ public class NetworkMembershipProfile : IRegister
|
||||
Created = Timestamp.FromDateTime(DateTime.SpecifyKind(h.CreatedAt, DateTimeKind.Utc))
|
||||
}) }
|
||||
});
|
||||
|
||||
// GetNetworkStatisticsResponseDto -> GetNetworkStatisticsResponse
|
||||
config.NewConfig<GetNetworkStatisticsResponseDto, GetNetworkStatisticsResponse>()
|
||||
.MapWith(src => new GetNetworkStatisticsResponse
|
||||
{
|
||||
TotalMembers = src.TotalMembers,
|
||||
ActiveMembers = src.ActiveMembers,
|
||||
LeftLegCount = src.LeftLegCount,
|
||||
RightLegCount = src.RightLegCount,
|
||||
LeftPercentage = src.LeftPercentage,
|
||||
RightPercentage = src.RightPercentage,
|
||||
AverageDepth = src.AverageDepth,
|
||||
MaxDepth = src.MaxDepth,
|
||||
LevelDistribution = { src.LevelDistribution.Select(l => new LevelDistribution
|
||||
{
|
||||
Level = l.Level,
|
||||
Count = l.Count
|
||||
}) },
|
||||
MonthlyGrowth = { src.MonthlyGrowth.Select(m => new MonthlyGrowth
|
||||
{
|
||||
Month = m.Month,
|
||||
NewMembers = m.NewMembers
|
||||
}) },
|
||||
TopUsers = { src.TopUsers.Select(u => new TopNetworkUser
|
||||
{
|
||||
Rank = u.Rank,
|
||||
UserId = u.UserId,
|
||||
UserName = u.UserName,
|
||||
TotalChildren = u.TotalChildren,
|
||||
LeftCount = u.LeftCount,
|
||||
RightCount = u.RightCount
|
||||
}) }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user