update: 增加轨迹来源的约束
update:增加【轨迹发生时间】筛选项用于放宽修改轨迹明细限制
This commit is contained in:
parent
a1986273c6
commit
5166ec42b4
@ -285,8 +285,9 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
|||||||
TrackDetailsIndex? track;
|
TrackDetailsIndex? track;
|
||||||
if (!@event.IsAdd)
|
if (!@event.IsAdd)
|
||||||
{
|
{
|
||||||
//同一订单同轨迹code如果有多条轨迹明细则不允许修改
|
//同一订单同轨迹code同一轨迹时间如果有多条轨迹明细则不允许修改
|
||||||
var existTracks = tracks.Where(x => x.OrderId == order.OrderId).ToArray();
|
var existTracks = tracks.Where(x => x.OrderId == order.OrderId
|
||||||
|
&& x.TrackTime == @event.TrackTime).ToArray();
|
||||||
if (existTracks.Length > 1)
|
if (existTracks.Length > 1)
|
||||||
{
|
{
|
||||||
// 修改轨迹时,订单存在多条轨迹不允许修改
|
// 修改轨迹时,订单存在多条轨迹不允许修改
|
||||||
|
|||||||
@ -55,6 +55,11 @@ public partial class TrackService : ApplicationService, ITrackService
|
|||||||
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
|
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))
|
if (input.TrackTime < DateTime.Now.AddYears(-100) || input.TrackTime > DateTime.Now.AddYears(100))
|
||||||
{
|
{
|
||||||
throw new BusinessException(message: "轨迹时间不合法");
|
throw new BusinessException(message: "轨迹时间不合法");
|
||||||
@ -93,9 +98,11 @@ public partial class TrackService : ApplicationService, ITrackService
|
|||||||
throw new BusinessException(message: $"轨迹代码:{input.TrackCode}不允许手动更新");
|
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)
|
if (!input.IsAdd && tracks.Count > 1)
|
||||||
{
|
{
|
||||||
throw new BusinessException(message: $"订单:{input.OrderNo},轨迹代码:{input.TrackCode}存在多条记录,不允许修改");
|
throw new BusinessException(message: $"订单:{input.OrderNo},轨迹代码:{input.TrackCode}存在多条记录,不允许修改");
|
||||||
@ -291,6 +298,11 @@ public partial class TrackService : ApplicationService, ITrackService
|
|||||||
throw new BusinessException(message: "订单一个都不存在");
|
throw new BusinessException(message: "订单一个都不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!GlobalConst.SupportTrackSources.Contains(input.Source))
|
||||||
|
{
|
||||||
|
throw new BusinessException(message: "轨迹来源是必须的");
|
||||||
|
}
|
||||||
|
|
||||||
//当修改时,如果为来源为外部提供商则不允许修改
|
//当修改时,如果为来源为外部提供商则不允许修改
|
||||||
if (!input.IsAdd && input.Source == (int) TrackSourceEnum.ExternalServiceProvide)
|
if (!input.IsAdd && input.Source == (int) TrackSourceEnum.ExternalServiceProvide)
|
||||||
{
|
{
|
||||||
@ -334,9 +346,11 @@ public partial class TrackService : ApplicationService, ITrackService
|
|||||||
throw new BusinessException(message: $"轨迹代码:{input.TrackCode}不允许手动更新");
|
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)
|
if (!input.IsAdd && tracks.Count > 1)
|
||||||
{
|
{
|
||||||
throw new BusinessException(message: $"订单:{order.OrderNo},轨迹代码:{input.TrackCode}存在多条记录,不允许修改");
|
throw new BusinessException(message: $"订单:{order.OrderNo},轨迹代码:{input.TrackCode}存在多条记录,不允许修改");
|
||||||
|
|||||||
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