feat: update commission payout model with user names and timestamps
All checks were successful
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 4m11s

This commit is contained in:
masoodafar-web
2025-12-12 19:31:32 +03:30
parent 2ae6034fbb
commit 6ae1b0cd70
5 changed files with 44 additions and 13 deletions

View File

@@ -12,6 +12,7 @@ public class GetUserCommissionPayoutsQueryHandler : IRequestHandler<GetUserCommi
public async Task<GetUserCommissionPayoutsResponseDto> Handle(GetUserCommissionPayoutsQuery request, CancellationToken cancellationToken)
{
var query = _context.UserCommissionPayouts
.Include(x => x.User)
.AsNoTracking()
.AsQueryable();
@@ -41,6 +42,8 @@ public class GetUserCommissionPayoutsQueryHandler : IRequestHandler<GetUserCommi
{
Id = x.Id,
UserId = x.UserId,
FirstName = x.User.FirstName,
LastName = x.User.LastName,
WeekNumber = x.WeekNumber,
WeeklyPoolId = x.WeeklyPoolId,
BalancesEarned = x.BalancesEarned,

View File

@@ -10,6 +10,8 @@ public class GetUserCommissionPayoutsResponseModel
{
public long Id { get; set; }
public long UserId { get; set; }
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public string WeekNumber { get; set; } = string.Empty;
public long WeeklyPoolId { get; set; }
public long BalancesEarned { get; set; }

View File

@@ -3,7 +3,7 @@
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.149</Version>
<Version>0.0.152</Version>
<DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>

View File

@@ -209,18 +209,20 @@ message GetUserCommissionPayoutsResponse
message UserCommissionPayoutModel
{
int64 id = 1;
int64 user_id = 2;
string user_name = 3;
string week_number = 4;
int32 balances_earned = 5;
int64 value_per_balance = 6;
int64 total_amount = 7;
int32 status = 8; // CommissionPayoutStatus enum
google.protobuf.Int32Value withdrawal_method = 9;
string iban_number = 10;
google.protobuf.Timestamp created = 11;
google.protobuf.Timestamp last_modified = 12;
int64 id = 1;
int64 user_id = 2;
string user_name = 3;
string week_number = 4;
int64 weekly_pool_id = 5;
int64 balances_earned = 6;
int64 value_per_balance = 7;
int64 total_amount = 8;
int32 status = 9; // CommissionPayoutStatus enum
google.protobuf.Timestamp paid_at = 10;
google.protobuf.Int32Value withdrawal_method = 11;
string iban_number = 12;
google.protobuf.Timestamp withdrawn_at = 13;
google.protobuf.Timestamp created = 14;
}
// GetCommissionPayoutHistory Query

View File

@@ -1,4 +1,5 @@
using CMSMicroservice.Application.CommissionCQ.Queries.GetAvailableWeeks;
using CMSMicroservice.Application.CommissionCQ.Queries.GetUserCommissionPayouts;
using CMSMicroservice.Protobuf.Protos.Commission;
using Google.Protobuf.WellKnownTypes;
using Mapster;
@@ -35,5 +36,28 @@ public class CommissionProfile : IRegister
.Map(dest => dest.TotalPoolAmount, src => src.TotalPoolAmount ?? 0)
.Map(dest => dest.EligibleUsersCount, src => src.EligibleUsersCount ?? 0)
.Map(dest => dest.DisplayText, src => src.DisplayText);
// GetUserCommissionPayouts Response Model Mapping
config.NewConfig<GetUserCommissionPayoutsResponseModel, UserCommissionPayoutModel>()
.Map(dest => dest.Id, src => src.Id)
.Map(dest => dest.UserId, src => src.UserId)
.Map(dest => dest.UserName, src => $"{src.FirstName} {src.LastName}")
.Map(dest => dest.WeekNumber, src => src.WeekNumber)
.Map(dest => dest.WeeklyPoolId, src => src.WeeklyPoolId)
.Map(dest => dest.BalancesEarned, src => src.BalancesEarned)
.Map(dest => dest.ValuePerBalance, src => src.ValuePerBalance)
.Map(dest => dest.TotalAmount, src => src.TotalAmount)
.Map(dest => dest.Status, src => (int)src.Status)
.Map(dest => dest.PaidAt, src => src.PaidAt.HasValue
? Timestamp.FromDateTime(src.PaidAt.Value.ToUniversalTime())
: null)
.Map(dest => dest.WithdrawalMethod, src => src.WithdrawalMethod.HasValue
? (int)src.WithdrawalMethod.Value
: (int?)null)
.Map(dest => dest.IbanNumber, src => src.IbanNumber ?? string.Empty)
.Map(dest => dest.WithdrawnAt, src => src.WithdrawnAt.HasValue
? Timestamp.FromDateTime(src.WithdrawnAt.Value.ToUniversalTime())
: null)
.Map(dest => dest.Created, src => Timestamp.FromDateTimeOffset(src.Created));
}
}