查价/下单/入库/出库统一校验与计费上下文;待排货状态及可选入库排货;运单号改为 IDE+yyMMddHHmmss;补充迁移 SQL 与测试修复。 Co-authored-by: Cursor <cursoragent@cursor.com>
133 lines
3.9 KiB
C#
133 lines
3.9 KiB
C#
using System.Globalization;
|
|
using Oms.Application.Dtos.Channels;
|
|
using Oms.Application.Dtos.Orders;
|
|
using Oms.Application.Shared;
|
|
using Oms.Domain.ChannelsAggregate.Entities;
|
|
|
|
namespace Oms.Tests.Support;
|
|
|
|
internal static class ParcelBillingTestData
|
|
{
|
|
private static readonly DateTime EffectiveTime = new(2026, 4, 1, 0, 0, 0, DateTimeKind.Utc);
|
|
private const string PriceVersion = "P20260401001";
|
|
private const string Zone = "美西";
|
|
|
|
public static SalesProductPricePublishSnapshotDto BuildReceivableSnapshot(
|
|
params SalesProductPriceListOutput[] prices) =>
|
|
new()
|
|
{
|
|
SalesProductId = 1,
|
|
Prices = prices.Select(PublishSnapshotSlimmer.SlimPrice).ToList()
|
|
};
|
|
|
|
public static List<ServiceChannelPriceListOutput> BuildPayablePrices(
|
|
params ServiceChannelPriceListOutput[] prices) => prices.ToList();
|
|
|
|
public static SalesProductPriceListOutput ReceivablePriceItem(
|
|
byte status,
|
|
string costItem,
|
|
params ChannelPriceDetailOutput[] details) =>
|
|
new()
|
|
{
|
|
Status = status == 0 ? (byte)0 : (byte)2,
|
|
CostItem = costItem,
|
|
Currency = "CNY",
|
|
Details = details.ToList()
|
|
};
|
|
|
|
public static ServiceChannelPriceListOutput PayablePriceItem(
|
|
byte status,
|
|
string costItem,
|
|
params ChannelPriceDetailOutput[] details) =>
|
|
new()
|
|
{
|
|
Status = status == 0 ? (byte)0 : (byte)2,
|
|
CostItem = costItem,
|
|
Currency = "CNY",
|
|
Details = details.ToList()
|
|
};
|
|
|
|
public static ChannelPriceDetailOutput ContinueFreightDetail(
|
|
decimal firstWeight = 1M,
|
|
decimal firstPrice = 18M,
|
|
decimal continueUnit = 0.5M,
|
|
decimal continuePrice = 6M,
|
|
string zone = Zone,
|
|
string cargoType = "普货") =>
|
|
new()
|
|
{
|
|
CalculationFormula = "续单价",
|
|
FactorValuesJson = new Dictionary<string, string>
|
|
{
|
|
["分区"] = zone,
|
|
["货物类型"] = cargoType,
|
|
["首重"] = firstWeight.ToString(CultureInfo.InvariantCulture),
|
|
["首重价"] = firstPrice.ToString(CultureInfo.InvariantCulture),
|
|
["续重单位"] = continueUnit.ToString(CultureInfo.InvariantCulture),
|
|
["续重价"] = continuePrice.ToString(CultureInfo.InvariantCulture)
|
|
}
|
|
};
|
|
|
|
public static ChannelPriceDetailOutput FixedPriceDetail(
|
|
decimal amount,
|
|
string zone = Zone,
|
|
string cargoType = "普货") =>
|
|
new()
|
|
{
|
|
CalculationFormula = "固定价",
|
|
CalculatedValue = amount,
|
|
FactorValuesJson = new Dictionary<string, string>
|
|
{
|
|
["分区"] = zone,
|
|
["货物类型"] = cargoType
|
|
}
|
|
};
|
|
|
|
public static ChannelPriceDetailOutput UnitPriceDetail(
|
|
decimal unitPrice,
|
|
string zone = Zone) =>
|
|
new()
|
|
{
|
|
CalculationFormula = "单价",
|
|
CalculatedValue = unitPrice,
|
|
FactorValuesJson = new Dictionary<string, string> { ["分区"] = zone }
|
|
};
|
|
|
|
public static ChannelPriceDetailOutput TotalTierDetail(
|
|
string zone,
|
|
decimal weightTier,
|
|
decimal normalCustomerPrice,
|
|
string? weightInterval = null) =>
|
|
new()
|
|
{
|
|
CalculationFormula = "total",
|
|
CalculatedValue = 0,
|
|
FactorValuesJson = new Dictionary<string, string>
|
|
{
|
|
["分区"] = zone,
|
|
["重量"] = weightInterval ?? weightTier.ToString(CultureInfo.InvariantCulture)
|
|
},
|
|
CustomerGroupValues = new Dictionary<string, decimal> { ["普通客户"] = normalCustomerPrice }
|
|
};
|
|
|
|
public static WeightRuleInfo GwRule(string condition = "gw>=vw", string factor = "6000") =>
|
|
new()
|
|
{
|
|
Id = 1,
|
|
Condition = condition,
|
|
BillableWeight = "gw",
|
|
VolumetricFactor = factor
|
|
};
|
|
|
|
public static WeightRoundingInfo RoundingRange(decimal start, decimal end, string unit) =>
|
|
new()
|
|
{
|
|
Id = 1,
|
|
StartValue = start,
|
|
EndValue = end,
|
|
Public = unit
|
|
};
|
|
|
|
public static (string PriceVersion, DateTime EffectiveTime) SnapshotMeta() => (PriceVersion, EffectiveTime);
|
|
}
|