diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 59cf6b32..4470e7d4 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -11881,11 +11881,92 @@ namespace Myshipping.Application */ try { + if(string.IsNullOrWhiteSpace(model.collectionOriginCityName)) + throw Oops.Oh($"始发地不能为空"); + if (string.IsNullOrWhiteSpace(model.deliveryDestinationCityName)) + throw Oops.Oh($"目的地不能为空"); + + if (string.IsNullOrWhiteSpace(model.vesselOperatorCarrierCode)) + throw Oops.Oh($"服务船公司不能为空"); + + if (string.IsNullOrWhiteSpace(model.startDate)) + throw Oops.Oh($"预计离港日期不能为空"); + + DateTime etd = DateTime.MinValue; + + if(!DateTime.TryParse(model.startDate,out etd)) + throw Oops.Oh($"预计离港日期格式错误"); + + string queryUrl = string.Empty; + + if (model.carrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase)) + { + queryUrl = _cache.GetAllDictData().GetAwaiter().GetResult() + .FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == CONST_MSK_API_Poing2P_SECD_URL)?.Value; + } + else + { + throw Oops.Oh($"当前船公司 {model.carrierId} 未配置相应的请求接口"); + } + + if (string.IsNullOrWhiteSpace(queryUrl)) + throw Oops.Oh("未配置查询船期请求接口地址,请联系管理员"); + + var webAccountConfig = _webAccountConfig + .GetAccountConfig("MSKApi", UserManager.UserId).GetAwaiter().GetResult(); + + if (webAccountConfig == null) + throw Oops.Oh("未配置个人账户,请先配置个人账户 类型-MSKApi"); + + MSKAPISearchPoint2PointScheduleDto queryInfo = new MSKAPISearchPoint2PointScheduleDto + { + userKey = App.Configuration["MSKAPIDjyUserKey"], + userSecret = App.Configuration["MSKAPIDjyUserSecret"], + operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"], + mskAppKey = webAccountConfig.Account, + collectionOriginCityName = model.collectionOriginCityName, + collectionOriginCountryCode = model.collectionOriginCountryCode, + deliveryDestinationCityName = model.deliveryDestinationCityName, + deliveryDestinationCountryCode = model.deliveryDestinationCountryCode, + cargoType = model.cargoType, + exportServiceMode = model.exportServiceMode, + importServiceMode = model.importServiceMode, + vesselOperatorCarrierCode = model.vesselOperatorCarrierCode, + startDate = etd.ToString("yyyy-MM-dd"), + startDateType = "D", + }; + + MSKAPISearchPoint2PointScheduleResultDto resultInfo = null; + + var rlt = await queryUrl.SetBody(queryInfo) + .PostAsStringAsync(); + + if (!string.IsNullOrWhiteSpace(rlt)) + { + try + { + resultInfo = JSON.Deserialize(rlt); + } + catch (Exception ex) + { + _logger.LogInformation($"请求MSK API查询船期异常,原因:{ex.Message}"); + + throw Oops.Bah($"请求MSK API查询船期异常,原因:{ex.Message}"); + } + } + + if (resultInfo != null && resultInfo.code == 200 + && resultInfo.data != null && resultInfo.data.Count > 0) + { + list = resultInfo.data.Adapt>(); + } } catch (Exception ex) { + _logger.LogError($"检索海运船期详情异常,req={JSON.Serialize(model)} 原因:{ex.Message}"); + throw Oops.Bah($"检索海运船期详情失败,{ex.Message}"); } return list; diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MSKAPI/MSKAPISearchPoint2PointScheduleDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MSKAPI/MSKAPISearchPoint2PointScheduleDto.cs index 649ef298..b7ef0854 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/MSKAPI/MSKAPISearchPoint2PointScheduleDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/MSKAPI/MSKAPISearchPoint2PointScheduleDto.cs @@ -109,7 +109,7 @@ namespace Myshipping.Application /// /// 箱体积 /// - public int stuffingVolume { get; set; } + public Nullable stuffingVolume { get; set; } /// /// 体积单位(MTQ, FTQ) diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MSKAPI/MSKAPISearchPoint2PointScheduleResultDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MSKAPI/MSKAPISearchPoint2PointScheduleResultDto.cs index aebef052..05d5b8df 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/MSKAPI/MSKAPISearchPoint2PointScheduleResultDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/MSKAPI/MSKAPISearchPoint2PointScheduleResultDto.cs @@ -24,7 +24,7 @@ namespace Myshipping.Application /// /// 回执代码 /// - public MSKAPISearchPoint2PointScheduleResultDataDto data { get; set; } + public List data { get; set; } } public class MSKAPISearchPoint2PointScheduleResultDataDto diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs index 4630e2a6..cb05a233 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs @@ -187,6 +187,14 @@ namespace Myshipping.Application /// public string commodityCodeType { get; set; } + /// + /// 箱型箱量列表 + /// + public List ctns { get; set; } + } + + public class MSKBookingCtnInfo + { /// /// 箱型 /// diff --git a/Myshipping.Application/Service/BookingOrder/Dto/QueryShipSailingScheduleDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/QueryShipSailingScheduleDto.cs index c8436203..c5ad3cb9 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/QueryShipSailingScheduleDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/QueryShipSailingScheduleDto.cs @@ -11,6 +11,11 @@ namespace Myshipping.Application /// public class QueryShipSailingScheduleDto { + /// + /// 船公司代码 + /// + public string carrierId { get; set; } + /// /// 起始地的GEO ID ///