diff --git a/src/SJZY.Track.Application.Contract/Services/IOrderService.cs b/src/SJZY.Track.Application.Contract/Services/IOrderService.cs index 5a1b4067..f36dc7da 100644 --- a/src/SJZY.Track.Application.Contract/Services/IOrderService.cs +++ b/src/SJZY.Track.Application.Contract/Services/IOrderService.cs @@ -10,14 +10,14 @@ public interface IOrderService : IRemoteService /// /// /// - Task UpsertAsync(UpsertOrderInput input); + Task> UpsertAsync(UpsertOrderInput input); /// /// 删除订单 /// /// /// - Task DeleteOrderAsync(DeleteOrderInput input); + Task> DeleteOrderAsync(DeleteOrderInput input); /// /// 关联订单 diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs index 7818fd9e..4d25a09a 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs @@ -32,7 +32,7 @@ public partial class OrderService : ApplicationService, IOrderService /// /// [HttpPost("Order/Upsert")] - public async Task UpsertAsync(UpsertOrderInput input) + public async Task> UpsertAsync(UpsertOrderInput input) { var subSystemId = CurrentUserRequest.SubSystemId; @@ -44,25 +44,21 @@ public partial class OrderService : ApplicationService, IOrderService // 订单已存在则视为更新 await UpdateOrderAsync(input, order); - return new UnifyResultDto() + return new UnifyResultDto(true, new IdBaseDto { - Code = "200", - Msg = "操作成功", - Data = "创建成功" - }; + Id = order.Id + }); } order = ObjectMapper.Map(input); order.SubSystemId = subSystemId; order.OrderFlights = ObjectMapper.Map, List>(input.FlightInfos); - await _orderRepository.CreateOrderAsync(order); - return new UnifyResultDto() + var orderId = await _orderRepository.CreateOrderAsync(order); + return new UnifyResultDto(true, new IdBaseDto { - Code = "200", - Msg = "操作成功", - Data = "新增成功" - }; + Id = orderId + }); } /// @@ -72,10 +68,11 @@ public partial class OrderService : ApplicationService, IOrderService /// /// [HttpPost("Order/Delete")] - public async Task DeleteOrderAsync(DeleteOrderInput input) + public async Task> DeleteOrderAsync(DeleteOrderInput input) { + var susSystemId = CurrentUserRequest.SubSystemId; var orderId = await _orderRepository.GetFirstAsync(x => - x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => x.Id); + x.SubSystemId == susSystemId && x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => x.Id); if (orderId == default) { throw new BusinessException(message: $"订单:{input.OrderNo}不存在"); @@ -83,7 +80,10 @@ public partial class OrderService : ApplicationService, IOrderService await _orderRepository.DeleteOrderAsync(orderId); - return new UnifyResultDto(true, true); + return new UnifyResultDto(true, new IdBaseDto + { + Id = orderId + }); } private async Task UpdateOrderAsync(UpdateOrderInput input, OrderEntity order) diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs index 3ff7261a..767aefd5 100644 --- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs @@ -9,7 +9,7 @@ public interface IOrderRepository : IBasicRepository /// /// /// - Task CreateOrderAsync(OrderEntity order); + Task CreateOrderAsync(OrderEntity order); /// /// 更新订单 diff --git a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs index e28b4f25..b89ed57c 100644 --- a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs @@ -6,7 +6,7 @@ namespace SJZY.Track.Repository.Repositories; public class OrderRepository : BasicRepository, IOrderRepository, ITransientDependency { - public async Task CreateOrderAsync(OrderEntity order) + public async Task CreateOrderAsync(OrderEntity order) { using var tran = TransactionHelper.GetReadCommitted(); @@ -15,6 +15,8 @@ public class OrderRepository : BasicRepository, IOrderRepository, I await Context.Insertable(order.OrderFlights).ExecuteCommandAsync(); tran.Complete(); + + return orderId; } public Task UpdateBatchIdsAsync(List ids, int newValue)