fix:时间轴顺序问题

This commit is contained in:
eli 2024-11-21 11:21:18 +08:00
parent 5166ec42b4
commit 9511dac81d

View File

@ -235,20 +235,27 @@ public class TrackOrderService : ApplicationService
}); });
} }
//如果轨迹状态没完结则追加最后一个默认节点 // 按轨迹发生时间正序排序
if (!order.IsCompleted) res.Data = res.Data?.OrderBy(m => m.TrackTime).ToList();
if (!order.IsCompleted) //如果没完结则显示签收节点
{
var eddUnixTimestamp = order.EstimatedDeliveryDate.HasValue ? ToUnixTimestamp(DateTime.Parse(order.EstimatedDeliveryDate.ToString()!)) : 0;
//订单上有预计签收时间,需要对比预计到达时间是否大于时间轴上所有轨迹内容的发生时间,如果有任意一条时间大于预计签收时间,则隐藏签收节点
if (eddUnixTimestamp > 0 && res.Data != null && res.Data.All(m => m.TrackTime < eddUnixTimestamp))
{ {
res.Data.Add(new GetDetailTimelineOutput() res.Data.Add(new GetDetailTimelineOutput()
{ {
Content = "签收", Content = "签收",
IsHighlight = false, IsHighlight = false,
TrackTimeZone = order.EstimatedDeliveryDate.HasValue ? $"GMT{(order.DestinationTimeZone >= 0 ? "+" : "-")}{order.DestinationTimeZone}" : "", TrackTimeZone = order.EstimatedDeliveryDate.HasValue ? $"GMT{(order.DestinationTimeZone >= 0 ? "+" : "-")}{order.DestinationTimeZone}" : "",
TrackTime = order.EstimatedDeliveryDate.HasValue ? ToUnixTimestamp(DateTime.Parse(order.EstimatedDeliveryDate.ToString()!)) : 0, TrackTime = eddUnixTimestamp,
TrackTimePrefix = order.EstimatedDeliveryDate.HasValue ? "预计签收时间:" : "", TrackTimePrefix = order.EstimatedDeliveryDate.HasValue ? "预计签收时间:" : "",
}); });
} }
}
res.Data = res.Data?.OrderBy(m => m.TrackTime).ToList();
return res; return res;
} }