admin/src/Oms.Application/Shared/PublishSnapshotSlimmer.cs
zzh e2dca20966 fix: strip audit fields from channel price publish snapshots
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-23 11:55:21 +08:00

109 lines
3.6 KiB
C#

using Oms.Application.Dtos.Channels;
using Oms.Application.Dtos.Orders;
using Oms.Domain.ChannelsAggregate.Entities;
namespace Oms.Application.Shared;
/// <summary>
/// 发布快照瘦身:去掉审计时间等计费无用字段。
/// </summary>
public static class PublishSnapshotSlimmer
{
public static SalesProductPriceSnapshotItemDto SlimPrice(SalesProductPriceListOutput price) =>
new()
{
Id = price.Id,
SerialNumber = price.SerialNumber,
Status = price.Status,
PriceName = price.PriceName,
CostItem = price.CostItem,
CostUnit = price.CostUnit,
Currency = price.Currency,
ChargingCondition = price.ChargingCondition,
Factors = price.Factors,
Details = price.Details
};
public static ServiceChannelPriceSnapshotItemDto SlimChannelPrice(ServiceChannelPriceListOutput price) =>
new()
{
Id = price.Id,
ServiceChannelId = price.ServiceChannelId,
SerialNumber = price.SerialNumber,
Status = price.Status,
PriceName = price.PriceName,
CostItem = price.CostItem,
CostUnit = price.CostUnit,
Currency = price.Currency,
ChargingCondition = price.ChargingCondition,
Factors = price.Factors,
Details = price.Details
};
public static ServiceChannelPriceListOutput ToChannelPriceListOutput(ServiceChannelPriceSnapshotItemDto price) =>
new()
{
Id = price.Id,
ServiceChannelId = price.ServiceChannelId,
SerialNumber = price.SerialNumber,
Status = price.Status,
PriceName = price.PriceName,
CostItem = price.CostItem,
CostUnit = price.CostUnit,
Currency = price.Currency,
ChargingCondition = price.ChargingCondition,
Factors = price.Factors,
Details = price.Details
};
public static SalesProductAllocationProviderSnapshotDto SlimAllocationProvider(
SalesProductAllocationProviderOutput provider) =>
new()
{
Id = provider.Id,
SalesProductId = provider.SalesProductId,
SerialNumber = provider.SerialNumber,
ProviderName = provider.ProviderName,
ServiceChannelId = provider.ServiceChannelId,
ServiceChannelName = provider.ServiceChannelName,
Weight = provider.Weight,
CustomerIds = provider.CustomerIds
};
public static WeightRuleSnapshotRuleDto SlimWeightRule(WeightRuleInfo entity) =>
new()
{
Id = entity.Id,
Condition = entity.Condition,
BillableWeight = entity.BillableWeight,
VolumetricFactor = entity.VolumetricFactor
};
public static WeightRoundingSnapshotRangeDto SlimWeightRounding(WeightRoundingInfo entity) =>
new()
{
Id = entity.Id,
Start = entity.StartValue,
End = entity.EndValue,
Public = entity.Public
};
public static WeightRuleInfo ToWeightRuleEntity(WeightRuleSnapshotRuleDto rule) =>
new()
{
Id = rule.Id,
Condition = rule.Condition,
BillableWeight = rule.BillableWeight,
VolumetricFactor = rule.VolumetricFactor
};
public static WeightRoundingInfo ToWeightRoundingEntity(WeightRoundingSnapshotRangeDto range) =>
new()
{
Id = range.Id,
StartValue = range.Start,
EndValue = range.End,
Public = range.Public
};
}