Merge branch 'refs/heads/S06' into test
This commit is contained in:
commit
107a277ee9
@ -285,8 +285,9 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
TrackDetailsIndex? track;
|
||||
if (!@event.IsAdd)
|
||||
{
|
||||
//同一订单同轨迹code如果有多条轨迹明细则不允许修改
|
||||
var existTracks = tracks.Where(x => x.OrderId == order.OrderId).ToArray();
|
||||
//同一订单同轨迹code同一轨迹时间如果有多条轨迹明细则不允许修改
|
||||
var existTracks = tracks.Where(x => x.OrderId == order.OrderId
|
||||
&& x.TrackTime == @event.TrackTime).ToArray();
|
||||
if (existTracks.Length > 1)
|
||||
{
|
||||
// 修改轨迹时,订单存在多条轨迹不允许修改
|
||||
|
||||
@ -55,6 +55,11 @@ public partial class TrackService : ApplicationService, ITrackService
|
||||
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
|
||||
}
|
||||
|
||||
if (!GlobalConst.SupportTrackSources.Contains(input.Source))
|
||||
{
|
||||
throw new BusinessException(message: "轨迹来源是必须的");
|
||||
}
|
||||
|
||||
if (input.TrackTime < DateTime.Now.AddYears(-100) || input.TrackTime > DateTime.Now.AddYears(100))
|
||||
{
|
||||
throw new BusinessException(message: "轨迹时间不合法");
|
||||
@ -93,9 +98,11 @@ public partial class TrackService : ApplicationService, ITrackService
|
||||
throw new BusinessException(message: $"轨迹代码:{input.TrackCode}不允许手动更新");
|
||||
}
|
||||
|
||||
var tracks = await _trackDetailsEsRepository.GetListAsync(new[] { order.Id }, input.TrackCode, true);
|
||||
var tracks = (await _trackDetailsEsRepository.GetListAsync(new[] { order.Id }, input.TrackCode, true))
|
||||
.Where(x => x.TrackTime == input.TrackTime)
|
||||
.ToList();
|
||||
|
||||
//更新轨迹,但存在多条轨迹记录,理由:不清晰到底要修改哪一条或是全部修改
|
||||
//更新轨迹,同一时间存在多条轨迹记录,理由:不清晰到底要修改哪一条或是全部修改
|
||||
if (!input.IsAdd && tracks.Count > 1)
|
||||
{
|
||||
throw new BusinessException(message: $"订单:{input.OrderNo},轨迹代码:{input.TrackCode}存在多条记录,不允许修改");
|
||||
@ -291,6 +298,11 @@ public partial class TrackService : ApplicationService, ITrackService
|
||||
throw new BusinessException(message: "订单一个都不存在");
|
||||
}
|
||||
|
||||
if (!GlobalConst.SupportTrackSources.Contains(input.Source))
|
||||
{
|
||||
throw new BusinessException(message: "轨迹来源是必须的");
|
||||
}
|
||||
|
||||
//当修改时,如果为来源为外部提供商则不允许修改
|
||||
if (!input.IsAdd && input.Source == (int) TrackSourceEnum.ExternalServiceProvide)
|
||||
{
|
||||
@ -334,9 +346,11 @@ public partial class TrackService : ApplicationService, ITrackService
|
||||
throw new BusinessException(message: $"轨迹代码:{input.TrackCode}不允许手动更新");
|
||||
}
|
||||
|
||||
var tracks = await _trackDetailsEsRepository.GetListAsync(new[] { order.Id }, input.TrackCode, true);
|
||||
var tracks = (await _trackDetailsEsRepository.GetListAsync(new[] { order.Id }, input.TrackCode, true))
|
||||
.Where(x => x.TrackTime == input.TrackTime)
|
||||
.ToList();
|
||||
|
||||
//更新轨迹,存在多条轨迹记录不允许更改,理由:不清晰到底要修改哪一条或是全部修改
|
||||
//更新轨迹,同一时间存在多条轨迹记录,理由:不清晰到底要修改哪一条或是全部修改
|
||||
if (!input.IsAdd && tracks.Count > 1)
|
||||
{
|
||||
throw new BusinessException(message: $"订单:{order.OrderNo},轨迹代码:{input.TrackCode}存在多条记录,不允许修改");
|
||||
|
||||
@ -235,20 +235,27 @@ public class TrackOrderService : ApplicationService
|
||||
});
|
||||
}
|
||||
|
||||
//如果轨迹状态没完结则追加最后一个默认节点
|
||||
if (!order.IsCompleted)
|
||||
// 按轨迹发生时间正序排序
|
||||
res.Data = res.Data?.OrderBy(m => m.TrackTime).ToList();
|
||||
|
||||
if (!order.IsCompleted) //如果没完结则显示签收节点
|
||||
{
|
||||
res.Data.Add(new GetDetailTimelineOutput()
|
||||
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))
|
||||
{
|
||||
Content = "签收",
|
||||
IsHighlight = false,
|
||||
TrackTimeZone = order.EstimatedDeliveryDate.HasValue ? $"GMT{(order.DestinationTimeZone >= 0 ? "+" : "-")}{order.DestinationTimeZone}" : "",
|
||||
TrackTime = order.EstimatedDeliveryDate.HasValue ? ToUnixTimestamp(DateTime.Parse(order.EstimatedDeliveryDate.ToString()!)) : 0,
|
||||
TrackTimePrefix = order.EstimatedDeliveryDate.HasValue ? "预计签收时间:" : "",
|
||||
});
|
||||
res.Data.Add(new GetDetailTimelineOutput()
|
||||
{
|
||||
Content = "签收",
|
||||
IsHighlight = false,
|
||||
TrackTimeZone = order.EstimatedDeliveryDate.HasValue ? $"GMT{(order.DestinationTimeZone >= 0 ? "+" : "-")}{order.DestinationTimeZone}" : "",
|
||||
TrackTime = eddUnixTimestamp,
|
||||
TrackTimePrefix = order.EstimatedDeliveryDate.HasValue ? "预计签收时间:" : "",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
res.Data = res.Data?.OrderBy(m => m.TrackTime).ToList();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
11
src/SJZY.Track.Domain/Consts/GlobalConst.Track.cs
Normal file
11
src/SJZY.Track.Domain/Consts/GlobalConst.Track.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace SJZY.Track.Domain.Consts;
|
||||
|
||||
public partial class GlobalConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹数据来源:1外部服务商创建,2内部系统创建,3人工创建
|
||||
/// </summary>
|
||||
public static readonly ImmutableHashSet<int> SupportTrackSources = ImmutableHashSet.Create(1, 2, 3);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user