diff --git a/src/FrontOffice.Main/FrontOffice.Main.csproj b/src/FrontOffice.Main/FrontOffice.Main.csproj index 3d4a5a6..7339178 100644 --- a/src/FrontOffice.Main/FrontOffice.Main.csproj +++ b/src/FrontOffice.Main/FrontOffice.Main.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/FrontOffice.Main/Pages/DiscountStore/OrderDetail.razor b/src/FrontOffice.Main/Pages/DiscountStore/OrderDetail.razor index a00c0de..0ce13da 100644 --- a/src/FrontOffice.Main/Pages/DiscountStore/OrderDetail.razor +++ b/src/FrontOffice.Main/Pages/DiscountStore/OrderDetail.razor @@ -33,9 +33,9 @@ else - - @(_order.PaymentCompleted ? "پرداخت شده" : "در انتظار پرداخت") + @DiscountOrderService.GetPaymentStatusText(_order.PaymentStatus) @@ -43,6 +43,17 @@ else + @if (_order.PaymentStatus == 2) + { + + پرداخت این سفارش ناموفق بود و سفارش منقضی شده است. موجودی رزرو شده آزاد شد. + + بازگشت به فروشگاه و ثبت سفارش جدید + + + } + diff --git a/src/FrontOffice.Main/Pages/DiscountStore/Orders.razor b/src/FrontOffice.Main/Pages/DiscountStore/Orders.razor index a91cb51..7b0b99d 100644 --- a/src/FrontOffice.Main/Pages/DiscountStore/Orders.razor +++ b/src/FrontOffice.Main/Pages/DiscountStore/Orders.razor @@ -52,9 +52,9 @@ @FormatPrice(context.GatewayAmount) - @(context.PaymentCompleted ? "پرداخت شده" : "در انتظار پرداخت") + @DiscountOrderService.GetPaymentStatusText(context.PaymentStatus) @@ -87,9 +87,9 @@ سفارش #@order.OrderNumber - @(order.PaymentCompleted ? "پرداخت شده" : "در انتظار") + @DiscountOrderService.GetPaymentStatusText(order.PaymentStatus) diff --git a/src/FrontOffice.Main/Utilities/DiscountOrderService.cs b/src/FrontOffice.Main/Utilities/DiscountOrderService.cs index beebc6b..58aa5af 100644 --- a/src/FrontOffice.Main/Utilities/DiscountOrderService.cs +++ b/src/FrontOffice.Main/Utilities/DiscountOrderService.cs @@ -12,6 +12,7 @@ public record DiscountOrderSummary( long DiscountBalanceUsed, long GatewayAmount, bool PaymentCompleted, + int PaymentStatus, int DeliveryStatus, string? TrackingCode, int ItemsCount, @@ -24,6 +25,7 @@ public record DiscountOrderDetail( long DiscountBalanceUsed, long GatewayAmount, bool PaymentCompleted, + int PaymentStatus, string? TransactionId, int DeliveryStatus, string? TrackingCode, @@ -127,6 +129,7 @@ public class DiscountOrderService DiscountBalanceUsed: m.DiscountBalanceUsed, GatewayAmount: m.GatewayAmount, PaymentCompleted: m.PaymentCompleted, + PaymentStatus: (int)m.PaymentStatus, DeliveryStatus: (int)m.DeliveryStatus, TrackingCode: m.TrackingCode, ItemsCount: m.ItemsCount, @@ -172,6 +175,7 @@ public class DiscountOrderService DiscountBalanceUsed: r.DiscountBalanceUsed, GatewayAmount: r.GatewayAmount, PaymentCompleted: r.PaymentCompleted, + PaymentStatus: (int)r.PaymentStatus, TransactionId: r.TransactionId, DeliveryStatus: (int)r.DeliveryStatus, TrackingCode: r.TrackingCode, @@ -206,4 +210,23 @@ public class DiscountOrderService 4 => Color.Error, _ => Color.Default }; + + // PaymentStatus: 0=Pending, 1=Completed, 2=Failed, 3=Refunded + public static string GetPaymentStatusText(int status) => status switch + { + 0 => "در انتظار پرداخت", + 1 => "پرداخت شده", + 2 => "پرداخت ناموفق", + 3 => "بازگشت وجه", + _ => "نامشخص" + }; + + public static Color GetPaymentStatusColor(int status) => status switch + { + 0 => Color.Warning, + 1 => Color.Success, + 2 => Color.Error, + 3 => Color.Info, + _ => Color.Default + }; }