From eb5030560d40ecc6afa5434b1b4957e042583c61 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Mon, 6 May 2024 14:48:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E8=88=B1=E5=88=A0=E9=99=A4=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=88=A0=E9=99=A4=E5=B7=B2=E5=BC=95=E5=85=A5=E7=9A=84?= =?UTF-8?q?=E8=88=B1=E4=BD=8D=E7=9A=84=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 79 +++++++++++++------ 1 file changed, 54 insertions(+), 25 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 3e8aa8f1..0608cb35 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -2296,7 +2296,7 @@ namespace Myshipping.Application var tenantParamList = await _cache.GetAllTenantParam(); var isAskDs = tenantParamList.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID && x.ParaCode == TenantParamCode.ASK_DS_BEFORE_DELETE_BOOKING_ORDER); - + foreach (var ar in arr) { long Id = Convert.ToInt64(ar); @@ -2306,6 +2306,10 @@ namespace Myshipping.Application { continue; } + + // 通过租户参数判断这一票的租户是否启用了舱位引入功能 + var isCancelAllocationSlot = tenantParamList.FirstOrDefault(x => x.TenantId == order.TenantId && x.ParaCode == TenantParamCode.ENABLE_SLOT_ABILITY)?.ItemCode; + var mblno = order.MBLNO; // 将待删除的订舱单id存放到Cache中。目的:使用SendBookingOrder()推送订舱单数据前通过Cache判断是否正在走删除逻辑,来决定是否推送(如果是正在处理删除逻辑的数据,则不推送) @@ -2349,6 +2353,12 @@ namespace Myshipping.Application // 取消订阅运踪 waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno)); + if (isCancelAllocationSlot == "YES") + { + // 取消关联舱位 + await CancelAllocationSlot(Id); + } + // 记录日志 var newOrder = order.Adapt(); newOrder.IsDeleted = true; @@ -2379,6 +2389,12 @@ namespace Myshipping.Application // 取消订阅运踪 waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno)); + if (isCancelAllocationSlot == "YES") + { + // 取消关联舱位 + await CancelAllocationSlot(Id); + } + // 记录日志 var newOrder = order.Adapt(); newOrder.IsDeleted = true; @@ -11866,10 +11882,22 @@ namespace Myshipping.Application [HttpPost("/BookingOrder/CancelAllocationSlot")] public async Task CancelAllocationSlot(long id) { - var slotList = await _repSlotAllocation.AsQueryable().Where(a => a.BOOKING_ID == id).ToListAsync(); - var slotIdList = slotList.Select(s => s.Id); + var slotList = await _repSlotAllocation.AsQueryable().Where(a => a.BOOKING_ID == id).Select(x => new + { + x.Id, + x.BOOKING_SLOT_TYPE, + x.CARRIERID, + x.CONTRACT_NO, + x.VESSEL, + x.VOYNO, + x.PLACERECEIPT, + x.PLACEDELIVERY + }).ToListAsync(); - await _repSlotAllocation.Context.Updateable() + if (slotList.Count > 0) + { + var slotIdList = slotList.Select(s => s.Id); + await _repSlotAllocation.Context.Updateable() .SetColumns(a => a.IsDeleted == true) .SetColumns(a => a.UpdatedTime == DateTime.Now) .SetColumns(a => a.UpdatedUserId == UserManager.UserId) @@ -11877,27 +11905,28 @@ namespace Myshipping.Application .Where(a => slotIdList.Contains(a.Id)) .ExecuteCommandAsync(); - await _repSlotAllocationCtn.Context.Updateable() - .SetColumns(a => a.IsDeleted == true) - .SetColumns(a => a.UpdatedTime == DateTime.Now) - .SetColumns(a => a.UpdatedUserId == UserManager.UserId) - .SetColumns(a => a.UpdatedUserName == UserManager.Name) - .Where(a => slotIdList.Contains(a.SLOT_ALLOC_ID)) - .ExecuteCommandAsync(); - - // 更新库存 - foreach (var item in slotList) - { - await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new Event.BookingSlotStockUpdateModel - { - BOOKING_SLOT_TYPE = item.BOOKING_SLOT_TYPE, - CARRIERID = item.CARRIERID, - CONTRACT_NO = item.CONTRACT_NO, - VESSEL = item.VESSEL, - VOYNO = item.VOYNO, - PLACERECEIPT = item.PLACERECEIPT, - PLACEDELIVERY = item.PLACEDELIVERY - })); + await _repSlotAllocationCtn.Context.Updateable() + .SetColumns(a => a.IsDeleted == true) + .SetColumns(a => a.UpdatedTime == DateTime.Now) + .SetColumns(a => a.UpdatedUserId == UserManager.UserId) + .SetColumns(a => a.UpdatedUserName == UserManager.Name) + .Where(a => slotIdList.Contains(a.SLOT_ALLOC_ID)) + .ExecuteCommandAsync(); + + // 更新库存 + foreach (var item in slotList) + { + await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new Event.BookingSlotStockUpdateModel + { + BOOKING_SLOT_TYPE = item.BOOKING_SLOT_TYPE, + CARRIERID = item.CARRIERID, + CONTRACT_NO = item.CONTRACT_NO, + VESSEL = item.VESSEL, + VOYNO = item.VOYNO, + PLACERECEIPT = item.PLACERECEIPT, + PLACEDELIVERY = item.PLACEDELIVERY + })); + } } } #endregion