update
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using BackOffice.BFF.Commission.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using BackOffice.BFF.Commission.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetUserPayouts;
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances;
|
||||
|
||||
public record GetUserWeeklyBalancesQuery : IRequest<GetUserWeeklyBalancesResponseDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه کاربر (فیلتر اختیاری)
|
||||
/// </summary>
|
||||
public long? UserId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره هفته (فیلتر اختیاری)
|
||||
/// </summary>
|
||||
public string? WeekNumber { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// فقط تعادلهای فعال (منقضی نشده)
|
||||
/// </summary>
|
||||
public bool OnlyActive { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره صفحه
|
||||
/// </summary>
|
||||
public int PageIndex { get; init; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// تعداد در صفحه
|
||||
/// </summary>
|
||||
public int PageSize { get; init; } = 10;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using BackOffice.BFF.Commission.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances;
|
||||
|
||||
public class GetUserWeeklyBalancesQueryHandler : IRequestHandler<GetUserWeeklyBalancesQuery, GetUserWeeklyBalancesResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetUserWeeklyBalancesQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetUserWeeklyBalancesResponseDto> Handle(GetUserWeeklyBalancesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var grpcRequest = new GetUserWeeklyBalancesRequest
|
||||
{
|
||||
OnlyActive = request.OnlyActive,
|
||||
PageIndex = request.PageIndex,
|
||||
PageSize = request.PageSize
|
||||
};
|
||||
|
||||
if (request.UserId.HasValue)
|
||||
{
|
||||
grpcRequest.UserId = request.UserId.Value;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.WeekNumber))
|
||||
{
|
||||
grpcRequest.WeekNumber = request.WeekNumber;
|
||||
}
|
||||
|
||||
var response = await _context.Commissions.GetUserWeeklyBalancesAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return response.Adapt<GetUserWeeklyBalancesResponseDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances;
|
||||
|
||||
public record GetUserWeeklyBalancesResponseDto
|
||||
{
|
||||
public MetaDataDto MetaData { get; init; } = new();
|
||||
public List<UserWeeklyBalanceDto> Models { get; init; } = new();
|
||||
}
|
||||
|
||||
public record UserWeeklyBalanceDto
|
||||
{
|
||||
public long Id { get; init; }
|
||||
public long UserId { get; init; }
|
||||
public string WeekNumber { get; init; } = string.Empty;
|
||||
public int LeftLegBalances { get; init; }
|
||||
public int RightLegBalances { get; init; }
|
||||
public int TotalBalances { get; init; }
|
||||
public long WeeklyPoolContribution { get; init; }
|
||||
public DateTime? CalculatedAt { get; init; }
|
||||
public bool IsExpired { get; init; }
|
||||
public DateTime Created { get; init; }
|
||||
}
|
||||
|
||||
public record MetaDataDto
|
||||
{
|
||||
public int TotalCount { get; init; }
|
||||
public int PageSize { get; init; }
|
||||
public int CurrentPage { get; init; }
|
||||
public int TotalPages { get; init; }
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using BackOffice.BFF.Commission.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWeeklyPool;
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ public class GetWithdrawalRequestsQueryHandler : IRequestHandler<GetWithdrawalRe
|
||||
}
|
||||
|
||||
var response = await _context.Commissions.GetWithdrawalRequestsAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return response.Adapt<GetWithdrawalRequestsResponseDto>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWorkerExecutionLogs;
|
||||
|
||||
public class GetWorkerExecutionLogsQuery : IRequest<GetWorkerExecutionLogsResponseDto>
|
||||
{
|
||||
public string? WeekNumber { get; set; }
|
||||
public string? ExecutionId { get; set; }
|
||||
public bool? SuccessOnly { get; set; }
|
||||
public bool? FailedOnly { get; set; }
|
||||
public int PageIndex { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using BackOffice.BFF.Commission.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWorkerExecutionLogs;
|
||||
|
||||
public class GetWorkerExecutionLogsQueryHandler : IRequestHandler<GetWorkerExecutionLogsQuery, GetWorkerExecutionLogsResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetWorkerExecutionLogsQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetWorkerExecutionLogsResponseDto> Handle(GetWorkerExecutionLogsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var grpcRequest = new GetWorkerExecutionLogsRequest
|
||||
{
|
||||
PageIndex = request.PageIndex,
|
||||
PageSize = request.PageSize
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.WeekNumber))
|
||||
{
|
||||
grpcRequest.WeekNumber = request.WeekNumber;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.ExecutionId))
|
||||
{
|
||||
grpcRequest.ExecutionId = request.ExecutionId;
|
||||
}
|
||||
|
||||
if (request.SuccessOnly.HasValue)
|
||||
{
|
||||
grpcRequest.SuccessOnly = request.SuccessOnly.Value;
|
||||
}
|
||||
|
||||
if (request.FailedOnly.HasValue)
|
||||
{
|
||||
grpcRequest.FailedOnly = request.FailedOnly.Value;
|
||||
}
|
||||
|
||||
var response = await _context.Commissions.GetWorkerExecutionLogsAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return response.Adapt<GetWorkerExecutionLogsResponseDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using BackOffice.BFF.Application.Common.Models;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWorkerExecutionLogs;
|
||||
|
||||
public class GetWorkerExecutionLogsResponseDto
|
||||
{
|
||||
public MetaData MetaData { get; set; } = new();
|
||||
public List<WorkerExecutionLogModel> Models { get; set; } = new();
|
||||
}
|
||||
|
||||
public class WorkerExecutionLogModel
|
||||
{
|
||||
public string ExecutionId { get; set; } = string.Empty;
|
||||
public string WeekNumber { get; set; } = string.Empty;
|
||||
public string Step { get; set; } = string.Empty;
|
||||
public bool Success { get; set; }
|
||||
public string? ErrorMessage { get; set; }
|
||||
public DateTime StartedAt { get; set; }
|
||||
public DateTime CompletedAt { get; set; }
|
||||
public long DurationMs { get; set; }
|
||||
public int RecordsProcessed { get; set; }
|
||||
public string? Details { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWorkerStatus;
|
||||
|
||||
public class GetWorkerStatusQuery : IRequest<GetWorkerStatusResponseDto>
|
||||
{
|
||||
// No parameters needed - returns current worker status
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using BackOffice.BFF.Commission.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWorkerStatus;
|
||||
|
||||
public class GetWorkerStatusQueryHandler : IRequestHandler<GetWorkerStatusQuery, GetWorkerStatusResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetWorkerStatusQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetWorkerStatusResponseDto> Handle(GetWorkerStatusQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var grpcRequest = new GetWorkerStatusRequest();
|
||||
|
||||
var response = await _context.Commissions.GetWorkerStatusAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return response.Adapt<GetWorkerStatusResponseDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWorkerStatus;
|
||||
|
||||
public class GetWorkerStatusResponseDto
|
||||
{
|
||||
public bool IsRunning { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
public string? CurrentExecutionId { get; set; }
|
||||
public string? CurrentWeekNumber { get; set; }
|
||||
public string? CurrentStep { get; set; }
|
||||
public DateTime? LastRunAt { get; set; }
|
||||
public DateTime? NextScheduledRun { get; set; }
|
||||
public int TotalExecutions { get; set; }
|
||||
public int SuccessfulExecutions { get; set; }
|
||||
public int FailedExecutions { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user