admin/src/Oms.Application/Shared/PublishSnapshotSlimmer.cs
zzh 7827b4803e feat: slim rules/price publish snapshots with PostcodeRange (left,right]
Use slim DTOs without audit timestamps; migrate legacy LeftPostcode/RightPostcode on read.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 14:10:34 +08:00

64 lines
2.0 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,
ChargingTime = price.ChargingTime,
ChargingCondition = price.ChargingCondition,
Factors = price.Factors,
Details = price.Details
};
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
};
}