All checks were successful
Build and Deploy / deploy (push) Successful in 1m0s
Co-authored-by: Cursor <cursoragent@cursor.com>
56 lines
1.9 KiB
C#
56 lines
1.9 KiB
C#
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<OrderOperationLogWriter>();
|
|
|
|
/// <summary>
|
|
/// 运单操作日志列表(按时间倒序)。
|
|
/// </summary>
|
|
[HttpGet("/order/operation-log/list")]
|
|
public async Task<OrderOperationLogListOutput> GetOperationLogListAsync([FromQuery] int orderId)
|
|
{
|
|
await GetOrderOrThrowAsync(orderId);
|
|
return await OperationLogWriter.ListByOrderIdAsync(orderId);
|
|
}
|
|
|
|
private async Task<Dictionary<string, string?>> CaptureOrderAuditSnapshotAsync(
|
|
Order order,
|
|
bool includeParties = false,
|
|
bool includeWeights = false,
|
|
bool includeFees = false)
|
|
{
|
|
var parts = new List<IReadOnlyDictionary<string, string?>>
|
|
{
|
|
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());
|
|
}
|
|
}
|