namespace Oms.Application.Services.Orders; using Oms.Application.Dtos.Orders; /// /// 查价入参完整度(用于估算逻辑与对客提示)。 /// internal sealed class PriceCheckInputProfile { public bool HasDimensions { get; init; } public bool HasPostalCode { get; init; } public bool HasProvince { get; init; } public bool HasCity { get; init; } public bool HasCargoTypeFilter { get; init; } public bool HasWarehouseFilter { get; init; } public bool HasShippingMethodFilter { get; init; } public IReadOnlyList MissingFieldCodes { get; init; } = []; public static PriceCheckInputProfile FromInput(OrderPriceCheckInput input) { var hasDimensions = input.Length is > 0 && input.Width is > 0 && input.Height is > 0; var hasPostal = !string.IsNullOrWhiteSpace(input.PostalCode); var hasProvince = !string.IsNullOrWhiteSpace(input.DestinationProvince); var hasCity = !string.IsNullOrWhiteSpace(input.DestinationCity); var cargoCodes = (input.CargoTypes ?? []) .Where(x => !string.IsNullOrWhiteSpace(x)) .ToList(); if (cargoCodes.Count == 0 && !string.IsNullOrWhiteSpace(input.CargoType)) { cargoCodes.Add(input.CargoType.Trim()); } var hasCargoFilter = cargoCodes.Count > 0; var hasWarehouseFilter = (input.WarehouseIds ?? []).Any(x => x > 0); var hasShippingFilter = !string.IsNullOrWhiteSpace(input.ShippingMethod); var missing = new List(); if (!hasDimensions) { missing.Add(PriceCheckMissingFieldCodes.Dimensions); } if (!hasPostal) { missing.Add(PriceCheckMissingFieldCodes.PostalCode); } if (!hasProvince) { missing.Add(PriceCheckMissingFieldCodes.Province); } if (!hasCargoFilter) { missing.Add(PriceCheckMissingFieldCodes.CargoType); } if (!hasWarehouseFilter) { missing.Add(PriceCheckMissingFieldCodes.Warehouse); } return new PriceCheckInputProfile { HasDimensions = hasDimensions, HasPostalCode = hasPostal, HasProvince = hasProvince, HasCity = hasCity, HasCargoTypeFilter = hasCargoFilter, HasWarehouseFilter = hasWarehouseFilter, HasShippingMethodFilter = hasShippingFilter, MissingFieldCodes = missing }; } public bool IsQueryEstimated => MissingFieldCodes.Count > 0; } internal static class PriceCheckMissingFieldCodes { public const string Dimensions = "dimensions"; public const string PostalCode = "postalCode"; public const string Province = "province"; public const string City = "city"; public const string CargoType = "cargoType"; public const string Warehouse = "warehouse"; }