feat: enhance GetWithdrawalRequests response structure and update related mappings
Build and Deploy / build (push) Failing after 1m11s

This commit is contained in:
masoodafar-web
2025-12-27 21:52:50 +03:30
parent f5e7d0c882
commit ce7683c736
6 changed files with 87 additions and 46 deletions
@@ -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
@@ -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;
@@ -135,33 +136,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.14</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