合并代码
This commit is contained in:
commit
bf1a9e0169
@ -2,6 +2,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<!-- <WarningsAsErrors>Nullable</WarningsAsErrors>-->
|
<!-- <WarningsAsErrors>Nullable</WarningsAsErrors>-->
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -0,0 +1,86 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Application.Dtos.ProvideServices;
|
||||||
|
|
||||||
|
public class CreateOrderInput
|
||||||
|
{
|
||||||
|
public OrderInfo OrderInfo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 客户id
|
||||||
|
/// </summary>
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单模板
|
||||||
|
/// </summary>
|
||||||
|
public List<OrderTemplateInfo> Templates { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单明细
|
||||||
|
/// </summary>
|
||||||
|
public OrderDetails Details { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class OrderTemplateInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 模板id
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public int TemplateId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务商id
|
||||||
|
/// </summary>
|
||||||
|
public int ServiceProviderId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OrderDetails
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 目的港口
|
||||||
|
/// </summary>
|
||||||
|
public string? ArrivalPort { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 起运港口
|
||||||
|
/// </summary>
|
||||||
|
public string? LeavePort { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 目的国家,必填
|
||||||
|
/// </summary>
|
||||||
|
public string ArrivalCountry { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 起运国家,必填
|
||||||
|
/// </summary>
|
||||||
|
public string LeaveCountry { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 目的城市,必填
|
||||||
|
/// </summary>
|
||||||
|
public string ArrivalCity { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 起运城市,必填
|
||||||
|
/// </summary>
|
||||||
|
public string LeaveCity { get; set; }
|
||||||
|
|
||||||
|
public List<FligthInfo> FligthInfos { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FligthInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 航班号
|
||||||
|
/// </summary>
|
||||||
|
public string FlightNo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 班期
|
||||||
|
/// </summary>
|
||||||
|
public string FlightDate { get; set; }
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Application.Dtos.ProvideServices;
|
||||||
|
|
||||||
|
public class LinkOrderInput
|
||||||
|
{
|
||||||
|
public OrderInfo OrderInfo { get; set; }
|
||||||
|
|
||||||
|
public List<OrderInfo> LinkedOrderInfos { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class OrderInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 订单类型
|
||||||
|
/// </summary>
|
||||||
|
public int NoType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单号
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string OrderNo { get; set; }
|
||||||
|
}
|
||||||
@ -1,10 +1,10 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<Import Project="../../common.props" />
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<!--<Nullable>enable</Nullable>-->
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -0,0 +1,83 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using SJZY.Track.Application.Dtos.ProvideServices;
|
||||||
|
using SJZY.Track.Domain;
|
||||||
|
using SJZY.Track.Domain.OrderAggregate;
|
||||||
|
using SJZY.UserCenter.HttpApi.Services;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单服务
|
||||||
|
/// </summary>
|
||||||
|
[ApiExplorerSettings(GroupName = "提供接口")]
|
||||||
|
public class OrderService: ApplicationService
|
||||||
|
{
|
||||||
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
|
||||||
|
public OrderService(IOrderRepository orderRepository)
|
||||||
|
{
|
||||||
|
_orderRepository = orderRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建订单
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="BusinessException"></exception>
|
||||||
|
[HttpPost("Order/Create")]
|
||||||
|
public async Task<bool> CreateOrderAsync(CreateOrderInput input)
|
||||||
|
{
|
||||||
|
if (await _orderRepository.IsAnyAsync(x =>
|
||||||
|
x.OrderType == input.OrderInfo.NoType && x.OrderNo == input.OrderInfo.OrderNo))
|
||||||
|
{
|
||||||
|
throw new BusinessException(message: $"单号:{input.OrderInfo.OrderNo}已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
var order = new OrderEntity
|
||||||
|
{
|
||||||
|
CustomId = input.ClientId,
|
||||||
|
OrderDetails = JsonConvert.SerializeObject(input.Details),
|
||||||
|
OrderNo = input.OrderInfo.OrderNo,
|
||||||
|
OrderType = input.OrderInfo.NoType,
|
||||||
|
SubSystemId = CurrentUserRequest.SubSystemId
|
||||||
|
};
|
||||||
|
|
||||||
|
using var tran = TransactionHelper.GetReadCommitted();
|
||||||
|
|
||||||
|
// 创建订单
|
||||||
|
var orderId = await _orderRepository.InsertReturnIdentityAsync(order);
|
||||||
|
|
||||||
|
// 创建订单模板
|
||||||
|
var templates = input.Templates.Select(x => new OrderTemplateEntity
|
||||||
|
{
|
||||||
|
OrderId = orderId,
|
||||||
|
ServiceProviderId = x.ServiceProviderId,
|
||||||
|
TrackTemplateId = x.TemplateId
|
||||||
|
}).ToList();
|
||||||
|
await _orderRepository.CreateOrderTemplatesAsync(templates);
|
||||||
|
tran.Complete();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关联订单
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("Order/Link")]
|
||||||
|
public async Task<bool> LinkOrderAsync(LinkOrderInput input)
|
||||||
|
{
|
||||||
|
// var distinctOrderNos = input.LinkedOrderInfos.Distinct().ToList();
|
||||||
|
//
|
||||||
|
// var links = input.LinkedOrderInfos.Select(x => new OrderLinkEntity
|
||||||
|
// {
|
||||||
|
// LinkOrderId = x.,
|
||||||
|
// OrderId = 0
|
||||||
|
// })
|
||||||
|
// _orderRepository.LinkOrderAsync();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,11 +2,15 @@ using SJZY.Track.Application.Dtos.ProvideServices;
|
|||||||
using SJZY.Track.Domain;
|
using SJZY.Track.Domain;
|
||||||
using SJZY.Track.Domain.OrderAggregate;
|
using SJZY.Track.Domain.OrderAggregate;
|
||||||
using SJZY.Track.Domain.TrackTemplateAggregate;
|
using SJZY.Track.Domain.TrackTemplateAggregate;
|
||||||
|
using SJZY.Track.Application.Dtos.ProvideServices;
|
||||||
using SJZY.Track.Repository.TrackDetails;
|
using SJZY.Track.Repository.TrackDetails;
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||||
|
|
||||||
[ApiExplorerSettings(GroupName = "TrackQuery")]
|
/// <summary>
|
||||||
|
/// 轨迹查询服务
|
||||||
|
/// </summary>
|
||||||
|
[ApiExplorerSettings(GroupName = "提供接口")]
|
||||||
public class TrackQueryService : ApplicationService
|
public class TrackQueryService : ApplicationService
|
||||||
{
|
{
|
||||||
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
private readonly ITrackDetailsRepository _trackDetailsRepository;
|
||||||
@ -21,8 +25,14 @@ public class TrackQueryService : ApplicationService
|
|||||||
_trackTemplateRepository = trackTemplateRepository;
|
_trackTemplateRepository = trackTemplateRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("TrackQuery/GetTrack")]
|
/// <summary>
|
||||||
public async Task<List<GetTrackOutput>> GetTrackAsync(GetTrackInput input)
|
/// 根据订单号获取轨迹
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="BusinessException"></exception>
|
||||||
|
[HttpPost("TrackQuery/GetByOrderNos")]
|
||||||
|
public async Task<List<GetTrackOutput>> GetByOrderNosAsync(GetTrackInput input)
|
||||||
{
|
{
|
||||||
if (input.OrderNos.Count > 500)
|
if (input.OrderNos.Count > 500)
|
||||||
{
|
{
|
||||||
@ -30,9 +40,9 @@ public class TrackQueryService : ApplicationService
|
|||||||
}
|
}
|
||||||
|
|
||||||
var res = new List<GetTrackOutput>();
|
var res = new List<GetTrackOutput>();
|
||||||
var distinctOrderNumbers = input.OrderNos.Distinct().ToList();
|
var distinctOrderNos = input.OrderNos.Distinct().ToList();
|
||||||
var details = await _trackDetailsRepository.GetListAsync(distinctOrderNumbers);
|
var details = await _trackDetailsRepository.GetListAsync(distinctOrderNos);
|
||||||
var orderTemplates = await _orderRepository.GetOrderTemplatesAsync(distinctOrderNumbers);
|
var orderTemplates = await _orderRepository.GetOrderTemplatesAsync(distinctOrderNos);
|
||||||
var distinctTemplateIds = orderTemplates.Select(x => x.TrackTemplateId).Distinct().ToList();
|
var distinctTemplateIds = orderTemplates.Select(x => x.TrackTemplateId).Distinct().ToList();
|
||||||
var templateContents = await _trackTemplateRepository.GetTemplateContentsAsync(distinctTemplateIds);
|
var templateContents = await _trackTemplateRepository.GetTemplateContentsAsync(distinctTemplateIds);
|
||||||
|
|
||||||
@ -61,15 +71,6 @@ public class TrackQueryService : ApplicationService
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task CreateOrder()
|
|
||||||
{
|
|
||||||
using var tran = TransactionHelper.GetReadCommitted();
|
|
||||||
await _orderRepository.InsertAsync(new OrderEntity());
|
|
||||||
await _orderRepository.CreateOrderTemplateAsync(new OrderTemplateEntity());
|
|
||||||
|
|
||||||
tran.Complete();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TrackDetailSort(GetTrackOutput item, SortMethod sortMethod)
|
private void TrackDetailSort(GetTrackOutput item, SortMethod sortMethod)
|
||||||
{
|
{
|
||||||
switch (sortMethod)
|
switch (sortMethod)
|
||||||
|
|||||||
@ -14,7 +14,7 @@ public interface IOrderRepository : IBasicRepository<OrderEntity>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建订单模板
|
/// 创建订单模板
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="templateEntity"></param>
|
/// <param name="templateEntities"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task CreateOrderTemplateAsync(OrderTemplateEntity templateEntity);
|
Task CreateOrderTemplatesAsync(List<OrderTemplateEntity> templateEntities);
|
||||||
}
|
}
|
||||||
@ -14,8 +14,8 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task CreateOrderTemplateAsync(OrderTemplateEntity templateEntity)
|
public async Task CreateOrderTemplatesAsync(List<OrderTemplateEntity> templateEntities)
|
||||||
{
|
{
|
||||||
await Context.Insertable(templateEntity).ExecuteCommandAsync();
|
await Context.Insertable(templateEntities).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user