diff --git a/src/TrackCenter.Application/Dtos/TrackPull/TrackPullPayload.cs b/src/TrackCenter.Application/Dtos/TrackPull/TrackPullPayload.cs
index c48bdded..75612ffa 100644
--- a/src/TrackCenter.Application/Dtos/TrackPull/TrackPullPayload.cs
+++ b/src/TrackCenter.Application/Dtos/TrackPull/TrackPullPayload.cs
@@ -3,7 +3,17 @@ namespace TrackCenter.Application.Dtos.TrackPull;
public class TrackPullPayload
{
///
- /// 订单号
+ /// 订单号(按拉取优先级配置的单号类型解析后的主单号)
///
public string OrderNo { get; set; } = null!;
+
+ ///
+ /// 尾程单号 / 跟踪号
+ ///
+ public string? TrackNo { get; set; }
+
+ ///
+ /// 其他单号
+ ///
+ public string? OtherNo { get; set; }
}
diff --git a/src/TrackCenter.Application/Queries/ProvideQueries.cs b/src/TrackCenter.Application/Queries/ProvideQueries.cs
index 1e5226fc..57da1285 100644
--- a/src/TrackCenter.Application/Queries/ProvideQueries.cs
+++ b/src/TrackCenter.Application/Queries/ProvideQueries.cs
@@ -62,6 +62,8 @@ public class ProvideQueries : SqlSugarRootlessRepository,
OrderNo = d.OrderNoType == TrackOrderNoType.客户单号 ? a.OrderNo :
d.OrderNoType == TrackOrderNoType.跟踪单号 ? a.TrackNo :
d.OrderNoType == TrackOrderNoType.其他单号 ? a.ThirdPartyOrderNumber : a.OrderNo,
+ TrackNo = a.TrackNo,
+ OtherNo = a.ThirdPartyOrderNumber,
OrderType = a.OrderType,
AppKey = a.AppKey,
ServiceProviderCode = b.ServiceProviderCode,
@@ -165,6 +167,8 @@ public class ProvideQueries : SqlSugarRootlessRepository,
OrderNo = config.OrderNoType == TrackOrderNoType.客户单号 ? a.OrderNo :
config.OrderNoType == TrackOrderNoType.跟踪单号 ? a.TrackNo :
config.OrderNoType == TrackOrderNoType.其他单号 ? a.ThirdPartyOrderNumber : a.OrderNo,
+ TrackNo = a.TrackNo,
+ OtherNo = a.ThirdPartyOrderNumber,
OrderType = a.OrderType,
AppKey = a.AppKey,
ServiceProviderCode = b.ServiceProviderCode
diff --git a/src/TrackCenter.Application/Services/ProvideServices/OrderService.V2.cs b/src/TrackCenter.Application/Services/ProvideServices/OrderService.V2.cs
index cbcfc734..af38574f 100644
--- a/src/TrackCenter.Application/Services/ProvideServices/OrderService.V2.cs
+++ b/src/TrackCenter.Application/Services/ProvideServices/OrderService.V2.cs
@@ -23,7 +23,9 @@ public partial class OrderService
x.AppKey == AppKey && x.OrderType == TrackOrderType.小包 && x.OrderNo == input.OrderNo);
if (order != null)
{
+ var existing = order;
order = await BuiltOrder(input);
+ ApplyUpsertOntoExisting(order, existing, resetTrackInfoWhenTrackNoChanged: true);
await _orderRepository.UpdateOrderAsync(order);
@@ -71,7 +73,9 @@ public partial class OrderService
x.AppKey == AppKey && x.OrderType == TrackOrderType.大包 && x.OrderNo == input.BagNo);
if (order != null)
{
+ var existing = order;
order = await BuiltOrder(input);
+ ApplyUpsertOntoExisting(order, existing, resetTrackInfoWhenTrackNoChanged: false);
await _orderRepository.UpdateOrderAsync(order);
@@ -119,7 +123,9 @@ public partial class OrderService
x.AppKey == AppKey && x.OrderType == TrackOrderType.主单 && x.OrderNo == input.MasterNo);
if (order != null)
{
+ var existing = order;
order = await BuiltOrder(input);
+ ApplyUpsertOntoExisting(order, existing, resetTrackInfoWhenTrackNoChanged: false);
await _orderRepository.UpdateOrderAsync(order);
@@ -260,6 +266,41 @@ public partial class OrderService
return order;
}
+ ///
+ /// 合并到已有订单:保留 Id;跟踪号未变则保留轨迹摘要,变更则清空便于重拉。
+ ///
+ private static void ApplyUpsertOntoExisting(
+ OrderEntity built,
+ OrderEntity existing,
+ bool resetTrackInfoWhenTrackNoChanged)
+ {
+ built.Id = existing.Id;
+
+ var previousTrackNo = existing.TrackNo?.Trim() ?? string.Empty;
+ var nextTrackNo = built.TrackNo?.Trim() ?? string.Empty;
+ var trackNoChanged = !string.Equals(previousTrackNo, nextTrackNo, StringComparison.Ordinal);
+
+ if (resetTrackInfoWhenTrackNoChanged && trackNoChanged)
+ {
+ built.ResetTrackInfo();
+ return;
+ }
+
+ built.IsCompleted = existing.IsCompleted;
+ built.LatestPushTrackCode = existing.LatestPushTrackCode;
+ built.LatestPushTime = existing.LatestPushTime;
+ built.LatestPushError = existing.LatestPushError;
+ built.LatestTrackStatus = existing.LatestTrackStatus;
+ built.LatestTrackContent = existing.LatestTrackContent;
+ built.LatestTrackEnContent = existing.LatestTrackEnContent;
+ built.LatestTrackTime = existing.LatestTrackTime;
+ built.LatestTrackTimeZone = existing.LatestTrackTimeZone;
+ built.LatestTrackPlace = existing.LatestTrackPlace;
+ built.EstimatedDeliveryDate = existing.EstimatedDeliveryDate;
+ built.DestinationTimeZone = existing.DestinationTimeZone;
+ built.QuestionType = existing.QuestionType;
+ }
+
private static OrderPullStatusEntity CreateOrderPullStatus(TrackPullConfigEntity config, OrderEntity order)
{
var status = new OrderPullStatusEntity
diff --git a/src/TrackCenter.Application/Services/ProvideServices/TrackPullService.cs b/src/TrackCenter.Application/Services/ProvideServices/TrackPullService.cs
index 22fd0039..a4248da4 100644
--- a/src/TrackCenter.Application/Services/ProvideServices/TrackPullService.cs
+++ b/src/TrackCenter.Application/Services/ProvideServices/TrackPullService.cs
@@ -68,7 +68,9 @@ public class TrackPullService : ApplicationServiceBase
{
var data = new List