fix: 未排货时不再用产品编码占位 ChannelCode
All checks were successful
Build and Deploy / deploy (push) Successful in 1m23s
All checks were successful
Build and Deploy / deploy (push) Successful in 1m23s
建单与单号上下文不再把 ProductCode 写入 ChannelCode;排货失败清掉历史占位,首次排货成功不再误清跟踪号。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
caca756c94
commit
955b673226
@ -169,13 +169,14 @@ public partial class OrderService
|
|||||||
var snapshotBinding = await ResolveSnapshotBindingAsync(product, bindTime);
|
var snapshotBinding = await ResolveSnapshotBindingAsync(product, bindTime);
|
||||||
var country = await GetCountryOrThrowAsync(input.Receiver.CountryCode);
|
var country = await GetCountryOrThrowAsync(input.Receiver.CountryCode);
|
||||||
|
|
||||||
var channelCode = string.IsNullOrWhiteSpace(input.ChannelCode)
|
// 单号上下文里的 ChannelCode 仅在入参显式指定时带上;未排货前不要用产品编码冒充渠道。
|
||||||
? product.ProductCode
|
var channelCodeForDoc = string.IsNullOrWhiteSpace(input.ChannelCode)
|
||||||
|
? null
|
||||||
: input.ChannelCode.Trim();
|
: input.ChannelCode.Trim();
|
||||||
var numberContext = new DocNumberGenerateContext
|
var numberContext = new DocNumberGenerateContext
|
||||||
{
|
{
|
||||||
ProductCode = product.ProductCode,
|
ProductCode = product.ProductCode,
|
||||||
ChannelCode = channelCode,
|
ChannelCode = channelCodeForDoc,
|
||||||
CountryCode = country.CountryCode,
|
CountryCode = country.CountryCode,
|
||||||
CustomerId = sessionCustomer.Id
|
CustomerId = sessionCustomer.Id
|
||||||
};
|
};
|
||||||
@ -1030,10 +1031,12 @@ public partial class OrderService
|
|||||||
|
|
||||||
var previousChannelCode = order.ChannelCode?.Trim();
|
var previousChannelCode = order.ChannelCode?.Trim();
|
||||||
var newChannelCode = selectedCandidate.Channel.ChannelCode?.Trim() ?? string.Empty;
|
var newChannelCode = selectedCandidate.Channel.ChannelCode?.Trim() ?? string.Empty;
|
||||||
var channelChanged = !string.Equals(
|
// 仅「已有渠道 → 换成另一渠道」才算换渠道;首次从空排到渠道不算,避免误清跟踪号。
|
||||||
previousChannelCode,
|
var channelChanged = !string.IsNullOrWhiteSpace(previousChannelCode)
|
||||||
newChannelCode,
|
&& !string.Equals(
|
||||||
StringComparison.OrdinalIgnoreCase);
|
previousChannelCode,
|
||||||
|
newChannelCode,
|
||||||
|
StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
order.ChannelCode = selectedCandidate.Channel.ChannelCode;
|
order.ChannelCode = selectedCandidate.Channel.ChannelCode;
|
||||||
AllocationProviderSnapshotEnricher.ApplyDownstreamFieldsToOrder(
|
AllocationProviderSnapshotEnricher.ApplyDownstreamFieldsToOrder(
|
||||||
@ -1633,10 +1636,40 @@ public partial class OrderService
|
|||||||
{
|
{
|
||||||
var message = ex.Message.Trim();
|
var message = ex.Message.Trim();
|
||||||
order.AllocationPendingReason = message.Length > 512 ? message[..512] : message;
|
order.AllocationPendingReason = message.Length > 512 ? message[..512] : message;
|
||||||
|
// 清掉历史「用产品 code 占位 ChannelCode」的脏数据;已真实排过的渠道(含与产品同码)予以保留。
|
||||||
|
ClearUnallocatedProductCodeChannelPlaceholder(order);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 未真正排货成功前,曾把 ProductCode 写入 ChannelCode 作占位;排货失败时清掉该占位,避免详情误显示。
|
||||||
|
/// 若 ChannelCode 与产品同码但已带下游字段,视为真实渠道,不清。
|
||||||
|
/// </summary>
|
||||||
|
private static void ClearUnallocatedProductCodeChannelPlaceholder(Order order)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(order.ChannelCode) || string.IsNullOrWhiteSpace(order.ProductCode))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.Equals(order.ChannelCode.Trim(), order.ProductCode.Trim(), StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var hasDownstream = !string.IsNullOrWhiteSpace(order.DownstreamSupplierCode)
|
||||||
|
|| !string.IsNullOrWhiteSpace(order.DownstreamSupplierName)
|
||||||
|
|| !string.IsNullOrWhiteSpace(order.ChannelForecastCode)
|
||||||
|
|| order.DownstreamAppId is > 0;
|
||||||
|
if (hasDownstream)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
order.ChannelCode = null;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<List<SalesProductAllocationProviderSnapshotDto>> ResolveAllocationProvidersAsync(
|
private async Task<List<SalesProductAllocationProviderSnapshotDto>> ResolveAllocationProvidersAsync(
|
||||||
SalesProduct product,
|
SalesProduct product,
|
||||||
SalesProductRulesPublishSnapshotDto rulesSnapshot)
|
SalesProductRulesPublishSnapshotDto rulesSnapshot)
|
||||||
@ -2642,7 +2675,8 @@ public partial class OrderService
|
|||||||
TrackNo = input.TrackNo,
|
TrackNo = input.TrackNo,
|
||||||
ServiceNo = serviceNo,
|
ServiceNo = serviceNo,
|
||||||
ProductCode = input.ProductCode,
|
ProductCode = input.ProductCode,
|
||||||
ChannelCode = input.ChannelCode ?? product.ProductCode,
|
// 服务渠道仅排货成功后写入;未排货保持空,避免详情把产品 code 当成渠道 code。
|
||||||
|
ChannelCode = string.IsNullOrWhiteSpace(input.ChannelCode) ? null : input.ChannelCode.Trim(),
|
||||||
ConsigneeCountry = consigneeCountry,
|
ConsigneeCountry = consigneeCountry,
|
||||||
ConsigneeCountryName = consigneeCountryName,
|
ConsigneeCountryName = consigneeCountryName,
|
||||||
CargoAttribute = input.CargoAttribute ?? CargoAttributeCodes.General,
|
CargoAttribute = input.CargoAttribute ?? CargoAttributeCodes.General,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user