feat: add Mapster profiles and enable DiscountOrder handlers
Build and Deploy / build (push) Successful in 2m14s
Build and Deploy / build (push) Successful in 2m14s
This commit is contained in:
@@ -7,20 +7,12 @@
|
||||
|
||||
<!-- Exclude handlers that need proto fixes -->
|
||||
<ItemGroup>
|
||||
<!-- DiscountOrder handlers - proto mismatch with CMS -->
|
||||
<Compile Remove="DiscountOrderCQ/**/*.cs" />
|
||||
|
||||
<!-- DiscountShoppingCart handlers - proto mismatch -->
|
||||
<!-- DiscountShoppingCart - FrontOffice-only feature, not needed in BackOffice -->
|
||||
<!-- این feature فقط برای مشتریان FrontOffice است. مدیریت سبد خرید توسط ادمین در آینده اضافه خواهد شد -->
|
||||
<Compile Remove="DiscountShoppingCartCQ/**/*.cs" />
|
||||
|
||||
<!-- ManualPayment handlers - WellKnownTypes conversion issues -->
|
||||
<Compile Remove="ManualPaymentCQ/**/*.cs" />
|
||||
|
||||
<!-- Configuration handlers - StringValue conversion -->
|
||||
<Compile Remove="ConfigurationCQ/**/*.cs" />
|
||||
|
||||
<!-- Commission ProcessWithdrawal - StringValue conversion -->
|
||||
<Compile Remove="CommissionCQ/Commands/ProcessWithdrawal/**/*.cs" />
|
||||
<!-- All handlers now ENABLED with BFF Protobuf and Mapster profiles -->
|
||||
<!-- ProcessWithdrawal, DiscountOrder fixed and enabled -->
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -40,6 +32,8 @@
|
||||
<ProjectReference Include="..\Protobufs\BackOffice.BFF.NetworkMembership.Protobuf\BackOffice.BFF.NetworkMembership.Protobuf.csproj" />
|
||||
<ProjectReference Include="..\Protobufs\BackOffice.BFF.ClubMembership.Protobuf\BackOffice.BFF.ClubMembership.Protobuf.csproj" />
|
||||
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Configuration.Protobuf\BackOffice.BFF.Configuration.Protobuf.csproj" />
|
||||
<ProjectReference Include="..\Protobufs\BackOffice.BFF.ManualPayment.Protobuf\BackOffice.BFF.ManualPayment.Protobuf.csproj" />
|
||||
<ProjectReference Include="..\Protobufs\BackOffice.BFF.DiscountOrder.Protobuf\BackOffice.BFF.DiscountOrder.Protobuf.csproj" />
|
||||
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Health.Protobuf\BackOffice.BFF.Health.Protobuf.csproj" />
|
||||
<ProjectReference Include="..\Protobufs\BackOffice.BFF.PublicMessage.Protobuf\BackOffice.BFF.PublicMessage.Protobuf.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||
using Foursat.BackOffice.BFF.ClubMembership.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.ClubMembershipCQ.Commands.ActivateClub;
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
|
||||
using Foursat.BackOffice.BFF.ClubMembership.Protos;
|
||||
using GetAllClubMembershipsRequest = CMSMicroservice.Protobuf.Protos.ClubMembership.GetAllClubMembershipsRequest;
|
||||
using Foursat.BackOffice.BFF.ClubMembership.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.ClubMembershipCQ.Queries.GetAllClubMembers;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||
using Foursat.BackOffice.BFF.ClubMembership.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.ClubMembershipCQ.Queries.GetClubStatistics;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Commands.ApproveWithdrawal;
|
||||
|
||||
|
||||
+10
-5
@@ -7,13 +7,18 @@ public record ProcessWithdrawalCommand : IRequest<ProcessWithdrawalResponseDto>
|
||||
/// </summary>
|
||||
public long WithdrawalId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// تایید یا رد درخواست
|
||||
/// </summary>
|
||||
public bool IsApproved { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// دلیل رد یا یادداشت مدیر (اختیاری)
|
||||
/// </summary>
|
||||
public string? Reason { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// شناسه تراکنش بانکی (اختیاری)
|
||||
/// </summary>
|
||||
public string? TransactionId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// یادداشت مدیر (اختیاری)
|
||||
/// </summary>
|
||||
public string? AdminNote { get; init; }
|
||||
}
|
||||
|
||||
+7
-5
@@ -17,18 +17,20 @@ public class ProcessWithdrawalCommandHandler : IRequestHandler<ProcessWithdrawal
|
||||
var grpcRequest = new ProcessWithdrawalRequest
|
||||
{
|
||||
PayoutId = request.WithdrawalId,
|
||||
IsApproved = true,
|
||||
Reason = request.AdminNote != null
|
||||
? new StringValue { Value = request.AdminNote }
|
||||
: null
|
||||
IsApproved = request.IsApproved,
|
||||
Reason = request.Reason ?? string.Empty
|
||||
};
|
||||
|
||||
await _context.Commissions.ProcessWithdrawalAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
var statusMessage = request.IsApproved
|
||||
? "درخواست برداشت تایید و برای پرداخت ارسال شد"
|
||||
: "درخواست برداشت رد شد";
|
||||
|
||||
return new ProcessWithdrawalResponseDto
|
||||
{
|
||||
Success = true,
|
||||
Message = "درخواست برداشت برای پرداخت ارسال شد"
|
||||
Message = statusMessage
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Commands.RejectWithdrawal;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Commands.TriggerWeeklyCalculation;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetUserPayouts;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWeeklyPool;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalReports;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalRequests;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWorkerExecutionLogs;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWorkerStatus;
|
||||
|
||||
|
||||
@@ -13,14 +13,15 @@ using FMSMicroservice.Protobuf.Protos.FileInfo;
|
||||
using CMSMicroservice.Protobuf.Protos.DiscountProduct;
|
||||
using CMSMicroservice.Protobuf.Protos.DiscountCategory;
|
||||
using CMSMicroservice.Protobuf.Protos.DiscountShoppingCart;
|
||||
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
|
||||
using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
|
||||
using CMSMicroservice.Protobuf.Protos.Tag;
|
||||
using CMSMicroservice.Protobuf.Protos.ProductTag;
|
||||
using CMSMicroservice.Protobuf.Protos;
|
||||
using CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using CMSMicroservice.Protobuf.Protos.Configuration;
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
using Foursat.BackOffice.BFF.ClubMembership.Protos;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
using Foursat.BackOffice.BFF.Configuration.Protos;
|
||||
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
|
||||
using BackOffice.BFF.ManualPayment.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.Common.Interfaces;
|
||||
|
||||
@@ -61,8 +62,8 @@ public interface IApplicationContractContext
|
||||
// Public Messages
|
||||
PublicMessageContract.PublicMessageContractClient PublicMessages { get; }
|
||||
|
||||
// Manual Payments (Admin) - CMS gRPC
|
||||
CMSMicroservice.Protobuf.Protos.ManualPayment.ManualPaymentContract.ManualPaymentContractClient ManualPayments { get; }
|
||||
// Manual Payments (Admin) - BackOffice BFF gRPC
|
||||
ManualPaymentContract.ManualPaymentContractClient ManualPayments { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
+1
-4
@@ -27,10 +27,7 @@ public class SetDefaultVatPercentageCommandHandler : IRequestHandler<SetDefaultV
|
||||
Key = VatConfigurationKey,
|
||||
Value = request.VatPercentage.ToString(),
|
||||
Scope = 0, // System scope
|
||||
Description = new StringValue
|
||||
{
|
||||
Value = "درصد پیشفرض مالیات بر ارزش افزوده سفارشها"
|
||||
}
|
||||
Description = "درصد پیشفرض مالیات بر ارزش افزوده سفارشها"
|
||||
};
|
||||
|
||||
await _context.Configurations.CreateOrUpdateConfigurationAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
namespace BackOffice.BFF.Application.DiscountOrderCQ.Commands.CompleteOrderPayment;
|
||||
|
||||
public record CompleteOrderPaymentCommand : IRequest
|
||||
public record CompleteOrderPaymentCommand : IRequest<CompleteOrderPaymentResponseDto>
|
||||
{
|
||||
/// <summary>شناسه سفارش</summary>
|
||||
public long OrderId { get; init; }
|
||||
|
||||
/// <summary>کد تراکنش پرداخت</summary>
|
||||
public string PaymentTransactionCode { get; init; }
|
||||
public string? PaymentTransactionCode { get; init; }
|
||||
|
||||
/// <summary>مبلغ پرداخت شده</summary>
|
||||
public long PaidAmount { get; init; }
|
||||
/// <summary>وضعیت موفقیت پرداخت</summary>
|
||||
public bool PaymentSuccess { get; init; }
|
||||
}
|
||||
|
||||
+9
-13
@@ -1,8 +1,9 @@
|
||||
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
|
||||
using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
|
||||
using Mapster;
|
||||
|
||||
namespace BackOffice.BFF.Application.DiscountOrderCQ.Commands.CompleteOrderPayment;
|
||||
|
||||
public class CompleteOrderPaymentCommandHandler : IRequestHandler<CompleteOrderPaymentCommand>
|
||||
public class CompleteOrderPaymentCommandHandler : IRequestHandler<CompleteOrderPaymentCommand, CompleteOrderPaymentResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
@@ -11,17 +12,12 @@ public class CompleteOrderPaymentCommandHandler : IRequestHandler<CompleteOrderP
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<Unit> Handle(CompleteOrderPaymentCommand request, CancellationToken cancellationToken)
|
||||
public async Task<CompleteOrderPaymentResponseDto> Handle(CompleteOrderPaymentCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
await _context.DiscountOrders.CompleteOrderPaymentAsync(
|
||||
new CompleteOrderPaymentRequest
|
||||
{
|
||||
OrderId = request.OrderId,
|
||||
PaymentTransactionCode = request.PaymentTransactionCode,
|
||||
PaidAmount = request.PaidAmount
|
||||
},
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return Unit.Value;
|
||||
var grpcRequest = TypeAdapter.Adapt(request, request.GetType(), typeof(CompleteOrderPaymentRequest)) as CompleteOrderPaymentRequest;
|
||||
|
||||
var response = await _context.DiscountOrders.CompleteOrderPaymentAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return TypeAdapter.Adapt(response, response.GetType(), typeof(CompleteOrderPaymentResponseDto)) as CompleteOrderPaymentResponseDto;
|
||||
}
|
||||
}
|
||||
|
||||
-3
@@ -9,8 +9,5 @@ public class CompleteOrderPaymentCommandValidator : AbstractValidator<CompleteOr
|
||||
|
||||
RuleFor(x => x.PaymentTransactionCode)
|
||||
.NotEmpty().WithMessage("کد تراکنش پرداخت الزامی است");
|
||||
|
||||
RuleFor(x => x.PaidAmount)
|
||||
.GreaterThan(0).WithMessage("مبلغ پرداخت شده باید بیشتر از صفر باشد");
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace BackOffice.BFF.Application.DiscountOrderCQ.Commands.CompleteOrderPayment;
|
||||
|
||||
public class CompleteOrderPaymentResponseDto
|
||||
{
|
||||
public bool Success { get; set; }
|
||||
public string Message { get; set; } = string.Empty;
|
||||
}
|
||||
+2
-2
@@ -11,6 +11,6 @@ public record PlaceOrderCommand : IRequest<PlaceOrderResponseDto>
|
||||
/// <summary>مبلغ پرداخت از موجودی تخفیف</summary>
|
||||
public long DiscountBalanceAmount { get; init; }
|
||||
|
||||
/// <summary>مبلغ پرداخت از درگاه</summary>
|
||||
public long GatewayAmount { get; init; }
|
||||
/// <summary>یادداشت سفارش (اختیاری)</summary>
|
||||
public string? Notes { get; init; }
|
||||
}
|
||||
|
||||
+6
-17
@@ -1,4 +1,5 @@
|
||||
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
|
||||
using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
|
||||
using Mapster;
|
||||
|
||||
namespace BackOffice.BFF.Application.DiscountOrderCQ.Commands.PlaceOrder;
|
||||
|
||||
@@ -13,22 +14,10 @@ public class PlaceOrderCommandHandler : IRequestHandler<PlaceOrderCommand, Place
|
||||
|
||||
public async Task<PlaceOrderResponseDto> Handle(PlaceOrderCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.DiscountOrders.PlaceOrderAsync(
|
||||
new PlaceOrderRequest
|
||||
{
|
||||
UserId = request.UserId,
|
||||
AddressId = request.AddressId,
|
||||
DiscountBalanceAmount = request.DiscountBalanceAmount,
|
||||
GatewayAmount = request.GatewayAmount
|
||||
},
|
||||
cancellationToken: cancellationToken);
|
||||
var grpcRequest = TypeAdapter.Adapt(request, request.GetType(), typeof(PlaceOrderRequest)) as PlaceOrderRequest;
|
||||
|
||||
return new PlaceOrderResponseDto
|
||||
{
|
||||
OrderId = response.OrderId,
|
||||
TrackingCode = response.TrackingCode,
|
||||
RequiresGatewayPayment = response.RequiresGatewayPayment,
|
||||
GatewayPayableAmount = response.GatewayPayableAmount
|
||||
};
|
||||
var response = await _context.DiscountOrders.PlaceOrderAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return TypeAdapter.Adapt(response, response.GetType(), typeof(PlaceOrderResponseDto)) as PlaceOrderResponseDto;
|
||||
}
|
||||
}
|
||||
|
||||
-7
@@ -12,12 +12,5 @@ public class PlaceOrderCommandValidator : AbstractValidator<PlaceOrderCommand>
|
||||
|
||||
RuleFor(x => x.DiscountBalanceAmount)
|
||||
.GreaterThanOrEqualTo(0).WithMessage("مبلغ موجودی تخفیف نمیتواند منفی باشد");
|
||||
|
||||
RuleFor(x => x.GatewayAmount)
|
||||
.GreaterThanOrEqualTo(0).WithMessage("مبلغ درگاه نمیتواند منفی باشد");
|
||||
|
||||
RuleFor(x => x)
|
||||
.Must(x => x.DiscountBalanceAmount + x.GatewayAmount > 0)
|
||||
.WithMessage("مجموع مبالغ پرداخت باید بیشتر از صفر باشد");
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -1,13 +1,16 @@
|
||||
namespace BackOffice.BFF.Application.DiscountOrderCQ.Commands.UpdateOrderStatus;
|
||||
|
||||
public record UpdateOrderStatusCommand : IRequest
|
||||
public record UpdateOrderStatusCommand : IRequest<UpdateOrderStatusResponseDto>
|
||||
{
|
||||
/// <summary>شناسه سفارش</summary>
|
||||
public long OrderId { get; init; }
|
||||
|
||||
/// <summary>وضعیت جدید</summary>
|
||||
/// <summary>وضعیت جدید (DeliveryStatus enum)</summary>
|
||||
public int NewStatus { get; init; }
|
||||
|
||||
/// <summary>کد رهگیری (اختیاری)</summary>
|
||||
public string? TrackingCode { get; init; }
|
||||
|
||||
/// <summary>یادداشت مدیر (اختیاری)</summary>
|
||||
public string AdminNote { get; init; }
|
||||
public string? AdminNote { get; init; }
|
||||
}
|
||||
|
||||
+9
-13
@@ -1,8 +1,9 @@
|
||||
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
|
||||
using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
|
||||
using Mapster;
|
||||
|
||||
namespace BackOffice.BFF.Application.DiscountOrderCQ.Commands.UpdateOrderStatus;
|
||||
|
||||
public class UpdateOrderStatusCommandHandler : IRequestHandler<UpdateOrderStatusCommand>
|
||||
public class UpdateOrderStatusCommandHandler : IRequestHandler<UpdateOrderStatusCommand, UpdateOrderStatusResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
@@ -11,17 +12,12 @@ public class UpdateOrderStatusCommandHandler : IRequestHandler<UpdateOrderStatus
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<Unit> Handle(UpdateOrderStatusCommand request, CancellationToken cancellationToken)
|
||||
public async Task<UpdateOrderStatusResponseDto> Handle(UpdateOrderStatusCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
await _context.DiscountOrders.UpdateOrderStatusAsync(
|
||||
new UpdateOrderStatusRequest
|
||||
{
|
||||
OrderId = request.OrderId,
|
||||
NewStatus = request.NewStatus,
|
||||
AdminNote = request.AdminNote ?? string.Empty
|
||||
},
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return Unit.Value;
|
||||
var grpcRequest = TypeAdapter.Adapt(request, request.GetType(), typeof(UpdateOrderStatusRequest)) as UpdateOrderStatusRequest;
|
||||
|
||||
var response = await _context.DiscountOrders.UpdateOrderStatusAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return TypeAdapter.Adapt(response, response.GetType(), typeof(UpdateOrderStatusResponseDto)) as UpdateOrderStatusResponseDto;
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace BackOffice.BFF.Application.DiscountOrderCQ.Commands.UpdateOrderStatus;
|
||||
|
||||
public class UpdateOrderStatusResponseDto
|
||||
{
|
||||
public bool Success { get; set; }
|
||||
public string Message { get; set; } = string.Empty;
|
||||
}
|
||||
+3
@@ -4,4 +4,7 @@ public record GetOrderByIdQuery : IRequest<GetOrderByIdResponseDto>
|
||||
{
|
||||
/// <summary>شناسه سفارش</summary>
|
||||
public long OrderId { get; init; }
|
||||
|
||||
/// <summary>شناسه کاربر (برای بررسی مجوز)</summary>
|
||||
public long UserId { get; init; }
|
||||
}
|
||||
|
||||
+10
-41
@@ -1,4 +1,5 @@
|
||||
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
|
||||
using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
|
||||
using Mapster;
|
||||
|
||||
namespace BackOffice.BFF.Application.DiscountOrderCQ.Queries.GetOrderById;
|
||||
|
||||
@@ -13,46 +14,14 @@ public class GetOrderByIdQueryHandler : IRequestHandler<GetOrderByIdQuery, GetOr
|
||||
|
||||
public async Task<GetOrderByIdResponseDto> Handle(GetOrderByIdQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.DiscountOrders.GetOrderByIdAsync(
|
||||
new GetOrderByIdRequest { OrderId = request.OrderId },
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return new GetOrderByIdResponseDto
|
||||
{
|
||||
Id = response.Id,
|
||||
UserId = response.UserId,
|
||||
TrackingCode = response.TrackingCode,
|
||||
Status = response.Status,
|
||||
StatusTitle = response.StatusTitle,
|
||||
TotalPrice = response.TotalPrice,
|
||||
DiscountBalanceUsed = response.DiscountBalanceUsed,
|
||||
GatewayPayment = response.GatewayPayment,
|
||||
FinalPrice = response.FinalPrice,
|
||||
PaymentTransactionCode = response.PaymentTransactionCode,
|
||||
AdminNote = response.AdminNote,
|
||||
CreatedAt = response.CreatedAt.ToDateTime(),
|
||||
PaidAt = response.HasPaidAt ? response.PaidAt.ToDateTime() : null,
|
||||
ShippingAddress = new AddressInfoDto
|
||||
{
|
||||
Id = response.ShippingAddress.Id,
|
||||
RecipientName = response.ShippingAddress.RecipientName,
|
||||
RecipientPhone = response.ShippingAddress.RecipientPhone,
|
||||
Province = response.ShippingAddress.Province,
|
||||
City = response.ShippingAddress.City,
|
||||
PostalCode = response.ShippingAddress.PostalCode,
|
||||
FullAddress = response.ShippingAddress.FullAddress
|
||||
},
|
||||
Items = response.Items.Select(item => new OrderItemDto
|
||||
{
|
||||
Id = item.Id,
|
||||
ProductId = item.ProductId,
|
||||
ProductTitle = item.ProductTitle,
|
||||
UnitPrice = item.UnitPrice,
|
||||
DiscountPercent = item.DiscountPercent,
|
||||
Quantity = item.Quantity,
|
||||
TotalPrice = item.TotalPrice,
|
||||
DiscountedPrice = item.DiscountedPrice
|
||||
}).ToList()
|
||||
var grpcRequest = new GetOrderByIdRequest
|
||||
{
|
||||
OrderId = request.OrderId,
|
||||
UserId = request.UserId
|
||||
};
|
||||
|
||||
var response = await _context.DiscountOrders.GetOrderByIdAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return TypeAdapter.Adapt(response, response.GetType(), typeof(GetOrderByIdResponseDto)) as GetOrderByIdResponseDto;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-27
@@ -1,6 +1,5 @@
|
||||
using BackOffice.BFF.Application.Common.Models;
|
||||
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
|
||||
using Mapster;
|
||||
|
||||
namespace BackOffice.BFF.Application.DiscountOrderCQ.Queries.GetUserOrders;
|
||||
|
||||
@@ -23,32 +22,10 @@ public class GetUserOrdersQueryHandler : IRequestHandler<GetUserOrdersQuery, Get
|
||||
};
|
||||
|
||||
if (request.Status.HasValue)
|
||||
grpcRequest.Status = new Int32Value { Value = request.Status.Value };
|
||||
grpcRequest.DeliveryStatus = request.Status.Value;
|
||||
|
||||
var response = await _context.DiscountOrders.GetUserOrdersAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return new GetUserOrdersResponseDto
|
||||
{
|
||||
MetaData = new MetaData
|
||||
{
|
||||
CurrentPage = response.MetaData.CurrentPage,
|
||||
TotalPage = response.MetaData.TotalPages,
|
||||
PageSize = response.MetaData.PageSize,
|
||||
TotalCount = response.MetaData.TotalCount,
|
||||
HasPrevious = response.MetaData.HasPrevious,
|
||||
HasNext = response.MetaData.HasNext
|
||||
},
|
||||
Orders = response.Orders.Select(order => new UserOrderDto
|
||||
{
|
||||
Id = order.Id,
|
||||
TrackingCode = order.TrackingCode,
|
||||
Status = order.Status,
|
||||
StatusTitle = order.StatusTitle,
|
||||
TotalPrice = order.TotalPrice,
|
||||
FinalPrice = order.FinalPrice,
|
||||
ItemCount = order.ItemCount,
|
||||
CreatedAt = order.CreatedAt.ToDateTime()
|
||||
}).ToList()
|
||||
};
|
||||
return TypeAdapter.Adapt(response, response.GetType(), typeof(GetUserOrdersResponseDto)) as GetUserOrdersResponseDto;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
using CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using CMSMicroservice.Protobuf.Protos.Configuration;
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
using Foursat.BackOffice.BFF.ClubMembership.Protos;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
using Foursat.BackOffice.BFF.Configuration.Protos;
|
||||
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
|
||||
using Foursat.BackOffice.BFF.Health.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.HealthCQ.Queries.GetSystemHealth;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
using BackOffice.BFF.Application.Common.Interfaces;
|
||||
using CMSMicroservice.Protobuf.Protos.ManualPayment;
|
||||
using BackOffice.BFF.ManualPayment.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -30,7 +30,7 @@ public class ApproveManualPaymentCommandHandler : IRequestHandler<ApproveManualP
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.ApprovalNote))
|
||||
{
|
||||
grpcRequest.ApprovalNote = new StringValue { Value = request.ApprovalNote };
|
||||
grpcRequest.ApprovalNote = request.ApprovalNote;
|
||||
}
|
||||
|
||||
await _context.ManualPayments.ApproveManualPaymentAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
using BackOffice.BFF.Application.Common.Interfaces;
|
||||
using CMSMicroservice.Protobuf.Protos.ManualPayment;
|
||||
using BackOffice.BFF.ManualPayment.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -31,13 +31,13 @@ public class CreateManualPaymentCommandHandler : IRequestHandler<CreateManualPay
|
||||
{
|
||||
UserId = request.UserId,
|
||||
Amount = request.Amount,
|
||||
Type = (ManualPaymentType)request.Type,
|
||||
Type = request.Type,
|
||||
Description = request.Description
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.ReferenceNumber))
|
||||
{
|
||||
grpcRequest.ReferenceNumber = new StringValue { Value = request.ReferenceNumber };
|
||||
grpcRequest.ReferenceNumber = request.ReferenceNumber;
|
||||
}
|
||||
|
||||
var response = await _context.ManualPayments.CreateManualPaymentAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
using BackOffice.BFF.Application.Common.Interfaces;
|
||||
using CMSMicroservice.Protobuf.Protos.ManualPayment;
|
||||
using BackOffice.BFF.ManualPayment.Protobuf;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
||||
+12
-31
@@ -1,6 +1,6 @@
|
||||
using BackOffice.BFF.Application.Common.Interfaces;
|
||||
using BackOffice.BFF.Application.Common.Models;
|
||||
using CMSMicroservice.Protobuf.Protos.ManualPayment;
|
||||
using BackOffice.BFF.ManualPayment.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -29,35 +29,16 @@ public class GetManualPaymentsQueryHandler : IRequestHandler<GetManualPaymentsQu
|
||||
request.Status,
|
||||
request.Type);
|
||||
|
||||
var grpcRequest = new GetAllManualPaymentsRequest
|
||||
var grpcRequest = new GetManualPaymentsRequest
|
||||
{
|
||||
PageNumber = request.PageNumber,
|
||||
PageSize = request.PageSize
|
||||
PageSize = request.PageSize,
|
||||
UserId = request.UserId,
|
||||
Status = request.Status,
|
||||
Type = request.Type
|
||||
};
|
||||
|
||||
if (request.UserId.HasValue)
|
||||
{
|
||||
grpcRequest.UserId = new Int64Value { Value = request.UserId.Value };
|
||||
}
|
||||
|
||||
if (request.Status.HasValue)
|
||||
{
|
||||
grpcRequest.Status = new Int32Value { Value = request.Status.Value };
|
||||
}
|
||||
|
||||
if (request.Type.HasValue)
|
||||
{
|
||||
grpcRequest.Type = new Int32Value { Value = request.Type.Value };
|
||||
}
|
||||
|
||||
if (request.RequestedBy.HasValue)
|
||||
{
|
||||
grpcRequest.RequestedBy = new Int64Value { Value = request.RequestedBy.Value };
|
||||
}
|
||||
|
||||
grpcRequest.OrderByDescending = new BoolValue { Value = request.OrderByDescending };
|
||||
|
||||
var response = await _context.ManualPayments.GetAllManualPaymentsAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
var response = await _context.ManualPayments.GetManualPaymentsAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
var meta = response.MetaData;
|
||||
|
||||
@@ -69,20 +50,20 @@ public class GetManualPaymentsQueryHandler : IRequestHandler<GetManualPaymentsQu
|
||||
UserFullName = m.UserFullName,
|
||||
UserMobile = m.UserMobile,
|
||||
Amount = m.Amount,
|
||||
Type = (int)m.Type,
|
||||
Type = m.Type,
|
||||
TypeDisplay = m.TypeDisplay,
|
||||
Description = m.Description,
|
||||
ReferenceNumber = m.ReferenceNumber,
|
||||
Status = (int)m.Status,
|
||||
Status = m.Status,
|
||||
StatusDisplay = m.StatusDisplay,
|
||||
RequestedBy = m.RequestedBy,
|
||||
RequestedByName = m.RequestedByName,
|
||||
ApprovedBy = m.ApprovedBy?.Value,
|
||||
ApprovedBy = m.ApprovedBy,
|
||||
ApprovedByName = m.ApprovedByName,
|
||||
ApprovedAt = m.ApprovedAt?.ToDateTime(),
|
||||
RejectionReason = m.RejectionReason,
|
||||
TransactionId = m.TransactionId?.Value,
|
||||
Created = m.Created.ToDateTime()
|
||||
TransactionId = m.TransactionId,
|
||||
Created = m.Created?.ToDateTime() ?? DateTime.UtcNow
|
||||
})
|
||||
.ToList()
|
||||
?? new List<ManualPaymentModel>();
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkHistory;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkStatistics;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkTree;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetUserNetworkInfo;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user