feat(UserPayouts): implement withdrawal approval and rejection functionality
Build and Deploy / build (push) Successful in 2m6s
Build and Deploy / build (push) Successful in 2m6s
This commit is contained in:
@@ -109,13 +109,19 @@
|
|||||||
Color="Color.Info"
|
Color="Color.Info"
|
||||||
OnClick="@(() => ViewDetails(context.Item))" />
|
OnClick="@(() => ViewDetails(context.Item))" />
|
||||||
</MudTooltip>
|
</MudTooltip>
|
||||||
@if (context.Item.Status == 0)
|
@if (context.Item.Status == 2) @* WithdrawRequested *@
|
||||||
{
|
{
|
||||||
<MudTooltip Text="پردازش برداشت">
|
<MudTooltip Text="تایید برداشت">
|
||||||
<MudIconButton Icon="@Icons.Material.Filled.Payment"
|
<MudIconButton Icon="@Icons.Material.Filled.CheckCircle"
|
||||||
Size="Size.Small"
|
Size="Size.Small"
|
||||||
Color="Color.Success"
|
Color="Color.Success"
|
||||||
OnClick="@(() => ProcessWithdrawal(context.Item))" />
|
OnClick="@(() => ApproveWithdrawal(context.Item))" />
|
||||||
|
</MudTooltip>
|
||||||
|
<MudTooltip Text="رد برداشت">
|
||||||
|
<MudIconButton Icon="@Icons.Material.Filled.Cancel"
|
||||||
|
Size="Size.Small"
|
||||||
|
Color="Color.Error"
|
||||||
|
OnClick="@(() => RejectWithdrawal(context.Item))" />
|
||||||
</MudTooltip>
|
</MudTooltip>
|
||||||
}
|
}
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
|||||||
@@ -112,24 +112,55 @@ public partial class UserPayouts
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ProcessWithdrawal(UserCommissionPayoutModel payout)
|
private async Task ApproveWithdrawal(UserCommissionPayoutModel payout)
|
||||||
{
|
{
|
||||||
var confirmed = await DialogService.ShowMessageBox(
|
var confirmed = await DialogService.ShowMessageBox(
|
||||||
"تایید پردازش برداشت",
|
"تایید برداشت",
|
||||||
$"آیا از پردازش برداشت برای کاربر {payout.UserName} (مبلغ: {payout.TotalAmount:N0} ریال) مطمئن هستید؟",
|
$"آیا از تایید برداشت برای کاربر {payout.UserName} (مبلغ: {payout.TotalAmount:N0} ریال) مطمئن هستید؟",
|
||||||
yesText: "تایید", cancelText: "لغو");
|
yesText: "تایید", cancelText: "لغو");
|
||||||
|
|
||||||
if (confirmed == true)
|
if (confirmed == true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// TODO: Call ProcessWithdrawal API
|
await CommissionContract.ProcessWithdrawalAsync(new ProcessWithdrawalRequest
|
||||||
Snackbar.Add("درخواست برداشت با موفقیت پردازش شد", Severity.Success);
|
{
|
||||||
|
PayoutId = payout.Id,
|
||||||
|
IsApproved = true
|
||||||
|
});
|
||||||
|
Snackbar.Add("درخواست برداشت با موفقیت تایید شد", Severity.Success);
|
||||||
await ApplyFilter();
|
await ApplyFilter();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Snackbar.Add($"خطا در پردازش: {ex.Message}", Severity.Error);
|
Snackbar.Add($"خطا در تایید: {ex.Message}", Severity.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RejectWithdrawal(UserCommissionPayoutModel payout)
|
||||||
|
{
|
||||||
|
var reason = await DialogService.ShowMessageBox(
|
||||||
|
"رد برداشت",
|
||||||
|
$"آیا از رد برداشت برای کاربر {payout.UserName} مطمئن هستید؟",
|
||||||
|
yesText: "رد کردن", cancelText: "لغو");
|
||||||
|
|
||||||
|
if (reason == true)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await CommissionContract.ProcessWithdrawalAsync(new ProcessWithdrawalRequest
|
||||||
|
{
|
||||||
|
PayoutId = payout.Id,
|
||||||
|
IsApproved = false,
|
||||||
|
Reason = "رد شده توسط ادمین"
|
||||||
|
});
|
||||||
|
Snackbar.Add("درخواست برداشت رد شد", Severity.Warning);
|
||||||
|
await ApplyFilter();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Snackbar.Add($"خطا در رد: {ex.Message}", Severity.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user