添加修改日志到轨迹订单
This commit is contained in:
parent
e2171767fb
commit
48385cb961
@ -27,6 +27,11 @@ public class TrackDeleteEvent
|
||||
/// </summary>
|
||||
public string? OperationMan { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作人姓名
|
||||
/// </summary>
|
||||
public int OperationManId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已经处理过的订单
|
||||
/// </summary>
|
||||
|
||||
@ -24,6 +24,11 @@ public class TrackUpsertEvent
|
||||
/// </summary>
|
||||
public string? OperationMan { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作人id
|
||||
/// </summary>
|
||||
public int OperationManId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// true新增,false更新
|
||||
/// </summary>
|
||||
|
||||
@ -23,13 +23,15 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
|
||||
private readonly IProvideQueries _provideQueries;
|
||||
private readonly ITrackDetailsEsRepository _trackDetailsEsRepository;
|
||||
private readonly RabbitClientBus _rabbitClientBus;
|
||||
private readonly IOrderOperationRecordEsRepository _orderOperationRecordEsRepository;
|
||||
|
||||
public TrackDeleteEventHandler(IProvideQueries provideQueries,
|
||||
IOrderRepository orderRepository, ICapPublisher capPublisher,
|
||||
ITrackDetailsEsRepository trackDetailsEsRepository,
|
||||
RabbitClientBus rabbitClientBus,
|
||||
ITrackStatusRepository trackStatusRepository,
|
||||
ITrackContentRepository trackContentRepository)
|
||||
ITrackContentRepository trackContentRepository,
|
||||
IOrderOperationRecordEsRepository orderOperationRecordEsRepository)
|
||||
{
|
||||
_provideQueries = provideQueries;
|
||||
_orderRepository = orderRepository;
|
||||
@ -38,6 +40,7 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
|
||||
_rabbitClientBus = rabbitClientBus;
|
||||
_trackStatusRepository = trackStatusRepository;
|
||||
_trackContentRepository = trackContentRepository;
|
||||
_orderOperationRecordEsRepository = orderOperationRecordEsRepository;
|
||||
}
|
||||
|
||||
[CapSubscribe(GlobalConst.TrackDeleteSubscribe, Group = GlobalConst.TrackDeleteSubscribe)]
|
||||
@ -168,6 +171,7 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
|
||||
{
|
||||
tracks = await _trackDetailsEsRepository.GetDataByIds(@event.EsIds);
|
||||
orderIds = tracks.Select(m => m.OrderId).Distinct().ToList();
|
||||
@event.OrderIds = orderIds.ToArray();
|
||||
|
||||
// 外部api获取的轨迹不允许删除
|
||||
if (tracks.Any(m => m.Source == TrackSourceEnum.ExternalServiceProvide.GetHashCode()))
|
||||
@ -223,6 +227,19 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
|
||||
order.LatestTrackTime = track.TrackTime;
|
||||
order.LatestTrackTimeZone = track.TrackTimeZone;
|
||||
}
|
||||
|
||||
|
||||
// 写入操作日志
|
||||
_ = _orderOperationRecordEsRepository.AddAsync(new OrderOperationRecordIndex
|
||||
{
|
||||
OrderId = order.Id,
|
||||
OrderNo = order.OrderNo,
|
||||
OptionType = OrderOperationType.删除轨迹.ToString(),
|
||||
Content = tracks?.Where(m=>m.OrderId == order.Id)?.ToList().ToJson(),
|
||||
CreateUserId = @event.OperationManId,
|
||||
CreateUserName = @event.OperationMan ?? "",
|
||||
CreateTime = DateTime.Now
|
||||
});
|
||||
}
|
||||
|
||||
await _orderRepository.UpdateRangeAsync(orders,
|
||||
|
||||
@ -22,20 +22,22 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
private readonly IProvideQueries _provideQueries;
|
||||
private readonly ITrackDetailsEsRepository _trackDetailsEsRepository;
|
||||
private readonly RabbitClientBus _rabbitClientBus;
|
||||
private readonly IOrderOperationRecordEsRepository _orderOperationRecordEsRepository;
|
||||
|
||||
public TrackUpsertEventHandler(
|
||||
IOrderRepository orderRepository,
|
||||
ICapPublisher capPublisher,
|
||||
IProvideQueries provideQueries,
|
||||
ITrackDetailsEsRepository trackDetailsEsRepository,
|
||||
ITrackStatusRepository trackStatusRepository,
|
||||
RabbitClientBus rabbitClientBus)
|
||||
RabbitClientBus rabbitClientBus,
|
||||
IOrderOperationRecordEsRepository orderOperationRecordEsRepository)
|
||||
{
|
||||
_orderRepository = orderRepository;
|
||||
_capPublisher = capPublisher;
|
||||
_provideQueries = provideQueries;
|
||||
_trackDetailsEsRepository = trackDetailsEsRepository;
|
||||
_rabbitClientBus = rabbitClientBus;
|
||||
_orderOperationRecordEsRepository = orderOperationRecordEsRepository;
|
||||
}
|
||||
|
||||
[CapSubscribe(GlobalConst.TrackUpsertSubscribe, Group = GlobalConst.TrackUpsertSubscribe)]
|
||||
@ -294,6 +296,19 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
|
||||
//来源与外部服务商不允许修改
|
||||
if (track.Source == (int) TrackSourceEnum.ExternalServiceProvide) continue;
|
||||
|
||||
|
||||
// 写入操作日志
|
||||
_ = _orderOperationRecordEsRepository.AddAsync(new OrderOperationRecordIndex
|
||||
{
|
||||
OrderId = order.OrderId,
|
||||
OrderNo = order.OrderNo,
|
||||
OptionType = OrderOperationType.创建轨迹.ToString(),
|
||||
Content = track.ToJson(),
|
||||
CreateUserId = @event.OperationManId,
|
||||
CreateUserName = @event.OperationMan ?? "",
|
||||
CreateTime = DateTime.Now
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -329,6 +344,18 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
}
|
||||
|
||||
//其余情况:A,D都为新增操作,无需检查数量,track为null执行新增操作
|
||||
|
||||
// 写入操作日志
|
||||
_ = _orderOperationRecordEsRepository.AddAsync(new OrderOperationRecordIndex
|
||||
{
|
||||
OrderId = order.OrderId,
|
||||
OrderNo = order.OrderNo,
|
||||
OptionType = OrderOperationType.修改轨迹.ToString(),
|
||||
Content = track.ToJson(),
|
||||
CreateUserId = @event.OperationManId,
|
||||
CreateUserName = @event.OperationMan ?? "",
|
||||
CreateTime = DateTime.Now
|
||||
});
|
||||
}
|
||||
|
||||
if (track == default)
|
||||
|
||||
@ -60,7 +60,7 @@ public partial class OrderService : ApplicationService, IOrderService
|
||||
OptionType = OrderOperationType.修改订单.ToString(),
|
||||
Content = input.ToJson(),
|
||||
CreateUserId = currentUser.UserId,
|
||||
CreateUserString = currentUser.Name,
|
||||
CreateUserName = currentUser.Name,
|
||||
};
|
||||
|
||||
_ = _orderOperationRecordEsRepository.AddAsync(index);
|
||||
@ -87,7 +87,7 @@ public partial class OrderService : ApplicationService, IOrderService
|
||||
OptionType = OrderOperationType.创建订单.ToString(),
|
||||
Content = input.ToJson(),
|
||||
CreateUserId = currentUser.UserId,
|
||||
CreateUserString = currentUser.Name,
|
||||
CreateUserName = currentUser.Name,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
_ = _orderOperationRecordEsRepository.AddAsync(indexForAdd);
|
||||
|
||||
@ -195,11 +195,13 @@ public partial class TrackService : ApplicationService, ITrackService
|
||||
}
|
||||
|
||||
// 删除轨迹
|
||||
var currentUser = CurrentUserRequest.CurrentUser;
|
||||
var @event = new TrackDeleteEvent
|
||||
{
|
||||
EsIds = input.TrackContentEsIds.ToArray(),
|
||||
SubSystemId = tracks.First().SubSystemId,
|
||||
OperationMan = userInfo.Data.UserName,
|
||||
OperationMan = currentUser.Name,
|
||||
OperationManId = currentUser.UserId
|
||||
};
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackDeleteSubscribe, @event);
|
||||
|
||||
@ -350,6 +352,7 @@ public partial class TrackService : ApplicationService, ITrackService
|
||||
TrackTime = input.TrackTime,
|
||||
TrackTimeZone = input.TrackTimeZone,
|
||||
OperationMan = userInfo.Data.UserName,
|
||||
OperationManId= userInfo.Data.UserId,
|
||||
IsVisibility = input.IsVisibility,
|
||||
Source = input.Source,
|
||||
Remarks = input.Remarks,
|
||||
@ -361,7 +364,8 @@ public partial class TrackService : ApplicationService, ITrackService
|
||||
TrackPlaceNation = input.TrackPlaceNation,
|
||||
TrackPlacePostcode = input.TrackPlacePostcode,
|
||||
EstimatedDeliveryDate = input.EstimatedDeliveryDate,
|
||||
DestinationTimeZone = input.DestinationTimeZone
|
||||
DestinationTimeZone = input.DestinationTimeZone,
|
||||
|
||||
};
|
||||
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ public class OrderOperationRecordIndex : IdBaseIndex
|
||||
/// <summary>
|
||||
/// 创建人姓名
|
||||
/// </summary>
|
||||
public string CreateUserString { get; set; }
|
||||
public string CreateUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
|
||||
Loading…
Reference in New Issue
Block a user