Merge branch 'S07' into test
This commit is contained in:
commit
74abe3782d
@ -84,9 +84,8 @@ public partial class OrderService : ApplicationService, IOrderService
|
|||||||
order = ObjectMapper.Map<UpsertOrderInput, OrderEntity>(input);
|
order = ObjectMapper.Map<UpsertOrderInput, OrderEntity>(input);
|
||||||
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
|
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
|
||||||
order.OrderPullStatus = BuiltOrderPullStatus(input.PullConfigInfos);
|
order.OrderPullStatus = BuiltOrderPullStatus(input.PullConfigInfos);
|
||||||
order.OrderPlatformNumbers = BuiltOrderPlatformNumbers(input.PullConfigInfos);
|
|
||||||
order.TemplateCodes = input.TemplateCodes == null ? null : string.Join(',', input.TemplateCodes);
|
order.TemplateCodes = input.TemplateCodes == null ? null : string.Join(',', input.TemplateCodes);
|
||||||
order.SetThirdPartyOrderNumber(order.OrderPlatformNumbers);
|
order.SetThirdPartyOrderNumber(order.OrderPullStatus);
|
||||||
|
|
||||||
var orderId = await _orderRepository.CreateOrderAsync(order);
|
var orderId = await _orderRepository.CreateOrderAsync(order);
|
||||||
|
|
||||||
@ -143,9 +142,8 @@ public partial class OrderService : ApplicationService, IOrderService
|
|||||||
var order2 = ObjectMapper.Map(input2, order);
|
var order2 = ObjectMapper.Map(input2, order);
|
||||||
order2.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input2.FlightInfos);
|
order2.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input2.FlightInfos);
|
||||||
order2.OrderPullStatus = BuiltOrderPullStatus(input2.PullConfigInfos);
|
order2.OrderPullStatus = BuiltOrderPullStatus(input2.PullConfigInfos);
|
||||||
order2.OrderPlatformNumbers = BuiltOrderPlatformNumbers(input2.PullConfigInfos);
|
|
||||||
order2.TemplateCodes = input2.TemplateCodes == null ? null : string.Join(',', input2.TemplateCodes);
|
order2.TemplateCodes = input2.TemplateCodes == null ? null : string.Join(',', input2.TemplateCodes);
|
||||||
order2.SetThirdPartyOrderNumber(order.OrderPlatformNumbers);
|
order2.SetThirdPartyOrderNumber(order.OrderPullStatus);
|
||||||
updateOrders.Add(order2);
|
updateOrders.Add(order2);
|
||||||
updateRecords.Add(new OrderOperationRecordIndex
|
updateRecords.Add(new OrderOperationRecordIndex
|
||||||
{
|
{
|
||||||
@ -180,9 +178,8 @@ public partial class OrderService : ApplicationService, IOrderService
|
|||||||
var order = ObjectMapper.Map<UpsertOrderInput, OrderEntity>(insertInput);
|
var order = ObjectMapper.Map<UpsertOrderInput, OrderEntity>(insertInput);
|
||||||
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(insertInput.FlightInfos);
|
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(insertInput.FlightInfos);
|
||||||
order.OrderPullStatus = BuiltOrderPullStatus(insertInput.PullConfigInfos);
|
order.OrderPullStatus = BuiltOrderPullStatus(insertInput.PullConfigInfos);
|
||||||
order.OrderPlatformNumbers = BuiltOrderPlatformNumbers(insertInput.PullConfigInfos);
|
|
||||||
order.TemplateCodes = insertInput.TemplateCodes == null ? null : string.Join(',', insertInput.TemplateCodes);
|
order.TemplateCodes = insertInput.TemplateCodes == null ? null : string.Join(',', insertInput.TemplateCodes);
|
||||||
order.SetThirdPartyOrderNumber(order.OrderPlatformNumbers);
|
order.SetThirdPartyOrderNumber(order.OrderPullStatus);
|
||||||
insertOrders.Add(order);
|
insertOrders.Add(order);
|
||||||
createRecords.Add(new OrderOperationRecordIndex
|
createRecords.Add(new OrderOperationRecordIndex
|
||||||
{
|
{
|
||||||
@ -240,9 +237,8 @@ public partial class OrderService : ApplicationService, IOrderService
|
|||||||
order = ObjectMapper.Map(input, order);
|
order = ObjectMapper.Map(input, order);
|
||||||
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
|
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
|
||||||
order.OrderPullStatus = BuiltOrderPullStatus(input.PullConfigInfos);
|
order.OrderPullStatus = BuiltOrderPullStatus(input.PullConfigInfos);
|
||||||
order.OrderPlatformNumbers = BuiltOrderPlatformNumbers(input.PullConfigInfos);
|
|
||||||
order.TemplateCodes = input.TemplateCodes == null ? null : string.Join(',', input.TemplateCodes);
|
order.TemplateCodes = input.TemplateCodes == null ? null : string.Join(',', input.TemplateCodes);
|
||||||
order.SetThirdPartyOrderNumber(order.OrderPlatformNumbers);
|
order.SetThirdPartyOrderNumber(order.OrderPullStatus);
|
||||||
await _orderRepository.UpdateOrderAsync(order);
|
await _orderRepository.UpdateOrderAsync(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,24 +273,6 @@ public partial class OrderService : ApplicationService, IOrderService
|
|||||||
}).ToList();
|
}).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)
|
private void WarningCalc_OrderDeletedOrCompleted(OrderEntity order)
|
||||||
{
|
{
|
||||||
order.IsDeleted = true;
|
order.IsDeleted = true;
|
||||||
|
|||||||
@ -206,10 +206,6 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
|||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsIgnore = true)]
|
||||||
public List<OrderPullStatusEntity> OrderPullStatus { get; set; }
|
public List<OrderPullStatusEntity> OrderPullStatus { get; set; }
|
||||||
|
|
||||||
[Navigate(NavigateType.OneToMany, nameof(OrderPlatformNumberEntity.OrderId))]
|
|
||||||
[SugarColumn(IsIgnore = true)]
|
|
||||||
public List<OrderPlatformNumberEntity> OrderPlatformNumbers { get; set; }
|
|
||||||
|
|
||||||
public void ResetTrackInfo()
|
public void ResetTrackInfo()
|
||||||
{
|
{
|
||||||
IsCompleted = false;
|
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;
|
ThirdPartyOrderNumber = GlobalConst.EmptyString;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string separator = "、";
|
const string separator = "、";
|
||||||
var thirdPartyOrderNumbers = orderPlatformNumberEntities
|
var thirdPartyOrderNumbers = orderPullStatusEntities
|
||||||
.Where(x => !string.IsNullOrWhiteSpace(x.OrderNumber))
|
.Where(x => !string.IsNullOrWhiteSpace(x.OrderNo))
|
||||||
.Select(x => $"{x.OrderNumber}({x.Platform})")
|
.Select(x => $"{x.OrderNo}({x.ServiceProviderCode})")
|
||||||
.ToList();
|
.ToList();
|
||||||
if (thirdPartyOrderNumbers.Count == 0)
|
if (thirdPartyOrderNumbers.Count == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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; }
|
|
||||||
}
|
|
||||||
@ -146,8 +146,8 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
//匹配外部单
|
//匹配外部单
|
||||||
var orderIdsForThirdParty = await Context.Queryable<OrderPlatformNumberEntity>()
|
var orderIdsForThirdParty = await Context.Queryable<OrderPullStatusEntity>()
|
||||||
.Where(x => !string.IsNullOrWhiteSpace(x.OrderNumber) && orderNos.Contains(x.OrderNumber))
|
.Where(x => !string.IsNullOrWhiteSpace(x.OrderNo) && orderNos.Contains(x.OrderNo))
|
||||||
.Select(x => x.OrderId)
|
.Select(x => x.OrderId)
|
||||||
.ToListAsync();
|
.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)
|
public async Task<(int MainOrderId, string OrderNo, int CustomId)> GetTrackOrderByProviderAndOrderNo(string serviceProviderCode, string orderNo)
|
||||||
{
|
{
|
||||||
var orderList = await Context.Queryable<OrderEntity>()
|
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
|
.Where((a, b) => a.OrderNo == orderNo
|
||||||
|| (b.Platform == serviceProviderCode && b.OrderNumber == orderNo))
|
|| (b.ServiceProviderCode == serviceProviderCode && b.OrderNo == orderNo))
|
||||||
.Select((a, b) => new
|
.Select((a, b) => new
|
||||||
{
|
{
|
||||||
a.Id,
|
a.Id,
|
||||||
a.CustomId,
|
a.CustomId,
|
||||||
a.OrderNo,
|
a.OrderNo,
|
||||||
b.Platform,
|
Platform = b.ServiceProviderCode,
|
||||||
b.OrderNumber
|
OrderNumber = b.OrderNo
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
@ -274,8 +274,6 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
|||||||
await Context.Insertable(order.OrderFlights).ExecuteCommandAsync();
|
await Context.Insertable(order.OrderFlights).ExecuteCommandAsync();
|
||||||
order.OrderPullStatus.ForEach(x => x.OrderId = orderId);
|
order.OrderPullStatus.ForEach(x => x.OrderId = orderId);
|
||||||
await Context.Insertable(order.OrderPullStatus).ExecuteCommandAsync();
|
await Context.Insertable(order.OrderPullStatus).ExecuteCommandAsync();
|
||||||
order.OrderPlatformNumbers.ForEach(x => x.OrderId = orderId);
|
|
||||||
await Context.Insertable(order.OrderPlatformNumbers).ExecuteCommandAsync();
|
|
||||||
|
|
||||||
tran.Complete();
|
tran.Complete();
|
||||||
|
|
||||||
@ -289,7 +287,6 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
|||||||
|
|
||||||
var orderFlights = orders.SelectMany(x => x.OrderFlights).ToList();
|
var orderFlights = orders.SelectMany(x => x.OrderFlights).ToList();
|
||||||
var orderPullStatus = orders.SelectMany(x => x.OrderPullStatus).ToList();
|
var orderPullStatus = orders.SelectMany(x => x.OrderPullStatus).ToList();
|
||||||
var orderPlatformNumbers = orders.SelectMany(x => x.OrderPlatformNumbers).ToList();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -314,12 +311,10 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
|||||||
var orderId = orderNoIdDict[order.OrderNo];
|
var orderId = orderNoIdDict[order.OrderNo];
|
||||||
order.OrderFlights.ForEach(x => x.OrderId = orderId);
|
order.OrderFlights.ForEach(x => x.OrderId = orderId);
|
||||||
order.OrderPullStatus.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(orderFlights).ExecuteCommandAsync();
|
||||||
await Context.Insertable(orderPullStatus).ExecuteCommandAsync();
|
await Context.Insertable(orderPullStatus).ExecuteCommandAsync();
|
||||||
await Context.Insertable(orderPlatformNumbers).ExecuteCommandAsync();
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -356,11 +351,6 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
|||||||
order.OrderPullStatus.ForEach(x => x.OrderId = order.Id);
|
order.OrderPullStatus.ForEach(x => x.OrderId = order.Id);
|
||||||
await Context.Insertable(order.OrderPullStatus).ExecuteCommandAsync();
|
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();
|
await Context.Deleteable<OrderFlightEntity>().Where(x => x.OrderId == order.Id).ExecuteCommandAsync();
|
||||||
order.OrderFlights.ForEach(x => x.OrderId = order.Id);
|
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 orderIds = orders.Select(x => x.Id).ToHashSet();
|
||||||
var orderFlights = orders.SelectMany(x => x.OrderFlights).ToList();
|
var orderFlights = orders.SelectMany(x => x.OrderFlights).ToList();
|
||||||
var orderPullStatus = orders.SelectMany(x => x.OrderPullStatus).ToList();
|
var orderPullStatus = orders.SelectMany(x => x.OrderPullStatus).ToList();
|
||||||
var orderPlatformNumbers = orders.SelectMany(x => x.OrderPlatformNumbers).ToList();
|
|
||||||
foreach (var order in orders)
|
foreach (var order in orders)
|
||||||
{
|
{
|
||||||
order.OrderPullStatus.ForEach(x => x.OrderId = order.Id);
|
order.OrderPullStatus.ForEach(x => x.OrderId = order.Id);
|
||||||
order.OrderPlatformNumbers.ForEach(x => x.OrderId = order.Id);
|
|
||||||
order.OrderFlights.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.Deleteable<OrderPullStatusEntity>().Where(x => orderIds.Contains(x.OrderId)).ExecuteCommandAsync();
|
||||||
await Context.Insertable(orderPullStatus).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.Deleteable<OrderFlightEntity>().Where(x => orderIds.Contains(x.OrderId)).ExecuteCommandAsync();
|
||||||
await Context.Insertable(orderFlights).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 订单关联
|
#region 订单关联
|
||||||
|
|
||||||
public async Task<List<LinkedOrderVO>> GetLinkedOrdersAsync(int[] orderIds)
|
public async Task<List<LinkedOrderVO>> GetLinkedOrdersAsync(int[] orderIds)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user