feat: Implement customer profile and referral queries

- Add GetCustomerProfileResponseDto for retrieving customer profile information.
- Create GetCustomerReferralsQuery and GetCustomerReferralsQueryHandler to fetch customer referrals with pagination and filtering options.
- Introduce GetCustomerReferralsResponseDto to structure the response for customer referrals.
- Implement GetCustomerSettingsQuery and GetCustomerSettingsQueryHandler to retrieve user settings.
- Add GetCustomerOrder and GetCustomerOrderQueryHandler for fetching specific customer orders.
- Create GetCustomerOrderHistoryQuery and GetCustomerOrderHistoryQueryHandler to retrieve order history with filtering options.
- Implement GetCustomerOrdersQuery and GetCustomerOrdersQueryHandler for fetching multiple customer orders with filters.
- Add GetCustomerWalletChangeLogQuery and GetCustomerWalletChangeLogQueryHandler for retrieving wallet change logs.
- Implement GetCustomerWithdrawalSettingsQuery and GetCustomerWithdrawalSettingsQueryHandler for fetching withdrawal settings.
- Create GetCustomerWithdrawalsQuery and GetCustomerWithdrawalsQueryHandler to retrieve customer withdrawal requests.
This commit is contained in:
masoodafar-web
2026-02-05 23:01:50 +03:30
parent b41342dcad
commit b2d676b555
96 changed files with 4822 additions and 589 deletions
@@ -0,0 +1,15 @@
using CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetNetworkTree;
namespace CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetMyNetworkTree;
/// <summary>
/// Query برای دریافت درخت شبکه کاربر جاری (Customer-facing)
/// از ICurrentUserService برای دریافت UserId استفاده می‌کند
/// </summary>
public record GetMyNetworkTreeQuery : IRequest<NetworkTreeDto?>
{
/// <summary>
/// تعداد سطوح (Depth) که می‌خواهیم نمایش دهیم (پیش‌فرض: 3)
/// </summary>
public int MaxDepth { get; init; } = 3;
}
@@ -0,0 +1,40 @@
using CMSMicroservice.Application.Common.Interfaces;
using CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetNetworkTree;
namespace CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetMyNetworkTree;
/// <summary>
/// Handler برای دریافت درخت شبکه کاربر جاری
/// </summary>
public class GetMyNetworkTreeQueryHandler : IRequestHandler<GetMyNetworkTreeQuery, NetworkTreeDto?>
{
private readonly ICurrentUserService _currentUser;
private readonly ISender _sender;
public GetMyNetworkTreeQueryHandler(
ICurrentUserService currentUser,
ISender sender)
{
_currentUser = currentUser;
_sender = sender;
}
public async Task<NetworkTreeDto?> Handle(GetMyNetworkTreeQuery request, CancellationToken cancellationToken)
{
// دریافت UserId از JWT
var userId = long.TryParse(_currentUser.UserId, out var id) ? id : 0;
if (userId == 0)
{
throw new UnauthorizedAccessException("User not authenticated");
}
// استفاده از GetNetworkTreeQuery موجود با UserId از JWT
var query = new GetNetworkTreeQuery
{
UserId = userId,
MaxDepth = request.MaxDepth > 0 ? request.MaxDepth : 3
};
return await _sender.Send(query, cancellationToken);
}
}
@@ -0,0 +1,24 @@
namespace CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetMyNetworkTree;
public class GetMyNetworkTreeQueryValidator : AbstractValidator<GetMyNetworkTreeQuery>
{
public GetMyNetworkTreeQueryValidator()
{
RuleFor(x => x.MaxDepth)
.InclusiveBetween(1, 100)
.WithMessage("عمق درخت باید بین 1 تا 100 باشد");
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(
ValidationContext<GetMyNetworkTreeQuery>.CreateWithOptions(
(GetMyNetworkTreeQuery)model,
x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}