Add response DTOs for withdrawal and club activation commands
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools;
|
||||
|
||||
public record GetAllWeeklyPoolsQuery : IRequest<GetAllWeeklyPoolsResponseDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// از هفته (فیلتر اختیاری)
|
||||
/// </summary>
|
||||
public string? FromWeek { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// تا هفته (فیلتر اختیاری)
|
||||
/// </summary>
|
||||
public string? ToWeek { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// فقط Pool های محاسبه شده
|
||||
/// </summary>
|
||||
public bool? OnlyCalculated { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره صفحه
|
||||
/// </summary>
|
||||
public int PageIndex { get; init; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// تعداد در صفحه
|
||||
/// </summary>
|
||||
public int PageSize { get; init; } = 10;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools;
|
||||
|
||||
public class GetAllWeeklyPoolsQueryHandler : IRequestHandler<GetAllWeeklyPoolsQuery, GetAllWeeklyPoolsResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetAllWeeklyPoolsQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetAllWeeklyPoolsResponseDto> Handle(GetAllWeeklyPoolsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var grpcRequest = new GetAllWeeklyPoolsRequest
|
||||
{
|
||||
PageIndex = request.PageIndex,
|
||||
PageSize = request.PageSize
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.FromWeek))
|
||||
{
|
||||
grpcRequest.FromWeek = request.FromWeek;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.ToWeek))
|
||||
{
|
||||
grpcRequest.ToWeek = request.ToWeek;
|
||||
}
|
||||
|
||||
if (request.OnlyCalculated.HasValue)
|
||||
{
|
||||
grpcRequest.OnlyCalculated = request.OnlyCalculated.Value;
|
||||
}
|
||||
|
||||
var response = await _context.Commissions.GetAllWeeklyPoolsAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return response.Adapt<GetAllWeeklyPoolsResponseDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools;
|
||||
|
||||
public record GetAllWeeklyPoolsResponseDto
|
||||
{
|
||||
public MetaDataDto MetaData { get; init; } = new();
|
||||
public List<WeeklyCommissionPoolDto> Models { get; init; } = new();
|
||||
}
|
||||
|
||||
public record WeeklyCommissionPoolDto
|
||||
{
|
||||
public long Id { get; init; }
|
||||
public string WeekNumber { get; init; } = string.Empty;
|
||||
public long TotalPoolAmount { get; init; }
|
||||
public int TotalBalances { get; init; }
|
||||
public long ValuePerBalance { get; init; }
|
||||
public bool IsCalculated { get; init; }
|
||||
public DateTime? CalculatedAt { 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; }
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetUserPayouts;
|
||||
|
||||
public record GetUserPayoutsQuery : IRequest<GetUserPayoutsResponseDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه کاربر
|
||||
/// </summary>
|
||||
public long UserId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره هفته (اختیاری - برای فیلتر)
|
||||
/// </summary>
|
||||
public string? WeekNumber { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره صفحه (پیشفرض: 1)
|
||||
/// </summary>
|
||||
public int PageNumber { get; init; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// تعداد در هر صفحه (پیشفرض: 10)
|
||||
/// </summary>
|
||||
public int PageSize { get; init; } = 10;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetUserPayouts;
|
||||
|
||||
public class GetUserPayoutsQueryHandler : IRequestHandler<GetUserPayoutsQuery, GetUserPayoutsResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetUserPayoutsQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetUserPayoutsResponseDto> Handle(GetUserPayoutsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.Commissions.GetUserCommissionPayoutsAsync(
|
||||
request.Adapt<GetUserCommissionPayoutsRequest>(),
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return response.Adapt<GetUserPayoutsResponseDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetUserPayouts;
|
||||
|
||||
public class GetUserPayoutsResponseDto
|
||||
{
|
||||
/// <summary>
|
||||
/// لیست Payout ها
|
||||
/// </summary>
|
||||
public List<UserPayoutDto> Payouts { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// تعداد کل رکوردها
|
||||
/// </summary>
|
||||
public int TotalCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره صفحه فعلی
|
||||
/// </summary>
|
||||
public int PageNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تعداد در هر صفحه
|
||||
/// </summary>
|
||||
public int PageSize { get; set; }
|
||||
}
|
||||
|
||||
public class UserPayoutDto
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه Payout
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شناسه کاربر
|
||||
/// </summary>
|
||||
public long UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره هفته
|
||||
/// </summary>
|
||||
public string WeekNumber { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// بالانس Leg چپ
|
||||
/// </summary>
|
||||
public decimal LeftLegBalance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// بالانس Leg راست
|
||||
/// </summary>
|
||||
public decimal RightLegBalance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// بالانس Leg ضعیفتر
|
||||
/// </summary>
|
||||
public decimal WeakerLegBalance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ کمیسیون (تومان)
|
||||
/// </summary>
|
||||
public decimal CommissionAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// وضعیت پرداخت
|
||||
/// </summary>
|
||||
public string Status { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ پرداخت
|
||||
/// </summary>
|
||||
public DateTime? PaidAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ ایجاد
|
||||
/// </summary>
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWeeklyPool;
|
||||
|
||||
public record GetWeeklyPoolQuery : IRequest<GetWeeklyPoolResponseDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// شماره هفته (فرمت: YYYY-Www مثلاً 2025-W48)
|
||||
/// </summary>
|
||||
public string WeekNumber { get; init; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWeeklyPool;
|
||||
|
||||
public class GetWeeklyPoolQueryHandler : IRequestHandler<GetWeeklyPoolQuery, GetWeeklyPoolResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetWeeklyPoolQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetWeeklyPoolResponseDto> Handle(GetWeeklyPoolQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.Commissions.GetWeeklyCommissionPoolAsync(
|
||||
request.Adapt<GetWeeklyCommissionPoolRequest>(),
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return response.Adapt<GetWeeklyPoolResponseDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWeeklyPool;
|
||||
|
||||
public class GetWeeklyPoolResponseDto
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه Pool
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره هفته (فرمت: YYYY-Www)
|
||||
/// </summary>
|
||||
public string WeekNumber { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// مجموع کل Pool (تومان)
|
||||
/// </summary>
|
||||
public decimal TotalPoolValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مجموع مشارکتهای اولیه (InitialContribution)
|
||||
/// </summary>
|
||||
public decimal TotalContributions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مجموع Payout های پرداخت شده
|
||||
/// </summary>
|
||||
public decimal TotalPayouts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// باقیمانده Pool
|
||||
/// </summary>
|
||||
public decimal LeftBalance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تعداد اعضای فعال در این هفته
|
||||
/// </summary>
|
||||
public int ActiveMembersCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آیا محاسبه شده است؟
|
||||
/// </summary>
|
||||
public bool IsCalculated { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ محاسبه
|
||||
/// </summary>
|
||||
public DateTime? CalculatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ ایجاد
|
||||
/// </summary>
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ آخرین ویرایش
|
||||
/// </summary>
|
||||
public DateTime? ModifiedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalRequests;
|
||||
|
||||
public record GetWithdrawalRequestsQuery : IRequest<GetWithdrawalRequestsResponseDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// شماره صفحه (پیشفرض: 1)
|
||||
/// </summary>
|
||||
public int PageIndex { get; init; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// تعداد در هر صفحه (پیشفرض: 10)
|
||||
/// </summary>
|
||||
public int PageSize { get; init; } = 10;
|
||||
|
||||
/// <summary>
|
||||
/// فیلتر وضعیت (اختیاری): 0=Pending, 1=Approved, 2=Rejected, 3=Processed
|
||||
/// </summary>
|
||||
public int? Status { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// فیلتر شناسه کاربر (اختیاری)
|
||||
/// </summary>
|
||||
public long? UserId { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using BackOffice.BFF.Commission.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalRequests;
|
||||
|
||||
public class GetWithdrawalRequestsQueryHandler : IRequestHandler<GetWithdrawalRequestsQuery, GetWithdrawalRequestsResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetWithdrawalRequestsQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetWithdrawalRequestsResponseDto> Handle(GetWithdrawalRequestsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var grpcRequest = new GetWithdrawalRequestsRequest
|
||||
{
|
||||
PageIndex = request.PageIndex,
|
||||
PageSize = request.PageSize
|
||||
};
|
||||
|
||||
if (request.Status.HasValue)
|
||||
{
|
||||
grpcRequest.Status = request.Status.Value;
|
||||
}
|
||||
|
||||
if (request.UserId.HasValue)
|
||||
{
|
||||
grpcRequest.UserId = request.UserId.Value;
|
||||
}
|
||||
|
||||
var response = await _context.Commissions.GetWithdrawalRequestsAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return response.Adapt<GetWithdrawalRequestsResponseDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalRequests;
|
||||
|
||||
public record GetWithdrawalRequestsResponseDto
|
||||
{
|
||||
public List<WithdrawalRequestDto> Models { get; init; } = new();
|
||||
public MetaDataDto MetaData { get; init; } = new();
|
||||
}
|
||||
|
||||
public record WithdrawalRequestDto
|
||||
{
|
||||
public long Id { get; init; }
|
||||
public long UserId { get; init; }
|
||||
public string UserName { get; init; } = string.Empty;
|
||||
public string PhoneNumber { get; init; } = string.Empty;
|
||||
public long Amount { get; init; }
|
||||
public int Status { get; init; }
|
||||
public string Method { get; init; } = "Bank";
|
||||
public string? BankAccount { get; init; }
|
||||
public string? BankName { get; init; }
|
||||
public DateTime RequestDate { get; init; }
|
||||
public DateTime? ProcessedDate { get; init; }
|
||||
public string? AdminNote { 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; }
|
||||
}
|
||||
Reference in New Issue
Block a user