Merge branch 'S07' into test

This commit is contained in:
hardstylewyl 2025-06-26 16:22:38 +08:00
commit 74abe3782d
4 changed files with 15 additions and 107 deletions

View File

@ -84,9 +84,8 @@ public partial class OrderService : ApplicationService, IOrderService
order = ObjectMapper.Map<UpsertOrderInput, OrderEntity>(input);
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
order.OrderPullStatus = BuiltOrderPullStatus(input.PullConfigInfos);
order.OrderPlatformNumbers = BuiltOrderPlatformNumbers(input.PullConfigInfos);
order.TemplateCodes = input.TemplateCodes == null ? null : string.Join(',', input.TemplateCodes);
order.SetThirdPartyOrderNumber(order.OrderPlatformNumbers);
order.SetThirdPartyOrderNumber(order.OrderPullStatus);
var orderId = await _orderRepository.CreateOrderAsync(order);
@ -143,9 +142,8 @@ public partial class OrderService : ApplicationService, IOrderService
var order2 = ObjectMapper.Map(input2, order);
order2.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input2.FlightInfos);
order2.OrderPullStatus = BuiltOrderPullStatus(input2.PullConfigInfos);
order2.OrderPlatformNumbers = BuiltOrderPlatformNumbers(input2.PullConfigInfos);
order2.TemplateCodes = input2.TemplateCodes == null ? null : string.Join(',', input2.TemplateCodes);
order2.SetThirdPartyOrderNumber(order.OrderPlatformNumbers);
order2.SetThirdPartyOrderNumber(order.OrderPullStatus);
updateOrders.Add(order2);
updateRecords.Add(new OrderOperationRecordIndex
{
@ -180,9 +178,8 @@ public partial class OrderService : ApplicationService, IOrderService
var order = ObjectMapper.Map<UpsertOrderInput, OrderEntity>(insertInput);
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(insertInput.FlightInfos);
order.OrderPullStatus = BuiltOrderPullStatus(insertInput.PullConfigInfos);
order.OrderPlatformNumbers = BuiltOrderPlatformNumbers(insertInput.PullConfigInfos);
order.TemplateCodes = insertInput.TemplateCodes == null ? null : string.Join(',', insertInput.TemplateCodes);
order.SetThirdPartyOrderNumber(order.OrderPlatformNumbers);
order.SetThirdPartyOrderNumber(order.OrderPullStatus);
insertOrders.Add(order);
createRecords.Add(new OrderOperationRecordIndex
{
@ -240,9 +237,8 @@ public partial class OrderService : ApplicationService, IOrderService
order = ObjectMapper.Map(input, order);
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
order.OrderPullStatus = BuiltOrderPullStatus(input.PullConfigInfos);
order.OrderPlatformNumbers = BuiltOrderPlatformNumbers(input.PullConfigInfos);
order.TemplateCodes = input.TemplateCodes == null ? null : string.Join(',', input.TemplateCodes);
order.SetThirdPartyOrderNumber(order.OrderPlatformNumbers);
order.SetThirdPartyOrderNumber(order.OrderPullStatus);
await _orderRepository.UpdateOrderAsync(order);
}
@ -277,24 +273,6 @@ public partial class OrderService : ApplicationService, IOrderService
}).ToList();
}
private static List<OrderPlatformNumberEntity> BuiltOrderPlatformNumbers(List<PullConfigInfo>? pullConfigInfos)
{
if (pullConfigInfos == null) return new List<OrderPlatformNumberEntity>();
return pullConfigInfos.Select(x =>
{
var status = new OrderPlatformNumberEntity
{
//三方单号
OrderNumber = x.OrderNo,
//三方平台名称,目前认为是服务商code
Platform = x.ServiceCode,
};
return status;
}).ToList();
}
private void WarningCalc_OrderDeletedOrCompleted(OrderEntity order)
{
order.IsDeleted = true;

View File

@ -206,10 +206,6 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
[SugarColumn(IsIgnore = true)]
public List<OrderPullStatusEntity> OrderPullStatus { get; set; }
[Navigate(NavigateType.OneToMany, nameof(OrderPlatformNumberEntity.OrderId))]
[SugarColumn(IsIgnore = true)]
public List<OrderPlatformNumberEntity> OrderPlatformNumbers { get; set; }
public void ResetTrackInfo()
{
IsCompleted = false;
@ -224,18 +220,18 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
}
// 设置三方单号字段
public void SetThirdPartyOrderNumber(List<OrderPlatformNumberEntity> orderPlatformNumberEntities)
public void SetThirdPartyOrderNumber(List<OrderPullStatusEntity> orderPullStatusEntities)
{
if (orderPlatformNumberEntities.Count == 0)
if (orderPullStatusEntities.Count == 0)
{
ThirdPartyOrderNumber = GlobalConst.EmptyString;
return;
}
const string separator = "、";
var thirdPartyOrderNumbers = orderPlatformNumberEntities
.Where(x => !string.IsNullOrWhiteSpace(x.OrderNumber))
.Select(x => $"{x.OrderNumber}({x.Platform})")
var thirdPartyOrderNumbers = orderPullStatusEntities
.Where(x => !string.IsNullOrWhiteSpace(x.OrderNo))
.Select(x => $"{x.OrderNo}({x.ServiceProviderCode})")
.ToList();
if (thirdPartyOrderNumbers.Count == 0)
{

View File

@ -1,32 +0,0 @@
namespace SJZY.Track.Domain.Aggregates.OrderAggregate;
/// <summary>
/// 外部单号关联表
/// </summary>
[SugarTable("t_order_platform_number")]
public class OrderPlatformNumberEntity : IFullAuditedBasicEntitys, IEntity
{
/// <summary>
/// 自增主键
/// </summary>
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 订单id
/// </summary>
[SugarColumn(ColumnName = "OrderId")]
public int OrderId { get; set; }
/// <summary>
/// 外部单号
/// </summary>
[SugarColumn(ColumnName = "OrderNumber")]
public string? OrderNumber { get; set; }
/// <summary>
/// 平台名称
/// </summary>
[SugarColumn(ColumnName = "Platform")]
public string? Platform { get; set; }
}

View File

@ -146,8 +146,8 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
.ToListAsync();
//匹配外部单
var orderIdsForThirdParty = await Context.Queryable<OrderPlatformNumberEntity>()
.Where(x => !string.IsNullOrWhiteSpace(x.OrderNumber) && orderNos.Contains(x.OrderNumber))
var orderIdsForThirdParty = await Context.Queryable<OrderPullStatusEntity>()
.Where(x => !string.IsNullOrWhiteSpace(x.OrderNo) && orderNos.Contains(x.OrderNo))
.Select(x => x.OrderId)
.ToListAsync();
@ -239,16 +239,16 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
public async Task<(int MainOrderId, string OrderNo, int CustomId)> GetTrackOrderByProviderAndOrderNo(string serviceProviderCode, string orderNo)
{
var orderList = await Context.Queryable<OrderEntity>()
.LeftJoin<OrderPlatformNumberEntity>((a, b) => a.Id == b.OrderId && b.IsDeleted == false)
.LeftJoin<OrderPullStatusEntity>((a, b) => a.Id == b.OrderId)
.Where((a, b) => a.OrderNo == orderNo
|| (b.Platform == serviceProviderCode && b.OrderNumber == orderNo))
|| (b.ServiceProviderCode == serviceProviderCode && b.OrderNo == orderNo))
.Select((a, b) => new
{
a.Id,
a.CustomId,
a.OrderNo,
b.Platform,
b.OrderNumber
Platform = b.ServiceProviderCode,
OrderNumber = b.OrderNo
})
.ToListAsync();
@ -274,8 +274,6 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
await Context.Insertable(order.OrderFlights).ExecuteCommandAsync();
order.OrderPullStatus.ForEach(x => x.OrderId = orderId);
await Context.Insertable(order.OrderPullStatus).ExecuteCommandAsync();
order.OrderPlatformNumbers.ForEach(x => x.OrderId = orderId);
await Context.Insertable(order.OrderPlatformNumbers).ExecuteCommandAsync();
tran.Complete();
@ -289,7 +287,6 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
var orderFlights = orders.SelectMany(x => x.OrderFlights).ToList();
var orderPullStatus = orders.SelectMany(x => x.OrderPullStatus).ToList();
var orderPlatformNumbers = orders.SelectMany(x => x.OrderPlatformNumbers).ToList();
try
{
@ -314,12 +311,10 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
var orderId = orderNoIdDict[order.OrderNo];
order.OrderFlights.ForEach(x => x.OrderId = orderId);
order.OrderPullStatus.ForEach(x => x.OrderId = orderId);
order.OrderPlatformNumbers.ForEach(x => x.OrderId = orderId);
}
await Context.Insertable(orderFlights).ExecuteCommandAsync();
await Context.Insertable(orderPullStatus).ExecuteCommandAsync();
await Context.Insertable(orderPlatformNumbers).ExecuteCommandAsync();
}
finally
{
@ -356,11 +351,6 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
order.OrderPullStatus.ForEach(x => x.OrderId = order.Id);
await Context.Insertable(order.OrderPullStatus).ExecuteCommandAsync();
// 更新订单三方关联
await Context.Deleteable<OrderPlatformNumberEntity>().Where(x => x.OrderId == order.Id).ExecuteCommandAsync();
order.OrderPlatformNumbers.ForEach(x => x.OrderId = order.Id);
await Context.Insertable(order.OrderPlatformNumbers).ExecuteCommandAsync();
// 更新订单航班
await Context.Deleteable<OrderFlightEntity>().Where(x => x.OrderId == order.Id).ExecuteCommandAsync();
order.OrderFlights.ForEach(x => x.OrderId = order.Id);
@ -385,11 +375,9 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
var orderIds = orders.Select(x => x.Id).ToHashSet();
var orderFlights = orders.SelectMany(x => x.OrderFlights).ToList();
var orderPullStatus = orders.SelectMany(x => x.OrderPullStatus).ToList();
var orderPlatformNumbers = orders.SelectMany(x => x.OrderPlatformNumbers).ToList();
foreach (var order in orders)
{
order.OrderPullStatus.ForEach(x => x.OrderId = order.Id);
order.OrderPlatformNumbers.ForEach(x => x.OrderId = order.Id);
order.OrderFlights.ForEach(x => x.OrderId = order.Id);
}
@ -397,10 +385,6 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
await Context.Deleteable<OrderPullStatusEntity>().Where(x => orderIds.Contains(x.OrderId)).ExecuteCommandAsync();
await Context.Insertable(orderPullStatus).ExecuteCommandAsync();
// 更新订单三方关联
await Context.Deleteable<OrderPlatformNumberEntity>().Where(x => orderIds.Contains(x.OrderId)).ExecuteCommandAsync();
await Context.Insertable(orderPlatformNumbers).ExecuteCommandAsync();
// 更新订单航班
await Context.Deleteable<OrderFlightEntity>().Where(x => orderIds.Contains(x.OrderId)).ExecuteCommandAsync();
await Context.Insertable(orderFlights).ExecuteCommandAsync();
@ -522,24 +506,6 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
});
}
/// <summary>
/// 拼接多个三方单号,默认使用分隔符默认(、)
/// 第三方单号展示: 0000000(服务商)、0000000(服务商)
/// </summary>
/// <param name="orderPlatformNumberEntities"></param>
/// <returns></returns>
public string BuildThirdPartyOrderNumber(List<OrderPlatformNumberEntity> orderPlatformNumberEntities)
{
if (orderPlatformNumberEntities.Count == 0) return GlobalConst.EmptyString;
const string separator = "、";
var thirdPartyOrderNumbers = orderPlatformNumberEntities
.Where(x => !string.IsNullOrWhiteSpace(x.OrderNumber))
.Select(x => $"{x.OrderNumber}({x.Platform})")
.ToList();
if (thirdPartyOrderNumbers.Count == 0) return GlobalConst.EmptyString;
return string.Join(separator, thirdPartyOrderNumbers);
}
#region 订单关联
public async Task<List<LinkedOrderVO>> GetLinkedOrdersAsync(int[] orderIds)