feat: 完善库存锁定幂等与批次扣减策略

This commit is contained in:
2025-12-04 11:31:26 +08:00
parent cd8862b223
commit 7e6125c687
35 changed files with 1670 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
using TakeoutSaaS.Application.App.Inventory.Dto;
using TakeoutSaaS.Domain.Inventory.Entities;
namespace TakeoutSaaS.Application.App.Inventory;
/// <summary>
/// 库存映射辅助。
/// </summary>
public static class InventoryMapping
{
/// <summary>
/// 映射库存 DTO。
/// </summary>
public static InventoryItemDto ToDto(InventoryItem item) => new()
{
Id = item.Id,
TenantId = item.TenantId,
StoreId = item.StoreId,
ProductSkuId = item.ProductSkuId,
BatchNumber = item.BatchNumber,
QuantityOnHand = item.QuantityOnHand,
QuantityReserved = item.QuantityReserved,
SafetyStock = item.SafetyStock,
Location = item.Location,
ExpireDate = item.ExpireDate,
IsPresale = item.IsPresale,
PresaleStartTime = item.PresaleStartTime,
PresaleEndTime = item.PresaleEndTime,
PresaleCapacity = item.PresaleCapacity,
PresaleLocked = item.PresaleLocked,
MaxQuantityPerOrder = item.MaxQuantityPerOrder,
IsSoldOut = item.IsSoldOut
};
/// <summary>
/// 映射批次 DTO。
/// </summary>
public static InventoryBatchDto ToDto(InventoryBatch batch) => new()
{
Id = batch.Id,
StoreId = batch.StoreId,
ProductSkuId = batch.ProductSkuId,
BatchNumber = batch.BatchNumber,
ProductionDate = batch.ProductionDate,
ExpireDate = batch.ExpireDate,
Quantity = batch.Quantity,
RemainingQuantity = batch.RemainingQuantity
};
}