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
@@ -6,15 +6,28 @@ using CMSMicroservice.Application.UserAddressCQ.Commands.DeleteUserAddress;
using CMSMicroservice.Application.UserAddressCQ.Queries.GetUserAddress;
using CMSMicroservice.Application.UserAddressCQ.Queries.GetAllUserAddressByFilter;
using CMSMicroservice.Application.UserAddressCQ.Commands.SetAddressAsDefault;
using CMSMicroservice.Application.UserAddressCQ.Queries.GetCustomerAddresses;
using CMSMicroservice.Application.UserAddressCQ.Commands.CreateCustomerAddress;
using CMSMicroservice.Application.UserAddressCQ.Commands.UpdateCustomerAddress;
using CMSMicroservice.Application.UserAddressCQ.Commands.DeleteCustomerAddress;
using CMSMicroservice.Application.UserAddressCQ.Commands.SetCustomerDefaultAddress;
using MediatR;
namespace CMSMicroservice.WebApi.Services;
public class UserAddressService : UserAddressContract.UserAddressContractBase
{
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
private readonly ISender _sender;
public UserAddressService(IDispatchRequestToCQRS dispatchRequestToCQRS)
public UserAddressService(IDispatchRequestToCQRS dispatchRequestToCQRS, ISender sender)
{
_dispatchRequestToCQRS = dispatchRequestToCQRS;
_sender = sender;
}
#region Admin Methods
public override async Task<CreateNewUserAddressResponse> CreateNewUserAddress(CreateNewUserAddressRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<CreateNewUserAddressRequest, CreateNewUserAddressCommand, CreateNewUserAddressResponse>(request, context);
@@ -39,4 +52,96 @@ public class UserAddressService : UserAddressContract.UserAddressContractBase
{
return await _dispatchRequestToCQRS.Handle<SetAddressAsDefaultRequest, SetAddressAsDefaultCommand>(request, context);
}
#endregion
#region Customer Methods
public override async Task<GetCustomerAddressesResponse> GetCustomerAddresses(GetCustomerAddressesRequest request, ServerCallContext context)
{
var query = new GetCustomerAddressesQuery();
var result = await _sender.Send(query);
var response = new GetCustomerAddressesResponse();
foreach (var addr in result.Addresses)
{
response.Models.Add(new CMSMicroservice.Protobuf.Protos.UserAddress.CustomerAddressModel
{
Id = addr.Id,
Title = addr.Title,
Address = addr.Address,
PostalCode = addr.PostalCode,
IsDefault = addr.IsDefault,
CityId = addr.CityId,
CityName = addr.CityName,
ProvinceName = addr.ProvinceName
});
}
return response;
}
public override async Task<CreateCustomerAddressResponse> CreateCustomerAddress(CreateCustomerAddressRequest request, ServerCallContext context)
{
var command = new CreateCustomerAddressCommand
{
Title = request.Title,
Address = request.Address,
PostalCode = request.PostalCode,
IsDefault = request.IsDefault,
CityId = request.CityId
};
var result = await _sender.Send(command);
return new CreateCustomerAddressResponse
{
Id = result.Id,
Message = result.Message
};
}
public override async Task<Empty> UpdateCustomerAddress(UpdateCustomerAddressRequest request, ServerCallContext context)
{
var command = new UpdateCustomerAddressCommand
{
Id = request.Id,
Title = request.Title,
Address = request.Address,
PostalCode = request.PostalCode,
IsDefault = request.IsDefault,
CityId = request.CityId
};
await _sender.Send(command);
return new Empty();
}
public override async Task<Empty> DeleteCustomerAddress(DeleteCustomerAddressRequest request, ServerCallContext context)
{
var command = new DeleteCustomerAddressCommand
{
Id = request.Id
};
await _sender.Send(command);
return new Empty();
}
public override async Task<Empty> SetCustomerDefaultAddress(SetCustomerDefaultAddressRequest request, ServerCallContext context)
{
var command = new SetCustomerDefaultAddressCommand
{
Id = request.Id
};
await _sender.Send(command);
return new Empty();
}
#endregion
}