Add response DTOs for withdrawal and club activation commands
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BackOffice.BFF.Domain\BackOffice.BFF.Domain.csproj" />
|
||||
<ProjectReference Include="..\Protobufs\BackOffice.BFF.UserOrder.Protobuf\BackOffice.BFF.UserOrder.Protobuf.csproj" />
|
||||
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Commission.Protobuf\BackOffice.BFF.Commission.Protobuf.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace BackOffice.BFF.Application.ClubMembershipCQ.Commands.ActivateClub;
|
||||
|
||||
public record ActivateClubCommand : IRequest<ActivateClubResponseDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه کاربر
|
||||
/// </summary>
|
||||
public long UserId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// شناسه بسته (Package)
|
||||
/// </summary>
|
||||
public long PackageId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// کد فعالسازی (اختیاری)
|
||||
/// </summary>
|
||||
public string? ActivationCode { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// مدت زمان عضویت به ماه (پیشفرض: 12)
|
||||
/// </summary>
|
||||
public int DurationMonths { get; init; } = 12;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||
|
||||
namespace BackOffice.BFF.Application.ClubMembershipCQ.Commands.ActivateClub;
|
||||
|
||||
public class ActivateClubCommandHandler : IRequestHandler<ActivateClubCommand, ActivateClubResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public ActivateClubCommandHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<ActivateClubResponseDto> Handle(ActivateClubCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var grpcRequest = new ActivateClubMembershipRequest
|
||||
{
|
||||
UserId = request.UserId,
|
||||
PackageId = request.PackageId,
|
||||
DurationMonths = request.DurationMonths
|
||||
};
|
||||
|
||||
// اگر کد فعالسازی ارسال شده، اضافه کن
|
||||
if (!string.IsNullOrEmpty(request.ActivationCode))
|
||||
{
|
||||
grpcRequest.ActivationCode = request.ActivationCode;
|
||||
}
|
||||
|
||||
var response = await _context.ClubMemberships.ActivateClubMembershipAsync(
|
||||
grpcRequest,
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return new ActivateClubResponseDto
|
||||
{
|
||||
Message = "Club membership activated successfully"
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace BackOffice.BFF.Application.ClubMembershipCQ.Commands.ActivateClub;
|
||||
|
||||
public class ActivateClubResponseDto
|
||||
{
|
||||
/// <summary>
|
||||
/// پیام موفقیت
|
||||
/// </summary>
|
||||
public string Message { get; set; } = "Club membership activated successfully";
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace BackOffice.BFF.Application.ClubMembershipCQ.Queries.GetAllClubMembers;
|
||||
|
||||
public record GetAllClubMembersQuery : IRequest<GetAllClubMembersResponseDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// فیلتر بر اساس وضعیت فعال/غیرفعال (null = همه)
|
||||
/// </summary>
|
||||
public bool? IsActive { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره صفحه (پیشفرض: 1)
|
||||
/// </summary>
|
||||
public int PageNumber { get; init; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// تعداد در هر صفحه (پیشفرض: 20)
|
||||
/// </summary>
|
||||
public int PageSize { get; init; } = 20;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||
|
||||
namespace BackOffice.BFF.Application.ClubMembershipCQ.Queries.GetAllClubMembers;
|
||||
|
||||
public class GetAllClubMembersQueryHandler : IRequestHandler<GetAllClubMembersQuery, GetAllClubMembersResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetAllClubMembersQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetAllClubMembersResponseDto> Handle(GetAllClubMembersQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.ClubMemberships.GetAllClubMembershipsAsync(
|
||||
request.Adapt<GetAllClubMembershipsRequest>(),
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return response.Adapt<GetAllClubMembersResponseDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
namespace BackOffice.BFF.Application.ClubMembershipCQ.Queries.GetAllClubMembers;
|
||||
|
||||
public class GetAllClubMembersResponseDto
|
||||
{
|
||||
/// <summary>
|
||||
/// لیست اعضای باشگاه
|
||||
/// </summary>
|
||||
public List<ClubMemberDto> Members { 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 ClubMemberDto
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه ClubMembership
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شناسه کاربر
|
||||
/// </summary>
|
||||
public long UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کاربر
|
||||
/// </summary>
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ فعالسازی
|
||||
/// </summary>
|
||||
public DateTime ActivationDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ مشارکت اولیه (تومان)
|
||||
/// </summary>
|
||||
public decimal InitialContribution { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// وضعیت فعال/غیرفعال
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ غیرفعال شدن (در صورت وجود)
|
||||
/// </summary>
|
||||
public DateTime? DeactivationDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// دلیل غیرفعال شدن (در صورت وجود)
|
||||
/// </summary>
|
||||
public string? DeactivationReason { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ ایجاد
|
||||
/// </summary>
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Commands.ApproveWithdrawal;
|
||||
|
||||
public record ApproveWithdrawalCommand : IRequest<ApproveWithdrawalResponseDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه درخواست برداشت
|
||||
/// </summary>
|
||||
public long WithdrawalId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// یادداشت مدیر (اختیاری)
|
||||
/// </summary>
|
||||
public string? AdminNote { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using BackOffice.BFF.Commission.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Commands.ApproveWithdrawal;
|
||||
|
||||
public class ApproveWithdrawalCommandHandler : IRequestHandler<ApproveWithdrawalCommand, ApproveWithdrawalResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public ApproveWithdrawalCommandHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<ApproveWithdrawalResponseDto> Handle(ApproveWithdrawalCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var grpcRequest = new ApproveWithdrawalRequest
|
||||
{
|
||||
WithdrawalId = request.WithdrawalId,
|
||||
AdminNote = request.AdminNote ?? string.Empty
|
||||
};
|
||||
|
||||
var response = await _context.Commissions.ApproveWithdrawalAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return new ApproveWithdrawalResponseDto
|
||||
{
|
||||
Success = response.Success,
|
||||
Message = response.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Commands.ApproveWithdrawal;
|
||||
|
||||
public record ApproveWithdrawalResponseDto
|
||||
{
|
||||
public bool Success { get; init; }
|
||||
public string Message { get; init; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Commands.ProcessWithdrawal;
|
||||
|
||||
public record ProcessWithdrawalCommand : IRequest<ProcessWithdrawalResponseDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه درخواست برداشت
|
||||
/// </summary>
|
||||
public long WithdrawalId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// شناسه تراکنش بانکی (اختیاری)
|
||||
/// </summary>
|
||||
public string? TransactionId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// یادداشت مدیر (اختیاری)
|
||||
/// </summary>
|
||||
public string? AdminNote { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using BackOffice.BFF.Commission.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Commands.ProcessWithdrawal;
|
||||
|
||||
public class ProcessWithdrawalCommandHandler : IRequestHandler<ProcessWithdrawalCommand, ProcessWithdrawalResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public ProcessWithdrawalCommandHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<ProcessWithdrawalResponseDto> Handle(ProcessWithdrawalCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var grpcRequest = new ProcessWithdrawalRequest
|
||||
{
|
||||
WithdrawalId = request.WithdrawalId,
|
||||
TransactionId = request.TransactionId ?? string.Empty,
|
||||
AdminNote = request.AdminNote ?? string.Empty
|
||||
};
|
||||
|
||||
var response = await _context.Commissions.ProcessWithdrawalAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return new ProcessWithdrawalResponseDto
|
||||
{
|
||||
Success = response.Success,
|
||||
Message = response.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Commands.ProcessWithdrawal;
|
||||
|
||||
public record ProcessWithdrawalResponseDto
|
||||
{
|
||||
public bool Success { get; init; }
|
||||
public string Message { get; init; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Commands.RejectWithdrawal;
|
||||
|
||||
public record RejectWithdrawalCommand : IRequest<RejectWithdrawalResponseDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه درخواست برداشت
|
||||
/// </summary>
|
||||
public long WithdrawalId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// دلیل رد (الزامی)
|
||||
/// </summary>
|
||||
public string RejectReason { get; init; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using BackOffice.BFF.Commission.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Commands.RejectWithdrawal;
|
||||
|
||||
public class RejectWithdrawalCommandHandler : IRequestHandler<RejectWithdrawalCommand, RejectWithdrawalResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public RejectWithdrawalCommandHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<RejectWithdrawalResponseDto> Handle(RejectWithdrawalCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var grpcRequest = new RejectWithdrawalRequest
|
||||
{
|
||||
WithdrawalId = request.WithdrawalId,
|
||||
RejectReason = request.RejectReason
|
||||
};
|
||||
|
||||
var response = await _context.Commissions.RejectWithdrawalAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return new RejectWithdrawalResponseDto
|
||||
{
|
||||
Success = response.Success,
|
||||
Message = response.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Commands.RejectWithdrawal;
|
||||
|
||||
public record RejectWithdrawalResponseDto
|
||||
{
|
||||
public bool Success { get; init; }
|
||||
public string Message { get; init; } = string.Empty;
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -9,6 +9,9 @@ using CMSMicroservice.Protobuf.Protos.ProductImages;
|
||||
using CMSMicroservice.Protobuf.Protos.ProductGallerys;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
using CMSMicroservice.Protobuf.Protos.PruductCategory;
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
using CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||
using FMSMicroservice.Protobuf.Protos.FileInfo;
|
||||
|
||||
namespace BackOffice.BFF.Application.Common.Interfaces;
|
||||
@@ -30,6 +33,11 @@ public interface IApplicationContractContext
|
||||
UserContract.UserContractClient Users { get; }
|
||||
UserOrderContract.UserOrderContractClient UserOrders { get; }
|
||||
UserRoleContract.UserRoleContractClient UserRoles { get; }
|
||||
|
||||
// Network & Commission System
|
||||
CommissionContract.CommissionContractClient Commissions { get; }
|
||||
NetworkMembershipContract.NetworkMembershipContractClient NetworkMemberships { get; }
|
||||
ClubMembershipContract.ClubMembershipContractClient ClubMemberships { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkHistory;
|
||||
|
||||
public record GetNetworkHistoryQuery : IRequest<GetNetworkHistoryResponseDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه کاربر (اختیاری)
|
||||
/// </summary>
|
||||
public long? UserId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// شناسه والد (اختیاری)
|
||||
/// </summary>
|
||||
public long? ParentId { 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.NetworkMembership;
|
||||
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkHistory;
|
||||
|
||||
public class GetNetworkHistoryQueryHandler : IRequestHandler<GetNetworkHistoryQuery, GetNetworkHistoryResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetNetworkHistoryQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetNetworkHistoryResponseDto> Handle(GetNetworkHistoryQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.NetworkMemberships.GetNetworkMembershipHistoryAsync(
|
||||
request.Adapt<GetNetworkMembershipHistoryRequest>(),
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return response.Adapt<GetNetworkHistoryResponseDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkHistory;
|
||||
|
||||
public class GetNetworkHistoryResponseDto
|
||||
{
|
||||
/// <summary>
|
||||
/// لیست تاریخچه تغییرات شبکه
|
||||
/// </summary>
|
||||
public List<NetworkHistoryDto> History { 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 NetworkHistoryDto
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه تاریخچه
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شناسه کاربر
|
||||
/// </summary>
|
||||
public long UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شناسه والد قبلی
|
||||
/// </summary>
|
||||
public long? OldParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شناسه والد جدید
|
||||
/// </summary>
|
||||
public long? NewParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// موقعیت قبلی (0=Left, 1=Right)
|
||||
/// </summary>
|
||||
public int? OldNetworkLeg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// موقعیت جدید
|
||||
/// </summary>
|
||||
public int? NewNetworkLeg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// سطح قبلی
|
||||
/// </summary>
|
||||
public int? OldNetworkLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// سطح جدید
|
||||
/// </summary>
|
||||
public int? NewNetworkLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نوع عملیات
|
||||
/// </summary>
|
||||
public int Action { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// انجام دهنده عملیات
|
||||
/// </summary>
|
||||
public string PerformedBy { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// دلیل تغییر
|
||||
/// </summary>
|
||||
public string Reason { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ ایجاد
|
||||
/// </summary>
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkTree;
|
||||
|
||||
public record GetNetworkTreeQuery : IRequest<GetNetworkTreeResponseDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه کاربر ریشه (Root)
|
||||
/// </summary>
|
||||
public long RootUserId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// حداکثر عمق درخت (اختیاری، پیشفرض: 5)
|
||||
/// </summary>
|
||||
public int? MaxDepth { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// فقط کاربران فعال (اختیاری)
|
||||
/// </summary>
|
||||
public bool? OnlyActive { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkTree;
|
||||
|
||||
public class GetNetworkTreeQueryHandler : IRequestHandler<GetNetworkTreeQuery, GetNetworkTreeResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetNetworkTreeQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetNetworkTreeResponseDto> Handle(GetNetworkTreeQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.NetworkMemberships.GetNetworkTreeAsync(
|
||||
request.Adapt<GetNetworkTreeRequest>(),
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return response.Adapt<GetNetworkTreeResponseDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkTree;
|
||||
|
||||
public class GetNetworkTreeResponseDto
|
||||
{
|
||||
/// <summary>
|
||||
/// لیست گرههای درخت شبکه
|
||||
/// </summary>
|
||||
public List<NetworkTreeNodeDto> Nodes { get; set; } = new();
|
||||
}
|
||||
|
||||
public class NetworkTreeNodeDto
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه کاربر
|
||||
/// </summary>
|
||||
public long UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کاربر
|
||||
/// </summary>
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// شناسه والد
|
||||
/// </summary>
|
||||
public long? ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// موقعیت در شبکه (0=Left, 1=Right)
|
||||
/// </summary>
|
||||
public int NetworkLeg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// سطح در شبکه
|
||||
/// </summary>
|
||||
public int NetworkLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// وضعیت فعال/غیرفعال
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ عضویت
|
||||
/// </summary>
|
||||
public DateTime JoinedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetUserNetworkInfo;
|
||||
|
||||
public record GetUserNetworkInfoQuery : IRequest<GetUserNetworkInfoResponseDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه کاربر
|
||||
/// </summary>
|
||||
public long UserId { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetUserNetworkInfo;
|
||||
|
||||
public class GetUserNetworkInfoQueryHandler : IRequestHandler<GetUserNetworkInfoQuery, GetUserNetworkInfoResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetUserNetworkInfoQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetUserNetworkInfoResponseDto> Handle(GetUserNetworkInfoQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.NetworkMemberships.GetUserNetworkAsync(
|
||||
request.Adapt<GetUserNetworkRequest>(),
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return response.Adapt<GetUserNetworkInfoResponseDto>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetUserNetworkInfo;
|
||||
|
||||
public class GetUserNetworkInfoResponseDto
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه عضویت شبکه
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شناسه کاربر
|
||||
/// </summary>
|
||||
public long UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کاربر
|
||||
/// </summary>
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// شناسه والد در شبکه
|
||||
/// </summary>
|
||||
public long? ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام والد
|
||||
/// </summary>
|
||||
public string ParentName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// موقعیت در شبکه (0=Left, 1=Right)
|
||||
/// </summary>
|
||||
public int NetworkLeg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شناسه فرزند چپ
|
||||
/// </summary>
|
||||
public long? LeftChildId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام فرزند چپ
|
||||
/// </summary>
|
||||
public string LeftChildName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// شناسه فرزند راست
|
||||
/// </summary>
|
||||
public long? RightChildId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام فرزند راست
|
||||
/// </summary>
|
||||
public string RightChildName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// سطح در شبکه
|
||||
/// </summary>
|
||||
public int NetworkLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// کد معرف
|
||||
/// </summary>
|
||||
public string ReferralCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ عضویت در شبکه
|
||||
/// </summary>
|
||||
public DateTime JoinedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ ایجاد
|
||||
/// </summary>
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user