diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 24c5a77e..194c5836 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -13542,5 +13542,92 @@ namespace Myshipping.Application return rlt; } #endregion + + #region 检索订单信息 + /// + /// 检索订单信息(如果当前为拆、合票,内包含分票信息) + /// + /// 提单号 + /// + public async Task SearchOrderInfo(string mblNo) + { + SeaExportOrderExtension model = new SeaExportOrderExtension(); + + /* + 1、先用主提单号检索,如果没有取到结果,再用订舱编号检索。 + 2、是拆票的,找到主票和其他分票,并返回当前订单的完整详情。 + 3、是合票的,找到主票和其他分票,并返回当前订单的完整详情。 + */ + var orderList = await _rep.AsQueryable().Filter(null, true) + .Where(a => (a.MBLNO == mblNo || a.CUSTNO == mblNo) && a.IsDeleted == false).ToListAsync(); + + var currOrder = orderList.FirstOrDefault(a => a.MBLNO == mblNo); + + if (currOrder != null) + { + model.currOrder = currOrder.Adapt(); + model.splitOrMergeFlag = currOrder.SPLIT_OR_MERGE_FLAG.HasValue ? currOrder.SPLIT_OR_MERGE_FLAG.Value : 0; + + if (!currOrder.SPLIT_OR_MERGE_FLAG.HasValue || (currOrder.SPLIT_OR_MERGE_FLAG.HasValue && currOrder.SPLIT_OR_MERGE_FLAG.Value > 0)) + { + //拆票 + if (currOrder.SPLIT_OR_MERGE_FLAG.Value == 1) + { + //如果分单号和订舱编号不一致表示分票已经改成正式的提单号 + if (!currOrder.HBLNO.Equals(currOrder.CUSTNO)) + { + model.finalMBLNo = currOrder.HBLNO; + } + + model.orderNo = currOrder.CUSTNO; + + //找到所有相关的分票 + var list = await _rep.AsQueryable().Filter(null, true) + .Where(a => a.CUSTNO == mblNo && a.IsDeleted == false && a.Id != currOrder.Id).ToListAsync(); + + model.otherOrderList = list.Select(b => new SeaExportOrderExtensionSubInfo + { + Id = b.Id, + OrderNo = b.CUSTNO, + MBLNO = b.MBLNO, + HBLNO = b.HBLNO + }).ToList(); + } + else if (currOrder.SPLIT_OR_MERGE_FLAG.Value == 2) + { + //合票 + if (currOrder.CUSTNO.Equals(currOrder.HBLNO)) + { + //如果订舱编号和分单号一致,表示当前为主合票信息 + model.isMaster = true; + model.masterId = currOrder.Id; + model.orderNo = currOrder.MBLNO; + } + + //找到所有相关的分票 + var list = await _rep.AsQueryable().Filter(null, true) + .Where(a => a.HBLNO == currOrder.HBLNO && a.IsDeleted == false && a.Id != currOrder.Id).ToListAsync(); + + model.otherOrderList = list.Select(b => new SeaExportOrderExtensionSubInfo + { + Id = b.Id, + OrderNo = b.CUSTNO, + MBLNO = b.MBLNO, + HBLNO = b.HBLNO + }).ToList(); + + var masterOrder = model.otherOrderList.FirstOrDefault(x => x.OrderNo == x.HBLNO); + + if (masterOrder != null) + { + model.masterId = masterOrder.Id; + model.orderNo = masterOrder.OrderNo; + } + } + } + } + return model; + } + #endregion } } diff --git a/Myshipping.Application/Service/BookingOrder/Dto/SeaExportOrderExtension.cs b/Myshipping.Application/Service/BookingOrder/Dto/SeaExportOrderExtension.cs new file mode 100644 index 00000000..11bf234b --- /dev/null +++ b/Myshipping.Application/Service/BookingOrder/Dto/SeaExportOrderExtension.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application.Service.BookingOrder.Dto +{ + /// + /// 检索海运订单 + /// + public class SeaExportOrderExtension + { + /// + /// 当前订单 + /// + public BookingOrderDto currOrder { get; set; } + + /// + /// 是否主票 true-主票;false-分票 + /// + public bool isMaster { get; set; } + + /// + /// 拆票或合票标志 1-拆票 2-合票 + /// + public int splitOrMergeFlag { get; set; } + + /// + /// 主票主键 + /// + public long masterId { get; set; } + + /// + /// 主票订舱编号 + /// + public string orderNo { get; set; } + + /// + /// 最终提单号(拆票后最终提单号) + /// + public string finalMBLNo { get; set; } + + /// + /// 分票订单信息 + /// + public List otherOrderList { get; set; } + } + + /// + /// 分单号详情 + /// + public class SeaExportOrderExtensionSubInfo + { + /// + /// 海运订单主键 + /// + public long Id { get; set; } + + /// + /// Desc:订舱编号 + /// + public string OrderNo { get; set; } + + /// + /// 主提单号 + /// + public string MBLNO { get; set; } + + /// + /// 分提单号 + /// + public string HBLNO { get; set; } + } +} diff --git a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs index 91a087cd..44013555 100644 --- a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs @@ -163,5 +163,12 @@ namespace Myshipping.Application /// 舱位拆票或者合票请求 /// 返回舱位拆票或者合票结果 Task GetBookingSlotMergeOrSplitResult(BookingSlotMergeOrSplitRequestDto model); + + /// + /// 检索订单信息(如果当前为拆、合票,内包含分票信息) + /// + /// 提单号 + /// + Task SearchOrderInfo(string mblNo); } } \ No newline at end of file