You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.7 KiB
C#

using System.Linq.Expressions;
using DS.WMS.Core.Application.Dtos;
using DS.WMS.Core.Application.Entity;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Method;
using DS.WMS.Core.Op.Entity;
using SqlSugar;
namespace DS.WMS.Core.Application.Method
{
/// <summary>
/// 申请单相关服务基类
/// </summary>
public abstract class ApplicationServiceBase : FeeServiceBase
{
/// <summary>
/// 初始化
/// </summary>
/// <param name="serviceProvider">服务提供程序</param>
protected ApplicationServiceBase(IServiceProvider serviceProvider) : base(serviceProvider)
{
}
/// <summary>
/// 返回针对费用申请明细及其关联业务的查询对象
/// </summary>
/// <param name="expr1">关联条件1</param>
/// <returns>查询对象</returns>
public ISugarQueryable<ApplicationDetailDto> CreateApplicationDetailQuery(
Expression<Func<ApplicationDetail, FeeRecord, SeaExport, bool>>? expr1 = null)
{
//海运出口
var query1 = TenantDb.Queryable<ApplicationDetail>()
.InnerJoin<FeeRecord>((d, f) => d.RecordId == f.Id)
.LeftJoin<SeaExport>((d, f, s) => f.BusinessId == s.Id && f.BusinessType == BusinessType.OceanShippingExport)
.WhereIF(expr1 != null, expr1)
.Select((d, f, s) => new ApplicationDetailDto
{
//---------------明细表--------------
Id = d.Id,
ApplicationId = d.ApplicationId,
DetailId = d.DetailId,
RefId = d.RefId,
RecordId = d.RecordId,
FeeType = d.FeeType,
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
CustomerName = f.CustomerName,
OrderAmount = f.OrderAmount,
InvoiceAmount = f.InvoiceAmount,
SettlementAmount = f.SettlementAmount,
OrderSettlementAmount = f.OrderSettlementAmount,
OrderInvSettlementAmount = f.OrderInvSettlementAmount,
BusinessId = f.BusinessId,
BusinessType = f.BusinessType,
//---------------业务表--------------
AccountDate = s.AccountDate,
CntrTotal = s.CntrTotal,
CustomerNo = s.CustomerNo,
ClientName = s.CustomerName, //委托单位
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 = s.SourceName
});
//海运进口
return TenantDb.UnionAll(new List<ISugarQueryable<ApplicationDetailDto>> { query1 });
}
}
}