Compare commits
7 Commits
cbc61ad0f5
...
kub-stage
| Author | SHA1 | Date | |
|---|---|---|---|
| fe79089770 | |||
| aa97d25302 | |||
| 24ae4ec15c | |||
| c3ee46ff62 | |||
| e9f8328404 | |||
| 6a9d142dc6 | |||
| 1d78633e17 |
+1
-1
@@ -11,7 +11,7 @@
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# Docs moved to totalDoc
|
||||
|
||||
See [totalDoc/INDEX.md](../../totalDoc/INDEX.md) for all documentation.
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
<ProjectReference Include="../../../CMS/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="!Exists('../../../CMS/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj')">
|
||||
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.206" />
|
||||
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.209" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- ============================================================ -->
|
||||
|
||||
@@ -8,21 +8,46 @@ namespace BackOffice.Common.BaseComponents;
|
||||
public partial class DateRangePicker
|
||||
{
|
||||
private DateRange _dateRange = new();
|
||||
private MudDateRangePicker _picker = default!;
|
||||
private DateTime? _lastSyncedFrom;
|
||||
private DateTime? _lastSyncedTo;
|
||||
|
||||
private MudDateRangePicker _picker;
|
||||
[Parameter] public string Label { get; set; } = "انتخاب بازه زمانی";
|
||||
[Parameter] public DateTime? DefaultStart { get; set; }
|
||||
[Parameter] public DateTime? DefaultEnd { get; set; }
|
||||
[Parameter] public EventCallback<DateRange> OnChanged { get; set; }
|
||||
|
||||
[Parameter] public DateTime? From { get; set; }
|
||||
[Parameter] public EventCallback<DateTime?> FromChanged { get; set; }
|
||||
[Parameter] public DateTime? To { get; set; }
|
||||
[Parameter] public EventCallback<DateTime?> ToChanged { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
if (DefaultStart.HasValue)
|
||||
_dateRange.Start = DefaultStart.Value.Date;
|
||||
|
||||
if (DefaultEnd.HasValue)
|
||||
_dateRange.End = DefaultEnd.Value.Date;
|
||||
var start = From ?? DefaultStart;
|
||||
var end = To ?? DefaultEnd;
|
||||
ApplyExternalRange(start, end);
|
||||
_lastSyncedFrom = From;
|
||||
_lastSyncedTo = To;
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
// فقط وقتی والد From/To را عوض کرده (مثلاً پاک کردن فیلتر)، نه هنگام انتخاب داخل پیکر
|
||||
if (From == _lastSyncedFrom && To == _lastSyncedTo)
|
||||
return;
|
||||
|
||||
_lastSyncedFrom = From;
|
||||
_lastSyncedTo = To;
|
||||
ApplyExternalRange(From, To);
|
||||
}
|
||||
|
||||
private void ApplyExternalRange(DateTime? start, DateTime? end)
|
||||
{
|
||||
_dateRange = new DateRange(start?.Date, end?.Date);
|
||||
}
|
||||
|
||||
public CultureInfo GetPersianCulture()
|
||||
{
|
||||
var culture = new CultureInfo("fa-IR");
|
||||
@@ -53,19 +78,35 @@ public partial class DateRangePicker
|
||||
culture.NumberFormat.NumberNegativePattern = 0;
|
||||
return culture;
|
||||
}
|
||||
|
||||
private async Task OnClickOK()
|
||||
{
|
||||
if (_picker.DateRange is not null)
|
||||
{
|
||||
await OnChanged.InvokeAsync(_picker.DateRange);
|
||||
}
|
||||
|
||||
var range = _picker.DateRange ?? _dateRange;
|
||||
_dateRange = range ?? new DateRange();
|
||||
await NotifyRangeChangedAsync(_dateRange);
|
||||
await _picker.CloseAsync();
|
||||
}
|
||||
|
||||
private async Task OnClickClear()
|
||||
{
|
||||
_dateRange = new DateRange();
|
||||
await OnChanged.InvokeAsync(_dateRange);
|
||||
await NotifyRangeChangedAsync(_dateRange);
|
||||
await _picker.CloseAsync();
|
||||
}
|
||||
|
||||
private async Task NotifyRangeChangedAsync(DateRange range)
|
||||
{
|
||||
var start = range.Start?.Date;
|
||||
var end = range.End?.Date;
|
||||
|
||||
_lastSyncedFrom = start;
|
||||
_lastSyncedTo = end;
|
||||
|
||||
if (From != start)
|
||||
await FromChanged.InvokeAsync(start);
|
||||
if (To != end)
|
||||
await ToChanged.InvokeAsync(end);
|
||||
|
||||
await OnChanged.InvokeAsync(range);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace BackOffice.Common.Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// خروجی سازگار با Excel فارسی:
|
||||
/// - XML Spreadsheet (.xls) برای ستونبندی مطمئن + متن فارسی
|
||||
/// - CSV با جداکننده ; بهعنوان جایگزین سبک
|
||||
/// </summary>
|
||||
public static class CsvExportHelper
|
||||
{
|
||||
/// <summary>جداکننده پیشفرض ویندوز فارسی برای CSV.</summary>
|
||||
public const char Separator = ';';
|
||||
|
||||
public static string Escape(string? value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return string.Empty;
|
||||
|
||||
// همیشه quote تا Excel فارسی ستون را نشکند
|
||||
return $"\"{value.Replace("\"", "\"\"")}\"";
|
||||
}
|
||||
|
||||
public static string Cell(object? value) => value switch
|
||||
{
|
||||
null => Escape(string.Empty),
|
||||
string s => Escape(s),
|
||||
bool b => b ? "1" : "0",
|
||||
byte or sbyte or short or ushort or int or uint or long or ulong or float or double or decimal
|
||||
=> Convert.ToString(value, CultureInfo.InvariantCulture) ?? "0",
|
||||
IFormattable f => Escape(f.ToString(null, CultureInfo.InvariantCulture) ?? string.Empty),
|
||||
_ => Escape(Convert.ToString(value, CultureInfo.InvariantCulture))
|
||||
};
|
||||
|
||||
public static string Row(params object?[] cells) =>
|
||||
string.Join(Separator, cells.Select(Cell));
|
||||
|
||||
/// <summary>
|
||||
/// نام نمایشی مشتری؛ اگر خالی باشد موبایل یا شناسه کاربر.
|
||||
/// </summary>
|
||||
public static string CustomerName(string? fullName, string? mobile = null, long? userId = null)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(fullName))
|
||||
return fullName.Trim();
|
||||
if (!string.IsNullOrWhiteSpace(mobile))
|
||||
return mobile.Trim();
|
||||
if (userId is > 0)
|
||||
return $"کاربر {userId}";
|
||||
return "—";
|
||||
}
|
||||
|
||||
public static string ToBase64(StringBuilder body)
|
||||
{
|
||||
// CRLF صریح — Excel روی ویندوز با \n لینوکس گاهی بههم میریزد
|
||||
var text = body.ToString().Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n");
|
||||
var bytes = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes(text)).ToArray();
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// خروجی SpreadsheetML که Excel بهصورت ستونستون و با UTF-8 درست باز میکند.
|
||||
/// فایل را با پسوند .xls ذخیره کنید.
|
||||
/// </summary>
|
||||
public static string ToExcelXmlBase64(string sheetName, IReadOnlyList<string> headers, IEnumerable<object?[]> rows)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine(@"<?xml version=""1.0"" encoding=""UTF-8""?>");
|
||||
sb.AppendLine(@"<?mso-application progid=""Excel.Sheet""?>");
|
||||
sb.AppendLine(@"<Workbook xmlns=""urn:schemas-microsoft-com:office:spreadsheet""");
|
||||
sb.AppendLine(@" xmlns:o=""urn:schemas-microsoft-com:office:office""");
|
||||
sb.AppendLine(@" xmlns:x=""urn:schemas-microsoft-com:office:excel""");
|
||||
sb.AppendLine(@" xmlns:ss=""urn:schemas-microsoft-com:office:spreadsheet""");
|
||||
sb.AppendLine(@" xmlns:html=""http://www.w3.org/TR/REC-html40"">");
|
||||
sb.AppendLine(@"<Styles>");
|
||||
sb.AppendLine(@"<Style ss:ID=""Header""><Font ss:Bold=""1""/></Style>");
|
||||
sb.AppendLine(@"<Style ss:ID=""Text""><NumberFormat ss:Format=""@""/></Style>");
|
||||
sb.AppendLine(@"</Styles>");
|
||||
sb.Append("<Worksheet ss:Name=\"").Append(XmlEscape(sheetName)).AppendLine("\">");
|
||||
sb.AppendLine("<Table>");
|
||||
|
||||
sb.AppendLine("<Row>");
|
||||
foreach (var header in headers)
|
||||
{
|
||||
sb.Append("<Cell ss:StyleID=\"Header\"><Data ss:Type=\"String\">")
|
||||
.Append(XmlEscape(header))
|
||||
.AppendLine("</Data></Cell>");
|
||||
}
|
||||
sb.AppendLine("</Row>");
|
||||
|
||||
foreach (var row in rows)
|
||||
{
|
||||
sb.AppendLine("<Row>");
|
||||
foreach (var cell in row)
|
||||
AppendExcelCell(sb, cell);
|
||||
sb.AppendLine("</Row>");
|
||||
}
|
||||
|
||||
sb.AppendLine("</Table>");
|
||||
sb.AppendLine("</Worksheet>");
|
||||
sb.AppendLine("</Workbook>");
|
||||
|
||||
var bytes = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes(sb.ToString())).ToArray();
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
|
||||
private static void AppendExcelCell(StringBuilder sb, object? value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case null:
|
||||
sb.AppendLine(@"<Cell ss:StyleID=""Text""><Data ss:Type=""String""></Data></Cell>");
|
||||
break;
|
||||
case string s:
|
||||
sb.Append(@"<Cell ss:StyleID=""Text""><Data ss:Type=""String"">")
|
||||
.Append(XmlEscape(s))
|
||||
.AppendLine("</Data></Cell>");
|
||||
break;
|
||||
case bool b:
|
||||
sb.Append(@"<Cell><Data ss:Type=""Boolean"">")
|
||||
.Append(b ? "1" : "0")
|
||||
.AppendLine("</Data></Cell>");
|
||||
break;
|
||||
case byte or sbyte or short or ushort or int or uint or long or ulong:
|
||||
sb.Append(@"<Cell><Data ss:Type=""Number"">")
|
||||
.Append(Convert.ToString(value, CultureInfo.InvariantCulture))
|
||||
.AppendLine("</Data></Cell>");
|
||||
break;
|
||||
case float or double or decimal:
|
||||
sb.Append(@"<Cell><Data ss:Type=""Number"">")
|
||||
.Append(Convert.ToString(value, CultureInfo.InvariantCulture))
|
||||
.AppendLine("</Data></Cell>");
|
||||
break;
|
||||
default:
|
||||
sb.Append(@"<Cell ss:StyleID=""Text""><Data ss:Type=""String"">")
|
||||
.Append(XmlEscape(Convert.ToString(value, CultureInfo.InvariantCulture)))
|
||||
.AppendLine("</Data></Cell>");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static string XmlEscape(string? value) =>
|
||||
WebUtility.HtmlEncode(value ?? string.Empty);
|
||||
}
|
||||
@@ -42,8 +42,9 @@ public static class ReportLabels
|
||||
|
||||
public static string GetPurchaseMethodLabel(int method) => method switch
|
||||
{
|
||||
1 => "وام دایا",
|
||||
2 => "خرید مستقیم",
|
||||
1 => "دایا",
|
||||
2 => "درگاه",
|
||||
3 => "دستی",
|
||||
_ => "نامشخص"
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@page "/club"
|
||||
@page "/club/members"
|
||||
@page "/club/purchases"
|
||||
@page "/club/customer-packages"
|
||||
@page "/club/cycles"
|
||||
@page "/club/history"
|
||||
@page "/club/statistics"
|
||||
@@ -18,6 +19,9 @@
|
||||
<MudTabPanel Text="گزارش خرید پکیج" Icon="@Icons.Material.Filled.ShoppingBag">
|
||||
<ClubPackagePurchasesReport />
|
||||
</MudTabPanel>
|
||||
<MudTabPanel Text="گزارش مشتریان پکیج" Icon="@Icons.Material.Filled.PeopleAlt">
|
||||
<CustomerPackagePurchasesReport />
|
||||
</MudTabPanel>
|
||||
<MudTabPanel Text="گزارش دورهها" Icon="@Icons.Material.Filled.Loop">
|
||||
<ClubCyclesReport />
|
||||
</MudTabPanel>
|
||||
@@ -39,9 +43,10 @@
|
||||
_activeTab = uri switch
|
||||
{
|
||||
"club/purchases" => 1,
|
||||
"club/cycles" => 2,
|
||||
"club/history" => 3,
|
||||
"club/statistics" => 4,
|
||||
"club/customer-packages" => 2,
|
||||
"club/cycles" => 3,
|
||||
"club/history" => 4,
|
||||
"club/statistics" => 5,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
<MudSelect T="int?" Clearable="true" Label="روش خرید" Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense" @bind-Value="_purchaseMethod">
|
||||
<MudSelectItem T="int?" Value="1">وام دایا</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="2">خرید مستقیم</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="1">دایا</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="3">دستی</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="2">درگاه</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
@using CMSMicroservice.Protobuf.Protos.UserPackagePurchase
|
||||
@using Google.Protobuf.WellKnownTypes
|
||||
@using DateTimeConverterCL
|
||||
|
||||
@inject UserPackagePurchaseContract.UserPackagePurchaseContractClient PurchaseClient
|
||||
|
||||
<MudDialog>
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">
|
||||
جزئیات خرید پکیج — @UserName
|
||||
</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
@if (_loading)
|
||||
{
|
||||
<MudProgressLinear Indeterminate="true" Color="Color.Primary" Class="my-4" />
|
||||
}
|
||||
else if (_items.Count == 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Dense="true">خریدی برای این کاربر یافت نشد.</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudTable Items="_items" Dense="true" Hover="true" Breakpoint="Breakpoint.Sm">
|
||||
<HeaderContent>
|
||||
<MudTh>شناسه</MudTh>
|
||||
<MudTh>پکیج</MudTh>
|
||||
<MudTh>روش</MudTh>
|
||||
<MudTh>مبلغ (ریال)</MudTh>
|
||||
<MudTh>تاریخ خرید</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="شناسه">@context.Id</MudTd>
|
||||
<MudTd DataLabel="پکیج">@context.PackageName</MudTd>
|
||||
<MudTd DataLabel="روش">
|
||||
<MudChip T="string" Size="Size.Small" Variant="Variant.Outlined"
|
||||
Color="@GetMethodColor(context.PurchaseMethod)">
|
||||
@ReportLabels.GetPurchaseMethodLabel(context.PurchaseMethod)
|
||||
</MudChip>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="مبلغ">@context.Amount.ToString("N0")</MudTd>
|
||||
<MudTd DataLabel="تاریخ">
|
||||
@(context.PurchasedAt != null
|
||||
? context.PurchasedAt.ToDateTime().ToLocalTime().MiladiToJalaliWithTime()
|
||||
: "-")
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Close" Variant="Variant.Text">بستن</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter] IMudDialogInstance MudDialog { get; set; } = null!;
|
||||
[Parameter] public long UserId { get; set; }
|
||||
[Parameter] public string UserName { get; set; } = string.Empty;
|
||||
|
||||
private bool _loading = true;
|
||||
private List<UserPackagePurchaseModel> _items = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await PurchaseClient.GetAllUserPackagePurchaseByFilterAsync(
|
||||
new GetAllUserPackagePurchaseByFilterRequest
|
||||
{
|
||||
PaginationState = new CMSMicroservice.Protobuf.Protos.PaginationState
|
||||
{
|
||||
PageNumber = 1,
|
||||
PageSize = 500
|
||||
},
|
||||
Filter = new GetAllUserPackagePurchaseByFilterFilter
|
||||
{
|
||||
UserId = UserId
|
||||
}
|
||||
});
|
||||
|
||||
_items = result?.Models?
|
||||
.OrderBy(x => x.PurchasedAt?.ToDateTime() ?? DateTime.MinValue)
|
||||
.ToList() ?? new();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در بارگذاری جزئیات: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static Color GetMethodColor(int method) => method switch
|
||||
{
|
||||
1 => Color.Info, // دایا
|
||||
2 => Color.Primary, // درگاه
|
||||
3 => Color.Secondary, // دستی
|
||||
_ => Color.Default
|
||||
};
|
||||
|
||||
private void Close() => MudDialog.Close();
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
@using System.Text
|
||||
@using BackOffice.Common.BaseComponents
|
||||
@using BackOffice.Common.Utilities
|
||||
@using BackOffice.Pages.AutoComplete
|
||||
@using BackOffice.Pages.Club.Reports.Components
|
||||
@using CMSMicroservice.Protobuf.Protos.UserPackagePurchase
|
||||
@using Google.Protobuf.WellKnownTypes
|
||||
@using DateTimeConverterCL
|
||||
@using Microsoft.JSInterop
|
||||
|
||||
@inject UserPackagePurchaseContract.UserPackagePurchaseContractClient PurchaseClient
|
||||
@inject IDialogService DialogService
|
||||
@inject IJSRuntime JsRuntime
|
||||
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Text" Dense="true" Class="mb-3">
|
||||
گزارش تجمیعی مشتریان — اولین/آخرین پکیج، تفکیک دایا / دستی / درگاه. خروجی Excel مطابق فیلتر فعال است.
|
||||
</MudAlert>
|
||||
|
||||
<BasePageComponent @ref="_basePage" OnSubmitClick="OnFilterSubmit" OnClearFilterClick="OnFilterCleared">
|
||||
<Filters>
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
<UserAutoComplete Label="کاربر" @bind-SelectedUserId="_userId" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
<MudSelect T="int?" Clearable="true" Label="روش خرید" Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense" @bind-Value="_purchaseMethod">
|
||||
<MudSelectItem T="int?" Value="1">دایا</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="3">دستی</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="2">درگاه</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<DateRangePicker @bind-From="_fromDate" @bind-To="_toDate" Label="بازه خرید" />
|
||||
</MudItem>
|
||||
</Filters>
|
||||
<Content>
|
||||
<MudStack Row="true" Justify="Justify.FlexEnd" Class="mb-3">
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Success"
|
||||
StartIcon="@Icons.Material.Filled.FileDownload"
|
||||
OnClick="ExportToExcel" Disabled="_exporting">
|
||||
خروجی Excel
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudDataGrid @ref="_grid" T="CustomerPackagePurchaseRollupModel" ServerData="LoadData" ReadOnly="true"
|
||||
Hover="true" Dense="true" Height="calc(100vh - 420px)">
|
||||
<Columns>
|
||||
<TemplateColumn Title="مشتری">
|
||||
<CellTemplate>
|
||||
<MudStack Spacing="0">
|
||||
<MudText Typo="Typo.body2">@context.Item.UserName</MudText>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">@context.Item.UserMobile</MudText>
|
||||
</MudStack>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<TemplateColumn Title="اولین پکیج">
|
||||
<CellTemplate>
|
||||
<MudStack Spacing="0">
|
||||
<MudText Typo="Typo.body2">@context.Item.FirstPackageName</MudText>
|
||||
<MudText Typo="Typo.caption">@context.Item.FirstAmount.ToString("N0") ریال</MudText>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">
|
||||
@(context.Item.FirstPurchasedAt?.ToDateTime().ToLocalTime().MiladiToJalaliWithTime() ?? "-")
|
||||
</MudText>
|
||||
</MudStack>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<TemplateColumn Title="آخرین پکیج">
|
||||
<CellTemplate>
|
||||
<MudStack Spacing="0">
|
||||
<MudText Typo="Typo.body2">@context.Item.LastPackageName</MudText>
|
||||
<MudText Typo="Typo.caption">@context.Item.LastAmount.ToString("N0") ریال</MudText>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">
|
||||
@(context.Item.LastPurchasedAt?.ToDateTime().ToLocalTime().MiladiToJalaliWithTime() ?? "-")
|
||||
</MudText>
|
||||
<MudChip T="string" Size="Size.Small" Class="mt-1" Variant="Variant.Filled"
|
||||
Color="@GetMethodColor(context.Item.LastPurchaseMethod)">
|
||||
@ReportLabels.GetPurchaseMethodLabel(context.Item.LastPurchaseMethod)
|
||||
</MudChip>
|
||||
</MudStack>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<TemplateColumn Title="تعداد / جمع">
|
||||
<CellTemplate>
|
||||
<MudStack Spacing="0">
|
||||
<MudText>@context.Item.PurchaseCount خرید</MudText>
|
||||
<MudText Typo="Typo.caption">@context.Item.TotalAmount.ToString("N0") ریال</MudText>
|
||||
</MudStack>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<TemplateColumn Title="دایا">
|
||||
<CellTemplate>
|
||||
<MudText Typo="Typo.caption">@context.Item.DayaCount عدد</MudText>
|
||||
<MudText Typo="Typo.caption">@context.Item.DayaAmount.ToString("N0")</MudText>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<TemplateColumn Title="دستی">
|
||||
<CellTemplate>
|
||||
<MudText Typo="Typo.caption">@context.Item.ManualCount عدد</MudText>
|
||||
<MudText Typo="Typo.caption">@context.Item.ManualAmount.ToString("N0")</MudText>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<TemplateColumn Title="درگاه">
|
||||
<CellTemplate>
|
||||
<MudText Typo="Typo.caption">@context.Item.GatewayCount عدد</MudText>
|
||||
<MudText Typo="Typo.caption">@context.Item.GatewayAmount.ToString("N0")</MudText>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<TemplateColumn Title="عملیات">
|
||||
<CellTemplate>
|
||||
<MudButton Size="Size.Small" Variant="Variant.Outlined" Color="Color.Primary"
|
||||
OnClick="() => OpenDetails(context.Item)">
|
||||
جزئیات
|
||||
</MudButton>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
</Columns>
|
||||
<NoRecordsContent>
|
||||
<MudAlert Severity="Severity.Info" Dense="true" Variant="Variant.Text" Class="my-4">موردی یافت نشد.</MudAlert>
|
||||
</NoRecordsContent>
|
||||
<PagerContent>
|
||||
<MudDataGridPager T="CustomerPackagePurchaseRollupModel" PageSizeOptions="@(new int[] { 20, 50, 100 })"
|
||||
InfoFormat="سطر {first_item} تا {last_item} از {all_items}"
|
||||
RowsPerPageString="تعداد در صفحه" />
|
||||
</PagerContent>
|
||||
</MudDataGrid>
|
||||
</Content>
|
||||
</BasePageComponent>
|
||||
|
||||
@code {
|
||||
private BasePageComponent? _basePage;
|
||||
private MudDataGrid<CustomerPackagePurchaseRollupModel>? _grid;
|
||||
private long? _userId;
|
||||
private int? _purchaseMethod;
|
||||
private DateTime? _fromDate, _toDate;
|
||||
private bool _exporting;
|
||||
|
||||
private GetCustomerPackagePurchaseRollupFilter BuildFilter()
|
||||
{
|
||||
var filter = new GetCustomerPackagePurchaseRollupFilter();
|
||||
if (_userId is > 0)
|
||||
filter.UserId = _userId;
|
||||
if (_purchaseMethod.HasValue)
|
||||
filter.PurchaseMethod = _purchaseMethod.Value;
|
||||
if (_fromDate.HasValue)
|
||||
filter.PurchasedFrom = Timestamp.FromDateTime(DateTime.SpecifyKind(_fromDate.Value.Date, DateTimeKind.Utc));
|
||||
if (_toDate.HasValue)
|
||||
filter.PurchasedTo = Timestamp.FromDateTime(DateTime.SpecifyKind(_toDate.Value.Date.AddDays(1).AddTicks(-1), DateTimeKind.Utc));
|
||||
return filter;
|
||||
}
|
||||
|
||||
private async Task<GridData<CustomerPackagePurchaseRollupModel>> LoadData(GridState<CustomerPackagePurchaseRollupModel> state)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await PurchaseClient.GetCustomerPackagePurchaseRollupAsync(
|
||||
new GetCustomerPackagePurchaseRollupRequest
|
||||
{
|
||||
PaginationState = new CMSMicroservice.Protobuf.Protos.PaginationState
|
||||
{
|
||||
PageNumber = state.Page + 1,
|
||||
PageSize = state.PageSize
|
||||
},
|
||||
Filter = BuildFilter()
|
||||
});
|
||||
|
||||
return new GridData<CustomerPackagePurchaseRollupModel>
|
||||
{
|
||||
Items = result?.Models?.ToList() ?? new(),
|
||||
TotalItems = (int)(result?.MetaData?.TotalCount ?? 0)
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا: {ex.Message}", Severity.Error);
|
||||
return new GridData<CustomerPackagePurchaseRollupModel>();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnFilterSubmit()
|
||||
{
|
||||
if (_grid != null) await _grid.ReloadServerData();
|
||||
}
|
||||
|
||||
private async Task OnFilterCleared()
|
||||
{
|
||||
_userId = null;
|
||||
_purchaseMethod = null;
|
||||
_fromDate = _toDate = null;
|
||||
if (_grid != null) await _grid.ReloadServerData();
|
||||
}
|
||||
|
||||
private async Task OpenDetails(CustomerPackagePurchaseRollupModel row)
|
||||
{
|
||||
var parameters = new DialogParameters
|
||||
{
|
||||
{ nameof(CustomerPackagePurchaseDetailsDialog.UserId), row.UserId },
|
||||
{ nameof(CustomerPackagePurchaseDetailsDialog.UserName), row.UserName }
|
||||
};
|
||||
var options = new DialogOptions { MaxWidth = MaxWidth.Medium, FullWidth = true, CloseButton = true };
|
||||
await DialogService.ShowAsync<CustomerPackagePurchaseDetailsDialog>("جزئیات خرید پکیج", parameters, options);
|
||||
}
|
||||
|
||||
private async Task ExportToExcel()
|
||||
{
|
||||
_exporting = true;
|
||||
try
|
||||
{
|
||||
// PageSize=0 → همهٔ ردیفهای مطابق فیلتر، مستقل از صفحهبندی گرید
|
||||
var result = await PurchaseClient.GetCustomerPackagePurchaseRollupAsync(
|
||||
new GetCustomerPackagePurchaseRollupRequest
|
||||
{
|
||||
PaginationState = new CMSMicroservice.Protobuf.Protos.PaginationState
|
||||
{
|
||||
PageNumber = 1,
|
||||
PageSize = 0
|
||||
},
|
||||
Filter = BuildFilter()
|
||||
});
|
||||
|
||||
var all = result?.Models?.ToList() ?? new();
|
||||
if (all.Count == 0)
|
||||
{
|
||||
Snackbar.Add("دادهای برای خروجی با فیلتر فعلی وجود ندارد.", Severity.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
var headers = new[]
|
||||
{
|
||||
"شناسه کاربر", "نام مشتری", "موبایل",
|
||||
"اولین پکیج", "مبلغ اولین", "تاریخ اولین",
|
||||
"آخرین پکیج", "مبلغ آخرین", "تاریخ آخرین", "روش آخرین",
|
||||
"تعداد خرید", "جمع مبلغ",
|
||||
"تعداد دایا", "مبلغ دایا",
|
||||
"تعداد دستی", "مبلغ دستی",
|
||||
"تعداد درگاه", "مبلغ درگاه"
|
||||
};
|
||||
|
||||
var rows = all.Select(o => new object?[]
|
||||
{
|
||||
o.UserId,
|
||||
o.UserName,
|
||||
o.UserMobile,
|
||||
o.FirstPackageName,
|
||||
o.FirstAmount,
|
||||
o.FirstPurchasedAt?.ToDateTime().ToLocalTime().MiladiToJalaliWithTime() ?? "-",
|
||||
o.LastPackageName,
|
||||
o.LastAmount,
|
||||
o.LastPurchasedAt?.ToDateTime().ToLocalTime().MiladiToJalaliWithTime() ?? "-",
|
||||
ReportLabels.GetPurchaseMethodLabel(o.LastPurchaseMethod),
|
||||
o.PurchaseCount,
|
||||
o.TotalAmount,
|
||||
o.DayaCount,
|
||||
o.DayaAmount,
|
||||
o.ManualCount,
|
||||
o.ManualAmount,
|
||||
o.GatewayCount,
|
||||
o.GatewayAmount
|
||||
});
|
||||
|
||||
var filename = $"customer-packages-{DateTime.Now:yyyyMMddHHmmss}.xls";
|
||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename,
|
||||
CsvExportHelper.ToExcelXmlBase64("مشتریان پکیج", headers, rows));
|
||||
Snackbar.Add($"خروجی Excel آماده شد ({all.Count} مشتری).", Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در خروجی Excel: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_exporting = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static Color GetMethodColor(int method) => method switch
|
||||
{
|
||||
1 => Color.Info,
|
||||
2 => Color.Primary,
|
||||
3 => Color.Secondary,
|
||||
_ => Color.Default
|
||||
};
|
||||
}
|
||||
@@ -26,6 +26,7 @@
|
||||
<MudSelectItem T="OrderStatus" Value="@OrderStatus.Processing">در حال آمادهسازی</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus" Value="@OrderStatus.Shipped">ارسال شده</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus" Value="@OrderStatus.Delivered">تحویل داده شده</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus" Value="@OrderStatus.ReadyForOfficePickup">آماده تحویل در دفتر</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus" Value="@OrderStatus.Cancelled">لغو شده</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus" Value="@OrderStatus.Returned">مرجوع شده</MudSelectItem>
|
||||
</MudSelect>
|
||||
@@ -55,6 +56,15 @@
|
||||
</MudItem>
|
||||
}
|
||||
|
||||
@if (Model.Status == OrderStatus.ReadyForOfficePickup)
|
||||
{
|
||||
<MudItem xs="12">
|
||||
<MudAlert Severity="Severity.Info">
|
||||
<MudText>سفارش برای تحویل حضوری در دفتر آماده است.</MudText>
|
||||
</MudAlert>
|
||||
</MudItem>
|
||||
}
|
||||
|
||||
@if (Model.Status == OrderStatus.Shipped)
|
||||
{
|
||||
<MudItem xs="12">
|
||||
@@ -126,8 +136,9 @@
|
||||
OrderStatus.Processing => Color.Primary,
|
||||
OrderStatus.Shipped => Color.Secondary,
|
||||
OrderStatus.Delivered => Color.Success,
|
||||
OrderStatus.Cancelled => Color.Error,
|
||||
OrderStatus.Returned => Color.Dark,
|
||||
OrderStatus.ReadyForOfficePickup => Color.Primary,
|
||||
OrderStatus.Cancelled => Color.Dark,
|
||||
OrderStatus.Returned => Color.Error,
|
||||
_ => Color.Default
|
||||
};
|
||||
}
|
||||
@@ -141,6 +152,7 @@
|
||||
OrderStatus.Processing => "در حال آمادهسازی",
|
||||
OrderStatus.Shipped => "ارسال شده",
|
||||
OrderStatus.Delivered => "تحویل داده شده",
|
||||
OrderStatus.ReadyForOfficePickup => "آماده تحویل در دفتر",
|
||||
OrderStatus.Cancelled => "لغو شده",
|
||||
OrderStatus.Returned => "مرجوع شده",
|
||||
_ => "نامشخص"
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
<MudSelectItem T="OrderStatus" Value="@OrderStatus.Processing">در حال آمادهسازی</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus" Value="@OrderStatus.Shipped">ارسال شده</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus" Value="@OrderStatus.Delivered">تحویل داده شده</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus" Value="@OrderStatus.ReadyForOfficePickup">آماده تحویل در دفتر</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus" Value="@OrderStatus.Cancelled">لغو شده</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus" Value="@OrderStatus.Returned">مرجوع شده</MudSelectItem>
|
||||
</MudSelect>
|
||||
@@ -114,6 +115,12 @@
|
||||
توجه: در صورت لغو یا مرجوعی سفارش، موجودی محصولات به انبار بازگردانده میشود.
|
||||
</MudAlert>
|
||||
}
|
||||
@if (_newStatus == OrderStatus.ReadyForOfficePickup)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Dense="true">
|
||||
سفارش برای تحویل حضوری در دفتر آماده است.
|
||||
</MudAlert>
|
||||
}
|
||||
@if (_newStatus == OrderStatus.Shipped)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Dense="true">
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
<MudSelectItem T="OrderStatus?" Value="@OrderStatus.Shipped">ارسال شده</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus?" Value="@OrderStatus.Delivered">تحویل داده شده</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus?" Value="@OrderStatus.Cancelled">لغو شده</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus?" Value="@OrderStatus.ReadyForOfficePickup">آماده تحویل در دفتر</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus?" Value="@OrderStatus.Returned">مرجوع شده</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
</Filters>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text;
|
||||
using BackOffice.Common.BaseComponents;
|
||||
using BackOffice.Common.Utilities;
|
||||
using BackOffice.Services.DiscountOrder;
|
||||
using BackOffice.Pages.DiscountShop.Components;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -187,8 +188,9 @@ public partial class DiscountOrdersMainPage
|
||||
OrderStatus.Processing => Color.Primary,
|
||||
OrderStatus.Shipped => Color.Secondary,
|
||||
OrderStatus.Delivered => Color.Success,
|
||||
OrderStatus.Cancelled => Color.Error,
|
||||
OrderStatus.Returned => Color.Dark,
|
||||
OrderStatus.Cancelled => Color.Dark,
|
||||
OrderStatus.ReadyForOfficePickup => Color.Primary,
|
||||
OrderStatus.Returned => Color.Error,
|
||||
_ => Color.Default
|
||||
};
|
||||
}
|
||||
@@ -203,6 +205,7 @@ public partial class DiscountOrdersMainPage
|
||||
OrderStatus.Shipped => "ارسال شده",
|
||||
OrderStatus.Delivered => "تحویل داده شده",
|
||||
OrderStatus.Cancelled => "لغو شده",
|
||||
OrderStatus.ReadyForOfficePickup => "آماده تحویل در دفتر",
|
||||
OrderStatus.Returned => "مرجوع شده",
|
||||
_ => "نامشخص"
|
||||
};
|
||||
@@ -242,44 +245,36 @@ public partial class DiscountOrdersMainPage
|
||||
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("شناسه,نام کاربر,موبایل,مبلغ کل,کیف پول اعتباری,پرداخت درگاه,تعداد آیتم,وضعیت پرداخت,وضعیت ارسال,تاریخ پرداخت,تاریخ ثبت,آدرس");
|
||||
|
||||
foreach (var o in _orders)
|
||||
var headers = new[]
|
||||
{
|
||||
sb.AppendLine(string.Join(",",
|
||||
o.Id,
|
||||
EscapeCsv(o.UserFullName),
|
||||
EscapeCsv(o.UserMobile),
|
||||
o.TotalPrice.ToString("N0"),
|
||||
o.DiscountBalanceUsed.ToString("N0"),
|
||||
o.GatewayAmount.ToString("N0"),
|
||||
o.ItemsCount,
|
||||
EscapeCsv(GetPaymentStatusText(o.PaymentStatusValue)),
|
||||
EscapeCsv(GetStatusText(o.Status)),
|
||||
o.PaymentDate?.MiladiToJalaliWithTime() ?? "-",
|
||||
o.Created?.MiladiToJalaliWithTime() ?? "-",
|
||||
EscapeCsv(o.ShippingAddress ?? "-")));
|
||||
}
|
||||
"شناسه", "نام مشتری", "موبایل", "مبلغ کل", "کیف پول اعتباری", "پرداخت درگاه",
|
||||
"تعداد آیتم", "وضعیت پرداخت", "وضعیت ارسال", "تاریخ پرداخت", "تاریخ ثبت", "آدرس"
|
||||
};
|
||||
|
||||
var bytes = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes(sb.ToString())).ToArray();
|
||||
var base64 = Convert.ToBase64String(bytes);
|
||||
var filename = $"discount-orders-{DateTime.Now:yyyyMMddHHmmss}.csv";
|
||||
var rows = _orders.Select(o => new object?[]
|
||||
{
|
||||
o.Id,
|
||||
CsvExportHelper.CustomerName(o.UserFullName, o.UserMobile, o.UserId),
|
||||
o.UserMobile ?? "",
|
||||
o.TotalPrice,
|
||||
o.DiscountBalanceUsed,
|
||||
o.GatewayAmount,
|
||||
o.ItemsCount,
|
||||
GetPaymentStatusText(o.PaymentStatusValue),
|
||||
GetStatusText(o.Status),
|
||||
o.PaymentDate?.MiladiToJalaliWithTime() ?? "-",
|
||||
o.Created?.MiladiToJalaliWithTime() ?? "-",
|
||||
o.ShippingAddress ?? "-"
|
||||
});
|
||||
|
||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename, base64);
|
||||
Snackbar.Add("خروجی Excel (CSV) آماده شد.", Severity.Success);
|
||||
var filename = $"discount-orders-{DateTime.Now:yyyyMMddHHmmss}.xls";
|
||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename,
|
||||
CsvExportHelper.ToExcelXmlBase64("سفارشهای اعتباری", headers, rows));
|
||||
Snackbar.Add("خروجی Excel آماده شد.", Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در خروجی Excel: {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private static string EscapeCsv(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return "";
|
||||
if (value.Contains(',') || value.Contains('"') || value.Contains('\n'))
|
||||
return $"\"{value.Replace("\"", "\"\"")}\"";
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
<MudSelectItem T="OrderStatus?" Value="OrderStatus.Processing">در حال پردازش</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus?" Value="OrderStatus.Shipped">ارسال شده</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus?" Value="OrderStatus.Delivered">تحویل شده</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus?" Value="OrderStatus.ReadyForOfficePickup">آماده تحویل در دفتر</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus?" Value="OrderStatus.Cancelled">لغو شده</MudSelectItem>
|
||||
<MudSelectItem T="OrderStatus?" Value="OrderStatus.Returned">مرجوع شده</MudSelectItem>
|
||||
</MudSelect>
|
||||
@@ -498,7 +499,8 @@
|
||||
OrderStatus.Processing => Color.Info,
|
||||
OrderStatus.Shipped => Color.Info,
|
||||
OrderStatus.Delivered => Color.Success,
|
||||
OrderStatus.Cancelled => Color.Error,
|
||||
OrderStatus.ReadyForOfficePickup => Color.Primary,
|
||||
OrderStatus.Cancelled => Color.Dark,
|
||||
OrderStatus.Returned => Color.Error,
|
||||
_ => Color.Default
|
||||
};
|
||||
@@ -513,6 +515,7 @@
|
||||
OrderStatus.Processing => "در حال پردازش",
|
||||
OrderStatus.Shipped => "ارسال شده",
|
||||
OrderStatus.Delivered => "تحویل شده",
|
||||
OrderStatus.ReadyForOfficePickup => "آماده تحویل در دفتر",
|
||||
OrderStatus.Cancelled => "لغو شده",
|
||||
OrderStatus.Returned => "مرجوع شده",
|
||||
_ => "نامشخص"
|
||||
@@ -527,28 +530,31 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("شناسه,نام کاربر,موبایل,تاریخ ثبت,تعداد آیتم,مبلغ نهایی,تخفیف,وضعیت");
|
||||
|
||||
foreach (var o in _orders.Where(o => o.Created.HasValue).OrderBy(o => o.Created))
|
||||
var headers = new[]
|
||||
{
|
||||
sb.AppendLine(string.Join(",",
|
||||
"شناسه", "نام مشتری", "موبایل", "تاریخ ثبت", "تعداد آیتم", "مبلغ نهایی", "تخفیف", "وضعیت"
|
||||
};
|
||||
|
||||
var rows = _orders
|
||||
.OrderBy(o => o.Created ?? o.PaymentDate ?? DateTime.MaxValue)
|
||||
.Select(o => new object?[]
|
||||
{
|
||||
o.Id,
|
||||
EscapeCsv(o.UserFullName),
|
||||
EscapeCsv(o.UserMobile),
|
||||
o.Created?.MiladiToJalaliWithTime() ?? "-",
|
||||
CsvExportHelper.CustomerName(o.UserFullName, o.UserMobile, o.UserId),
|
||||
o.UserMobile ?? "",
|
||||
o.Created?.MiladiToJalaliWithTime()
|
||||
?? o.PaymentDate?.MiladiToJalaliWithTime()
|
||||
?? "-",
|
||||
o.ItemsCount,
|
||||
o.GatewayAmount,
|
||||
o.DiscountBalanceUsed,
|
||||
GetStatusText(o.Status)));
|
||||
}
|
||||
GetStatusText(o.Status)
|
||||
});
|
||||
|
||||
var bytes = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes(sb.ToString())).ToArray();
|
||||
var base64 = Convert.ToBase64String(bytes);
|
||||
var filename = $"discount-sales-{DateTime.Now:yyyyMMddHHmmss}.csv";
|
||||
|
||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename, base64);
|
||||
Snackbar.Add("خروجی Excel (CSV) آماده شد.", Severity.Success);
|
||||
var filename = $"discount-sales-{DateTime.Now:yyyyMMddHHmmss}.xls";
|
||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename,
|
||||
CsvExportHelper.ToExcelXmlBase64("گزارش فروش اعتباری", headers, rows));
|
||||
Snackbar.Add("خروجی Excel آماده شد.", Severity.Success);
|
||||
}
|
||||
|
||||
private async Task ExportToPdf()
|
||||
@@ -572,12 +578,12 @@
|
||||
sb.AppendLine();
|
||||
|
||||
sb.AppendLine("جزئیات سفارشها:");
|
||||
sb.AppendLine("شناسه | نام کاربر | تاریخ | تعداد آیتم | مبلغ نهایی | تخفیف | وضعیت");
|
||||
sb.AppendLine("شناسه | نام مشتری | تاریخ | تعداد آیتم | مبلغ نهایی | تخفیف | وضعیت");
|
||||
|
||||
foreach (var o in _orders.Where(o => o.Created.HasValue).OrderBy(o => o.Created))
|
||||
{
|
||||
sb.AppendLine(
|
||||
$"{o.Id} | {o.UserFullName} | {o.Created?.MiladiToJalaliWithTime() ?? "-"} | {o.ItemsCount} | {o.GatewayAmount:N0} | {o.DiscountBalanceUsed:N0} | {GetStatusText(o.Status)}");
|
||||
$"{o.Id} | {CsvExportHelper.CustomerName(o.UserFullName, o.UserMobile, o.UserId)} | {o.Created?.MiladiToJalaliWithTime() ?? "-"} | {o.ItemsCount} | {o.GatewayAmount:N0} | {o.DiscountBalanceUsed:N0} | {GetStatusText(o.Status)}");
|
||||
}
|
||||
|
||||
var bytes = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes(sb.ToString())).ToArray();
|
||||
@@ -587,14 +593,4 @@
|
||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename, base64);
|
||||
Snackbar.Add("خروجی PDF (نسخه متنی) آماده شد.", Severity.Success);
|
||||
}
|
||||
|
||||
private static string EscapeCsv(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return "";
|
||||
|
||||
var needsQuotes = value.Contains(',') || value.Contains('"') || value.Contains('\n');
|
||||
var escaped = value.Replace("\"", "\"\"");
|
||||
return needsQuotes ? $"\"{escaped}\"" : escaped;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
<col />
|
||||
<col />
|
||||
<col />
|
||||
<col style="min-width: 180px;" />
|
||||
<col />
|
||||
<col style="width: 58px;" />
|
||||
</ColGroup>
|
||||
<ToolBarContent>
|
||||
@@ -46,8 +48,21 @@
|
||||
</CellTemplate>
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="x => x.NationalCode" Title="کدملی" />
|
||||
|
||||
|
||||
<TemplateColumn Title="آدرس پیشفرض">
|
||||
<CellTemplate>
|
||||
<MudText Typo="Typo.caption" Style="max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"
|
||||
Title="@(context.Item.DefaultAddress ?? "")">
|
||||
@(string.IsNullOrWhiteSpace(context.Item.DefaultAddress) ? "-" : context.Item.DefaultAddress)
|
||||
</MudText>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<TemplateColumn Title="کدپستی پیشفرض">
|
||||
<CellTemplate>
|
||||
<MudText Typo="Typo.caption">
|
||||
@(string.IsNullOrWhiteSpace(context.Item.DefaultPostalCode) ? "-" : context.Item.DefaultPostalCode)
|
||||
</MudText>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
|
||||
<TemplateColumn StickyLeft="true" Title="عملیات" CellStyle="text-wrap: nowrap;" HeaderStyle="text-wrap: nowrap;">
|
||||
<CellTemplate>
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
using BackOffice.Common.BaseComponents;
|
||||
using BackOffice.Common.Utilities;
|
||||
using BackOffice.Pages.User.Components;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MudBlazor;
|
||||
using System.Text;
|
||||
using DateTimeConverterCL;
|
||||
using DataModel = CMSMicroservice.Protobuf.Protos.User.GetAllUserByFilterResponseModel;
|
||||
|
||||
namespace BackOffice.Pages.User;
|
||||
@@ -84,51 +83,63 @@ public partial class UserMainPage
|
||||
{
|
||||
try
|
||||
{
|
||||
var exportRequest = new GetAllUserByFilterRequest
|
||||
var filter = _request.Filter?.Clone() ?? new();
|
||||
var all = new List<DataModel>();
|
||||
const int pageSize = 200;
|
||||
var page = 1;
|
||||
|
||||
while (page <= 500)
|
||||
{
|
||||
Filter = _request.Filter?.Clone() ?? new(),
|
||||
PaginationState = new() { PageNumber = 1, PageSize = 1000 }
|
||||
};
|
||||
var result = await UserContract.GetAllUserByFilterAsync(new GetAllUserByFilterRequest
|
||||
{
|
||||
Filter = filter,
|
||||
PaginationState = new() { PageNumber = page, PageSize = pageSize }
|
||||
});
|
||||
|
||||
var result = await UserContract.GetAllUserByFilterAsync(exportRequest);
|
||||
var batch = result?.Models?.ToList() ?? new();
|
||||
if (batch.Count == 0)
|
||||
break;
|
||||
|
||||
if (result?.Models == null || !result.Models.Any())
|
||||
all.AddRange(batch);
|
||||
|
||||
var hasNext = result?.MetaData?.HasNext == true;
|
||||
if (!hasNext || batch.Count < pageSize)
|
||||
break;
|
||||
|
||||
page++;
|
||||
}
|
||||
|
||||
if (all.Count == 0)
|
||||
{
|
||||
Snackbar.Add("دادهای برای خروجی وجود ندارد.", Severity.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("شناسه,موبایل,نام,نام خانوادگی,کدملی");
|
||||
|
||||
foreach (var u in result.Models)
|
||||
var headers = new[]
|
||||
{
|
||||
sb.AppendLine(string.Join(",",
|
||||
u.Id,
|
||||
EscapeCsv(u.Mobile),
|
||||
EscapeCsv(u.FirstName),
|
||||
EscapeCsv(u.LastName),
|
||||
EscapeCsv(u.NationalCode)));
|
||||
}
|
||||
"شناسه", "موبایل", "نام", "نام خانوادگی", "کدملی",
|
||||
"آدرس پیشفرض", "کدپستی پیشفرض"
|
||||
};
|
||||
|
||||
var bytes = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes(sb.ToString())).ToArray();
|
||||
var base64 = Convert.ToBase64String(bytes);
|
||||
var filename = $"users-{DateTime.Now:yyyyMMddHHmmss}.csv";
|
||||
var rows = all.Select(u => new object?[]
|
||||
{
|
||||
u.Id,
|
||||
u.Mobile,
|
||||
u.FirstName,
|
||||
u.LastName,
|
||||
u.NationalCode,
|
||||
u.DefaultAddress,
|
||||
u.DefaultPostalCode
|
||||
});
|
||||
|
||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename, base64);
|
||||
Snackbar.Add("خروجی Excel (CSV) آماده شد.", Severity.Success);
|
||||
var filename = $"users-{DateTime.Now:yyyyMMddHHmmss}.xls";
|
||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename,
|
||||
CsvExportHelper.ToExcelXmlBase64("کاربران", headers, rows));
|
||||
Snackbar.Add($"خروجی Excel آماده شد ({all.Count} کاربر).", Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در خروجی Excel: {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private static string EscapeCsv(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return "";
|
||||
if (value.Contains(',') || value.Contains('"') || value.Contains('\n'))
|
||||
return $"\"{value.Replace("\"", "\"\"")}\"";
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
<MudSelectItem T="int" Value="2">تحویل پست</MudSelectItem>
|
||||
<MudSelectItem T="int" Value="3">تحویل به مشتری</MudSelectItem>
|
||||
<MudSelectItem T="int" Value="4">مرجوع شده</MudSelectItem>
|
||||
<MudSelectItem T="int" Value="5">لغو شده</MudSelectItem>
|
||||
<MudSelectItem T="int" Value="6">آماده تحویل در دفتر</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
|
||||
@@ -56,6 +58,24 @@
|
||||
</MudItem>
|
||||
}
|
||||
|
||||
@if (_newStatus == 5)
|
||||
{
|
||||
<MudItem xs="12">
|
||||
<MudAlert Severity="Severity.Warning">
|
||||
توجه: وضعیت «لغو شده» یعنی ارسال این سفارش متوقف شده است.
|
||||
</MudAlert>
|
||||
</MudItem>
|
||||
}
|
||||
|
||||
@if (_newStatus == 6)
|
||||
{
|
||||
<MudItem xs="12">
|
||||
<MudAlert Severity="Severity.Info">
|
||||
سفارش برای تحویل حضوری در دفتر آماده است.
|
||||
</MudAlert>
|
||||
</MudItem>
|
||||
}
|
||||
|
||||
@if (_newStatus == 2)
|
||||
{
|
||||
<MudItem xs="12">
|
||||
|
||||
@@ -37,6 +37,8 @@ public partial class ChangeOrderStatusDialog
|
||||
2 => "تحویل پست",
|
||||
3 => "تحویل به مشتری",
|
||||
4 => "مرجوع شده",
|
||||
5 => "لغو شده",
|
||||
6 => "آماده تحویل در دفتر",
|
||||
_ => "بدون ارسال / نامشخص"
|
||||
};
|
||||
}
|
||||
@@ -49,6 +51,8 @@ public partial class ChangeOrderStatusDialog
|
||||
2 => Color.Info,
|
||||
3 => Color.Success,
|
||||
4 => Color.Error,
|
||||
5 => Color.Dark,
|
||||
6 => Color.Primary,
|
||||
_ => Color.Default
|
||||
};
|
||||
}
|
||||
|
||||
@@ -95,6 +95,8 @@
|
||||
<MudSelectItem T="int" Value="2">تحویل پست</MudSelectItem>
|
||||
<MudSelectItem T="int" Value="3">تحویل به مشتری</MudSelectItem>
|
||||
<MudSelectItem T="int" Value="4">مرجوع شده</MudSelectItem>
|
||||
<MudSelectItem T="int" Value="5">لغو شده</MudSelectItem>
|
||||
<MudSelectItem T="int" Value="6">آماده تحویل در دفتر</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudText>
|
||||
<MudTextField T="string"
|
||||
|
||||
@@ -59,6 +59,8 @@ public partial class UserOrderDetailsDialog
|
||||
2 => Color.Info, // InTransit
|
||||
3 => Color.Success, // Delivered
|
||||
4 => Color.Error, // Returned
|
||||
5 => Color.Dark, // Cancelled
|
||||
6 => Color.Primary, // ReadyForOfficePickup
|
||||
_ => Color.Default // None / Unknown
|
||||
};
|
||||
}
|
||||
@@ -71,6 +73,8 @@ public partial class UserOrderDetailsDialog
|
||||
2 => "تحویل پست",
|
||||
3 => "تحویل به مشتری",
|
||||
4 => "مرجوع شده",
|
||||
5 => "لغو شده",
|
||||
6 => "آماده تحویل در دفتر",
|
||||
_ => "بدون ارسال / نامشخص"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
<MudSelectItem T="int?" Value="@(3)">تحویل به مشتری</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@(4)">مرجوع شده</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@(5)">لغو شده</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@(6)">آماده تحویل در دفتر</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text;
|
||||
using BackOffice.Common.Utilities;
|
||||
using CMSMicroservice.Protobuf.Protos;
|
||||
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -215,7 +216,8 @@ public partial class OrderSalesReports
|
||||
2 => Color.Info,
|
||||
3 => Color.Success,
|
||||
4 => Color.Error,
|
||||
5 => Color.Error,
|
||||
5 => Color.Dark,
|
||||
6 => Color.Primary,
|
||||
_ => Color.Default
|
||||
};
|
||||
}
|
||||
@@ -229,6 +231,7 @@ public partial class OrderSalesReports
|
||||
3 => "تحویل به مشتری",
|
||||
4 => "مرجوع شده",
|
||||
5 => "لغو شده",
|
||||
6 => "آماده تحویل در دفتر",
|
||||
_ => "بدون ارسال / نامشخص"
|
||||
};
|
||||
}
|
||||
@@ -241,27 +244,26 @@ public partial class OrderSalesReports
|
||||
return;
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("شناسه,کاربر,نام کاربر,مبلغ,وضعیت پرداخت,وضعیت ارسال,تاریخ پرداخت");
|
||||
|
||||
foreach (var o in _orders)
|
||||
var headers = new[]
|
||||
{
|
||||
sb.AppendLine(string.Join(",",
|
||||
o.Id,
|
||||
o.UserId,
|
||||
EscapeCsv(o.UserFullName),
|
||||
o.Amount,
|
||||
EscapeCsv(o.PaymentStatus == PaymentStatus.Success ? "پرداخت شده" : "پرداخت نشده"),
|
||||
EscapeCsv(GetDeliveryStatusText(o.DeliveryStatus.GetHashCode())),
|
||||
o.PaymentDate != null ? o.PaymentDate.ToDateTime().MiladiToJalaliWithTime() : "-"));
|
||||
}
|
||||
"شناسه", "کاربر", "نام مشتری", "مبلغ", "وضعیت پرداخت", "وضعیت ارسال", "تاریخ پرداخت"
|
||||
};
|
||||
|
||||
var bytes = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes(sb.ToString())).ToArray();
|
||||
var base64 = Convert.ToBase64String(bytes);
|
||||
var filename = $"store-sales-{DateTime.Now:yyyyMMddHHmmss}.csv";
|
||||
var rows = _orders.Select(o => new object?[]
|
||||
{
|
||||
o.Id,
|
||||
o.UserId,
|
||||
CsvExportHelper.CustomerName(o.UserFullName, userId: o.UserId),
|
||||
o.Amount,
|
||||
o.PaymentStatus == PaymentStatus.Success ? "پرداخت شده" : "پرداخت نشده",
|
||||
GetDeliveryStatusText(o.DeliveryStatus.GetHashCode()),
|
||||
o.PaymentDate != null ? o.PaymentDate.ToDateTime().MiladiToJalaliWithTime() : "-"
|
||||
});
|
||||
|
||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename, base64);
|
||||
Snackbar.Add("خروجی Excel (CSV) آماده شد.", Severity.Success);
|
||||
var filename = $"store-sales-{DateTime.Now:yyyyMMddHHmmss}.xls";
|
||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename,
|
||||
CsvExportHelper.ToExcelXmlBase64("گزارش فروش", headers, rows));
|
||||
Snackbar.Add("خروجی Excel آماده شد.", Severity.Success);
|
||||
}
|
||||
|
||||
protected async Task ExportToPdf()
|
||||
@@ -290,7 +292,7 @@ public partial class OrderSalesReports
|
||||
foreach (var o in _orders)
|
||||
{
|
||||
sb.AppendLine(
|
||||
$"{o.Id} | {o.UserFullName} | {o.Amount:N0} | {(o.PaymentStatus == PaymentStatus.Success ? "پرداخت شده" : "پرداخت نشده")} | {GetDeliveryStatusText(o.DeliveryStatus.GetHashCode())} | {(o.PaymentDate != null ? o.PaymentDate.ToDateTime().MiladiToJalaliWithTime() : "-")}");
|
||||
$"{o.Id} | {CsvExportHelper.CustomerName(o.UserFullName, userId: o.UserId)} | {o.Amount:N0} | {(o.PaymentStatus == PaymentStatus.Success ? "پرداخت شده" : "پرداخت نشده")} | {GetDeliveryStatusText(o.DeliveryStatus.GetHashCode())} | {(o.PaymentDate != null ? o.PaymentDate.ToDateTime().MiladiToJalaliWithTime() : "-")}");
|
||||
}
|
||||
|
||||
var bytes = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes(sb.ToString())).ToArray();
|
||||
@@ -349,12 +351,4 @@ public partial class OrderSalesReports
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static string EscapeCsv(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return "";
|
||||
if (value.Contains(',') || value.Contains('"') || value.Contains('\n'))
|
||||
return $"\"{value.Replace("\"", "\"\"")}\"";
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
<MudSelectItem T="int?" Value="@(3)">تحویل به مشتری</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@(4)">مرجوع شده</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@(5)">لغو شده</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@(6)">آماده تحویل در دفتر</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
</Filters>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System.Text.Json;
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using BackOffice.Common.BaseComponents;
|
||||
using BackOffice.Common.Utilities;
|
||||
using CMSMicroservice.Protobuf.Protos;
|
||||
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||
using BackOffice.Common.BaseComponents;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MudBlazor;
|
||||
@@ -213,6 +214,8 @@ public partial class UserOrderMainPage
|
||||
2 => Color.Info, // InTransit
|
||||
3 => Color.Success, // Delivered
|
||||
4 => Color.Error, // Returned
|
||||
5 => Color.Dark, // Cancelled
|
||||
6 => Color.Primary, // ReadyForOfficePickup
|
||||
_ => Color.Default // None / Unknown
|
||||
};
|
||||
}
|
||||
@@ -225,6 +228,8 @@ public partial class UserOrderMainPage
|
||||
2 => "تحویل پست",
|
||||
3 => "تحویل به مشتری",
|
||||
4 => "مرجوع شده",
|
||||
5 => "لغو شده",
|
||||
6 => "آماده تحویل در دفتر",
|
||||
_ => "بدون ارسال / نامشخص"
|
||||
};
|
||||
}
|
||||
@@ -238,6 +243,15 @@ public partial class UserOrderMainPage
|
||||
};
|
||||
}
|
||||
|
||||
// Domain PaymentStatus: Success=0, Reject=1, Pending=2
|
||||
private static string GetPaymentStatusText(int status) => status switch
|
||||
{
|
||||
0 => "پرداخت شده",
|
||||
1 => "پرداخت ناموفق",
|
||||
2 => "در انتظار پرداخت",
|
||||
_ => "نامشخص"
|
||||
};
|
||||
|
||||
private async Task OpenChangeStatus(DataModel model)
|
||||
{
|
||||
var parameters = new DialogParameters
|
||||
@@ -315,40 +329,31 @@ public partial class UserOrderMainPage
|
||||
return;
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("شناسه,کاربر,نام کاربر,مبلغ,وضعیت پرداخت,وضعیت ارسال,روش پرداخت,تاریخ پرداخت");
|
||||
|
||||
foreach (var o in result.Models)
|
||||
var headers = new[]
|
||||
{
|
||||
sb.AppendLine(string.Join(",",
|
||||
o.Id,
|
||||
o.UserId,
|
||||
EscapeCsv(o.UserFullName),
|
||||
o.Amount,
|
||||
EscapeCsv(o.PaymentStatus.ToString()),
|
||||
EscapeCsv(GetDeliveryStatusText(o.DeliveryStatus.GetHashCode())),
|
||||
EscapeCsv(GetPaymentMethodText(o.PaymentMethod.GetHashCode())),
|
||||
o.PaymentDate?.ToDateTime().ToLocalTime().MiladiToJalaliWithTime() ?? "-"));
|
||||
}
|
||||
"شناسه", "کاربر", "نام مشتری", "مبلغ", "وضعیت پرداخت", "وضعیت ارسال", "روش پرداخت", "تاریخ پرداخت"
|
||||
};
|
||||
|
||||
var bytes = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes(sb.ToString())).ToArray();
|
||||
var base64 = Convert.ToBase64String(bytes);
|
||||
var filename = $"user-orders-{DateTime.Now:yyyyMMddHHmmss}.csv";
|
||||
var rows = result.Models.Select(o => new object?[]
|
||||
{
|
||||
o.Id,
|
||||
o.UserId,
|
||||
CsvExportHelper.CustomerName(o.UserFullName, userId: o.UserId),
|
||||
o.Amount,
|
||||
GetPaymentStatusText(o.PaymentStatus.GetHashCode()),
|
||||
GetDeliveryStatusText(o.DeliveryStatus.GetHashCode()),
|
||||
GetPaymentMethodText(o.PaymentMethod.GetHashCode()),
|
||||
o.PaymentDate?.ToDateTime().ToLocalTime().MiladiToJalaliWithTime() ?? "-"
|
||||
});
|
||||
|
||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename, base64);
|
||||
Snackbar.Add("خروجی Excel (CSV) آماده شد.", Severity.Success);
|
||||
var filename = $"user-orders-{DateTime.Now:yyyyMMddHHmmss}.xls";
|
||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename,
|
||||
CsvExportHelper.ToExcelXmlBase64("سفارشها", headers, rows));
|
||||
Snackbar.Add("خروجی Excel آماده شد.", Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در خروجی Excel: {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private static string EscapeCsv(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return "";
|
||||
if (value.Contains(',') || value.Contains('"') || value.Contains('\n'))
|
||||
return $"\"{value.Replace("\"", "\"\"")}\"";
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,12 +201,13 @@ public class DiscountOrderService : IDiscountOrderService
|
||||
return status switch
|
||||
{
|
||||
OrderStatus.Pending => ProtoDeliveryStatus.DeliveryPending,
|
||||
OrderStatus.Paid => ProtoDeliveryStatus.DeliveryPending, // Paid but not processed yet
|
||||
OrderStatus.Paid => ProtoDeliveryStatus.DeliveryPending,
|
||||
OrderStatus.Processing => ProtoDeliveryStatus.DeliveryProcessing,
|
||||
OrderStatus.Shipped => ProtoDeliveryStatus.DeliveryShipped,
|
||||
OrderStatus.Delivered => ProtoDeliveryStatus.DeliveryDelivered,
|
||||
OrderStatus.Cancelled => ProtoDeliveryStatus.DeliveryCancelled,
|
||||
OrderStatus.Returned => ProtoDeliveryStatus.DeliveryCancelled, // Treat as cancelled
|
||||
OrderStatus.ReadyForOfficePickup => ProtoDeliveryStatus.DeliveryReadyForOffice,
|
||||
OrderStatus.Returned => ProtoDeliveryStatus.DeliveryReturned,
|
||||
_ => ProtoDeliveryStatus.DeliveryPending
|
||||
};
|
||||
}
|
||||
@@ -222,6 +223,8 @@ public class DiscountOrderService : IDiscountOrderService
|
||||
ProtoDeliveryStatus.DeliveryShipped => OrderStatus.Shipped,
|
||||
ProtoDeliveryStatus.DeliveryDelivered => OrderStatus.Delivered,
|
||||
ProtoDeliveryStatus.DeliveryCancelled => OrderStatus.Cancelled,
|
||||
ProtoDeliveryStatus.DeliveryReadyForOffice => OrderStatus.ReadyForOfficePickup,
|
||||
ProtoDeliveryStatus.DeliveryReturned => OrderStatus.Returned,
|
||||
_ => OrderStatus.Pending
|
||||
};
|
||||
}
|
||||
@@ -236,6 +239,8 @@ public class DiscountOrderService : IDiscountOrderService
|
||||
ProtoDeliveryStatus.DeliveryShipped => OrderStatus.Shipped,
|
||||
ProtoDeliveryStatus.DeliveryDelivered => OrderStatus.Delivered,
|
||||
ProtoDeliveryStatus.DeliveryCancelled => OrderStatus.Cancelled,
|
||||
ProtoDeliveryStatus.DeliveryReadyForOffice => OrderStatus.ReadyForOfficePickup,
|
||||
ProtoDeliveryStatus.DeliveryReturned => OrderStatus.Returned,
|
||||
_ => OrderStatus.Pending
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,13 +27,14 @@ public class OrderFilterDto
|
||||
// For backward compatibility with UI - maps to proto DeliveryStatus
|
||||
public enum OrderStatus
|
||||
{
|
||||
Pending = 0, // DELIVERY_PENDING
|
||||
Paid = 1, // Not in proto - handle in service
|
||||
Processing = 2, // DELIVERY_PROCESSING
|
||||
Shipped = 3, // DELIVERY_SHIPPED
|
||||
Delivered = 4, // DELIVERY_DELIVERED
|
||||
Cancelled = 5, // DELIVERY_CANCELLED
|
||||
Returned = 6 // Not in proto - handle in service
|
||||
Pending = 0, // DELIVERY_PENDING
|
||||
Paid = 1, // Not in proto - handle in service
|
||||
Processing = 2, // DELIVERY_PROCESSING
|
||||
Shipped = 3, // DELIVERY_SHIPPED
|
||||
Delivered = 4, // DELIVERY_DELIVERED
|
||||
Cancelled = 5, // DELIVERY_CANCELLED
|
||||
Returned = 6, // DELIVERY_RETURNED
|
||||
ReadyForOfficePickup = 7 // DELIVERY_READY_FOR_OFFICE
|
||||
}
|
||||
|
||||
public class DiscountOrderDto
|
||||
|
||||
@@ -77,6 +77,11 @@
|
||||
Icon="@Icons.Material.Filled.Groups">
|
||||
اعضا و گزارشها
|
||||
</MudNavLink>
|
||||
<MudNavLink Match="NavLinkMatch.Prefix"
|
||||
Href="/club/customer-packages"
|
||||
Icon="@Icons.Material.Filled.PeopleAlt">
|
||||
گزارش مشتریان پکیج
|
||||
</MudNavLink>
|
||||
<MudNavLink Match="NavLinkMatch.Prefix"
|
||||
Href="/club/features"
|
||||
Icon="@Icons.Material.Filled.Star">
|
||||
|
||||
Reference in New Issue
Block a user