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