Compare commits

...

2 Commits

Author SHA1 Message Date
masoodafar-web 721207f6a0 feat: update GetUserWeeklyBalances response structure and mappings
Build and Deploy / build (push) Successful in 1m47s
Build and Deploy to Production / build-and-deploy (push) Successful in 2m22s
2025-12-27 22:10:30 +03:30
masoodafar-web ce7683c736 feat: enhance GetWithdrawalRequests response structure and update related mappings
Build and Deploy / build (push) Failing after 1m11s
2025-12-27 21:52:50 +03:30
8 changed files with 137 additions and 51 deletions
@@ -10,10 +10,15 @@ public record UserWeeklyBalanceDto
{ {
public long Id { get; init; } public long Id { get; init; }
public long UserId { get; init; } public long UserId { get; init; }
public string UserFullName { get; init; } = string.Empty;
public long WeekDefinitionId { get; init; } public long WeekDefinitionId { get; init; }
public string WeekDisplayName { get; init; } = string.Empty; public string WeekDisplayName { get; init; } = string.Empty;
public int LeftLegBalances { get; init; } public int LeftLegNewMembers { get; init; }
public int RightLegBalances { get; init; } public int LeftLegCarryover { get; init; }
public int LeftLegTotal { get; init; }
public int RightLegNewMembers { get; init; }
public int RightLegCarryover { get; init; }
public int RightLegTotal { get; init; }
public int TotalBalances { get; init; } public int TotalBalances { get; init; }
public long WeeklyPoolContribution { get; init; } public long WeeklyPoolContribution { get; init; }
public DateTime? CalculatedAt { get; init; } public DateTime? CalculatedAt { get; init; }
@@ -37,6 +37,35 @@ public class GetWithdrawalRequestsQueryHandler : IRequestHandler<GetWithdrawalRe
} }
var response = await _context.Commissions.GetWithdrawalRequestsAsync(grpcRequest, cancellationToken: cancellationToken); var response = await _context.Commissions.GetWithdrawalRequestsAsync(grpcRequest, cancellationToken: cancellationToken);
return response.Adapt<GetWithdrawalRequestsResponseDto>();
return new GetWithdrawalRequestsResponseDto
{
MetaData = new MetaDataDto
{
TotalCount = (int)(response.MetaData?.TotalCount ?? 0),
PageSize = (int)(response.MetaData?.PageSize ?? request.PageSize),
CurrentPage = (int)(response.MetaData?.CurrentPage ?? request.PageIndex),
TotalPages = (int)(response.MetaData?.TotalPage ?? 0)
},
Models = response.Models.Select(m => new WithdrawalRequestDto
{
Id = m.Id,
UserId = m.UserId,
UserName = m.UserName,
WeekDefinitionId = m.WeekDefinitionId,
Amount = m.Amount,
Status = m.Status,
WithdrawalMethod = m.WithdrawalMethod,
IbanNumber = m.IbanNumber,
RequestedAt = m.RequestedAt?.ToDateTime() ?? DateTime.MinValue,
ProcessedAt = m.ProcessedAt?.ToDateTime(),
ProcessedBy = m.ProcessedBy,
Reason = m.Reason,
Created = m.Created?.ToDateTime() ?? DateTime.MinValue,
BankReferenceId = m.BankReferenceId,
BankTrackingCode = m.BankTrackingCode,
PaymentFailureReason = m.PaymentFailureReason
}).ToList()
};
} }
} }
@@ -11,18 +11,19 @@ public record WithdrawalRequestDto
public long Id { get; init; } public long Id { get; init; }
public long UserId { get; init; } public long UserId { get; init; }
public string UserName { get; init; } = string.Empty; public string UserName { get; init; } = string.Empty;
public string PhoneNumber { get; init; } = string.Empty; public long WeekDefinitionId { get; init; }
public long Amount { get; init; } public long Amount { get; init; }
public int Status { get; init; } public int Status { get; init; }
public string Method { get; init; } = "Bank"; public int WithdrawalMethod { get; init; }
public string? BankAccount { get; init; } public string? IbanNumber { get; init; }
public string? BankName { get; init; } public DateTime RequestedAt { get; init; }
public DateTime? ProcessedAt { get; init; }
public string? ProcessedBy { get; init; }
public string? Reason { get; init; }
public DateTime Created { get; init; }
public string? BankReferenceId { get; init; } public string? BankReferenceId { get; init; }
public string? BankTrackingCode { get; init; } public string? BankTrackingCode { get; init; }
public string? PaymentFailureReason { get; init; } public string? PaymentFailureReason { get; init; }
public DateTime RequestDate { get; init; }
public DateTime? ProcessedDate { get; init; }
public string? AdminNote { get; init; }
} }
public record MetaDataDto public record MetaDataDto
@@ -1,6 +1,9 @@
using BackOffice.BFF.Application.CommissionCQ.Queries.GetWeeklyPool; using BackOffice.BFF.Application.CommissionCQ.Queries.GetWeeklyPool;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools; using BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances;
using CMSMicroservice.Protobuf.Protos.Commission; using CMSMicroservice.Protobuf.Protos.Commission;
using WeeklyPoolsMetaDataDto = BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools.MetaDataDto;
using UserBalancesMetaDataDto = BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances.MetaDataDto;
namespace BackOffice.BFF.Application.Common.Mappings; namespace BackOffice.BFF.Application.Common.Mappings;
@@ -22,7 +25,7 @@ public class CommissionProfile : IRegister
config.NewConfig<GetAllWeeklyPoolsResponse, GetAllWeeklyPoolsResponseDto>() config.NewConfig<GetAllWeeklyPoolsResponse, GetAllWeeklyPoolsResponseDto>()
.MapWith(src => new GetAllWeeklyPoolsResponseDto .MapWith(src => new GetAllWeeklyPoolsResponseDto
{ {
MetaData = new MetaDataDto MetaData = new WeeklyPoolsMetaDataDto
{ {
TotalCount = (int)src.MetaData.TotalCount, TotalCount = (int)src.MetaData.TotalCount,
PageSize = (int)src.MetaData.PageSize, PageSize = (int)src.MetaData.PageSize,
@@ -42,5 +45,37 @@ public class CommissionProfile : IRegister
Created = m.Created.ToDateTime() Created = m.Created.ToDateTime()
}).ToList() }).ToList()
}); });
// CMS GetUserWeeklyBalancesResponse -> GetUserWeeklyBalancesResponseDto
config.NewConfig<GetUserWeeklyBalancesResponse, GetUserWeeklyBalancesResponseDto>()
.MapWith(src => new GetUserWeeklyBalancesResponseDto
{
MetaData = new UserBalancesMetaDataDto
{
TotalCount = (int)src.MetaData.TotalCount,
PageSize = (int)src.MetaData.PageSize,
CurrentPage = (int)src.MetaData.CurrentPage,
TotalPages = (int)src.MetaData.TotalPage
},
Models = src.Models.Select(m => new UserWeeklyBalanceDto
{
Id = m.Id,
UserId = m.UserId,
UserFullName = m.UserFullName ?? string.Empty,
WeekDefinitionId = m.WeekDefinitionId,
WeekDisplayName = m.WeekDisplayName ?? string.Empty,
LeftLegNewMembers = m.LeftLegNewMembers,
LeftLegCarryover = m.LeftLegCarryover,
LeftLegTotal = m.LeftLegTotal,
RightLegNewMembers = m.RightLegNewMembers,
RightLegCarryover = m.RightLegCarryover,
RightLegTotal = m.RightLegTotal,
TotalBalances = m.TotalBalances,
WeeklyPoolContribution = m.WeeklyPoolContribution,
CalculatedAt = m.CalculatedAt != null ? m.CalculatedAt.ToDateTime() : null,
IsExpired = m.IsExpired,
Created = m.Created.ToDateTime()
}).ToList()
});
} }
} }
@@ -7,7 +7,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Afrino.FMSMicroservice.Protobuf" Version="0.0.122" /> <PackageReference Include="Afrino.FMSMicroservice.Protobuf" Version="0.0.122" />
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.161" /> <PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.162" />
<PackageReference Include="Google.Protobuf" Version="3.23.3" /> <PackageReference Include="Google.Protobuf" Version="3.23.3" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.0" /> <PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.0" />
@@ -3,6 +3,7 @@ using BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances; using BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetAvailableWeeks; using BackOffice.BFF.Application.CommissionCQ.Queries.GetAvailableWeeks;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetUserPayouts; using BackOffice.BFF.Application.CommissionCQ.Queries.GetUserPayouts;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalRequests;
using BackOffice.BFF.Application.CommissionCQ.Commands.ProcessWithdrawal; using BackOffice.BFF.Application.CommissionCQ.Commands.ProcessWithdrawal;
using Foursat.BackOffice.BFF.Commission.Protos; using Foursat.BackOffice.BFF.Commission.Protos;
using System.Collections.Generic; using System.Collections.Generic;
@@ -120,10 +121,15 @@ public class CommissionProfile : IRegister
{ {
Id = m.Id, Id = m.Id,
UserId = m.UserId, UserId = m.UserId,
UserFullName = m.UserFullName ?? string.Empty,
WeekDefinitionId = m.WeekDefinitionId, WeekDefinitionId = m.WeekDefinitionId,
WeekDisplayName = m.WeekDisplayName ?? string.Empty, WeekDisplayName = m.WeekDisplayName ?? string.Empty,
LeftLegBalances = m.LeftLegBalances, LeftLegNewMembers = m.LeftLegNewMembers,
RightLegBalances = m.RightLegBalances, LeftLegCarryover = m.LeftLegCarryover,
LeftLegTotal = m.LeftLegTotal,
RightLegNewMembers = m.RightLegNewMembers,
RightLegCarryover = m.RightLegCarryover,
RightLegTotal = m.RightLegTotal,
TotalBalances = m.TotalBalances, TotalBalances = m.TotalBalances,
WeeklyPoolContribution = m.WeeklyPoolContribution, WeeklyPoolContribution = m.WeeklyPoolContribution,
CalculatedAt = m.CalculatedAt.HasValue CalculatedAt = m.CalculatedAt.HasValue
@@ -135,33 +141,38 @@ public class CommissionProfile : IRegister
}); });
// GetWithdrawalRequestsResponseDto -> GetWithdrawalRequestsResponse // GetWithdrawalRequestsResponseDto -> GetWithdrawalRequestsResponse
// config.NewConfig<GetWithdrawalRequestsResponseDto, GetWithdrawalRequestsResponse>() config.NewConfig<GetWithdrawalRequestsResponseDto, GetWithdrawalRequestsResponse>()
// .MapWith(src => new GetWithdrawalRequestsResponse .MapWith(src => new GetWithdrawalRequestsResponse
// { {
// MetaData = new BackOffice.BFF.Protobuf.Common.MetaData MetaData = new BackOffice.BFF.Protobuf.Common.MetaData
// { {
// CurrentPage = src.MetaData.CurrentPage, CurrentPage = src.MetaData.CurrentPage,
// PageSize = src.MetaData.PageSize, PageSize = src.MetaData.PageSize,
// TotalCount = src.MetaData.TotalCount, TotalCount = src.MetaData.TotalCount,
// TotalPage = src.MetaData.TotalPages TotalPage = src.MetaData.TotalPages
// }, },
// Models = { src.Models.Select(m => new WithdrawalRequestModel Models = { src.Models.Select(m => new WithdrawalRequestModel
// { {
// Id = m.Id, Id = m.Id,
// UserId = m.UserId, UserId = m.UserId,
// UserName = m.UserName ?? string.Empty, UserName = m.UserName ?? string.Empty,
// Amount = m.Amount, WeekDefinitionId = m.WeekDefinitionId,
// Status = m.Status, Amount = m.Amount,
// StatusDisplay = m.StatusDisplay ?? string.Empty, Status = m.Status,
// RequestedAt = Timestamp.FromDateTime(DateTime.SpecifyKind(m.RequestedAt, DateTimeKind.Utc)), WithdrawalMethod = m.WithdrawalMethod,
// ProcessedAt = m.ProcessedAt.HasValue IbanNumber = m.IbanNumber ?? string.Empty,
// ? Timestamp.FromDateTime(DateTime.SpecifyKind(m.ProcessedAt.Value, DateTimeKind.Utc)) RequestedAt = Timestamp.FromDateTime(DateTime.SpecifyKind(m.RequestedAt, DateTimeKind.Utc)),
// : null, ProcessedAt = m.ProcessedAt.HasValue
// ProcessedBy = m.ProcessedBy, ? Timestamp.FromDateTime(DateTime.SpecifyKind(m.ProcessedAt.Value, DateTimeKind.Utc))
// ProcessedByName = m.ProcessedByName ?? string.Empty, : null,
// RejectionReason = m.RejectionReason ?? string.Empty ProcessedBy = m.ProcessedBy ?? string.Empty,
// }) } Reason = m.Reason ?? string.Empty,
// }); Created = Timestamp.FromDateTime(DateTime.SpecifyKind(m.Created, DateTimeKind.Utc)),
BankReferenceId = m.BankReferenceId ?? string.Empty,
BankTrackingCode = m.BankTrackingCode ?? string.Empty,
PaymentFailureReason = m.PaymentFailureReason ?? string.Empty
}) }
});
// GetWithdrawalReportsResponseDto -> GetWithdrawalReportsResponse // GetWithdrawalReportsResponseDto -> GetWithdrawalReportsResponse
// config.NewConfig<GetWithdrawalReportsResponseDto, GetWithdrawalReportsResponse>() // config.NewConfig<GetWithdrawalReportsResponseDto, GetWithdrawalReportsResponse>()
@@ -6,7 +6,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<IsPackable>true</IsPackable> <IsPackable>true</IsPackable>
<PackageId>Foursat.BackOffice.BFF.Commission.Protobuf</PackageId> <PackageId>Foursat.BackOffice.BFF.Commission.Protobuf</PackageId>
<Version>0.0.13</Version> <Version>0.0.15</Version>
<Authors>FourSat</Authors> <Authors>FourSat</Authors>
<Company>FourSat</Company> <Company>FourSat</Company>
<Product>BackOffice.BFF.Commission.Protobuf</Product> <Product>BackOffice.BFF.Commission.Protobuf</Product>
@@ -279,15 +279,20 @@ message UserWeeklyBalanceModel
{ {
int64 id = 1; int64 id = 1;
int64 user_id = 2; int64 user_id = 2;
int64 week_definition_id = 3; string user_full_name = 3; // نام کامل کاربر
string week_display_name = 4; int64 week_definition_id = 4;
int32 left_leg_balances = 5; string week_display_name = 5;
int32 right_leg_balances = 6; int32 left_leg_new_members = 6; // اعضای جدید چپ این هفته
int32 total_balances = 7; int32 left_leg_carryover = 7; // باقیمانده چپ از هفته قبل
int64 weekly_pool_contribution = 8; int32 left_leg_total = 8; // مجموع چپ (NewMembers + Carryover)
google.protobuf.Timestamp calculated_at = 9; int32 right_leg_new_members = 9; // اعضای جدید راست این هفته
bool is_expired = 10; int32 right_leg_carryover = 10; // باقیمانده راست از هفته قبل
google.protobuf.Timestamp created = 11; int32 right_leg_total = 11; // مجموع راست (NewMembers + Carryover)
int32 total_balances = 12; // تعداد تعادل = MIN(چپ, راست)
int64 weekly_pool_contribution = 13;
google.protobuf.Timestamp calculated_at = 14;
bool is_expired = 15;
google.protobuf.Timestamp created = 16;
} }
// GetAllWeeklyPools Query // GetAllWeeklyPools Query