diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 2ad969e9..e49c6864 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -147,6 +147,8 @@ namespace Myshipping.Application private readonly IEventPublisher _publisher; + private readonly SqlSugarRepository _repTenantParamValue; + const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING"; const string CONST_MAPPING_MODULE_ROUTE = "BOOK_OR_CLOSING_RT"; const string CONST_MAPPING_MODULE_VOLTA = "BOOK_CLOSING_VOLTA"; @@ -175,7 +177,9 @@ namespace Myshipping.Application SqlSugarRepository repTenant, SqlSugarRepository repBookingStatus, SqlSugarRepository bookingEDIExt, SqlSugarRepository serviceItem, SqlSugarRepository paraContractNoInfoRepository, IHttpContextAccessor httpContextAccessor, IBookingGoodsStatusConfigService GoodsConfig, SqlSugarRepository djyWebsiteAccountConfigRepository, ISysOrgService orgService, SqlSugarRepository repLineOpMgrConfig, SqlSugarRepository repSysEmp, SqlSugarRepository repAutoYard, - IServiceWorkFlowManageService serviceWorkFlowManageService, IDjyUserConfigService djyUserConfigService, IEventPublisher publisher, SqlSugarRepository repSlotBase, SqlSugarRepository repSlotAllocation, SqlSugarRepository repSlotAllocationCtn, IBookingSlotService bookingSlotService, SqlSugarRepository repBookingStatusSubscribe) + IServiceWorkFlowManageService serviceWorkFlowManageService, IDjyUserConfigService djyUserConfigService, IEventPublisher publisher, SqlSugarRepository repSlotBase, + SqlSugarRepository repSlotAllocation, SqlSugarRepository repSlotAllocationCtn, IBookingSlotService bookingSlotService, + SqlSugarRepository repBookingStatusSubscribe, SqlSugarRepository repTenantParamValue) { this._logger = logger; this._rep = rep; @@ -228,6 +232,7 @@ namespace Myshipping.Application _repSlotAllocationCtn = repSlotAllocationCtn; this.bookingSlotService = bookingSlotService; _repBookingStatusSubscribe = repBookingStatusSubscribe; + _repTenantParamValue = repTenantParamValue; } #region 主表和箱信息 @@ -9941,6 +9946,15 @@ namespace Myshipping.Application { order.ATD = sjlg_time; flag = true; + + //当前租户配置为实际开船后扣费 + var paraVal = _repTenantParamValue.AsQueryable().Filter(null, true).First(x => x.TenantId == UserManager.TENANT_ID && x.ParaCode == "BOOKING_FEE_METHOD"); + //有实际开船,扣费 + if (paraVal != null && paraVal.ItemCode == "ATD") + { + //扣费 + await _publisher.PublishAsync(new ChannelEventSource($"Booking:DoFeeRecord", new { bsType = 28, sendtype = 0, idList = new List() { order.Id } })); + } } //同步船期 if (flag) @@ -11882,7 +11896,7 @@ namespace Myshipping.Application */ try { - if(string.IsNullOrWhiteSpace(model.collectionOriginCityName)) + if (string.IsNullOrWhiteSpace(model.collectionOriginCityName)) throw Oops.Oh($"始发地不能为空"); if (string.IsNullOrWhiteSpace(model.deliveryDestinationCityName)) @@ -11899,7 +11913,7 @@ namespace Myshipping.Application DateTime etd = DateTime.MinValue; - if(!DateTime.TryParse(model.startDate,out etd)) + if (!DateTime.TryParse(model.startDate, out etd)) throw Oops.Oh($"预计离港日期格式错误"); string queryUrl = string.Empty; @@ -11984,7 +11998,7 @@ namespace Myshipping.Application info.days = (int)Math.Ceiling(timeDiff / 24.0); } - if(b.facilities != null) + if (b.facilities != null) { info.orignCityName = b.facilities.collectionOrigin?.cityName; info.orignCarrierSiteGeoID = b.facilities.collectionOrigin?.carrierSiteGeoID; @@ -12016,7 +12030,7 @@ namespace Myshipping.Application info.transportMode = firstTransportLegs.transport.transportMode; info.carrierDepartureVoyageNumber = firstTransportLegs.transport.carrierDepartureVoyageNumber; } - + } list.Add(info); @@ -12080,7 +12094,8 @@ namespace Myshipping.Application throw Oops.Oh("未配置个人账户,请先配置个人账户 类型-MSKApi"); - MSKAPIBookingDto bookingDto = new MSKAPIBookingDto { + MSKAPIBookingDto bookingDto = new MSKAPIBookingDto + { userKey = App.Configuration["MSKAPIDjyUserKey"], userSecret = App.Configuration["MSKAPIDjyUserSecret"], operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"], @@ -12088,38 +12103,46 @@ namespace Myshipping.Application bookingBody = new MSKAPIBookingBodyDto() }; - bookingDto.bookingBody.references = new MSKAPIBookingReferenceDto { + bookingDto.bookingBody.references = new MSKAPIBookingReferenceDto + { priceReference = model.priceReference, productCode = model.productCode, sender = model.sender, }; - bookingDto.bookingBody.mandatoryParties = new MSKAPIBookingMandatoryParties { + bookingDto.bookingBody.mandatoryParties = new MSKAPIBookingMandatoryParties + { bookedByCompanyName = model.bookedByCompanyName, bookedByMaerskPartyCode = model.bookedByMaerskPartyCode, - bookedByPartyContact = new MSKAPIBookingMandatoryPartyContact { - name = model.bookedByCompanyContactName, + bookedByPartyContact = new MSKAPIBookingMandatoryPartyContact + { + name = model.bookedByCompanyContactName, email = model.bookedByCompanyContactEmail }, priceOwnerCompanyName = model.priceOwnerCompanyName, priceOwnerMaerskPartyCode = model.priceOwnerMaerskPartyCode, - priceOwnerPartyContact = new MSKAPIBookingMandatoryPartyContact { + priceOwnerPartyContact = new MSKAPIBookingMandatoryPartyContact + { name = model.priceOwnerContactName, email = model.priceOwnerContactEmail }, }; - bookingDto.bookingBody.transport = new MSKAPIBookingTransport { + bookingDto.bookingBody.transport = new MSKAPIBookingTransport + { carrierCode = model.carrierCode, earliestDepartureDate = model.earliestDepartureDate, exportServiceMode = model.exportServiceMode, importServiceMode = model.importServiceMode, - routeDetails = new MSKAPIBookingRouteDetails { - placeOfReceipt = new MSKAPIBookingRouteDetailsBase { + routeDetails = new MSKAPIBookingRouteDetails + { + placeOfReceipt = new MSKAPIBookingRouteDetailsBase + { UNLocationCode = model.placeOfReceiptUnLocCode, cityName = model.placeOfReceiptCityName, }, - placeOfDelivery = new MSKAPIBookingRouteDetailsBase { + placeOfDelivery = new MSKAPIBookingRouteDetailsBase + { UNLocationCode = model.placeOfDeliveryUnLocCode, cityName = model.placeOfDeliveryCityName, }, @@ -12174,7 +12197,7 @@ namespace Myshipping.Application throw Oops.Oh($"当前船公司 {model.carrierId} 未配置相应的请求接口"); } - if(string.IsNullOrWhiteSpace(queryUrl)) + if (string.IsNullOrWhiteSpace(queryUrl)) throw Oops.Oh("未配置商品请求接口地址,请联系管理员"); var webAccountConfig = _webAccountConfig @@ -12183,7 +12206,8 @@ namespace Myshipping.Application if (webAccountConfig == null) throw Oops.Oh("未配置个人账户,请先配置个人账户 类型-MSKApi"); - MSKAPISearchCommodityDto queryInfo = new MSKAPISearchCommodityDto { + MSKAPISearchCommodityDto queryInfo = new MSKAPISearchCommodityDto + { userKey = App.Configuration["MSKAPIDjyUserKey"], userSecret = App.Configuration["MSKAPIDjyUserSecret"], operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"], @@ -12202,7 +12226,7 @@ namespace Myshipping.Application { resultInfo = JSON.Deserialize(rlt); } - catch(Exception ex) + catch (Exception ex) { _logger.LogInformation($"请求MSK API检索商品异常,原因:{ex.Message}"); @@ -12210,7 +12234,7 @@ namespace Myshipping.Application } } - if (resultInfo != null && resultInfo.code == 200 + if (resultInfo != null && resultInfo.code == 200 && resultInfo.data != null && resultInfo.data.Count > 0) { list = resultInfo.data.Adapt>();