From 08bacf9d47e1cbd6ec9ad5fc225776d3b83764b0 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 5 Mar 2024 11:50:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A9=AC=E5=A3=AB=E5=9F=BAAP?= =?UTF-8?q?I=E8=AE=A2=E8=88=B1=E6=9F=A5=E8=AF=A2=E8=88=B9=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index fd88788c..2ad969e9 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -12048,14 +12048,89 @@ namespace Myshipping.Application /* MSKApiBooking + */ try { + if (string.IsNullOrWhiteSpace(model.carrierCode)) + throw Oops.Oh($"服务船公司不能为空"); + + if (string.IsNullOrWhiteSpace(model.carrierId)) + throw Oops.Oh("船公司代码不能为空"); + + string sendUrl = string.Empty; + + if (model.carrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase)) + { + sendUrl = _cache.GetAllDictData().GetAwaiter().GetResult() + .FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == CONST_MSK_API_BOOKING_URL)?.Value; + } + else + { + throw Oops.Oh($"当前船公司 {model.carrierId} 未配置相应的请求接口"); + } + + if (string.IsNullOrWhiteSpace(sendUrl)) + throw Oops.Oh("未配置发送订舱请求接口地址,请联系管理员"); + + var webAccountConfig = _webAccountConfig + .GetAccountConfig("MSKApi", UserManager.UserId).GetAwaiter().GetResult(); + + if (webAccountConfig == null) + throw Oops.Oh("未配置个人账户,请先配置个人账户 类型-MSKApi"); + + + MSKAPIBookingDto bookingDto = new MSKAPIBookingDto { + userKey = App.Configuration["MSKAPIDjyUserKey"], + userSecret = App.Configuration["MSKAPIDjyUserSecret"], + operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"], + mskAppKey = webAccountConfig.Account, + bookingBody = new MSKAPIBookingBodyDto() + }; + bookingDto.bookingBody.references = new MSKAPIBookingReferenceDto { + priceReference = model.priceReference, + productCode = model.productCode, + sender = model.sender, + }; + + bookingDto.bookingBody.mandatoryParties = new MSKAPIBookingMandatoryParties { + bookedByCompanyName = model.bookedByCompanyName, + bookedByMaerskPartyCode = model.bookedByMaerskPartyCode, + bookedByPartyContact = new MSKAPIBookingMandatoryPartyContact { + name = model.bookedByCompanyContactName, + email = model.bookedByCompanyContactEmail + }, + priceOwnerCompanyName = model.priceOwnerCompanyName, + priceOwnerMaerskPartyCode = model.priceOwnerMaerskPartyCode, + priceOwnerPartyContact = new MSKAPIBookingMandatoryPartyContact { + name = model.priceOwnerContactName, + email = model.priceOwnerContactEmail + }, + }; + + bookingDto.bookingBody.transport = new MSKAPIBookingTransport { + carrierCode = model.carrierCode, + earliestDepartureDate = model.earliestDepartureDate, + exportServiceMode = model.exportServiceMode, + importServiceMode = model.importServiceMode, + routeDetails = new MSKAPIBookingRouteDetails { + placeOfReceipt = new MSKAPIBookingRouteDetailsBase { + UNLocationCode = model.placeOfReceiptUnLocCode, + cityName = model.placeOfReceiptCityName, + }, + placeOfDelivery = new MSKAPIBookingRouteDetailsBase { + UNLocationCode = model.placeOfDeliveryUnLocCode, + cityName = model.placeOfDeliveryCityName, + }, + } + }; } catch (Exception ex) { + _logger.LogError($"检索海运船期详情异常,req={JSON.Serialize(model)} 原因:{ex.Message}"); + throw Oops.Bah($"检索海运船期详情失败,{ex.Message}"); } return result;