d0224d41b2
Build and Deploy / build (push) Successful in 2m33s
- Added GetDiscountSalesReportQuery and GetDiscountSalesReportQueryHandler to fetch discount sales reports. - Introduced DiscountSalesReportDto, SalesSummaryDto, and PeriodSalesDto for structured report data. feat: Add Discount Product Image Management - Created AddDiscountProductImageCommand and AddDiscountProductImageCommandHandler for image uploads. - Implemented DeleteDiscountProductImageCommand and DeleteDiscountProductImageCommandHandler for image deletion. - Added ReorderDiscountProductImagesCommand and ReorderDiscountProductImagesCommandHandler for image reordering. - Developed UpdateDiscountProductImageCommand and UpdateDiscountProductImageCommandHandler for image updates. feat: Enhance Product Tag Management - Introduced DeleteProductTagCommand and DeleteProductTagCommandHandler for tag deletion. - Added UpdateProductTagCommand and UpdateProductTagCommandHandler for updating product tags. - Implemented GetAllProductTagsQuery and GetAllProductTagsQueryHandler for fetching all product tags. - Created GetProductTagQuery and GetProductTagQueryHandler for retrieving specific product tags. feat: Develop Web API Services for Discount and Product Management - Implemented DiscountCategoryService for managing discount categories. - Created DiscountOrderService for handling discount orders and related queries. - Developed DiscountProductService for managing discount products and their images. - Added DiscountShoppingCartService for managing shopping cart operations. - Implemented ProductTagService for managing product tags and their associations. - Created TagService for managing tags and their related operations.
89 lines
3.5 KiB
C#
89 lines
3.5 KiB
C#
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
|
|
namespace BackOffice.BFF.Application.DiscountOrderCQ.Queries.GetAllDiscountOrders;
|
|
|
|
public class GetAllDiscountOrdersQueryHandler : IRequestHandler<GetAllDiscountOrdersQuery, GetAllDiscountOrdersResponseDto>
|
|
{
|
|
private readonly IApplicationContractContext _context;
|
|
|
|
public GetAllDiscountOrdersQueryHandler(IApplicationContractContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<GetAllDiscountOrdersResponseDto> Handle(GetAllDiscountOrdersQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var grpcRequest = new GetAllDiscountOrdersRequest
|
|
{
|
|
PageNumber = request.PageNumber,
|
|
PageSize = request.PageSize
|
|
};
|
|
|
|
if (request.UserId.HasValue)
|
|
grpcRequest.UserId = request.UserId.Value;
|
|
|
|
if (request.PaymentStatus.HasValue)
|
|
grpcRequest.PaymentStatus = request.PaymentStatus.Value;
|
|
|
|
if (request.DeliveryStatus.HasValue)
|
|
grpcRequest.DeliveryStatus = request.DeliveryStatus.Value;
|
|
|
|
if (!string.IsNullOrWhiteSpace(request.UserMobile))
|
|
grpcRequest.UserMobile = request.UserMobile;
|
|
|
|
if (!string.IsNullOrWhiteSpace(request.TrackingCode))
|
|
grpcRequest.TrackingCode = request.TrackingCode;
|
|
|
|
if (request.FromDate.HasValue)
|
|
grpcRequest.FromDate = Timestamp.FromDateTime(DateTime.SpecifyKind(request.FromDate.Value, DateTimeKind.Utc));
|
|
|
|
if (request.ToDate.HasValue)
|
|
grpcRequest.ToDate = Timestamp.FromDateTime(DateTime.SpecifyKind(request.ToDate.Value, DateTimeKind.Utc));
|
|
|
|
if (request.MinAmount.HasValue)
|
|
grpcRequest.MinAmount = request.MinAmount.Value;
|
|
|
|
if (request.MaxAmount.HasValue)
|
|
grpcRequest.MaxAmount = request.MaxAmount.Value;
|
|
|
|
var response = await _context.DiscountOrders.GetAllDiscountOrdersAsync(grpcRequest, cancellationToken: cancellationToken);
|
|
|
|
return new GetAllDiscountOrdersResponseDto
|
|
{
|
|
MetaData = new MetaData
|
|
{
|
|
CurrentPage = response.MetaData.CurrentPage,
|
|
TotalPage = response.MetaData.TotalPage,
|
|
PageSize = response.MetaData.PageSize,
|
|
TotalCount = response.MetaData.TotalCount,
|
|
HasPrevious = response.MetaData.HasPrevious,
|
|
HasNext = response.MetaData.HasNext
|
|
},
|
|
Orders = response.Models.Select(o => new AdminOrderDto
|
|
{
|
|
Id = o.Id,
|
|
UserId = o.UserId,
|
|
UserFullName = o.UserFullName,
|
|
UserMobile = o.UserMobile,
|
|
TotalAmount = o.TotalAmount,
|
|
DiscountBalanceUsed = o.DiscountBalanceUsed,
|
|
GatewayAmountPaid = o.GatewayAmountPaid,
|
|
VatAmount = o.VatAmount,
|
|
PaymentStatus = (int)o.PaymentStatus,
|
|
PaymentDate = o.PaymentDate?.ToDateTime(),
|
|
DeliveryStatus = (int)o.DeliveryStatus,
|
|
DeliveryDate = o.DeliveryDate?.ToDateTime(),
|
|
ShippingAddress = o.ShippingAddress,
|
|
ReceiverName = o.ReceiverName,
|
|
ReceiverMobile = o.ReceiverMobile,
|
|
TrackingCode = o.TrackingCode,
|
|
AdminNote = o.AdminNote,
|
|
Created = o.Created.ToDateTime(),
|
|
LastModified = o.LastModified?.ToDateTime(),
|
|
ItemsCount = o.ItemsCount
|
|
}).ToList()
|
|
};
|
|
}
|
|
}
|