Merge branch 'kub-stage' into production
Build and Deploy to Production / build-and-deploy (push) Failing after 2m40s
Build and Deploy to Production / build-and-deploy (push) Failing after 2m40s
This commit is contained in:
@@ -44,11 +44,11 @@
|
||||
Label="مبلغ (تومان)"
|
||||
Variant="Variant.Outlined"
|
||||
Min="10_000"
|
||||
Max="100_000_000"
|
||||
Max="1_000_000_000"
|
||||
Format="N0"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.Payments"
|
||||
HelperText="حداقل ۱۰,۰۰۰ و حداکثر ۱۰۰,۰۰۰,۰۰۰ تومان" />
|
||||
HelperText="حداقل ۱۰,۰۰۰ و حداکثر ۱,۰۰۰,۰۰۰,۰۰۰ تومان" />
|
||||
|
||||
@* دکمههای مبلغ سریع *@
|
||||
<MudStack Row="true" Spacing="1" Class="flex-wrap">
|
||||
|
||||
@@ -29,10 +29,8 @@ public partial class ChargeDiscountWallet : ComponentBase
|
||||
|
||||
try
|
||||
{
|
||||
// تبدیل تومان به ریال
|
||||
var amountInRial = _chargeAmount * 10;
|
||||
|
||||
var (success, gatewayUrl, error) = await WalletService.InitiateDiscountChargeAsync(amountInRial);
|
||||
// مبلغ به تومان — CMS خودش موقع ارسال به درگاه ×۱۰ میکنه
|
||||
var (success, gatewayUrl, error) = await WalletService.InitiateDiscountChargeAsync(_chargeAmount);
|
||||
|
||||
if (success && !string.IsNullOrEmpty(gatewayUrl))
|
||||
{
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
لینک دعوت شما هنوز فعال نشده است
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary mb-1" Style="max-width:560px; margin:0 auto;">
|
||||
برای فعالسازی لینک دعوت، ابتدا <strong>پکیج پایه</strong> را تهیه کنید و سپس در <strong>باشگاه مشتریان</strong> عضو شوید.
|
||||
برای فعالسازی لینک دعوت، ابتدا یکی از <strong>پکیجها</strong> را تهیه کنید و سپس در <strong>باشگاه مشتریان</strong> عضو شوید.
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary mb-4" Style="max-width:560px; margin:0 auto;">
|
||||
از مزایای ویژه عضویت بهرهمند شده و با فعالیت در زمینه توسعه فروشگاهها پاداش دریافت کنید.
|
||||
@@ -130,7 +130,7 @@
|
||||
Class="rounded-pill"
|
||||
StartIcon="@Icons.Material.Filled.ShoppingCart"
|
||||
OnClick="OpenPurchaseOptions">
|
||||
شروع فرآیند تامین اعتبار
|
||||
تهیه پکیج
|
||||
</MudButton>
|
||||
</MudPaper>
|
||||
}
|
||||
@@ -195,88 +195,4 @@
|
||||
</MudGrid>
|
||||
</MudContainer>
|
||||
|
||||
@* ── Purchase Options Dialog ── *@
|
||||
<MudDialog @bind-Visible="_showPurchaseBottomSheet">
|
||||
<DialogContent>
|
||||
<MudStack Spacing="3" Class="pa-2">
|
||||
<MudText Typo="Typo.h6" Align="Align.Center">
|
||||
خرید پکیج پایه ۵۶ میلیون تومان
|
||||
</MudText>
|
||||
<MudDivider />
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">
|
||||
برای خرید پکیج پایه، یکی از روشهای زیر را انتخاب کنید:
|
||||
</MudText>
|
||||
|
||||
<MudPaper Elevation="0" Class="pa-4 rounded-lg" Style="border: 2px solid var(--mud-palette-primary);">
|
||||
<MudStack Spacing="2">
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||
<MudIcon Icon="@Icons.Material.Filled.CreditCard" Color="Color.Primary" Size="Size.Medium" />
|
||||
<MudText Typo="Typo.subtitle1" Color="Color.Primary"><b>پرداخت مستقیم</b></MudText>
|
||||
</MudStack>
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">پرداخت آنی از طریق درگاه بانکی</MudText>
|
||||
@if (_purchaseCycleCount > 0)
|
||||
{
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" FullWidth="true"
|
||||
Disabled="@_isProcessingPayment"
|
||||
StartIcon="@Icons.Material.Filled.Payment"
|
||||
OnClick="DirectPayment">
|
||||
@if (_isProcessingPayment)
|
||||
{
|
||||
<MudProgressCircular Size="Size.Small" Indeterminate="true" Class="me-2" />
|
||||
<span>در حال انتقال به درگاه...</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>پرداخت با کارت بانکی</span>
|
||||
}
|
||||
</MudButton>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" FullWidth="true"
|
||||
Disabled="@_isProcessingPayment"
|
||||
StartIcon="@Icons.Material.Filled.Payment"
|
||||
OnClick="DirectPayment">
|
||||
@if (_isProcessingPayment)
|
||||
{
|
||||
<MudProgressCircular Size="Size.Small" Indeterminate="true" Class="me-2" />
|
||||
<span>در حال انتقال به درگاه...</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>پرداخت با کارت بانکی</span>
|
||||
}
|
||||
</MudButton>
|
||||
}
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
|
||||
@if (_purchaseCycleCount == 0)
|
||||
{
|
||||
<MudPaper Elevation="0" Class="pa-4 rounded-lg" Style="border: 2px solid var(--mud-palette-tertiary);">
|
||||
<MudStack Spacing="2">
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Diamond" Color="Color.Tertiary" Size="Size.Medium" />
|
||||
<MudText Typo="Typo.subtitle1" Color="Color.Tertiary"><b>اعتبار الماسی دایا</b></MudText>
|
||||
</MudStack>
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">تأمین اعتبار از طریق خرید توکن الماس و دریافت وام</MudText>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Tertiary" FullWidth="true"
|
||||
StartIcon="@Icons.Material.Filled.AccountBalance" OnClick="DayaLoanPayment">
|
||||
تأمین اعتبار الماسی
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Dense="true" Class="mt-1">
|
||||
از دور دوم به بعد، خرید پکیج فقط از طریق درگاه بانکی امکانپذیر است.
|
||||
</MudAlert>
|
||||
}
|
||||
|
||||
<MudButton Variant="Variant.Text" Color="Color.Default" FullWidth="true" OnClick="ClosePurchaseOptions">
|
||||
بستن
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</DialogContent>
|
||||
</MudDialog>
|
||||
|
||||
@@ -42,8 +42,7 @@ public partial class Index
|
||||
private bool _isClubMemberActive;
|
||||
private bool CanShowReferralLink => _hasPurchasedPackage && _isClubMemberActive;
|
||||
|
||||
// Purchase Options Bottom Sheet
|
||||
private bool _showPurchaseBottomSheet;
|
||||
// Purchase flow
|
||||
private bool _isProcessingPayment;
|
||||
private int _purchaseCycleCount; // تعداد دورهای خرید — اگر > 0 فقط IPG مجاز
|
||||
|
||||
@@ -55,7 +54,7 @@ public partial class Index
|
||||
new(RouteConstants.Profile.Tree, Icons.Material.Filled.AccountTree, "شجرهنامه", "ساختار تیم", "background:rgba(99,102,241,.12); color:#6366f1;"),
|
||||
new(RouteConstants.Gateway.StoreChooser, Icons.Material.Filled.Store, "فروشگاهها", "ورود به فروشگاه", "background:rgba(16,185,129,.12); color:#10b981;"),
|
||||
new(RouteConstants.Profile.Wallet, Icons.Material.Filled.AccountBalanceWallet, "کیف پول", "مدیریت و تاریخچه", "background:rgba(16,185,129,.12); color:#10b981;"),
|
||||
new(RouteConstants.Profile.MagicWallet, Icons.Material.Filled.AutoAwesome, "کیفپول جادویی", "شارژ ×2.5", "background:rgba(168,85,247,.12); color:#a855f7;"),
|
||||
new(RouteConstants.Profile.MagicWallet, Icons.Material.Filled.AutoAwesome, "کیفپول جادویی", "شارژ چندبرابری", "background:rgba(168,85,247,.12); color:#a855f7;"),
|
||||
new(RouteConstants.Profile.WithdrawalRequests, Icons.Material.Filled.RequestPage, "درخواست برداشت", "ثبت و پیگیری", "background:rgba(245,158,11,.12); color:#f59e0b;"),
|
||||
new(RouteConstants.Club.Membership, Icons.Material.Filled.CardMembership, "باشگاه مشتریان", "عضویت و مزایا", "background:rgba(168,85,247,.12); color:#a855f7;"),
|
||||
new(RouteConstants.Network.Statistics, Icons.Material.Filled.Groups, "آمار باشگاه", "جزئیات باشگاه", "background:rgba(59,130,246,.12); color:#3b82f6;"),
|
||||
@@ -394,41 +393,62 @@ public partial class Index
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenPurchaseOptions()
|
||||
private async Task OpenPurchaseOptions()
|
||||
{
|
||||
_showPurchaseBottomSheet = true;
|
||||
var options = new DialogOptions
|
||||
{
|
||||
MaxWidth = MaxWidth.Small,
|
||||
FullWidth = true,
|
||||
CloseOnEscapeKey = true,
|
||||
BackdropClick = true
|
||||
};
|
||||
|
||||
var parameters = new DialogParameters<Shared.PackagePurchaseDialog>
|
||||
{
|
||||
{ x => x.PurchaseCycleCount, _purchaseCycleCount }
|
||||
};
|
||||
|
||||
var dialog = await DialogService.ShowAsync<Shared.PackagePurchaseDialog>(
|
||||
string.Empty, parameters, options);
|
||||
var result = await dialog.Result;
|
||||
|
||||
if (result.Canceled) return;
|
||||
|
||||
if (result.Data is Shared.PackagePurchaseDialog.PackagePurchaseResult purchase)
|
||||
{
|
||||
switch (purchase.Method)
|
||||
{
|
||||
case Shared.PackagePurchaseDialog.PaymentMethodType.DirectPayment:
|
||||
await ProcessDirectPayment(purchase.Package.Id);
|
||||
break;
|
||||
case Shared.PackagePurchaseDialog.PaymentMethodType.DayaLoan:
|
||||
await ProcessDayaLoanPayment();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ClosePurchaseOptions()
|
||||
{
|
||||
_showPurchaseBottomSheet = false;
|
||||
}
|
||||
|
||||
private async Task DirectPayment()
|
||||
private async Task ProcessDirectPayment(long packageId)
|
||||
{
|
||||
if (_isProcessingPayment) return;
|
||||
|
||||
|
||||
_isProcessingPayment = true;
|
||||
_showPurchaseBottomSheet = false;
|
||||
|
||||
StateHasChanged();
|
||||
|
||||
try
|
||||
{
|
||||
// Create callback URL for payment verification
|
||||
var callbackUrl = $"{Navigation.BaseUri}profile/payment-callback";
|
||||
|
||||
// Call BFF to initiate payment (UserId is taken from JWT token in BFF)
|
||||
var response = await PackageContract.InitiateBasePackagePaymentAsync(new InitiateBasePackagePaymentRequest
|
||||
var response = await PackageContract.CustomerPurchasePackageAsync(new CustomerPurchasePackageRequest
|
||||
{
|
||||
CallbackUrl = callbackUrl
|
||||
PackageId = packageId,
|
||||
PurchaseMethod = PurchaseMethodEnum.PurchaseMethodGateway
|
||||
});
|
||||
|
||||
|
||||
if (!response.Success)
|
||||
{
|
||||
Snackbar.Add(response.Message ?? "خطا در آغاز فرآیند پرداخت", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
// Redirect to payment gateway
|
||||
|
||||
if (!string.IsNullOrEmpty(response.PaymentGatewayUrl))
|
||||
{
|
||||
Navigation.NavigateTo(response.PaymentGatewayUrl, forceLoad: true);
|
||||
@@ -449,41 +469,34 @@ public partial class Index
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DayaLoanPayment()
|
||||
private async Task ProcessDayaLoanPayment()
|
||||
{
|
||||
// Validate user info before redirecting
|
||||
if (string.IsNullOrWhiteSpace(_updateUserRequest.FirstName))
|
||||
{
|
||||
_showPurchaseBottomSheet = false;
|
||||
Snackbar.Add($"لطفا اطلاعات شخصی خود را تکمیل کنید. (نام وارد نشده)", Severity.Error);
|
||||
Snackbar.Add("لطفا اطلاعات شخصی خود را تکمیل کنید. (نام وارد نشده)", Severity.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(_updateUserRequest.LastName))
|
||||
{
|
||||
_showPurchaseBottomSheet = false;
|
||||
Snackbar.Add($"لطفا اطلاعات شخصی خود را تکمیل کنید. (نام خانوادگی وارد نشده)", Severity.Error);
|
||||
Snackbar.Add("لطفا اطلاعات شخصی خود را تکمیل کنید. (نام خانوادگی وارد نشده)", Severity.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(_updateUserRequest.NationalCode))
|
||||
{
|
||||
_showPurchaseBottomSheet = false;
|
||||
Snackbar.Add($"لطفا اطلاعات شخصی خود را تکمیل کنید. (کدملی وارد نشده)", Severity.Error);
|
||||
Snackbar.Add("لطفا اطلاعات شخصی خود را تکمیل کنید. (کدملی وارد نشده)", Severity.Error);
|
||||
return;
|
||||
}
|
||||
if (_updateUserRequest.BirthDate == null)
|
||||
{
|
||||
_showPurchaseBottomSheet = false;
|
||||
Snackbar.Add($"لطفا اطلاعات شخصی خود را تکمیل کنید. (تاریخ تولد وارد نشده)", Severity.Error);
|
||||
Snackbar.Add("لطفا اطلاعات شخصی خود را تکمیل کنید. (تاریخ تولد وارد نشده)", Severity.Error);
|
||||
return;
|
||||
}
|
||||
if (!_addresses.Any())
|
||||
{
|
||||
_showPurchaseBottomSheet = false;
|
||||
Snackbar.Add($"آدرس محل سکونت شما الزامی است!", Severity.Error);
|
||||
Snackbar.Add("آدرس محل سکونت شما الزامی است!", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_showPurchaseBottomSheet = false;
|
||||
|
||||
var url = "https://dayadiamond.ir/profile/creditpurchase/?merchantcode=56146364";
|
||||
await JSRuntime.InvokeVoidAsync("open", url, "_blank");
|
||||
}
|
||||
|
||||
@@ -36,6 +36,11 @@
|
||||
{
|
||||
@* ═══ حالت جادویی فعال ═══ *@
|
||||
|
||||
@* ── G4: هشدار تنظیمات پکیجبیس (Q28) ── *@
|
||||
<MudAlert Severity="Severity.Warning" Variant="Variant.Text" Dense="true" Icon="@Icons.Material.Filled.Warning">
|
||||
سقف واریز و ضریب اعتبار کیفپول جادویی بر اساس پکیج شما تنظیم شده است. پکیجهای بالاتر سقف و ضریب بیشتری دارند.
|
||||
</MudAlert>
|
||||
|
||||
@* ─── وضعیت و پیشرفت ─── *@
|
||||
<MudPaper Elevation="2" Class="pa-5 rounded-xl" Style="background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%); color: white;">
|
||||
<MudStack Spacing="2">
|
||||
@@ -92,8 +97,8 @@
|
||||
</MudText>
|
||||
|
||||
<MudAlert Severity="MudBlazor.Severity.Info" Dense="true" Class="mb-3" Icon="@Icons.Material.Filled.Info">
|
||||
مبلغ واریزی شما <strong>×۲.۵</strong> به موجودی اضافه میشود.
|
||||
مثلاً ۱۰ میلیون واریز = ۲۵ میلیون اعتبار.
|
||||
مبلغ واریزی شما <strong>×@_status.MagicMultiplier.ToString("0.#")</strong> به موجودی اضافه میشود.
|
||||
مثلاً ۱۰ میلیون واریز = @FormatToman((long)(10_000_000 * (decimal)_status.MagicMultiplier)) اعتبار.
|
||||
</MudAlert>
|
||||
|
||||
<MudStack Spacing="2">
|
||||
@@ -101,7 +106,7 @@
|
||||
Label="مبلغ واریز (تومان)"
|
||||
Variant="Variant.Outlined"
|
||||
Min="10_000"
|
||||
Max="@(_status.MagicRemainingDeposit / 10)"
|
||||
Max="@_status.MagicRemainingDeposit"
|
||||
Format="N0"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.Payments"
|
||||
@@ -115,8 +120,8 @@
|
||||
<MudText Typo="Typo.body2">@FormatToman(_chargeAmount)</MudText>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||
<MudText Typo="Typo.body2" Color="Color.Success"><strong>اعتبار دریافتی (×۲.۵):</strong></MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Success"><strong>@FormatToman((long)(_chargeAmount * 2.5m))</strong></MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Success"><strong>اعتبار دریافتی (×@_status.MagicMultiplier.ToString("0.#")):</strong></MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Success"><strong>@FormatToman((long)(_chargeAmount * (decimal)_status.MagicMultiplier))</strong></MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
}
|
||||
@@ -125,7 +130,7 @@
|
||||
<MudStack Row="true" Spacing="1" Class="flex-wrap">
|
||||
@foreach (var preset in _presetAmounts)
|
||||
{
|
||||
if (preset * 10 <= _status.MagicRemainingDeposit)
|
||||
if (preset <= _status.MagicRemainingDeposit)
|
||||
{
|
||||
<MudButton Variant="Variant.Outlined" Size="Size.Small"
|
||||
Color="@(_chargeAmount == preset ? Color.Primary : Color.Default)"
|
||||
@@ -171,13 +176,13 @@
|
||||
<MudExpansionPanel Text="قوانین کیفپول جادویی" MaxHeight="500" IsInitiallyExpanded="false">
|
||||
<MudList T="string" Dense="true">
|
||||
<MudListItem T="string" Icon="@Icons.Material.Filled.CheckCircle" IconColor="Color.Success">
|
||||
هر مبلغ واریزی ×۲.۵ به موجودی اضافه میشود
|
||||
هر مبلغ واریزی ×@_status.MagicMultiplier.ToString("0.#") به موجودی اضافه میشود
|
||||
</MudListItem>
|
||||
<MudListItem T="string" Icon="@Icons.Material.Filled.CheckCircle" IconColor="Color.Success">
|
||||
سقف واریز در هر دور: ۱۰۰ میلیون تومان
|
||||
سقف واریز در هر دور: @FormatPrice(_status.MagicMaxDeposit)
|
||||
</MudListItem>
|
||||
<MudListItem T="string" Icon="@Icons.Material.Filled.CheckCircle" IconColor="Color.Success">
|
||||
حداکثر اعتبار: ۲۵۰ میلیون تومان (سود ۱۵۰٪)
|
||||
حداکثر اعتبار: @FormatPrice(_status.MagicMaxCredit)
|
||||
</MudListItem>
|
||||
<MudListItem T="string" Icon="@Icons.Material.Filled.Warning" IconColor="Color.Warning">
|
||||
در حالت جادویی، کمیسیون و پاداش تیمی غیرفعال است
|
||||
|
||||
@@ -46,10 +46,8 @@ public partial class MagicWallet : ComponentBase
|
||||
|
||||
try
|
||||
{
|
||||
// تبدیل تومان به ریال
|
||||
var amountInRial = _chargeAmount * 10;
|
||||
|
||||
var (success, gatewayUrl, error) = await WalletService.InitiateMagicChargeAsync(amountInRial);
|
||||
// مبلغ به تومان — CMS خودش موقع ارسال به درگاه ×۱۰ میکنه
|
||||
var (success, gatewayUrl, error) = await WalletService.InitiateMagicChargeAsync(_chargeAmount);
|
||||
|
||||
if (success && !string.IsNullOrEmpty(gatewayUrl))
|
||||
{
|
||||
@@ -71,8 +69,8 @@ public partial class MagicWallet : ComponentBase
|
||||
}
|
||||
}
|
||||
|
||||
private static string FormatPrice(long priceInRial)
|
||||
=> string.Format("{0:N0} تومان", priceInRial / 10);
|
||||
private static string FormatPrice(long price)
|
||||
=> string.Format("{0:N0} تومان", price);
|
||||
|
||||
private static string FormatToman(long toman)
|
||||
=> string.Format("{0:N0} تومان", toman);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
@using Blazored.LocalStorage
|
||||
@using CMSMicroservice.Protobuf.Protos.Package
|
||||
@using CMSMicroservice.Protobuf.Protos.User
|
||||
@inject IJSRuntime JS
|
||||
@using FrontOffice.Main.Utilities
|
||||
|
||||
|
||||
<PageTitle>نتیجه پرداخت | کارا بازار سلامت</PageTitle>
|
||||
@@ -21,10 +21,10 @@
|
||||
<MudText Typo="Typo.h5" Color="Color.Success" Class="mt-4">پرداخت موفق</MudText>
|
||||
<MudText Typo="Typo.body1" Class="mt-2">@_message</MudText>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_refId))
|
||||
@if (_transactionId > 0)
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="mt-3">
|
||||
<strong>کد پیگیری:</strong> @_refId
|
||||
<strong>کد ارجاعی:</strong> @_transactionId
|
||||
</MudText>
|
||||
}
|
||||
|
||||
@@ -33,13 +33,10 @@
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">
|
||||
موجودی کیف پول اصلی: @FormatPrice(_walletBalance)
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">
|
||||
موجودی کیف پول اعتباری: @FormatPrice(_discountBalance)
|
||||
</MudText>
|
||||
|
||||
<MudButton Color="Color.Primary" Variant="Variant.Filled" Class="mt-6"
|
||||
OnClick="GoBack">
|
||||
بازگشت به پروفایل
|
||||
Href="@_successReturnUrl">
|
||||
@_successReturnText
|
||||
</MudButton>
|
||||
}
|
||||
else
|
||||
@@ -49,8 +46,8 @@
|
||||
<MudText Typo="Typo.body1" Class="mt-2">@_message</MudText>
|
||||
|
||||
<MudButton Color="Color.Primary" Variant="Variant.Filled" Class="mt-6"
|
||||
OnClick="GoBack">
|
||||
بازگشت به پروفایل
|
||||
Href="@_failReturnUrl">
|
||||
@_failReturnText
|
||||
</MudButton>
|
||||
|
||||
<MudButton Color="Color.Secondary" Variant="Variant.Outlined" Class="mt-3 mr-2"
|
||||
@@ -64,12 +61,19 @@
|
||||
@code {
|
||||
[Inject] private PackageContract.PackageContractClient PackageContractClient { get; set; } = default!;
|
||||
[Inject] private UserContract.UserContractClient UserContractClient { get; set; } = default!;
|
||||
[Inject] private DiscountOrderService DiscountOrderService { get; set; } = default!;
|
||||
[Inject] private ILocalStorageService LocalStorage { get; set; } = default!;
|
||||
[Inject] private AuthService AuthService { get; set; } = default!;
|
||||
[Inject] private NavigationManager NavManager { get; set; } = default!;
|
||||
|
||||
private const string TokenStorageKey = "auth:token";
|
||||
|
||||
/// <summary>
|
||||
/// نوع پرداخت: package (پیشفرض) | magic-wallet | discount-wallet | discount-order
|
||||
/// </summary>
|
||||
[SupplyParameterFromQuery(Name = "type")]
|
||||
private string? PaymentType { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery(Name = "orderId")]
|
||||
private long OrderId { get; set; }
|
||||
|
||||
@@ -85,9 +89,14 @@
|
||||
private bool _isLoading = true;
|
||||
private bool _isSuccess;
|
||||
private string _message = string.Empty;
|
||||
private string? _refId;
|
||||
private long _transactionId;
|
||||
private long _walletBalance;
|
||||
private long _discountBalance;
|
||||
|
||||
// دکمههای بازگشت بسته به نوع پرداخت
|
||||
private string _successReturnUrl = "/profile";
|
||||
private string _successReturnText = "بازگشت به پروفایل";
|
||||
private string _failReturnUrl = "/profile";
|
||||
private string _failReturnText = "بازگشت به پروفایل";
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
@@ -101,35 +110,23 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
if (OrderId <= 0 || TransactionId <= 0 || string.IsNullOrEmpty(Authority))
|
||||
{
|
||||
_isSuccess = false;
|
||||
_message = "پارامترهای پرداخت نامعتبر است";
|
||||
_isLoading = false;
|
||||
StateHasChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
var response = await PackageContractClient.VerifyBasePackagePaymentAsync(new VerifyBasePackagePaymentRequest
|
||||
{
|
||||
OrderId = OrderId,
|
||||
TransactionId = TransactionId,
|
||||
PaymentSuccess = Status == "OK",
|
||||
RefId = !string.IsNullOrEmpty(Authority) ? Authority : null,
|
||||
Message = !string.IsNullOrEmpty(Status) ? Status : null
|
||||
});
|
||||
|
||||
_isSuccess = response.Success;
|
||||
_message = response.Message;
|
||||
_refId = response.ReferenceCode ?? "";
|
||||
_walletBalance = response.WalletBalance;
|
||||
_discountBalance = response.DiscountBalance;
|
||||
// تعیین نوع پرداخت — اگر type نباشد، پیشفرض خرید پکیج
|
||||
var type = PaymentType?.ToLowerInvariant() ?? "package";
|
||||
|
||||
// اگر پرداخت موفق بود، توکن را refresh میکنیم
|
||||
// چون PackagePurchaseMethod تغییر کرده و باید در claims جدید باشد
|
||||
if (_isSuccess)
|
||||
switch (type)
|
||||
{
|
||||
await RefreshTokenAsync();
|
||||
case "magic-wallet":
|
||||
await VerifyMagicWalletCharge();
|
||||
break;
|
||||
case "discount-wallet":
|
||||
await VerifyDiscountWalletCharge();
|
||||
break;
|
||||
case "discount-order":
|
||||
await VerifyDiscountOrderPayment();
|
||||
break;
|
||||
default: // "package" or missing
|
||||
await VerifyPackagePurchase();
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -143,10 +140,156 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// تأیید خرید پکیج — رفتار فعلی
|
||||
/// </summary>
|
||||
private async Task VerifyPackagePurchase()
|
||||
{
|
||||
_successReturnUrl = "/profile";
|
||||
_successReturnText = "بازگشت به پروفایل";
|
||||
_failReturnUrl = "/profile";
|
||||
_failReturnText = "بازگشت به پروفایل";
|
||||
|
||||
if (OrderId <= 0 || string.IsNullOrEmpty(Authority))
|
||||
{
|
||||
_isSuccess = false;
|
||||
_message = "پارامترهای پرداخت نامعتبر است";
|
||||
return;
|
||||
}
|
||||
|
||||
var response = await PackageContractClient.CustomerVerifyPackagePurchaseAsync(new CustomerVerifyPackagePurchaseRequest
|
||||
{
|
||||
OrderId = OrderId,
|
||||
Authority = Authority ?? string.Empty,
|
||||
Status = Status ?? string.Empty
|
||||
});
|
||||
|
||||
_isSuccess = response.Success;
|
||||
_message = response.Message;
|
||||
_transactionId = response.TransactionId;
|
||||
|
||||
if (_isSuccess)
|
||||
{
|
||||
await UpdateWalletBalanceAndRefreshToken();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// تأیید شارژ کیفپول جادویی
|
||||
/// </summary>
|
||||
private async Task VerifyMagicWalletCharge()
|
||||
{
|
||||
_successReturnUrl = "/profile/magic-wallet";
|
||||
_successReturnText = "بازگشت به کیف پول جادویی";
|
||||
_failReturnUrl = "/profile/magic-wallet";
|
||||
_failReturnText = "بازگشت به کیف پول جادویی";
|
||||
|
||||
if (string.IsNullOrEmpty(Authority))
|
||||
{
|
||||
_isSuccess = false;
|
||||
_message = "کد Authority نامعتبر است";
|
||||
return;
|
||||
}
|
||||
|
||||
var (success, message) = await WalletService.VerifyMagicChargeAsync(
|
||||
Authority, Status ?? "NOK");
|
||||
|
||||
_isSuccess = success;
|
||||
_message = message;
|
||||
|
||||
if (_isSuccess)
|
||||
{
|
||||
await UpdateWalletBalance();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// تأیید شارژ کیف پول تخفیفی
|
||||
/// </summary>
|
||||
private async Task VerifyDiscountWalletCharge()
|
||||
{
|
||||
_successReturnUrl = "/profile/charge-discount-wallet";
|
||||
_successReturnText = "بازگشت به کیف پول تخفیفی";
|
||||
_failReturnUrl = "/profile/charge-discount-wallet";
|
||||
_failReturnText = "بازگشت به کیف پول تخفیفی";
|
||||
|
||||
if (string.IsNullOrEmpty(Authority))
|
||||
{
|
||||
_isSuccess = false;
|
||||
_message = "کد Authority نامعتبر است";
|
||||
return;
|
||||
}
|
||||
|
||||
var (success, message) = await WalletService.VerifyDiscountChargeAsync(
|
||||
Authority, Status ?? "NOK");
|
||||
|
||||
_isSuccess = success;
|
||||
_message = message;
|
||||
|
||||
if (_isSuccess)
|
||||
{
|
||||
await UpdateWalletBalance();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// تأیید پرداخت سفارش فروشگاه تخفیفی
|
||||
/// </summary>
|
||||
private async Task VerifyDiscountOrderPayment()
|
||||
{
|
||||
_successReturnUrl = $"/discount-store/order/{OrderId}";
|
||||
_successReturnText = "مشاهده سفارش";
|
||||
_failReturnUrl = $"/discount-store/order/{OrderId}";
|
||||
_failReturnText = "مشاهده سفارش";
|
||||
|
||||
if (OrderId <= 0 || string.IsNullOrEmpty(Authority))
|
||||
{
|
||||
_isSuccess = false;
|
||||
_message = "پارامترهای پرداخت نامعتبر است";
|
||||
return;
|
||||
}
|
||||
|
||||
var (success, message, _) = await DiscountOrderService.VerifyDiscountOrderPaymentAsync(
|
||||
OrderId, Authority, Status ?? "NOK");
|
||||
|
||||
_isSuccess = success;
|
||||
_message = message;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// بروزرسانی موجودی کیف پول
|
||||
/// </summary>
|
||||
private async Task UpdateWalletBalance()
|
||||
{
|
||||
try
|
||||
{
|
||||
var balances = await WalletService.GetBalancesAsync();
|
||||
_walletBalance = balances.CreditBalance;
|
||||
}
|
||||
catch { /* اگر خطا شد، صفر نمایش بده */ }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// بروزرسانی موجودی + refresh توکن (فقط برای خرید پکیج)
|
||||
/// </summary>
|
||||
private async Task UpdateWalletBalanceAndRefreshToken()
|
||||
{
|
||||
await UpdateWalletBalance();
|
||||
await RefreshTokenAsync();
|
||||
}
|
||||
|
||||
private void RetryPayment()
|
||||
{
|
||||
NavManager.NavigateTo("/profile");
|
||||
var type = PaymentType?.ToLowerInvariant() ?? "package";
|
||||
var url = type switch
|
||||
{
|
||||
"magic-wallet" => "/profile/magic-wallet",
|
||||
"discount-wallet" => "/profile/charge-discount-wallet",
|
||||
"discount-order" => "/discount-store",
|
||||
_ => "/profile"
|
||||
};
|
||||
NavManager.NavigateTo(url, forceLoad: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -174,6 +317,4 @@
|
||||
}
|
||||
|
||||
private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price);
|
||||
|
||||
private async Task GoBack() => await JS.InvokeVoidAsync("history.back");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user