| | | 1 | | using System.Text.Json; |
| | | 2 | | using System.Text.Json.Serialization; |
| | | 3 | | |
| | | 4 | | namespace OzonOrdersWeb.Authorization; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Единый перечень страниц Studio2 для меню «Заказы» и «Провести документ» (пресеты / seed / фильтр по правам). |
| | | 8 | | /// </summary> |
| | | 9 | | public static class Studio2RolePageMenuCatalog |
| | | 10 | | { |
| | | 11 | | public const string PresetKeyOrders = "ordersMenu"; |
| | | 12 | | public const string PresetKeyTransactions = "transactionsMenu"; |
| | | 13 | | public const string PresetKeyOrdersAndTransactions = "ordersAndTransactions"; |
| | | 14 | | |
| | | 15 | | // --- Пресеты: одна транзакция (ключи для JSON / data-tx-preset) --- |
| | | 16 | | public const string PresetKeyTxOrderToSupplier = "txOrderToSupplier"; |
| | | 17 | | public const string PresetKeyTxOrderedToSeller = "txOrderedToSeller"; |
| | | 18 | | public const string PresetKeyTxShippedBySupplier = "txShippedBySupplier"; |
| | | 19 | | public const string PresetKeyTxShippedToSeller = "txShippedToSeller"; |
| | | 20 | | public const string PresetKeyTxAcceptedToWarehouse = "txAcceptedToWarehouse"; |
| | | 21 | | public const string PresetKeyTxShippedToClient = "txShippedToClient"; |
| | | 22 | | public const string PresetKeyTxCustomerReturn = "txCustomerReturn"; |
| | | 23 | | public const string PresetKeyTxReturnToSupplier = "txReturnToSupplier"; |
| | | 24 | | public const string PresetKeyTxReturnToWarehouse = "txReturnToWarehouse"; |
| | | 25 | | public const string PresetKeyTxWarehouseChange = "txWarehouseChange"; |
| | | 26 | | public const string PresetKeyTxWarehouseTransfer = "txWarehouseTransfer"; |
| | | 27 | | public const string PresetKeyTxShippedToCommissioner = "txShippedToCommissioner"; |
| | | 28 | | public const string PresetKeyTxToCancellation = "txToCancellation"; |
| | | 29 | | public const string PresetKeyTxCancelled = "txCancelled"; |
| | | 30 | | public const string PresetKeyTxReturnTransfer = "txReturnTransfer"; |
| | | 31 | | public const string PresetKeyTxLostByCommissioner = "txLostByCommissioner"; |
| | | 32 | | |
| | | 33 | | /// <summary>Страницы под секцией «Заказы (Studio2)» в seed — оформление в дереве.</summary> |
| | 1 | 34 | | public static readonly Studio2MenuPageRow[] OrderRows = |
| | 1 | 35 | | { |
| | 1 | 36 | | new("Studio2.Orders.Index", "Studio2.Section.Orders", 1, "Список заказов", "fas fa-th-list", "text-body"), |
| | 1 | 37 | | new("Studio2.Orders.Returns", "Studio2.Section.Orders", 2, "Журнал возвратов", "fas fa-undo", "text-body"), |
| | 1 | 38 | | new("Studio2.Orders.MultiplayEditV2", "Studio2.Section.Orders", 3, "Множественное редактирование (v2)", "fas fa- |
| | 1 | 39 | | new("Studio2.Orders.Details", "Studio2.Section.Orders", 4, "Карточка заказа", "fas fa-file-alt", "text-body"), |
| | 1 | 40 | | new("Studio2.Orders.CancellationOrders", "Studio2.Section.Orders", 5, "Массовая отмена заказов", "fas fa-ban", " |
| | 1 | 41 | | }; |
| | | 42 | | |
| | 1 | 43 | | public static readonly Studio2MenuPageRow[] TransactionRows = |
| | 1 | 44 | | { |
| | 1 | 45 | | new("Studio2.OrderToSupplierTransaction.CreateOrderToSupplierTransactionV2", "Studio2.Section.TxMain", 1, "Заказ |
| | 1 | 46 | | new("Studio2.OrderedToSellerTransaction.CreateOrderedToSellerTransaction", "Studio2.Section.TxMain", 2, "Заказан |
| | 1 | 47 | | new("Studio2.ShippedBySupplierTransaction.CreateShippedBySupplierTransaction", "Studio2.Section.TxMain", 3, "Отг |
| | 1 | 48 | | new("Studio2.ShippedToSellerTransaction.CreateShippedToSellerTransaction", "Studio2.Section.TxMain", 4, "Отгруже |
| | 1 | 49 | | new("Studio2.ShippedToCommissionerTransaction.CreateShippedToCommissionerTransaction", "Studio2.Section.TxMain", |
| | 1 | 50 | | new("Studio2.AcceptedToWarehouseTransaction.AcceptedToWarehouseTransaction", "Studio2.Section.TxMain", 6, "Приня |
| | 1 | 51 | | new("Studio2.ShippedToClientTransaction.CreateShippedToClientTransaction", "Studio2.Section.TxMain", 7, "Отгруже |
| | 1 | 52 | | new("Studio2.CustomerReturnTransaction.CreateCustomerReturnTransaction", "Studio2.Section.TxReturns", 1, "Возвра |
| | 1 | 53 | | new("Studio2.ReturnToSupplierTransaction.CreateReturnToSupplierTransaction", "Studio2.Section.TxReturns", 2, "Во |
| | 1 | 54 | | new("Studio2.ReturnToWarehouseTransaction.CreateReturnToWarehouseTransaction", "Studio2.Section.TxReturns", 3, " |
| | 1 | 55 | | new("Studio2.WarehouseChangeTransaction.CreateWarehouseChangeTransaction", "Studio2.Section.TxWarehouse", 1, "Из |
| | 1 | 56 | | new("Studio2.WarehouseTransferTransaction.CreateWarehouseTransferTransaction", "Studio2.Section.TxWarehouse", 2, |
| | 1 | 57 | | new("Studio2.ReturnTransferTransaction.CreateReturnTransferTransaction", "Studio2.Section.TxReturns", 4, "Переме |
| | 1 | 58 | | new("Studio2.LostByCommissionerTransaction.CreateLostByCommissionerTransaction", "Studio2.Section.TxReturns", 5, |
| | 1 | 59 | | new("Studio2.ToCancellationTransaction.CreateToCancellationTransaction", "Studio2.Section.TxCancel", 1, "К отмен |
| | 1 | 60 | | new("Studio2.CancelledTransaction.CreateCancelledTransaction", "Studio2.Section.TxCancel", 2, "Отменен", "fas fa |
| | 1 | 61 | | }; |
| | | 62 | | |
| | 1 | 63 | | private static readonly (string PresetKey, string Code)[] TransactionSinglePresets = |
| | 1 | 64 | | { |
| | 1 | 65 | | (PresetKeyTxOrderToSupplier, "Studio2.OrderToSupplierTransaction.CreateOrderToSupplierTransactionV2"), |
| | 1 | 66 | | (PresetKeyTxOrderedToSeller, "Studio2.OrderedToSellerTransaction.CreateOrderedToSellerTransaction"), |
| | 1 | 67 | | (PresetKeyTxShippedBySupplier, "Studio2.ShippedBySupplierTransaction.CreateShippedBySupplierTransaction"), |
| | 1 | 68 | | (PresetKeyTxShippedToSeller, "Studio2.ShippedToSellerTransaction.CreateShippedToSellerTransaction"), |
| | 1 | 69 | | (PresetKeyTxShippedToCommissioner, "Studio2.ShippedToCommissionerTransaction.CreateShippedToCommissionerTransact |
| | 1 | 70 | | (PresetKeyTxAcceptedToWarehouse, "Studio2.AcceptedToWarehouseTransaction.AcceptedToWarehouseTransaction"), |
| | 1 | 71 | | (PresetKeyTxShippedToClient, "Studio2.ShippedToClientTransaction.CreateShippedToClientTransaction"), |
| | 1 | 72 | | (PresetKeyTxCustomerReturn, "Studio2.CustomerReturnTransaction.CreateCustomerReturnTransaction"), |
| | 1 | 73 | | (PresetKeyTxReturnToSupplier, "Studio2.ReturnToSupplierTransaction.CreateReturnToSupplierTransaction"), |
| | 1 | 74 | | (PresetKeyTxReturnToWarehouse, "Studio2.ReturnToWarehouseTransaction.CreateReturnToWarehouseTransaction"), |
| | 1 | 75 | | (PresetKeyTxWarehouseChange, "Studio2.WarehouseChangeTransaction.CreateWarehouseChangeTransaction"), |
| | 1 | 76 | | (PresetKeyTxWarehouseTransfer, "Studio2.WarehouseTransferTransaction.CreateWarehouseTransferTransaction"), |
| | 1 | 77 | | (PresetKeyTxToCancellation, "Studio2.ToCancellationTransaction.CreateToCancellationTransaction"), |
| | 1 | 78 | | (PresetKeyTxCancelled, "Studio2.CancelledTransaction.CreateCancelledTransaction"), |
| | 1 | 79 | | (PresetKeyTxReturnTransfer, "Studio2.ReturnTransferTransaction.CreateReturnTransferTransaction"), |
| | 1 | 80 | | (PresetKeyTxLostByCommissioner, "Studio2.LostByCommissionerTransaction.CreateLostByCommissionerTransaction"), |
| | 1 | 81 | | }; |
| | | 82 | | |
| | | 83 | | /// <summary>Полный набор <c>Studio2.Orders.*</c> для пресета «Заказы» (плюс основные список/карточка/мультир-редакт |
| | 1 | 84 | | public static readonly IReadOnlyList<string> OrderPresetPageCodes = new[] |
| | 1 | 85 | | { |
| | 1 | 86 | | "Studio2.Orders.Index", |
| | 1 | 87 | | "Studio2.Orders.Returns", |
| | 1 | 88 | | "Studio2.Orders.MultiplayEditV2", |
| | 1 | 89 | | "Studio2.Orders.Details", |
| | 1 | 90 | | "Studio2.Orders.AddIdsToSession", |
| | 1 | 91 | | "Studio2.Orders.AddIdToSession", |
| | 1 | 92 | | "Studio2.Orders.AppendFile", |
| | 1 | 93 | | "Studio2.Orders.CancellationOrders", |
| | 1 | 94 | | "Studio2.Orders.CheckLabelsInDropbox", |
| | 1 | 95 | | "Studio2.Orders.CheckOrderUnique", |
| | 1 | 96 | | "Studio2.Orders.ClearLabelsSession", |
| | 1 | 97 | | "Studio2.Orders.ClearSelectedIdsSession", |
| | 1 | 98 | | "Studio2.Orders.ConfirmAccepted", |
| | 1 | 99 | | "Studio2.Orders.ConfirmAcceptedV2", |
| | 1 | 100 | | "Studio2.Orders.DeleteDuplicateOrders", |
| | 1 | 101 | | "Studio2.Orders.DeleteOrderPage", |
| | 1 | 102 | | "Studio2.Orders.DeleteV2", |
| | 1 | 103 | | "Studio2.Orders.DelSortStateCookie", |
| | 1 | 104 | | "Studio2.Orders.DelSortStateCookieForV2", |
| | 1 | 105 | | "Studio2.Orders.DownloadLabels", |
| | 1 | 106 | | "Studio2.Orders.GenerateLabels", |
| | 1 | 107 | | "Studio2.Orders.GenerateYandexLabels", |
| | 1 | 108 | | "Studio2.Orders.GetClientStatusesByClient", |
| | 1 | 109 | | "Studio2.Orders.GetClientStatusesByClientType", |
| | 1 | 110 | | "Studio2.Orders.GetCurrencyByCode", |
| | 1 | 111 | | "Studio2.Orders.GetEtProducerMarketPrefix", |
| | 1 | 112 | | "Studio2.Orders.GetEtProducersByArticle", |
| | 1 | 113 | | "Studio2.Orders.GetOzonLabelEligibleOrders", |
| | 1 | 114 | | "Studio2.Orders.GetOrderProducts", |
| | 1 | 115 | | "Studio2.Orders.GetProductByArticle", |
| | 1 | 116 | | "Studio2.Orders.GetSelectedIdsFromSession", |
| | 1 | 117 | | "Studio2.Orders.GroupFileData", |
| | 1 | 118 | | "Studio2.Orders.MultiplayDeleteOrders", |
| | 1 | 119 | | "Studio2.Orders.MultiplayDeleteOrdersV2", |
| | 1 | 120 | | "Studio2.Orders.MultiplayUpdateOrdersStatusV2", |
| | 1 | 121 | | "Studio2.Orders.NewValuesProcessing", |
| | 1 | 122 | | "Studio2.Orders.OrderDetailedInformation", |
| | 1 | 123 | | "Studio2.Orders.OrderDetailedInformationForBitrix", |
| | 1 | 124 | | "Studio2.Orders.OrderStocks", |
| | 1 | 125 | | "Studio2.Orders.OrderSubstitute", |
| | 1 | 126 | | "Studio2.Orders.PrepaExcelTable", |
| | 1 | 127 | | "Studio2.Orders.PrintOrdersExcel", |
| | 1 | 128 | | "Studio2.Orders.PrintOrdersExcelForClient", |
| | 1 | 129 | | "Studio2.Orders.PrintOrdersExcelV2", |
| | 1 | 130 | | "Studio2.Orders.PrintOrdersLable", |
| | 1 | 131 | | "Studio2.Orders.ProcessNotFullOrdersInBackground", |
| | 1 | 132 | | "Studio2.Orders.Recover", |
| | 1 | 133 | | "Studio2.Orders.RemoveIdFromSession", |
| | 1 | 134 | | "Studio2.Orders.RemoveIdsFromSession", |
| | 1 | 135 | | "Studio2.Orders.SaveSelectedStockListToSession", |
| | 1 | 136 | | "Studio2.Orders.SearchArticleByEAN", |
| | 1 | 137 | | "Studio2.Orders.SearchEtProducers", |
| | 1 | 138 | | "Studio2.Orders.SetFilterLists", |
| | 1 | 139 | | "Studio2.Orders.SetNotFullOrdersData", |
| | 1 | 140 | | "Studio2.Orders.SetPageSize", |
| | 1 | 141 | | "Studio2.Orders.SetPageSizeForV2", |
| | 1 | 142 | | "Studio2.Orders.SplitOrder", |
| | 1 | 143 | | "Studio2.Orders.SplitOrderFromSetNotFull", |
| | 1 | 144 | | "Studio2.Orders.SplitOrders", |
| | 1 | 145 | | "Studio2.Orders.Update", |
| | 1 | 146 | | "Studio2.Orders.UpdateOrdersStatus", |
| | 1 | 147 | | "Studio2.Orders.UpdateOrdersStatusInBackground", |
| | 1 | 148 | | "Studio2.Orders.UpdateV2", |
| | 1 | 149 | | "Studio2.Orders.Upload", |
| | 1 | 150 | | "Studio2.Orders.UploadClientsData", |
| | 1 | 151 | | "Studio2.Orders.UploadExcelFile", |
| | 1 | 152 | | "Studio2.Orders.UploadExcelOrders", |
| | 1 | 153 | | "Studio2.Orders.UploadFile", |
| | 1 | 154 | | "Studio2.Orders.UploadInBackground", |
| | 1 | 155 | | "Studio2.Orders.ViewFile", |
| | 1 | 156 | | "Studio2.Orders.ViewOrders", |
| | 1 | 157 | | }; |
| | | 158 | | |
| | | 159 | | /// <summary>Коды «заказов» для пресетов/комбинирования (тот же состав, что <see cref="OrderPresetPageCodes"/>, с ун |
| | 2 | 160 | | public static IReadOnlyList<string> OrderPageCodes { get; } = OrderPresetPageCodes.Distinct(StringComparer.Ordinal). |
| | | 161 | | |
| | 20 | 162 | | public static IReadOnlyList<string> TransactionPageCodes { get; } = TransactionRows.Select(r => r.Code).ToList(); |
| | | 163 | | |
| | | 164 | | /// <summary>Коды страниц, которые проверяются в выпадающем «Провести документ» (транзакции + массовая отмена заказо |
| | 2 | 165 | | public static IReadOnlyList<string> TransactionDropdownPageCodes { get; } = TransactionPageCodes |
| | 1 | 166 | | .Append("Studio2.Orders.CancellationOrders") |
| | 1 | 167 | | .ToList(); |
| | | 168 | | |
| | 1 | 169 | | public static IReadOnlyList<string> OrdersAndTransactionPageCodes { get; } = OrderPageCodes |
| | 1 | 170 | | .Concat(TransactionPageCodes) |
| | 1 | 171 | | .Distinct(StringComparer.Ordinal) |
| | 1 | 172 | | .ToList(); |
| | | 173 | | |
| | 1 | 174 | | public static IReadOnlyList<string> AllTransactionMvcPaths { get; } = TransactionPageCodes |
| | 1 | 175 | | .Select(ToMvcPath) |
| | 1 | 176 | | .ToList(); |
| | | 177 | | |
| | 1 | 178 | | public static IReadOnlyList<string> AllTransactionDropdownMvcPaths { get; } = TransactionDropdownPageCodes |
| | 1 | 179 | | .Select(ToMvcPath) |
| | 1 | 180 | | .ToList(); |
| | | 181 | | |
| | | 182 | | private static IReadOnlyDictionary<string, IReadOnlyList<string>> BuildRolePagePresetsMap() |
| | | 183 | | { |
| | 0 | 184 | | var d = new Dictionary<string, IReadOnlyList<string>>(StringComparer.Ordinal) |
| | 0 | 185 | | { |
| | 0 | 186 | | [PresetKeyOrders] = OrderPageCodes, |
| | 0 | 187 | | [PresetKeyTransactions] = TransactionPageCodes, |
| | 0 | 188 | | [PresetKeyOrdersAndTransactions] = OrdersAndTransactionPageCodes, |
| | 0 | 189 | | }; |
| | 0 | 190 | | foreach (var (key, code) in TransactionSinglePresets) |
| | | 191 | | { |
| | 0 | 192 | | d[key] = new[] { code }; |
| | | 193 | | } |
| | 0 | 194 | | return d; |
| | | 195 | | } |
| | | 196 | | |
| | | 197 | | /// <summary>JSON-объект: ключ → коды страниц (для пресетов в админке).</summary> |
| | | 198 | | public static string GetRolePagePresetsJson() |
| | | 199 | | { |
| | 0 | 200 | | return JsonSerializer.Serialize(BuildRolePagePresetsMap(), new JsonSerializerOptions |
| | 0 | 201 | | { |
| | 0 | 202 | | PropertyNamingPolicy = null, |
| | 0 | 203 | | DefaultIgnoreCondition = JsonIgnoreCondition.Never |
| | 0 | 204 | | }); |
| | | 205 | | } |
| | | 206 | | |
| | | 207 | | /// <summary>Код <c>Area.Controller.Action</c> в путь <c>/Area/Controller/Action</c>.</summary> |
| | | 208 | | public static string ToMvcPath(string code) |
| | | 209 | | { |
| | 49 | 210 | | if (string.IsNullOrWhiteSpace(code)) |
| | 0 | 211 | | return string.Empty; |
| | 49 | 212 | | var parts = code.Split('.', 3, StringSplitOptions.RemoveEmptyEntries); |
| | 49 | 213 | | if (parts.Length != 3) |
| | 0 | 214 | | return "/" + string.Join('/', code.Split('.', StringSplitOptions.RemoveEmptyEntries)); |
| | 49 | 215 | | return $"/{parts[0]}/{parts[1]}/{parts[2]}"; |
| | | 216 | | } |
| | | 217 | | |
| | | 218 | | public readonly record struct Studio2MenuPageRow( |
| | 32 | 219 | | string Code, |
| | 0 | 220 | | string ParentSectionCode, |
| | 0 | 221 | | int Sort, |
| | 0 | 222 | | string Title, |
| | 0 | 223 | | string Icon, |
| | 0 | 224 | | string? Accent); |
| | | 225 | | } |