feat: Implement User Package Status and User Order Management features
- Added GetUserPackageStatus functionality with mapping and service implementation. - Introduced UserOrder service methods for updating order status, applying discounts, and calculating order PV. - Created Protobuf definitions for public messages and user orders, including necessary request and response messages. - Implemented mapping profiles for package and user order related queries and commands. - Developed query handlers and validators for new commands and queries in the application layer. - Established PublicMessage service for handling public messages with appropriate gRPC endpoints.
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
using BackOffice.BFF.Package.Protobuf.Protos.Package;
|
||||
using MediatR;
|
||||
|
||||
namespace BackOffice.BFF.Application.PackageCQ.Queries.GetUserPackageStatus;
|
||||
|
||||
public record GetUserPackageStatusQuery : IRequest<GetUserPackageStatusResponse>
|
||||
{
|
||||
public long UserId { get; init; }
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
using BackOffice.BFF.Package.Protobuf.Protos.Package;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BackOffice.BFF.Application.PackageCQ.Queries.GetUserPackageStatus;
|
||||
|
||||
public class GetUserPackageStatusQueryHandler : IRequestHandler<GetUserPackageStatusQuery, GetUserPackageStatusResponse>
|
||||
{
|
||||
private readonly PackageContract.PackageContractClient _packageClient;
|
||||
private readonly ILogger<GetUserPackageStatusQueryHandler> _logger;
|
||||
|
||||
public GetUserPackageStatusQueryHandler(
|
||||
PackageContract.PackageContractClient packageClient,
|
||||
ILogger<GetUserPackageStatusQueryHandler> logger)
|
||||
{
|
||||
_packageClient = packageClient;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<GetUserPackageStatusResponse> Handle(GetUserPackageStatusQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
// TODO: پیادهسازی GetUserPackageStatus
|
||||
//
|
||||
// 1. ایجاد gRPC Request:
|
||||
// - var grpcRequest = new CMSMicroservice.Protobuf.Protos.Package.GetUserPackageStatusRequest {
|
||||
// UserId = request.UserId
|
||||
// }
|
||||
//
|
||||
// 2. فراخوانی CMS:
|
||||
// - var response = await _packageClient.GetUserPackageStatusAsync(grpcRequest, cancellationToken: cancellationToken)
|
||||
//
|
||||
// 3. تبدیل به BFF Response:
|
||||
// - return new GetUserPackageStatusResponse {
|
||||
// UserId = response.UserId,
|
||||
// PackagePurchaseMethod = response.PackagePurchaseMethod,
|
||||
// HasPurchasedPackage = response.HasPurchasedPackage,
|
||||
// IsClubMemberActive = response.IsClubMemberActive,
|
||||
// WalletBalance = response.WalletBalance,
|
||||
// DiscountBalance = response.DiscountBalance,
|
||||
// CanActivateClubMembership = response.CanActivateClubMembership,
|
||||
// LastOrderNumber = response.LastOrderNumber,
|
||||
// LastPurchaseDate = response.LastPurchaseDate
|
||||
// }
|
||||
//
|
||||
// 4. Log:
|
||||
// - _logger.LogInformation("Retrieved package status for user {UserId}", request.UserId)
|
||||
//
|
||||
// نکته: این endpoint برای Admin است تا وضعیت کاربران را بررسی کند
|
||||
|
||||
throw new NotImplementedException("GetUserPackageStatus needs implementation");
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace BackOffice.BFF.Application.PackageCQ.Queries.GetUserPackageStatus;
|
||||
|
||||
public class GetUserPackageStatusQueryValidator : AbstractValidator<GetUserPackageStatusQuery>
|
||||
{
|
||||
public GetUserPackageStatusQueryValidator()
|
||||
{
|
||||
RuleFor(x => x.UserId)
|
||||
.GreaterThan(0)
|
||||
.WithMessage("شناسه کاربر باید بزرگتر از 0 باشد");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user