From a705d8aa8c22a7d6329e7c16d837e78c02b218c7 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 4 Jul 2024 09:49:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9MSK=20SPOT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingMSKSPOTAPIService.cs | 89 ++++++++++++++++--- 1 file changed, 76 insertions(+), 13 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs index 6f226002..d3fa5390 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs @@ -425,6 +425,24 @@ namespace Myshipping.Application.Service.BookingOrder //Legs if (model.scheduleDetails != null && model.scheduleDetails.Count > 0) { + if(model.scheduleDetails.Any(x => x.fromLocation.cityGeoId == model.originGeoId)) + { + showDto.orignCountryCode = model.scheduleDetails.FirstOrDefault(x => x.fromLocation.cityGeoId == model.originGeoId).fromLocation.countryCode; + } + else if (model.scheduleDetails.Any(x => x.toLocation.cityGeoId == model.originGeoId)) + { + showDto.orignCountryCode = model.scheduleDetails.FirstOrDefault(x => x.toLocation.cityGeoId == model.originGeoId).toLocation.countryCode; + } + + if (model.scheduleDetails.Any(x => x.fromLocation.cityGeoId == model.destinationGeoId)) + { + showDto.deliveryCountryCode = model.scheduleDetails.FirstOrDefault(x => x.fromLocation.cityGeoId == model.destinationGeoId).fromLocation.countryCode; + } + else if (model.scheduleDetails.Any(x => x.toLocation.cityGeoId == model.destinationGeoId)) + { + showDto.deliveryCountryCode = model.scheduleDetails.FirstOrDefault(x => x.toLocation.cityGeoId == model.destinationGeoId).toLocation.countryCode; + } + var legs = model.scheduleDetails.Select(b => { MSKAPISPOTScheduleRateResultShowLegsDto leg = new MSKAPISPOTScheduleRateResultShowLegsDto @@ -491,6 +509,8 @@ namespace Myshipping.Application.Service.BookingOrder return leg; }).ToList(); + + showDto.Legs = legs.OrderBy(t => t.ETD).Select((t, idx) => { t.SortNo = idx + 1; return t; @@ -728,8 +748,10 @@ namespace Myshipping.Application.Service.BookingOrder } }; - foreach (var detail in selectedShipSchedule.scheduleDetails) + for(int i=0;i< selectedShipSchedule.scheduleDetails.Count;i++) { + var detail = selectedShipSchedule.scheduleDetails[i]; + var currDto = new MSKAPIBookingSchedules(); //ETD if (!string.IsNullOrWhiteSpace(detail.fromLocation.date)) @@ -774,21 +796,62 @@ namespace Myshipping.Application.Service.BookingOrder currDto.serviceCode = detail.serviceCode; - currDto.startLocation = new MSKAPIBookingRouteDetailsBase { - cityName = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.cityName, - ISOcountryCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.countryCode, - UNLocationCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.unLocCode, - maerskCityGeoId = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.cityGeoId, - }; + //首个 + if(i == 0) + { + currDto.startLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.cityName, + ISOcountryCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.countryCode, + UNLocationCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.unLocCode, + maerskCityGeoId = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.cityGeoId, + }; - currDto.endLocation = new MSKAPIBookingRouteDetailsBase + currDto.endLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.cityName, + ISOcountryCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.countryCode, + UNLocationCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.unLocCode, + maerskSiteGeoId = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.siteGeoId, + }; + } + else if(i == selectedShipSchedule.scheduleDetails.Count - 1) { - cityName = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.cityName, - ISOcountryCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.countryCode, - UNLocationCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.unLocCode, - maerskCityGeoId = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.cityGeoId, - }; + currDto.startLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.cityName, + ISOcountryCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.countryCode, + UNLocationCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.unLocCode, + maerskSiteGeoId = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.siteGeoId, + }; + currDto.endLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.cityName, + ISOcountryCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.countryCode, + UNLocationCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.unLocCode, + maerskCityGeoId = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.cityGeoId, + }; + } + else + { + currDto.startLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.cityName, + ISOcountryCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.countryCode, + UNLocationCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.unLocCode, + maerskSiteGeoId = selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.siteGeoId, + }; + + currDto.endLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.cityName, + ISOcountryCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.countryCode, + UNLocationCode = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.unLocCode, + maerskSiteGeoId = selectedShipSchedule.scheduleDetails.FirstOrDefault().toLocation.siteGeoId, + }; + } + bookingDto.bookingBody.transport.routeDetails.selectedRoute.bookingSchedules.Add(currDto); }