| | | 1 | | using OzonDomains.Models; |
| | | 2 | | |
| | | 3 | | namespace Services.AiAssistant; |
| | | 4 | | |
| | | 5 | | /// <summary>Собирает ID транзакций заказа: текущая привязка + смены в orders_history.</summary> |
| | | 6 | | public static class AiOrderTransactionIdCollector |
| | | 7 | | { |
| | | 8 | | public static HashSet<int> Collect(Order order, IReadOnlyList<OrderHistory> histories) |
| | | 9 | | { |
| | 39 | 10 | | var ids = new HashSet<int>(); |
| | | 11 | | |
| | 39 | 12 | | if (order.TransactionId is > 0) |
| | 5 | 13 | | ids.Add(order.TransactionId.Value); |
| | | 14 | | |
| | 172 | 15 | | foreach (var h in histories) |
| | | 16 | | { |
| | 47 | 17 | | var isTransactionColumn = string.Equals(h.ColumnName, "TransactionId", StringComparison.OrdinalIgnoreCase) | |
| | 47 | 18 | | (h.ColumnDisplayName?.Contains("Транзакция", StringComparison.OrdinalIgnoreCase) == true); |
| | 47 | 19 | | if (!isTransactionColumn) continue; |
| | | 20 | | |
| | 53 | 21 | | if (int.TryParse(h.NewValue, out var newId) && newId > 0) ids.Add(newId); |
| | 52 | 22 | | if (int.TryParse(h.OldValue, out var oldId) && oldId > 0) ids.Add(oldId); |
| | | 23 | | } |
| | | 24 | | |
| | 39 | 25 | | return ids; |
| | | 26 | | } |
| | | 27 | | } |