Add payment method and delivery status filters to user order queries
This commit is contained in:
@@ -1,10 +1,65 @@
|
||||
using BackOffice.BFF.Application.UserOrderCQ.Queries.GetAllUserOrderByFilter;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using CmsUserOrderFilter = CMSMicroservice.Protobuf.Protos.UserOrder.GetAllUserOrderByFilterFilter;
|
||||
using CmsUserOrderRequest = CMSMicroservice.Protobuf.Protos.UserOrder.GetAllUserOrderByFilterRequest;
|
||||
|
||||
namespace BackOffice.BFF.Application.Common.Mappings;
|
||||
|
||||
public class UserOrderProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
//config.NewConfig<Source,Destination>()
|
||||
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
|
||||
config.NewConfig<GetAllUserOrderByFilterQuery, CmsUserOrderRequest>()
|
||||
.Map(dest => dest.PaginationState, src => src.PaginationState == null ? null : new CMSMicroservice.Protobuf.Protos.PaginationState
|
||||
{
|
||||
PageNumber = src.PaginationState.PageNumber,
|
||||
PageSize = src.PaginationState.PageSize
|
||||
})
|
||||
.Map(dest => dest.SortBy, src => src.SortBy)
|
||||
.Map(dest => dest.Filter, src => src.Filter == null ? null : BuildFilter(src.Filter));
|
||||
}
|
||||
|
||||
private static CmsUserOrderFilter BuildFilter(GetAllUserOrderByFilterFilter src)
|
||||
{
|
||||
var filter = new CmsUserOrderFilter();
|
||||
|
||||
if (src.Id.HasValue)
|
||||
filter.Id = src.Id.Value;
|
||||
|
||||
if (src.Price.HasValue)
|
||||
filter.Amount = src.Price.Value;
|
||||
|
||||
if (src.PackageId.HasValue)
|
||||
filter.PackageId = src.PackageId.Value;
|
||||
|
||||
if (src.TransactionId.HasValue)
|
||||
filter.TransactionId = src.TransactionId.Value;
|
||||
|
||||
if (src.PaymentDate.HasValue)
|
||||
{
|
||||
filter.PaymentDate = Timestamp.FromDateTime(DateTime.SpecifyKind(src.PaymentDate.Value, DateTimeKind.Utc));
|
||||
}
|
||||
|
||||
if (src.UserId.HasValue)
|
||||
filter.UserId = src.UserId.Value;
|
||||
|
||||
if (src.PaymentStatus.HasValue)
|
||||
{
|
||||
filter.PaymentStatus = src.PaymentStatus.Value
|
||||
? CMSMicroservice.Protobuf.Protos.PaymentStatus.Success
|
||||
: CMSMicroservice.Protobuf.Protos.PaymentStatus.Reject;
|
||||
}
|
||||
|
||||
if (src.DeliveryStatus.HasValue)
|
||||
{
|
||||
filter.DeliveryStatus = (CMSMicroservice.Protobuf.Protos.DeliveryStatus)src.DeliveryStatus.Value;
|
||||
}
|
||||
|
||||
if (src.PaymentMethod.HasValue)
|
||||
{
|
||||
filter.PaymentMethod = (CMSMicroservice.Protobuf.Protos.PaymentMethod)src.PaymentMethod.Value;
|
||||
}
|
||||
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,4 +24,8 @@ public record GetAllUserOrderByFilterQuery : IRequest<GetAllUserOrderByFilterRes
|
||||
public DateTime? PaymentDate { get; set; }
|
||||
//شناسه کاربر
|
||||
public long? UserId { get; set; }
|
||||
// وضعیت ارسال (int از DeliveryStatus)
|
||||
public int? DeliveryStatus { get; set; }
|
||||
// روش پرداخت (0=IPG,1=Wallet)
|
||||
public int? PaymentMethod { get; set; }
|
||||
}
|
||||
|
||||
@@ -38,4 +38,6 @@ public class GetAllUserOrderByFilterResponseModel
|
||||
public string? UserFullName { get; set; }
|
||||
// کدملی کاربر
|
||||
public string? UserNationalCode { get; set; }
|
||||
// روش پرداخت (0=IPG,1=Wallet)
|
||||
public int PaymentMethod { get; set; }
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ public class GetUserOrderResponseDto
|
||||
public bool PaymentStatus { get; set; }
|
||||
//تاریخ پرداخت
|
||||
public DateTime? PaymentDate { get; set; }
|
||||
// روش پرداخت (0=IPG,1=Wallet)
|
||||
public int PaymentMethod { get; set; }
|
||||
//شناسه کاربر
|
||||
public long UserId { get; set; }
|
||||
//شناسه آدرس کاربر
|
||||
|
||||
@@ -104,6 +104,8 @@ message GetUserOrderResponse
|
||||
google.protobuf.StringValue user_full_name = 14;
|
||||
// کدملی کاربر
|
||||
google.protobuf.StringValue user_national_code = 15;
|
||||
// روش پرداخت (0=IPG,1=Wallet)
|
||||
int32 payment_method = 16;
|
||||
}
|
||||
message GetAllUserOrderByFilterRequest
|
||||
{
|
||||
@@ -121,6 +123,10 @@ message GetAllUserOrderByFilterFilter
|
||||
google.protobuf.Timestamp payment_date = 6;
|
||||
google.protobuf.Int64Value user_id = 7;
|
||||
google.protobuf.Int64Value user_address_id = 8;
|
||||
// فیلتر وضعیت ارسال (مقدار عددی DeliveryStatus)
|
||||
google.protobuf.Int32Value delivery_status = 9;
|
||||
// فیلتر روش پرداخت (0=IPG,1=Wallet)
|
||||
google.protobuf.Int32Value payment_method = 10;
|
||||
}
|
||||
message GetAllUserOrderByFilterResponse
|
||||
{
|
||||
@@ -150,6 +156,8 @@ message GetAllUserOrderByFilterResponseModel
|
||||
google.protobuf.StringValue user_full_name = 13;
|
||||
// کدملی کاربر
|
||||
google.protobuf.StringValue user_national_code = 14;
|
||||
// روش پرداخت (0=IPG,1=Wallet)
|
||||
int32 payment_method = 15;
|
||||
}
|
||||
|
||||
// جزئیات فاکتور سفارش
|
||||
|
||||
Reference in New Issue
Block a user