fix(migration): суммы документов МойСклада как decimal (приходят «900000.0») + GET статуса job

МойСклад отдаёт sum/cashSum/price как число с точкой (900000.0) → long не парсился
(«JSON value could not be converted to System.Int64»). Поля DTO → decimal. Плюс
GET /api/admin/moysklad/jobs/{id} для наблюдения за прогрессом/ошибками переноса.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nns 2026-10-09 14:19:52 +05:00
parent f2a1493ea0
commit 10cd9f989b
2 changed files with 12 additions and 4 deletions

View file

@ -135,6 +135,14 @@ public async Task<ActionResult<object>> ImportCounterparties([FromBody] ImportRe
return Ok(new { jobId = job.Id }); return Ok(new { jobId = job.Id });
} }
[HttpGet("jobs/{id:guid}")]
public async Task<ActionResult<object>> JobStatus(Guid id, CancellationToken ct)
{
var j = await _db.ImportJobs.AsNoTracking().FirstOrDefaultAsync(x => x.Id == id, ct);
if (j is null) return NotFound();
return Ok(new { j.Kind, status = j.Status.ToString(), j.Stage, j.Total, j.Created, j.Updated, j.Skipped, j.Message, j.StartedAt, j.FinishedAt });
}
[HttpPost("import-supplies")] [HttpPost("import-supplies")]
public async Task<ActionResult<object>> ImportSupplies([FromBody] ImportRequest req, CancellationToken ct) public async Task<ActionResult<object>> ImportSupplies([FromBody] ImportRequest req, CancellationToken ct)
{ {

View file

@ -152,15 +152,15 @@ public class MsDocument
[JsonPropertyName("moment")] public string? Moment { get; set; } // "yyyy-MM-dd HH:mm:ss.fff" МСК [JsonPropertyName("moment")] public string? Moment { get; set; } // "yyyy-MM-dd HH:mm:ss.fff" МСК
[JsonPropertyName("description")] public string? Description { get; set; } [JsonPropertyName("description")] public string? Description { get; set; }
[JsonPropertyName("applicable")] public bool Applicable { get; set; } [JsonPropertyName("applicable")] public bool Applicable { get; set; }
[JsonPropertyName("sum")] public long Sum { get; set; } // тиыны [JsonPropertyName("sum")] public decimal Sum { get; set; } // тиыны (может прийти как 900000.0)
[JsonPropertyName("agent")] public MsMetaWrapper? Agent { get; set; } [JsonPropertyName("agent")] public MsMetaWrapper? Agent { get; set; }
[JsonPropertyName("store")] public MsMetaWrapper? Store { get; set; } [JsonPropertyName("store")] public MsMetaWrapper? Store { get; set; }
[JsonPropertyName("owner")] public MsMetaWrapper? Owner { get; set; } // сотрудник [JsonPropertyName("owner")] public MsMetaWrapper? Owner { get; set; } // сотрудник
[JsonPropertyName("organization")] public MsMetaWrapper? Organization { get; set; } [JsonPropertyName("organization")] public MsMetaWrapper? Organization { get; set; }
[JsonPropertyName("positions")] public MsListResponse<MsPosition>? Positions { get; set; } [JsonPropertyName("positions")] public MsListResponse<MsPosition>? Positions { get; set; }
// розничные продажи: // розничные продажи:
[JsonPropertyName("cashSum")] public long CashSum { get; set; } [JsonPropertyName("cashSum")] public decimal CashSum { get; set; }
[JsonPropertyName("noCashSum")] public long NoCashSum { get; set; } [JsonPropertyName("noCashSum")] public decimal NoCashSum { get; set; }
[JsonPropertyName("retailShift")] public MsMetaWrapper? RetailShift { get; set; } [JsonPropertyName("retailShift")] public MsMetaWrapper? RetailShift { get; set; }
[JsonPropertyName("demand")] public MsMetaWrapper? Demand { get; set; } // для retailsalesreturn — исходный чек [JsonPropertyName("demand")] public MsMetaWrapper? Demand { get; set; } // для retailsalesreturn — исходный чек
} }
@ -169,7 +169,7 @@ public class MsPosition
{ {
[JsonPropertyName("id")] public string? Id { get; set; } [JsonPropertyName("id")] public string? Id { get; set; }
[JsonPropertyName("quantity")] public decimal Quantity { get; set; } [JsonPropertyName("quantity")] public decimal Quantity { get; set; }
[JsonPropertyName("price")] public long Price { get; set; } // тиыны за ед. [JsonPropertyName("price")] public decimal Price { get; set; } // тиыны за ед.
[JsonPropertyName("discount")] public decimal Discount { get; set; } // % скидки [JsonPropertyName("discount")] public decimal Discount { get; set; } // % скидки
[JsonPropertyName("vat")] public int Vat { get; set; } [JsonPropertyName("vat")] public int Vat { get; set; }
[JsonPropertyName("assortment")] public MsMetaWrapper? Assortment { get; set; } [JsonPropertyName("assortment")] public MsMetaWrapper? Assortment { get; set; }