修改舱位生成订舱功能,增加租户参数是否要求联系人必填

master
jianghaiqing 6 months ago
parent 6a7ba34622
commit 0a8e7b55b9

@ -71,7 +71,7 @@ namespace Myshipping.Application
private readonly IDjyCustomerService _djyCustomerService;
private readonly IBookingValueAddedService _bookingValueAddedService;
private readonly IBookingLabelService _bookingLabelService;
private readonly IDjyTenantParamService _djyTenantParamService;
const string CONST_BC_FILE_CODE = "bc";
const string CONST_BC_FILE_NAME = "Booking Confirmation";
@ -85,6 +85,9 @@ namespace Myshipping.Application
const string CONST_BC_MODIFY_NOTICE_FILE_CODE = "bc_moidfynotice";
const string CONST_BC_MODIFY_NOTICE_FILE_NAME = "Booking Amendment Notice";
//租户默认参数管理BC任务或舱位生成订舱客户联系人必填
const string CONST_CREATE_BOOKING_NEED_CONTACT = "BC_TASK_OR_SLOT_BOOKING_NEED_CONTACT";
public BookingSlotService(SqlSugarRepository<BookingSlotBase> repBase,
SqlSugarRepository<BookingSlotCtn> repCtn,
SqlSugarRepository<BookingSlotStock> repStock,
@ -108,6 +111,7 @@ namespace Myshipping.Application
IBookingLabelService bookingLabelService,
INamedServiceProvider<ITaskManageService> namedTaskManageServiceProvider,
SqlSugarRepository<SysUser> sysUserRepository,
IDjyTenantParamService djyTenantParamService,
SqlSugarRepository<BookingPrintTemplate> repPrintTemplate)
{
_repBase = repBase;
@ -136,6 +140,8 @@ namespace Myshipping.Application
_sysUserRepository = sysUserRepository;
_namedTaskManageServiceProvider = namedTaskManageServiceProvider;
_djyTenantParamService = djyTenantParamService;
}
#region 舱位
@ -2683,6 +2689,56 @@ namespace Myshipping.Application
var fileList = await _bookingfile.AsQueryable().Filter(null, true)
.Where(u => u.BookingId == slotInfo.Id && u.Moudle == "BookingSlot").ToListAsync();
DjyTenantParamValueOutput paramConfig = null;
var paramList = _djyTenantParamService.GetParaCodeWithValue(new[] { CONST_CREATE_BOOKING_NEED_CONTACT }).GetAwaiter().GetResult();
if (paramList != null && paramList.Count > 0)
{
paramConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_CREATE_BOOKING_NEED_CONTACT, StringComparison.OrdinalIgnoreCase));
}
if (model.CustomerContactList != null && model.CustomerContactList.Count > 0)
{
//取委托客户下面所有的联系人列表
var djyCustomerInfo = _djyCustomerService.Detail(new GetDjyCustomerInput { Id = model.CustomerId.Value })
.GetAwaiter().GetResult();
if (djyCustomerInfo == null)
{
_logger.LogInformation($"委托单位{model.CustomerName} 获取失败,委托单位不存在或已作废 SlotId={model.SlotId.Value}");
throw Oops.Oh($"委托单位{model.CustomerName} 获取失败,委托单位不存在或已作废");
}
if (djyCustomerInfo.Contacts == null && djyCustomerInfo.Contacts.Count < 1)
{
_logger.LogInformation($"委托单位{model.CustomerName} 获取相关联系人失败,委托单位相关联系人为空 SlotId={model.SlotId.Value}");
throw Oops.Oh($"委托单位{model.CustomerName} 获取相关联系人失败,委托单位相关联系人为空");
}
model.CustomerContactList.ForEach(contact =>
{
DjyCustomerContactOutput djyCustomerContactMan = djyCustomerInfo.Contacts
.FirstOrDefault(a => a.Id == contact.CustomerContactId);
if (djyCustomerContactMan == null)
{
_logger.LogInformation($"委托单位{model.CustomerName} 联系人 {contact.CustomerContactName}获取失败,联系人不存在或已作废 SlotId={model.SlotId.Value}");
throw Oops.Oh($"委托单位{model.CustomerName} 联系人 {contact.CustomerContactName}获取失败,联系人不存在或已作废");
}
});
}
else
{
if (paramConfig != null && paramConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
{
throw Oops.Oh($"生成订舱时往来单位联系必填,请修改");
}
}
var bookingOrderId = await GenerateBookingOrder(slotInfo, fileList, model);
result.succ = true;

Loading…
Cancel
Save