| | | 1 | | using System.ComponentModel.DataAnnotations; |
| | | 2 | | using System.Text.Json.Serialization; |
| | | 3 | | |
| | | 4 | | namespace Services.OzonHandoverServices; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Контракт JSON-документа выдачи/приёма-передачи Ozon, экспортируемого приложением "Telegram Lite". |
| | | 8 | | /// Имена свойств — snake_case, как в исходном файле (document_type, closed, groups[].acts[].items[] и т.д.). |
| | | 9 | | /// </summary> |
| | | 10 | | public sealed class OzonHandoverImportRequest |
| | | 11 | | { |
| | | 12 | | [JsonPropertyName("document_type")] |
| | | 13 | | [Required, StringLength(50)] |
| | | 14 | | public string DocumentType { get; set; } = string.Empty; |
| | | 15 | | |
| | | 16 | | [JsonPropertyName("generated_at")] |
| | | 17 | | public DateTime GeneratedAt { get; set; } |
| | | 18 | | |
| | | 19 | | [JsonPropertyName("return_type")] |
| | | 20 | | [StringLength(20)] |
| | | 21 | | public string? ReturnType { get; set; } |
| | | 22 | | |
| | | 23 | | [JsonPropertyName("closed")] |
| | | 24 | | [Required] |
| | | 25 | | public OzonHandoverClosedDto Closed { get; set; } = new(); |
| | | 26 | | |
| | | 27 | | [JsonPropertyName("summary")] |
| | | 28 | | public OzonHandoverSummaryDto? Summary { get; set; } |
| | | 29 | | |
| | | 30 | | [JsonPropertyName("groups")] |
| | | 31 | | [Required, MinLength(1)] |
| | | 32 | | public List<OzonHandoverGroupDto> Groups { get; set; } = new(); |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | public sealed class OzonHandoverClosedDto |
| | | 36 | | { |
| | | 37 | | [JsonPropertyName("kind")] |
| | | 38 | | [StringLength(50)] |
| | | 39 | | public string? Kind { get; set; } |
| | | 40 | | |
| | | 41 | | /// <summary>Уникальный идентификатор батча источника — ключ идемпотентности импорта.</summary> |
| | | 42 | | [JsonPropertyName("id")] |
| | | 43 | | [Required, StringLength(300)] |
| | | 44 | | public string Id { get; set; } = string.Empty; |
| | | 45 | | |
| | | 46 | | [JsonPropertyName("return_type")] |
| | | 47 | | [StringLength(20)] |
| | | 48 | | public string? ReturnType { get; set; } |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | public sealed class OzonHandoverSummaryDto |
| | | 52 | | { |
| | | 53 | | [JsonPropertyName("acts_count")] |
| | | 54 | | public int ActsCount { get; set; } |
| | | 55 | | |
| | | 56 | | [JsonPropertyName("items_count")] |
| | | 57 | | public int ItemsCount { get; set; } |
| | | 58 | | |
| | | 59 | | [JsonPropertyName("total_value")] |
| | | 60 | | public decimal TotalValue { get; set; } |
| | | 61 | | |
| | | 62 | | [JsonPropertyName("accepted")] |
| | | 63 | | public OzonHandoverSummaryBucketDto? Accepted { get; set; } |
| | | 64 | | |
| | | 65 | | [JsonPropertyName("rejected")] |
| | | 66 | | public OzonHandoverSummaryBucketDto? Rejected { get; set; } |
| | | 67 | | |
| | | 68 | | [JsonPropertyName("pending")] |
| | | 69 | | public OzonHandoverSummaryBucketDto? Pending { get; set; } |
| | | 70 | | |
| | | 71 | | [JsonPropertyName("defect_count")] |
| | | 72 | | public int DefectCount { get; set; } |
| | | 73 | | |
| | | 74 | | [JsonPropertyName("missort_count")] |
| | | 75 | | public int MissortCount { get; set; } |
| | | 76 | | } |
| | | 77 | | |
| | | 78 | | public sealed class OzonHandoverSummaryBucketDto |
| | | 79 | | { |
| | | 80 | | [JsonPropertyName("items_count")] |
| | 0 | 81 | | public int ItemsCount { get; set; } |
| | | 82 | | |
| | | 83 | | [JsonPropertyName("total_value")] |
| | 0 | 84 | | public decimal TotalValue { get; set; } |
| | | 85 | | } |
| | | 86 | | |
| | | 87 | | public sealed class OzonHandoverGroupDto |
| | | 88 | | { |
| | | 89 | | [JsonPropertyName("group_key")] |
| | | 90 | | [StringLength(50)] |
| | | 91 | | public string? GroupKey { get; set; } |
| | | 92 | | |
| | | 93 | | [JsonPropertyName("group_name")] |
| | | 94 | | [StringLength(100)] |
| | | 95 | | public string? GroupName { get; set; } |
| | | 96 | | |
| | | 97 | | [JsonPropertyName("return_type")] |
| | | 98 | | [StringLength(20)] |
| | | 99 | | public string? ReturnType { get; set; } |
| | | 100 | | |
| | | 101 | | [JsonPropertyName("acts_count")] |
| | | 102 | | public int ActsCount { get; set; } |
| | | 103 | | |
| | | 104 | | [JsonPropertyName("items_count")] |
| | | 105 | | public int ItemsCount { get; set; } |
| | | 106 | | |
| | | 107 | | [JsonPropertyName("total_value")] |
| | | 108 | | public decimal TotalValue { get; set; } |
| | | 109 | | |
| | | 110 | | [JsonPropertyName("acts")] |
| | | 111 | | [Required] |
| | | 112 | | public List<OzonHandoverActDto> Acts { get; set; } = new(); |
| | | 113 | | } |
| | | 114 | | |
| | | 115 | | public sealed class OzonHandoverActDto |
| | | 116 | | { |
| | | 117 | | [JsonPropertyName("act_no")] |
| | | 118 | | [StringLength(100)] |
| | | 119 | | public string? ActNo { get; set; } |
| | | 120 | | |
| | | 121 | | [JsonPropertyName("act_date")] |
| | | 122 | | public DateTime ActDate { get; set; } |
| | | 123 | | |
| | | 124 | | [JsonPropertyName("act_type")] |
| | | 125 | | [StringLength(100)] |
| | | 126 | | public string? ActType { get; set; } |
| | | 127 | | |
| | | 128 | | [JsonPropertyName("pvz")] |
| | | 129 | | [StringLength(100)] |
| | | 130 | | public string? Pvz { get; set; } |
| | | 131 | | |
| | | 132 | | [JsonPropertyName("account")] |
| | | 133 | | [StringLength(50)] |
| | | 134 | | public string? Account { get; set; } |
| | | 135 | | |
| | | 136 | | [JsonPropertyName("source")] |
| | | 137 | | [StringLength(500)] |
| | | 138 | | public string? Source { get; set; } |
| | | 139 | | |
| | | 140 | | [JsonPropertyName("box_barcode")] |
| | | 141 | | [StringLength(100)] |
| | | 142 | | public string? BoxBarcode { get; set; } |
| | | 143 | | |
| | | 144 | | [JsonPropertyName("return_id")] |
| | | 145 | | public long? ReturnId { get; set; } |
| | | 146 | | |
| | | 147 | | [JsonPropertyName("return_type")] |
| | | 148 | | [StringLength(20)] |
| | | 149 | | public string? ReturnType { get; set; } |
| | | 150 | | |
| | | 151 | | /// <summary>Статус акта из источника. Игнорируется при импорте — пересчитывается из позиций.</summary> |
| | | 152 | | [JsonPropertyName("status")] |
| | | 153 | | public string? Status { get; set; } |
| | | 154 | | |
| | | 155 | | [JsonPropertyName("items")] |
| | | 156 | | [Required] |
| | | 157 | | public List<OzonHandoverItemDto> Items { get; set; } = new(); |
| | | 158 | | } |
| | | 159 | | |
| | | 160 | | public sealed class OzonHandoverItemDto |
| | | 161 | | { |
| | | 162 | | [JsonPropertyName("row_no")] |
| | | 163 | | public int RowNo { get; set; } |
| | | 164 | | |
| | | 165 | | [JsonPropertyName("item_no")] |
| | | 166 | | [Required, StringLength(50)] |
| | | 167 | | public string ItemNo { get; set; } = string.Empty; |
| | | 168 | | |
| | | 169 | | [JsonPropertyName("product_name")] |
| | | 170 | | [StringLength(500)] |
| | | 171 | | public string? ProductName { get; set; } |
| | | 172 | | |
| | | 173 | | [JsonPropertyName("barcode")] |
| | | 174 | | [StringLength(100)] |
| | | 175 | | public string? Barcode { get; set; } |
| | | 176 | | |
| | | 177 | | [JsonPropertyName("value")] |
| | | 178 | | public decimal Value { get; set; } |
| | | 179 | | |
| | | 180 | | [JsonPropertyName("value_api")] |
| | | 181 | | public decimal? ValueApi { get; set; } |
| | | 182 | | |
| | | 183 | | [JsonPropertyName("weight_g")] |
| | | 184 | | public int? WeightG { get; set; } |
| | | 185 | | |
| | | 186 | | /// <summary>accepted / rejected / pending.</summary> |
| | | 187 | | [JsonPropertyName("status")] |
| | | 188 | | [Required, StringLength(30)] |
| | | 189 | | public string Status { get; set; } = string.Empty; |
| | | 190 | | |
| | | 191 | | [JsonPropertyName("defect")] |
| | | 192 | | public bool Defect { get; set; } |
| | | 193 | | |
| | | 194 | | [JsonPropertyName("missort")] |
| | | 195 | | public bool Missort { get; set; } |
| | | 196 | | |
| | | 197 | | [JsonPropertyName("comment")] |
| | | 198 | | [StringLength(1000)] |
| | | 199 | | public string? Comment { get; set; } |
| | | 200 | | |
| | | 201 | | [JsonPropertyName("marked_at")] |
| | | 202 | | public DateTime? MarkedAt { get; set; } |
| | | 203 | | |
| | | 204 | | [JsonPropertyName("sku")] |
| | | 205 | | public long? Sku { get; set; } |
| | | 206 | | |
| | | 207 | | [JsonPropertyName("offer_id")] |
| | | 208 | | [StringLength(100)] |
| | | 209 | | public string? OfferId { get; set; } |
| | | 210 | | |
| | | 211 | | [JsonPropertyName("account")] |
| | | 212 | | [StringLength(50)] |
| | | 213 | | public string? Account { get; set; } |
| | | 214 | | |
| | | 215 | | [JsonPropertyName("return_id")] |
| | | 216 | | public long? ReturnId { get; set; } |
| | | 217 | | |
| | | 218 | | [JsonPropertyName("ozon_status")] |
| | | 219 | | [StringLength(50)] |
| | | 220 | | public string? OzonStatus { get; set; } |
| | | 221 | | |
| | | 222 | | [JsonPropertyName("ozon_status_name")] |
| | | 223 | | [StringLength(200)] |
| | | 224 | | public string? OzonStatusName { get; set; } |
| | | 225 | | |
| | | 226 | | [JsonPropertyName("return_type")] |
| | | 227 | | [StringLength(20)] |
| | | 228 | | public string? ReturnType { get; set; } |
| | | 229 | | |
| | | 230 | | [JsonPropertyName("box_barcode")] |
| | | 231 | | [StringLength(100)] |
| | | 232 | | public string? BoxBarcode { get; set; } |
| | | 233 | | |
| | | 234 | | [JsonPropertyName("reason")] |
| | | 235 | | [StringLength(1000)] |
| | | 236 | | public string? Reason { get; set; } |
| | | 237 | | |
| | | 238 | | [JsonPropertyName("reason_is_defect")] |
| | | 239 | | public bool ReasonIsDefect { get; set; } |
| | | 240 | | |
| | | 241 | | [JsonPropertyName("client_comment")] |
| | | 242 | | public string? ClientComment { get; set; } |
| | | 243 | | |
| | | 244 | | [JsonPropertyName("client_photos")] |
| | | 245 | | public List<string> ClientPhotos { get; set; } = new(); |
| | | 246 | | |
| | | 247 | | [JsonPropertyName("client_photos_expires_at")] |
| | | 248 | | public DateTime? ClientPhotosExpiresAt { get; set; } |
| | | 249 | | |
| | | 250 | | [JsonPropertyName("photos_count")] |
| | | 251 | | public int PhotosCount { get; set; } |
| | | 252 | | |
| | | 253 | | [JsonPropertyName("photos_error")] |
| | | 254 | | public string? PhotosError { get; set; } |
| | | 255 | | |
| | | 256 | | [JsonPropertyName("rejection_comment")] |
| | | 257 | | public string? RejectionComment { get; set; } |
| | | 258 | | |
| | | 259 | | [JsonPropertyName("rejection_reason")] |
| | | 260 | | [StringLength(1000)] |
| | | 261 | | public string? RejectionReason { get; set; } |
| | | 262 | | |
| | | 263 | | [JsonPropertyName("ru_post_tracking")] |
| | | 264 | | [StringLength(100)] |
| | | 265 | | public string? RuPostTracking { get; set; } |
| | | 266 | | |
| | | 267 | | [JsonPropertyName("return_number")] |
| | | 268 | | [StringLength(100)] |
| | | 269 | | public string? ReturnNumber { get; set; } |
| | | 270 | | |
| | | 271 | | [JsonPropertyName("order_number")] |
| | | 272 | | [StringLength(100)] |
| | | 273 | | public string? OrderNumber { get; set; } |
| | | 274 | | |
| | | 275 | | [JsonPropertyName("client_return_method")] |
| | | 276 | | [StringLength(100)] |
| | | 277 | | public string? ClientReturnMethod { get; set; } |
| | | 278 | | |
| | | 279 | | [JsonPropertyName("warehouse_id")] |
| | | 280 | | public long? WarehouseId { get; set; } |
| | | 281 | | } |
| | | 282 | | |
| | | 283 | | /// <summary>Результат импорта, возвращаемый клиенту.</summary> |
| | | 284 | | public sealed class OzonHandoverImportResult |
| | | 285 | | { |
| | | 286 | | public int BatchId { get; set; } |
| | | 287 | | public bool WasUpdated { get; set; } |
| | | 288 | | public int ActsCount { get; set; } |
| | | 289 | | public int ItemsCount { get; set; } |
| | | 290 | | public int MatchedItemsCount { get; set; } |
| | | 291 | | public int UnmatchedItemsCount { get; set; } |
| | | 292 | | public List<string> UnmatchedItemNumbers { get; set; } = new(); |
| | | 293 | | |
| | | 294 | | /// <summary>Позиции, сопоставленные с заказами — номер заказа (ShipmentNumber) по каждой позиции.</summary> |
| | | 295 | | public List<OzonHandoverMatchedOrderDto> MatchedOrders { get; set; } = new(); |
| | | 296 | | |
| | | 297 | | public int SavedPhotosCount { get; set; } |
| | | 298 | | public int FailedPhotosCount { get; set; } |
| | | 299 | | public List<string> Warnings { get; set; } = new(); |
| | | 300 | | } |
| | | 301 | | |
| | | 302 | | /// <summary>Одна позиция акта, сопоставленная с заказом в системе.</summary> |
| | | 303 | | public sealed class OzonHandoverMatchedOrderDto |
| | | 304 | | { |
| | | 305 | | public string ItemNo { get; set; } = string.Empty; |
| | | 306 | | public int OrderId { get; set; } |
| | | 307 | | |
| | | 308 | | /// <summary>Номер отправления заказа (Order.ShipmentNumber).</summary> |
| | | 309 | | public string? OrderNumber { get; set; } |
| | | 310 | | |
| | | 311 | | public string? Article { get; set; } |
| | | 312 | | public string? ClientName { get; set; } |
| | | 313 | | |
| | | 314 | | /// <summary>Статус клиента (Ozon) — имя и его системный цвет (StatusColor.ColorCode).</summary> |
| | | 315 | | public string? ClientStatus { get; set; } |
| | | 316 | | public string? ClientStatusColor { get; set; } |
| | | 317 | | |
| | | 318 | | /// <summary>Статус в отчёте (внутренний, AppStatus) — имя и его системный цвет.</summary> |
| | | 319 | | public string? AppStatus { get; set; } |
| | | 320 | | public string? AppStatusColor { get; set; } |
| | | 321 | | } |