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