diff --git a/Myshipping.Application/Service/ExpressDelivery/Dto/ExpressDeliveryDto.cs b/Myshipping.Application/Service/ExpressDelivery/Dto/ExpressDeliveryDto.cs index 2f084e3b..32dc0735 100644 --- a/Myshipping.Application/Service/ExpressDelivery/Dto/ExpressDeliveryDto.cs +++ b/Myshipping.Application/Service/ExpressDelivery/Dto/ExpressDeliveryDto.cs @@ -165,6 +165,11 @@ namespace Myshipping.Application.Service.ExpressDelivery.Dto public List FeeList { get; set; } + /// + /// 保存的同时,是否下单快递 + /// + public bool IsSending { get; set; } + public IEnumerable Validate(ValidationContext validationContext) { if (SettleAccountsTypeCode == "2" && string.IsNullOrWhiteSpace(MonthlyCard)) diff --git a/Myshipping.Application/Service/ExpressDelivery/ExpressDeliveryService.cs b/Myshipping.Application/Service/ExpressDelivery/ExpressDeliveryService.cs index 569edddd..1d65b1a0 100644 --- a/Myshipping.Application/Service/ExpressDelivery/ExpressDeliveryService.cs +++ b/Myshipping.Application/Service/ExpressDelivery/ExpressDeliveryService.cs @@ -238,13 +238,21 @@ namespace Myshipping.Application List cancelMblnoList = oldMblnoList.Except(newMblnoList).ToList(); await InsertNewBookingStatusWithMblnoList(cancelMblnoList, STATUS_DISASSOCIATION); - // 先删除,再新增业务信息 - await _businessRep.DeleteAsync(x => x.PId == entity.Id); - input.Business.ForEach(b => b.PId = entity.Id); - await _businessRep.InsertAsync(input.Business); + if (addMblnoList.Count != 0 || cancelMblnoList.Count != 0) + { + // 先删除,再新增业务信息 + await _businessRep.DeleteAsync(x => x.PId == entity.Id); + input.Business.ForEach(b => b.PId = entity.Id); + await _businessRep.InsertAsync(input.Business); + } } } #endregion + + if (input.IsSending) + { + await SendBooking(entity); + } } return await Get(entity.Id); } @@ -304,12 +312,10 @@ namespace Myshipping.Application /// /// 发送快递 /// - /// - /// - [HttpPost("SendBooking")] - public async Task SendBooking(long Id) + /// [HttpPost("SendBooking")] + [NonAction] + public async Task SendBooking(ExpressDeliveryOrder order) { - var order = _orderRep.FirstOrDefault(x => x.Id == Id); if (order == null) { throw Oops.Bah("请选择正确数据!"); @@ -322,6 +328,7 @@ namespace Myshipping.Application { throw Oops.Bah("下单失败,原因:重复下单"); } + var Id = order.Id; IDeliverySend deliverySend = GetDeliverySend(order.KDCompany); string waybillNo = await deliverySend.CreateOrder(order); diff --git a/Myshipping.Application/Service/ExpressDelivery/IExpressDeliveryService.cs b/Myshipping.Application/Service/ExpressDelivery/IExpressDeliveryService.cs index bb9746df..87815273 100644 --- a/Myshipping.Application/Service/ExpressDelivery/IExpressDeliveryService.cs +++ b/Myshipping.Application/Service/ExpressDelivery/IExpressDeliveryService.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Myshipping.Application.Entity; using Myshipping.Application.Service.ExpressDelivery.Dto; using Myshipping.Core; using System.Collections.Generic; @@ -12,7 +13,7 @@ namespace Myshipping.Application Task> Page([FromQuery] ExpressDeliveryInput input); //Task QueryKDSchedule(long Id); Task Save(ExpressDeliveryDto input); - Task SendBooking(long Id); + Task SendBooking(ExpressDeliveryOrder order); Task DeleteAddress(string ids); Task> GetAddressList(); Task SaveOrUpdateAddress(ExpressDeliveryAddressDto input);