修改MSK SPOT

master
jianghaiqing 5 months ago
parent fae7b93a25
commit c2a7434183

@ -566,5 +566,15 @@ namespace Myshipping.Application.Entity
/// 船期MD5
/// </summary>
public string SHIP_RATE_MD5 { get; set; }
/// <summary>
/// 收货地定位ID
/// </summary>
public string PLACERECEIPT_GEO_ID { get; set; }
/// <summary>
/// 交货地定位ID
/// </summary>
public string PLACEDELIVERY_GEO_ID { get; set; }
}
}

@ -21,6 +21,7 @@ using Myshipping.Core.Const;
using Yitter.IdGenerator;
using System.Diagnostics;
using Newtonsoft.Json;
using StackExchange.Profiling.Internal;
namespace Myshipping.Application.Service.BookingOrder
{
@ -349,6 +350,9 @@ namespace Myshipping.Application.Service.BookingOrder
Legs = new List<MSKAPISPOTScheduleRateResultShowLegsDto>()
};
if (a.totalAmount.HasValue)
showDto.totalAmountShow = string.Format("{0:N}", a.totalAmount.Value);
//ETD
if (!string.IsNullOrWhiteSpace(a.departureDate))
{
@ -593,6 +597,51 @@ namespace Myshipping.Application.Service.BookingOrder
//这里是校验必填项
ValidateMSKAPIData(model);
MSKAPISPOTSearchScheduleRateResultDataDto selectedShipSchedule = null;
BookingDeliveryRecordShipSchedule shipScheduleRecord = null;
if (model.PId == 0)
throw Oops.Oh("船期信息不能为空,请重新检索船期");
if (model.PId > 0)
{
if (model.id.HasValue && model.id.Value > 0)
{
var recordId = model.id.Value;
shipScheduleRecord = await _bookingDeliveryRecordShipScheduleRep.AsQueryable()
.FirstAsync(a => a.RECORD_ID == recordId && a.SHIP_RATE_PID != null &&
a.SHIP_RATE_PID.Value == model.PId && a.IsDeleted == false);
}
if (shipScheduleRecord == null)
{
selectedShipSchedule = GetCacheShipSailingSchedule(model.PId);
}
else
{
selectedShipSchedule = JSON.Deserialize<MSKAPISPOTSearchScheduleRateResultDataDto>(shipScheduleRecord.SHIP_JSON);
}
if (selectedShipSchedule == null)
throw Oops.Oh("船期数据校验失败,请重新查询船期信息");
if (selectedShipSchedule.priceID.Equals(model.priceID))
{
_logger.LogInformation($"请求当前船期请求参数错误 priceID={model.priceID} 缓存priceID={selectedShipSchedule.priceID} PId={model.PId}");
throw Oops.Oh("船期数据校验失败,当前船期请求参数错误,请重新查询船期信息");
}
if (selectedShipSchedule.totalAmount.Value != model.ShipRateTotalAmount.Value)
{
_logger.LogInformation($"请求当前船期请求参数错误 totalAmount={selectedShipSchedule.totalAmount.Value} 缓存totalAmount={model.ShipRateTotalAmount.Value} PId={model.PId}");
throw Oops.Oh("船期数据校验失败,当前船期请求参数错误,价格发生差异,请重新查询船期信息");
}
}
DateTime nowDate = DateTime.Now;
var recordInfo = model.Adapt<BookingDeliveryRecord>();
@ -618,7 +667,8 @@ namespace Myshipping.Application.Service.BookingOrder
priceReference = model.priceReference,
productCode = model.productCode,
sender = model.sender,
bookingOfficeUNLocationCode = "CNTAO"
bookingOfficeUNLocationCode = "CNTAO",
isSpotTermsAndConditionsAccepted = true,
};
bookingDto.bookingBody.mandatoryParties = new MSKAPIBookingMandatoryParties
@ -639,12 +689,6 @@ namespace Myshipping.Application.Service.BookingOrder
},
};
//排查怀疑这里是导致BC没有合约号胡的问题开启这个值看看
//if (model.isBookingPartOwnPrice)
//{
// bookingDto.bookingBody.mandatoryParties.isPriceOwnerFromServiceContractAccepted = true;
//}
bookingDto.bookingBody.transport = new MSKAPIBookingTransport
{
carrierCode = model.carrierCode,
@ -655,55 +699,84 @@ namespace Myshipping.Application.Service.BookingOrder
{
placeOfReceipt = new MSKAPIBookingRouteDetailsBase
{
UNLocationCode = model.userPlaceOfReceiptUnLocCode
//: model.placeOfReceiptUnLocCode,
//cityName = model.placeOfReceiptCityName,
UNLocationCode = model.userPlaceOfReceiptUnLocCode,
maerskCityGeoId = selectedShipSchedule.originGeoId,
},
placeOfDelivery = new MSKAPIBookingRouteDetailsBase
{
UNLocationCode = model.userPlaceOfDeliveryUnLocCode
//: model.placeOfDeliveryUnLocCode,
//cityName = model.placeOfDeliveryCityName,
UNLocationCode = model.userPlaceOfDeliveryUnLocCode,
maerskCityGeoId = selectedShipSchedule.destinationGeoId,
},
selectedRoute = new MSKAPIBookingRoute
{
bookingSchedules = new List<MSKAPIBookingSchedules> {
new MSKAPIBookingSchedules
{
originDepartureDateTimeLocal = model.originDepartureDateTimeLocal.Value.ToString("yyyy-MM-ddTHH:mm:ss"),
destinationArrivalDateTimeLocal = model.destinationArrivalDateTimeLocal.Value.ToString("yyyy-MM-ddTHH:mm:ss"),
transportMode = new MSKAPIBookingTransportMode
{
vessel = new MSKAPIBookingTransportModeVessel
{
name = model.vesselName,
maerskVesselCode = model.carrierVesselCode,
},
exportVoyageNumber = model.exportVoyageNumber,
},
startLocation = new MSKAPIBookingRouteDetailsBase
{
//cityName = model.placeOfReceiptCityName,
UNLocationCode = model.userPlaceOfReceiptUnLocCode
//: model.placeOfReceiptUnLocCode
},
endLocation = new MSKAPIBookingRouteDetailsBase
{
//cityName = model.placeOfDeliveryCityName,
UNLocationCode = model.userPlaceOfDeliveryUnLocCode
//: model.placeOfDeliveryUnLocCode
},
transportModeCode = model.transportMode
}
}
bookingSchedules = new List<MSKAPIBookingSchedules>(),
},
}
};
//if(!model.isSendNoSchedule)
//{
// bookingDto.bookingBody.transport.routeDetails.selectedRoute.routeScheduleId = model.carrierProductId;
//}
foreach (var detail in selectedShipSchedule.scheduleDetails)
{
var currDto = new MSKAPIBookingSchedules();
//ETD
if (!string.IsNullOrWhiteSpace(detail.fromLocation.date))
{
DateTime currDate = DateTime.MinValue;
if (DateTime.TryParse($"{detail.fromLocation.date} {detail.fromLocation.time}", out currDate))
{
currDto.originDepartureDateTimeLocal = currDate.ToString("yyyy-MM-ddTHH:mm:ss");
}
else
{
throw Oops.Bah($"查询船期错误priceID={model.priceID} pid={model.PId} 预计离港日期departureDate={detail.fromLocation.date} {detail.fromLocation.time} 格式解析错误");
}
}
//ETD
if (!string.IsNullOrWhiteSpace(detail.toLocation.date))
{
DateTime currDate = DateTime.MinValue;
if (DateTime.TryParse($"{detail.toLocation.date} {detail.toLocation.time}", out currDate))
{
currDto.destinationArrivalDateTimeLocal = currDate.ToString("yyyy-MM-ddTHH:mm:ss");
}
else
{
throw Oops.Bah($"查询船期错误priceID={model.priceID} pid={model.PId} 预计离港日期ArrivalDate={detail.toLocation.date} {detail.toLocation.time} 格式解析错误");
}
}
currDto.transportMode = new MSKAPIBookingTransportMode
{
vessel = new MSKAPIBookingTransportModeVessel
{
name = detail.transport.vessel.name,
maerskVesselCode = detail.transport.vessel.code,
vesselIMONumber = detail.transport.vessel.imoNumber
},
exportVoyageNumber = detail.transport.voyageNumber,
};
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,
};
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,
};
bookingDto.bookingBody.transport.routeDetails.selectedRoute.bookingSchedules.Add(currDto);
}
bookingDto.bookingBody.cargo = new MSKAPIBookingCargo
{
@ -1187,10 +1260,18 @@ namespace Myshipping.Application.Service.BookingOrder
MSKAPISPOTSearchScheduleRateResultDataDto selectedShipSchedule = null;
BookingDeliveryRecordShipSchedule shipScheduleRecord = null;
if (model.PId > 0)
{
var shipScheduleRecord = await _bookingDeliveryRecordShipScheduleRep.AsQueryable()
.FirstAsync(a => a.SHIP_RATE_PID != null && a.SHIP_RATE_PID.Value == model.PId);
if (model.id.HasValue && model.id.Value > 0)
{
var recordId = model.id.Value;
shipScheduleRecord = await _bookingDeliveryRecordShipScheduleRep.AsQueryable()
.FirstAsync(a => a.RECORD_ID == recordId && a.SHIP_RATE_PID != null &&
a.SHIP_RATE_PID.Value == model.PId && a.IsDeleted == false);
}
if (shipScheduleRecord == null)
{
@ -1203,6 +1284,28 @@ namespace Myshipping.Application.Service.BookingOrder
if (selectedShipSchedule == null)
throw Oops.Oh("船期数据校验失败,请重新查询船期信息");
if (selectedShipSchedule.priceID.Equals(model.priceID))
{
_logger.LogInformation($"请求当前船期请求参数错误 priceID={model.priceID} 缓存priceID={selectedShipSchedule.priceID} PId={model.PId}");
throw Oops.Oh("船期数据校验失败,当前船期请求参数错误,请重新查询船期信息");
}
if (selectedShipSchedule.totalAmount.Value != model.ShipRateTotalAmount.Value)
{
_logger.LogInformation($"请求当前船期请求参数错误 totalAmount={selectedShipSchedule.totalAmount.Value} 缓存totalAmount={model.ShipRateTotalAmount.Value} PId={model.PId}");
throw Oops.Oh("船期数据校验失败,当前船期请求参数错误,价格发生差异,请重新查询船期信息");
}
model.placeOfReceiptCountryName = selectedShipSchedule.originCountryName;
model.placeOfReceiptRegionName = selectedShipSchedule.originRegionName;
model.placeOfReceiptGeoId = selectedShipSchedule.originGeoId;
model.placeOfDeliveryRegionName = selectedShipSchedule.destinationCountryName;
model.placeOfDeliveryCountryName = selectedShipSchedule.destinationCountryName;
model.placeOfReceiptRegionName = selectedShipSchedule.destinationGeoId;
}
if (model.ctns != null && model.ctns.Count > 0)
@ -1328,14 +1431,36 @@ namespace Myshipping.Application.Service.BookingOrder
}
}
if(shipScheduleRecord == null)
{
if(model.PId > 0 && selectedShipSchedule != null)
{
shipScheduleRecord = new BookingDeliveryRecordShipSchedule
{
Id = YitIdHelper.NextId(),
RECORD_ID = model.id.Value,
PRICE_ID = model.priceID,
SHIP_RATE_PID = selectedShipSchedule.PId,
SHIP_RATE_MD5 = selectedShipSchedule.MD5,
SHIP_RATE_TOTAL_AMOUNT = selectedShipSchedule.totalAmount.HasValue ? selectedShipSchedule.totalAmount.Value : 0,
SHIP_RATE_TOTAL_CURRENCY = selectedShipSchedule.totalCurrency,
SHIP_JSON = Newtonsoft.Json.JsonConvert.SerializeObject(selectedShipSchedule),
CreatedTime = nowDate,
UpdatedTime = nowDate,
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name
};
await _bookingDeliveryRecordShipScheduleRep.InsertAsync(shipScheduleRecord);
}
}
return model.id.Value;
}
else
{
BookingDeliveryRecord entity = model.Adapt<BookingDeliveryRecord>();
entity.CreatedTime = nowDate;
entity.UpdatedTime = nowDate;
entity.CreatedUserId = UserManager.UserId;
@ -1372,6 +1497,71 @@ namespace Myshipping.Application.Service.BookingOrder
});
}
if (shipScheduleRecord == null)
{
if (model.PId > 0 && selectedShipSchedule != null)
{
shipScheduleRecord = new BookingDeliveryRecordShipSchedule
{
Id = YitIdHelper.NextId(),
RECORD_ID = model.id.Value,
PRICE_ID = model.priceID,
SHIP_RATE_PID = selectedShipSchedule.PId,
SHIP_RATE_MD5 = selectedShipSchedule.MD5,
SHIP_RATE_TOTAL_AMOUNT = selectedShipSchedule.totalAmount.HasValue ? selectedShipSchedule.totalAmount.Value : 0,
SHIP_RATE_TOTAL_CURRENCY = selectedShipSchedule.totalCurrency,
SHIP_JSON = Newtonsoft.Json.JsonConvert.SerializeObject(selectedShipSchedule),
CreatedTime = nowDate,
UpdatedTime = nowDate,
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name
};
await _bookingDeliveryRecordShipScheduleRep.InsertAsync(shipScheduleRecord);
}
}
else
{
//只有船期发生变化时才重新写入新的船期记录
if (model.PId != shipScheduleRecord.SHIP_RATE_PID.Value)
{
_logger.LogInformation($"MSK SPOT id={model.id} 换了船期 原记录:{selectedShipSchedule.PId} 新记录:{model.PId} 作废原船期,插入新船期");
shipScheduleRecord.IsDeleted = true;
shipScheduleRecord.UpdatedTime = nowDate;
shipScheduleRecord.UpdatedUserId = UserManager.UserId;
shipScheduleRecord.UpdatedUserName = UserManager.Name;
await _bookingDeliveryRecordShipScheduleRep.AsUpdateable(shipScheduleRecord).UpdateColumns(x=>new {
x.IsDeleted,
x.UpdatedUserId,
x.UpdatedUserName,
x.UpdatedTime
}).ExecuteCommandAsync();
shipScheduleRecord = new BookingDeliveryRecordShipSchedule
{
Id = YitIdHelper.NextId(),
RECORD_ID = model.id.Value,
PRICE_ID = model.priceID,
SHIP_RATE_PID = selectedShipSchedule.PId,
SHIP_RATE_MD5 = selectedShipSchedule.MD5,
SHIP_RATE_TOTAL_AMOUNT = selectedShipSchedule.totalAmount.HasValue ? selectedShipSchedule.totalAmount.Value : 0,
SHIP_RATE_TOTAL_CURRENCY = selectedShipSchedule.totalCurrency,
SHIP_JSON = Newtonsoft.Json.JsonConvert.SerializeObject(selectedShipSchedule),
CreatedTime = nowDate,
UpdatedTime = nowDate,
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name
};
await _bookingDeliveryRecordShipScheduleRep.InsertAsync(shipScheduleRecord);
}
else
{
_logger.LogInformation($"MSK SPOT id={model.id} 船期没变化 model.PId={model.PId} shipScheduleRecord.SHIP_RATE_PID={shipScheduleRecord.SHIP_RATE_PID.Value}");
}
}
return entity.Id;
}
}

@ -93,7 +93,9 @@ namespace Myshipping.Application
.Map(dest => dest.SHIP_RATE_TOTAL_AMOUNT, src => src.ShipRateTotalAmount)
.Map(dest => dest.SHIP_RATE_TOTAL_CURRENCY, src => src.ShipRateTotalCurrency)
.Map(dest => dest.SHIP_RATE_PID, src => src.PId)
.Map(dest => dest.SHIP_RATE_MD5, src => src.MD5);
.Map(dest => dest.SHIP_RATE_MD5, src => src.MD5)
.Map(dest => dest.PLACERECEIPT_GEO_ID, src => src.placeOfReceiptGeoId)
.Map(dest => dest.PLACEDELIVERY_GEO_ID, src => src.placeOfDeliveryGeoId);
config.ForType<BookingDeliveryRecord, MSKSPOTBookingDto>()
.Map(dest => dest.id, src => src.Id)
@ -166,7 +168,9 @@ namespace Myshipping.Application
.Map(dest => dest.PId, src => src.SHIP_RATE_PID)
.Map(dest => dest.MD5, src => src.SHIP_RATE_MD5)
.Map(dest => dest.bookingChannelTypeName, src => src.BOOKING_CHANNEL_TYPE_NAME)
.Map(dest => dest.bookingChannelType, src => src.BOOKING_CHANNEL_TYPE);
.Map(dest => dest.bookingChannelType, src => src.BOOKING_CHANNEL_TYPE)
.Map(dest => dest.placeOfReceiptGeoId, src => src.PLACERECEIPT_GEO_ID)
.Map(dest => dest.placeOfDeliveryGeoId, src => src.PLACEDELIVERY_GEO_ID);
config.ForType<MSKBookingCtnInfo, BookingDeliveryRecordCtn>()

@ -67,6 +67,11 @@ namespace Myshipping.Application
/// </summary>
public decimal totalAmount { get; set; }
/// <summary>
/// 金额格式化
/// </summary>
public string totalAmountShow { get; set; }
/// <summary>
/// 是否中转
/// </summary>

@ -396,5 +396,14 @@ namespace Myshipping.Application
/// </summary>
public string bookingChannelTypeName { get; set; }
/// <summary>
/// 收货地定位ID
/// </summary>
public string placeOfReceiptGeoId { get; set; }
/// <summary>
/// 交货地定位ID
/// </summary>
public string placeOfDeliveryGeoId { get; set; }
}
}

Loading…
Cancel
Save