diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs index 14c7ec51..e8e963c0 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs @@ -76,5 +76,11 @@ namespace Myshipping.Application /// 返回回执 Task> GetProjectList(); + /// + /// 发送邮件 + /// + /// BC任务主键 + /// 返回回执 + Task SendEmail(string taskPKId); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index b27489ed..e7069e2d 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -51,6 +51,7 @@ namespace Myshipping.Application private readonly IBookingOrderService _bookingOrderService; private readonly IBookingSlotService _bookingSlotService; private readonly IBookingValueAddedService _bookingValueAddedService; + private readonly IDjyCustomerService _djyCustomerService; const string CONST_BC_FILE_CODE = "bc"; const string CONST_BC_FILE_NAME = "Booking Confirmation"; @@ -68,6 +69,7 @@ namespace Myshipping.Application SqlSugarRepository bookingFileRepository, IServiceWorkFlowBaseService serviceWorkFlowBaseService, IBookingOrderService bookingOrderService, ILogger logger, + IDjyCustomerService djyCustomerService, IBookingSlotService bookingSlotService, ISysCacheService cache, IBookingValueAddedService bookingValueAddedService) { _taskBaseRepository = taskBaseRepository; @@ -83,6 +85,7 @@ namespace Myshipping.Application _cache = cache; _bookingValueAddedService = bookingValueAddedService; _bookingFileRepository = bookingFileRepository; + _djyCustomerService = djyCustomerService; _logger = logger; } @@ -682,7 +685,7 @@ namespace Myshipping.Application if (bookingOrderId > 0) { //更新库存 - _bookingSlotService. + //_bookingSlotService. var bcEntity = _taskBCInfoRepository.AsQueryable().First(a => a.PK_ID == bcOrder.PK_ID); if (bcEntity != null) @@ -1246,5 +1249,110 @@ namespace Myshipping.Application await _bookingFileRepository.InsertAsync(bookFile); } #endregion + + + private async Task InnerSendEmail(long bookingOrderId) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + /* + 1、提取邮件接收人、通过订舱的委托客户获取联系人信息(提取联系人中备注是BCNotice的邮箱) + 2、提取当票订舱对应的操作人邮箱、通过订舱的委托客户获取操作OP的邮箱 + 3、读取用户邮箱配置,主要提取显示名称BCNotice的邮箱,用来作为公共邮箱来发送邮件。 + 4、读取邮件模板,填充详情。 + 5、推送邮件给邮件接收人 + */ + + //读取订舱数据 + var bookingOrderEntity = _bookingOrderRepository.AsQueryable().Filter(null, true) + .First(a => a.Id == bookingOrderId); + + + if(bookingOrderEntity == null) + { + throw Oops.Oh($"订舱详情获取失败,请确认订舱是否存在或已删除"); + } + + if(!bookingOrderEntity.CUSTOMERID.HasValue || (bookingOrderEntity.CUSTOMERID.HasValue && bookingOrderEntity.CUSTOMERID.Value == 0)) + { + throw Oops.Oh($"订舱的委托客户不能为空"); + } + + var yardList = await _djyCustomerService.QuerytDjyCustomerInfo("", new string[] { "yard" }, 999); + + /* + if (yardList.Count > 0) + { + if ((string.IsNullOrWhiteSpace(model.YARDCONTRACT) || string.IsNullOrWhiteSpace(model.YARDCONTRACTTEL)) + && !string.IsNullOrWhiteSpace(model.YARD)) + { + var currYardList = yardList.Select(a => + { + return new + { + KNum = a.ShortName.IndexOf(model.YARD), + Equls = a.ShortName.Equals(model.YARD, StringComparison.OrdinalIgnoreCase) ? 1 : 0, + Obj = a + }; + }).Where(a => a.KNum >= 0).ToList(); + + if (currYardList.Count > 0) + { + var yardInfo = currYardList + .OrderByDescending(a => a.Equls) + .ThenBy(a => a.KNum) + .FirstOrDefault().Obj; + + if (yardInfo != null) + { + if (string.IsNullOrWhiteSpace(model.YARDCONTRACT)) + { + model.YARDCONTRACT = yardInfo.Chief?.Trim(); + } + + + if (string.IsNullOrWhiteSpace(model.YARDCONTRACTTEL)) + model.YARDCONTRACTTEL = yardInfo.Tel?.Trim(); + } + } + } + } + */ + } + catch (Exception ex) + { + + } + + return result; + } + + #region 发送邮件 + /// + /// 发送邮件 + /// + /// BC任务主键 + /// 返回回执 + public async Task SendEmail(string taskPKId) + { + if (string.IsNullOrWhiteSpace(taskPKId)) + throw Oops.Oh($"BC任务主键不能为空"); + + var bcTaskInfo = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId); + if (bcTaskInfo == null) + { + throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息"); + } + + var bcOrder = _taskBCInfoRepository.AsQueryable().First(a => a.TASK_ID == bcTaskInfo.PK_ID); + + if (bcOrder == null) + throw Oops.Oh($"任务主键{taskPKId}无法获取BC业务信息"); + + return await InnerSendEmail(0); + } + #endregion } }