feat: add PaymentStatus to discount order proto + expire pending orders background service
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 7m53s

- Added payment_status field to GetOrderByIdResponse and OrderSummaryDto in proto
- Proto version bumped to 0.0.179
- Added PaymentStatus mapping in DiscountOrderService gRPC responses
- Created ExpirePendingOrdersService: expires pending orders after 30 min, releases inventory
- Registered background service in ConfigureServices
This commit is contained in:
masoodafar-web
2026-02-16 22:37:58 +03:30
parent 18a65de8c7
commit c435319025
5 changed files with 133 additions and 1 deletions
@@ -92,6 +92,7 @@ public class DiscountOrderService : DiscountOrderContract.DiscountOrderContractB
DiscountBalanceUsed = result.DiscountBalanceUsed,
GatewayAmount = result.GatewayAmountPaid,
PaymentCompleted = result.PaymentStatus == DomainEnums.PaymentStatus.Success,
PaymentStatus = MapPaymentStatus(result.PaymentStatus),
DeliveryStatus = (DeliveryStatus)(int)result.DeliveryStatus,
Created = Timestamp.FromDateTime(DateTime.SpecifyKind(result.Created, DateTimeKind.Utc)),
};
@@ -151,6 +152,7 @@ public class DiscountOrderService : DiscountOrderContract.DiscountOrderContractB
DiscountBalanceUsed = o.DiscountBalanceUsed,
GatewayAmount = o.GatewayAmountPaid,
PaymentCompleted = o.PaymentStatus == DomainEnums.PaymentStatus.Success,
PaymentStatus = MapPaymentStatus(o.PaymentStatus),
DeliveryStatus = (DeliveryStatus)(int)o.DeliveryStatus,
ItemsCount = o.ItemsCount,
Created = Timestamp.FromDateTime(DateTime.SpecifyKind(o.Created, DateTimeKind.Utc)),
@@ -171,4 +173,12 @@ public class DiscountOrderService : DiscountOrderContract.DiscountOrderContractB
{
return await _dispatchRequestToCQRS.Handle<GetDiscountSalesReportRequest, GetDiscountSalesReportQuery, GetDiscountSalesReportResponse>(request, context);
}
private static CMSMicroservice.Protobuf.Protos.DiscountOrder.PaymentStatus MapPaymentStatus(DomainEnums.PaymentStatus status) => status switch
{
DomainEnums.PaymentStatus.Success => CMSMicroservice.Protobuf.Protos.DiscountOrder.PaymentStatus.PaymentCompleted,
DomainEnums.PaymentStatus.Reject => CMSMicroservice.Protobuf.Protos.DiscountOrder.PaymentStatus.PaymentFailed,
DomainEnums.PaymentStatus.Pending => CMSMicroservice.Protobuf.Protos.DiscountOrder.PaymentStatus.PaymentPending,
_ => CMSMicroservice.Protobuf.Protos.DiscountOrder.PaymentStatus.PaymentPending
};
}