InventoryWriteModels.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. namespace Admin.NET.Plugin.AiDOP.MaterialWarehouse.InventoryPosting.Inventory;
  2. /// <summary>InvMaster 写(W1 首建 / W2 更新为 After)。</summary>
  3. public sealed class InvMasterWrite
  4. {
  5. public long TenantId { get; set; }
  6. public string DomainCode { get; set; }
  7. public string ItemNum { get; set; }
  8. public string Location { get; set; }
  9. /// <summary>聚合增量(生产实库用相对 UPDATE `set x=x+delta` 防 lost-update,与 LIVE 相对更新一致)。</summary>
  10. public InventoryDeltas Delta { get; set; }
  11. /// <summary>计算后值(供 INSERT 新行 = 0+delta,及 Shadow 对账验证)。</summary>
  12. public InventoryBalance After { get; set; }
  13. /// <summary>无 InvMaster 且组内含入库 → 首建后再置 After。</summary>
  14. public bool InsertIfMissing { get; set; }
  15. public string User { get; set; }
  16. }
  17. /// <summary>ItemMaster.Location 语义写(W3 → ado_item_location_state;仅当原默认库位为空、txn Location 非空)。</summary>
  18. public sealed class ItemLocationWrite
  19. {
  20. public long TenantId { get; set; }
  21. public string DomainCode { get; set; }
  22. public string ItemNum { get; set; }
  23. public string DefaultLocation { get; set; }
  24. public string User { get; set; }
  25. }
  26. /// <summary>LocationDetail 写(W4 首建 / W5 更新为 After)。</summary>
  27. public sealed class LocationDetailWrite
  28. {
  29. public long TenantId { get; set; }
  30. public string DomainCode { get; set; }
  31. public string ItemNum { get; set; }
  32. public string Location { get; set; }
  33. public string LotSerial { get; set; }
  34. public string Refs { get; set; }
  35. /// <summary>聚合增量(生产实库用相对 UPDATE 防 lost-update)。</summary>
  36. public InventoryDeltas Delta { get; set; }
  37. /// <summary>计算后值(供 INSERT / 对账)。</summary>
  38. public InventoryBalance After { get; set; }
  39. public bool InsertIfMissing { get; set; }
  40. public decimal Cost { get; set; }
  41. public string Curr { get; set; }
  42. public string User { get; set; }
  43. }
  44. /// <summary>库存流水行(W6 append,映射 ado_inventory_transaction)。</summary>
  45. public sealed class InventoryTransactionRow
  46. {
  47. public long TenantId { get; set; }
  48. public string DomainCode { get; set; }
  49. public long PostingId { get; set; }
  50. public long TransactionGroupId { get; set; }
  51. public int Seq { get; set; }
  52. public string ItemNum { get; set; }
  53. public string Location { get; set; }
  54. public string LotSerial { get; set; }
  55. public string TransType { get; set; }
  56. public decimal QtyChange { get; set; }
  57. public decimal BeginBalance { get; set; }
  58. public decimal FreezeQty { get; set; }
  59. public decimal Assay { get; set; }
  60. public decimal Amt { get; set; }
  61. public string WorkOrd { get; set; }
  62. public string ShipperNum { get; set; }
  63. public string Fbillno { get; set; }
  64. public string Receiver { get; set; }
  65. public string RctQcNbr { get; set; }
  66. public string Remark { get; set; }
  67. public string User { get; set; }
  68. }
  69. /// <summary>一次过账计算出的全部写(W1-W6);由 store 在单事务内落地。</summary>
  70. public sealed class InventoryWriteSet
  71. {
  72. public List<InvMasterWrite> InvMasterWrites { get; } = new();
  73. public List<ItemLocationWrite> ItemLocationWrites { get; } = new();
  74. public List<LocationDetailWrite> LocationDetailWrites { get; } = new();
  75. public List<InventoryTransactionRow> TransactionRows { get; } = new();
  76. public int TotalWrites => InvMasterWrites.Count + ItemLocationWrites.Count + LocationDetailWrites.Count + TransactionRows.Count;
  77. }
  78. /// <summary>C5 过账结果类别。(Duplicate/Conflict 由上游 Phase 4 幂等层在 C5 之前判定,不在 C5 内。)</summary>
  79. public enum InventoryPostingOutcome
  80. {
  81. Success = 1,
  82. ValidationFailure = 2,
  83. Error = 3,
  84. }
  85. /// <summary>C5 过账结果(结构化错误码 + 保留 LIVE ReturnMsg 语义供 Shadow 对账)。</summary>
  86. public sealed class InventoryPostingResult
  87. {
  88. public InventoryPostingOutcome Outcome { get; set; }
  89. public IReadOnlyList<InventoryGuardError> GuardErrors { get; set; } = System.Array.Empty<InventoryGuardError>();
  90. public int WrittenRows { get; set; }
  91. public string ErrorCode { get; set; }
  92. public string ErrorMessage { get; set; }
  93. /// <summary>LIVE ReturnMsg 语义映射("保存成功"/守卫消息/"保存失败,…")。</summary>
  94. public string LegacyReturnMsg { get; set; }
  95. }