feat: show PaymentStatus on discount orders + failed payment UX
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 6m25s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 6m25s
- Updated NuGet to Protobuf v0.0.179 - Added PaymentStatus to DiscountOrderSummary and DiscountOrderDetail records - OrderDetail: show payment status chip (Pending/Success/Failed/Refunded) - OrderDetail: show alert with re-order link for failed payments - Orders: updated desktop table and mobile cards with PaymentStatus chips - Added GetPaymentStatusText() and GetPaymentStatusColor() helpers
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DateTimeConverterCL" Version="1.0.0" />
|
||||
<!-- Replace all FrontOffice.BFF protobuf packages with CMS protobuf -->
|
||||
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.178" />
|
||||
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.179" />
|
||||
<!--<ProjectReference Include="../../../CMS/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj" />-->
|
||||
<PackageReference Include="MudBlazor" Version="8.14.0" />
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
|
||||
|
||||
@@ -33,9 +33,9 @@ else
|
||||
<!-- Header -->
|
||||
<PageHeader Title="@($"سفارش #{_order.OrderNumber}")" BackHref="@RouteConstants.DiscountStore.Orders" />
|
||||
<MudStack Row="true" Spacing="2" Class="flex-wrap mb-4">
|
||||
<MudChip T="string" Color="@(_order.PaymentCompleted ? Color.Success : Color.Warning)"
|
||||
<MudChip T="string" Color="@DiscountOrderService.GetPaymentStatusColor(_order.PaymentStatus)"
|
||||
Variant="Variant.Filled">
|
||||
@(_order.PaymentCompleted ? "پرداخت شده" : "در انتظار پرداخت")
|
||||
@DiscountOrderService.GetPaymentStatusText(_order.PaymentStatus)
|
||||
</MudChip>
|
||||
<MudChip T="string" Color="@DiscountOrderService.GetDeliveryStatusColor(_order.DeliveryStatus)"
|
||||
Variant="Variant.Outlined">
|
||||
@@ -43,6 +43,17 @@ else
|
||||
</MudChip>
|
||||
</MudStack>
|
||||
|
||||
@if (_order.PaymentStatus == 2)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Variant="Variant.Outlined" Class="mb-4">
|
||||
<MudText>پرداخت این سفارش ناموفق بود و سفارش منقضی شده است. موجودی رزرو شده آزاد شد.</MudText>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Primary" Class="mt-2"
|
||||
Href="@RouteConstants.DiscountStore.Products">
|
||||
بازگشت به فروشگاه و ثبت سفارش جدید
|
||||
</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudStack Spacing="2">
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||
|
||||
@@ -52,9 +52,9 @@
|
||||
<MudTd>@FormatPrice(context.GatewayAmount)</MudTd>
|
||||
<MudTd>
|
||||
<MudChip T="string" Size="Size.Small"
|
||||
Color="@(context.PaymentCompleted ? Color.Success : Color.Warning)"
|
||||
Color="@DiscountOrderService.GetPaymentStatusColor(context.PaymentStatus)"
|
||||
Variant="Variant.Filled">
|
||||
@(context.PaymentCompleted ? "پرداخت شده" : "در انتظار پرداخت")
|
||||
@DiscountOrderService.GetPaymentStatusText(context.PaymentStatus)
|
||||
</MudChip>
|
||||
</MudTd>
|
||||
<MudTd>
|
||||
@@ -87,9 +87,9 @@
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.subtitle2">سفارش #@order.OrderNumber</MudText>
|
||||
<MudChip T="string" Size="Size.Small"
|
||||
Color="@(order.PaymentCompleted ? Color.Success : Color.Warning)"
|
||||
Color="@DiscountOrderService.GetPaymentStatusColor(order.PaymentStatus)"
|
||||
Variant="Variant.Filled">
|
||||
@(order.PaymentCompleted ? "پرداخت شده" : "در انتظار")
|
||||
@DiscountOrderService.GetPaymentStatusText(order.PaymentStatus)
|
||||
</MudChip>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user