50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
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
|
|
};
|
|
}
|