using Microsoft.AspNetCore.Mvc; using Oms.Application.Dtos.Orders; using Oms.Domain.OrdersAggregate.Entities; namespace Oms.Application.Services.Orders; public partial class OrderService { private OrderOperationLogWriter OperationLogWriter => LazyServiceProvider.GetRequiredService(); /// /// 运单操作日志列表(按时间倒序)。 /// [HttpGet("/order/operation-log/list")] public async Task GetOperationLogListAsync([FromQuery] int orderId) { await GetOrderOrThrowAsync(orderId); return await OperationLogWriter.ListByOrderIdAsync(orderId); } private async Task> CaptureOrderAuditSnapshotAsync( Order order, bool includeParties = false, bool includeWeights = false, bool includeFees = false) { var parts = new List> { OrderOperationLogSnapshot.CaptureOrder(order) }; if (includeParties) { var senders = await OrderRepository.GetSendersByOrderIdsAsync([order.Id]); var recipients = await OrderRepository.GetRecipientsByOrderIdsAsync([order.Id]); parts.Add(OrderOperationLogSnapshot.CaptureSender(senders.FirstOrDefault())); parts.Add(OrderOperationLogSnapshot.CaptureReceiver(recipients.FirstOrDefault())); } if (includeWeights) { var weights = await OrderRepository.GetWeightsByOrderIdsAsync([order.Id]); parts.Add(OrderOperationLogSnapshot.CaptureWeights(weights)); } if (includeFees) { var fees = await OrderRepository.GetFeesByOrderIdsAsync([order.Id]); parts.Add(OrderOperationLogSnapshot.CaptureFeeTotals(fees)); } return OrderOperationLogSnapshot.Merge(parts.ToArray()); } }