| | | 1 | | using OzonOrdersWeb.Areas.Studio2.ViewModels.Bitrix; |
| | | 2 | | |
| | | 3 | | namespace Services.BitrixStockServices; |
| | | 4 | | |
| | | 5 | | /// <summary>Фильтр обнуления — как на /BitrixStock с OnlyInactive и складами B1, B2, M1, M2, M3.</summary> |
| | | 6 | | public static class BitrixStockClearFilterTemplate |
| | | 7 | | { |
| | 0 | 8 | | public static readonly string[] StoreTitles = { "B1", "B2", "M1", "M2", "M3" }; |
| | | 9 | | |
| | | 10 | | public static string BuildQueryString(int ozonClientId) => |
| | 0 | 11 | | "SelectedStoreTitles=B1&SelectedStoreTitles=B2&SelectedStoreTitles=M1&SelectedStoreTitles=M2&SelectedStoreTitles |
| | 0 | 12 | | "&LoadOzonWarehouses=true&OnlyInactive=true&StoresFilterApplied=1" + |
| | 0 | 13 | | $"&SelectedClientId={ozonClientId}"; |
| | | 14 | | |
| | | 15 | | public static RemainingStockFilter BuildFilter(int ozonClientId, IReadOnlyList<string>? storeTitles = null) |
| | | 16 | | { |
| | 0 | 17 | | var filter = BitrixStockFilterQueryParser.FromQueryString(BuildQueryString(ozonClientId)); |
| | | 18 | | |
| | 0 | 19 | | if (storeTitles is { Count: > 0 }) |
| | | 20 | | { |
| | 0 | 21 | | filter.SelectedStoreTitles = storeTitles |
| | 0 | 22 | | .Where(s => !string.IsNullOrWhiteSpace(s)) |
| | 0 | 23 | | .Select(s => s.Trim()) |
| | 0 | 24 | | .Distinct(StringComparer.OrdinalIgnoreCase) |
| | 0 | 25 | | .ToList(); |
| | | 26 | | } |
| | | 27 | | |
| | 0 | 28 | | BitrixStockIndexFilterRules.ApplyLikeStocksPage(filter, new BitrixStockIndexFilterContext |
| | 0 | 29 | | { |
| | 0 | 30 | | HasLoadOzonWarehousesInQuery = true, |
| | 0 | 31 | | HasOnlyInactiveInQuery = true, |
| | 0 | 32 | | HasSelectedStoreTitlesInQuery = true, |
| | 0 | 33 | | StoresFilterApplied = true |
| | 0 | 34 | | }); |
| | | 35 | | |
| | 0 | 36 | | return filter; |
| | | 37 | | } |
| | | 38 | | } |