diff --git a/src/Oms.Application/Services/Orders/OrderService.ParcelQuote.cs b/src/Oms.Application/Services/Orders/OrderService.ParcelQuote.cs index 56590a2..eab16a7 100644 --- a/src/Oms.Application/Services/Orders/OrderService.ParcelQuote.cs +++ b/src/Oms.Application/Services/Orders/OrderService.ParcelQuote.cs @@ -14,6 +14,7 @@ public partial class OrderService { private const string SalesProductGroupDictType = "sales_product_group"; private const string UngroupedProductGroupCode = "_ungrouped"; + private const string DomesticPickupGroupNameKeyword = "国内揽收"; private sealed record PriceCheckCargoTarget(string Code, string DisplayName, string CargoAttribute); @@ -26,6 +27,13 @@ public partial class OrderService .ToList(); var dictRows = await DictRepository.GetListAsync(x => x.DictType == SalesProductGroupDictType); + // 查价页面不展示「国内揽收」分组的产品 + var domesticPickupGroupCodes = dictRows + .Where(x => !string.IsNullOrWhiteSpace(x.DictName) + && x.DictName.Trim().Contains(DomesticPickupGroupNameKeyword)) + .Select(x => x.DictCode?.Trim()) + .Where(code => !string.IsNullOrWhiteSpace(code)) + .ToHashSet(StringComparer.OrdinalIgnoreCase); var dictOrder = dictRows .OrderBy(x => x.DictSort) .ThenBy(x => x.DictCode) @@ -43,7 +51,10 @@ public partial class OrderService foreach (var dict in dictOrder) { var code = dict.DictCode?.Trim(); - if (string.IsNullOrWhiteSpace(code) || !grouped.TryGetValue(code, out var list) || list.Count == 0) + if (string.IsNullOrWhiteSpace(code) + || domesticPickupGroupCodes.Contains(code) + || !grouped.TryGetValue(code, out var list) + || list.Count == 0) { continue; } @@ -61,6 +72,7 @@ public partial class OrderService { if (pair.Key.Equals(UngroupedProductGroupCode, StringComparison.OrdinalIgnoreCase) || consumedCodes.Contains(pair.Key) + || domesticPickupGroupCodes.Contains(pair.Key) || pair.Value.Count == 0) { continue; @@ -152,6 +164,27 @@ public partial class OrderService } } + // 查价页面不展示「国内揽收」分组的产品 + var domesticPickupGroupCodes = (await DictRepository.GetListAsync(x => x.DictType == SalesProductGroupDictType)) + .Where(x => !string.IsNullOrWhiteSpace(x.DictName) + && x.DictName.Trim().Contains(DomesticPickupGroupNameKeyword)) + .Select(x => x.DictCode?.Trim()) + .Where(code => !string.IsNullOrWhiteSpace(code)) + .ToHashSet(StringComparer.OrdinalIgnoreCase); + + if (domesticPickupGroupCodes.Count > 0) + { + products = products + .Where(p => + { + var groupCode = string.IsNullOrWhiteSpace(p.ProductGroup) + ? UngroupedProductGroupCode + : p.ProductGroup.Trim(); + return !domesticPickupGroupCodes.Contains(groupCode); + }) + .ToList(); + } + var result = new OrderPriceCheckResultOutput { QueryHint = PriceCheckHintBuilder.BuildQueryHint(profile) @@ -639,6 +672,13 @@ public partial class OrderService await TryAddAsync(null, null, false); + // 如果按「仅目的国」都无法匹配到任何价格分区,则不要再用卖价快照的全量分区键兜底。 + // 否则会导致未配置国家也能返回参考价格(estimated),与预期不符。 + if (attempts.Count == 0) + { + return attempts; + } + foreach (var zoneKey in ParcelBillingCalculator.CollectDistinctDetailZoneKeys(snapshotBinding.Price)) { if (attempts.Any(x => x.ZoneKeys.Any(k => string.Equals(k, zoneKey, StringComparison.OrdinalIgnoreCase))))