using DS.WMS.Core.Application.Dtos; using DS.WMS.Core.Application.Entity; using DS.WMS.Core.Code.Entity; using DS.WMS.Core.Fee.Entity; using System.Linq.Expressions; using DS.WMS.Core.Fee.Method; using DS.WMS.Core.Op.Entity; using SqlSugar; namespace DS.WMS.Core.Application.Method { /// /// 申请单相关服务基类 /// public abstract class ApplicationServiceBase : FeeServiceBase { /// /// 初始化 /// /// 服务提供程序 protected ApplicationServiceBase(IServiceProvider serviceProvider) : base(serviceProvider) { } /// /// 返回针对费用申请明细及其关联业务的查询对象 /// /// 关联条件1 /// 查询对象 public ISugarQueryable CreateApplicationDetailQuery( Expression>? expr1 = null) { //海运出口 var query1 = TenantDb.Queryable() .InnerJoin((d, f) => d.RecordId == f.Id) .LeftJoin((d, f, s) => f.BusinessId == s.Id && f.BusinessType == BusinessType.OceanShippingExport) .WhereIF(expr1 != null, expr1) .LeftJoin((d, f, s, cs) => s.SourceId == cs.Id) .Select((d, f, s, cs) => new ApplicationDetailDto { //---------------明细表-------------- Id = d.Id, ApplicationId = d.ApplicationId, DetailId = d.DetailId, RecordId = d.RecordId, FeeType = d.FeeType, CustomerName = d.CustomerName, FeeId = d.FeeId, FeeName = d.FeeName, Currency = d.Currency, ApplyAmount = d.ApplyAmount, ExchangeRate = d.ExchangeRate, OriginalAmount = d.OriginalAmount, OriginalCurrency = d.OriginalCurrency, ProcessedAmount = d.ProcessedAmount, OriginalProcessedAmount = d.OriginalProcessedAmount, //---------------费用表-------------- OriginalRate = f.ExchangeRate, Amount = f.Amount, AccTaxRate = f.AccTaxRate, CustomerId = f.CustomerId,//费用对象ID OrderAmount = f.OrderAmount, InvoiceAmount = f.InvoiceAmount, SettlementAmount = f.SettlementAmount, OrderSettlementAmount = f.OrderSettlementAmount, OrderInvSettlementAmount = f.OrderInvSettlementAmount, //---------------业务表-------------- BusinessId = s.Id, BusinessType = BusinessType.OceanShippingExport, AccountDate = s.AccountDate, CntrTotal = s.CntrTotal, CustomerNo = s.CustomerNo, ClientName = s.CustomerName, //委托单位 //DischargePort = s.DischargePort, ETD = s.ETD, HBLNO = s.HBLNO, LoadPort = s.LoadPort, MBLNO = s.MBLNO, SaleDeptId = s.SaleDeptId, SaleName = s.Sale,//揽货人 Vessel = s.Vessel,//船名 Voyage = s.Voyno,//航次 BookingNo = s.BookingNo, //---------------附加表-------------- SourceName = cs.SourceName }); //海运进口 return TenantDb.UnionAll(new List> { query1 }); } } }