|
|
@ -34,23 +34,29 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task<DataResult<List<ApplicationSettlementDto>>> GetListAsync(PageRequest request)
|
|
|
|
public async Task<DataResult<List<ApplicationSettlementDto>>> GetListAsync(PageRequest<NumberQuery> request)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var query = TenantDb.Queryable<ApplicationSettlement>().Select(x => new ApplicationSettlementDto
|
|
|
|
var query = TenantDb.Queryable<ApplicationSettlement>().WhereIF(!string.IsNullOrEmpty(request.OtherQueryCondition?.Number), x =>
|
|
|
|
{
|
|
|
|
SqlFunc.Subqueryable<ApplicationDetail>().InnerJoin<FeeRecord>((d, f) => d.RecordId == f.Id && f.BusinessType == BusinessType.OceanShippingExport)
|
|
|
|
SettlementTypeName = x.SettlementType.StlName, //结算方式
|
|
|
|
.InnerJoin<SeaExport>((d, f, s) => f.BusinessId == s.Id).Where((d, f, s) =>
|
|
|
|
RMBAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => y.ApplicationId == x.Id && y.Currency == FeeCurrency.RMB_CODE)
|
|
|
|
s.CustomerNo.Contains(request.OtherQueryCondition.Number) || s.BookingNo.Contains(request.OtherQueryCondition.Number) ||
|
|
|
|
|
|
|
|
s.MBLNO.Contains(request.OtherQueryCondition.Number) || s.CustomerNum.Contains(request.OtherQueryCondition.Number)).Any())
|
|
|
|
|
|
|
|
.Select(x => new ApplicationSettlementDto
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
SettlementNO = x.SettlementNO,
|
|
|
|
|
|
|
|
SettlementTypeName = x.SettlementType.StlName, //结算方式
|
|
|
|
|
|
|
|
RMBAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => y.ApplicationId == x.Id && y.Currency == FeeCurrency.RMB_CODE)
|
|
|
|
.Select(y => SqlFunc.AggregateSum(y.ApplyAmount)),
|
|
|
|
.Select(y => SqlFunc.AggregateSum(y.ApplyAmount)),
|
|
|
|
USDAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => y.ApplicationId == x.Id && y.Currency == FeeCurrency.USD_CODE)
|
|
|
|
USDAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => y.ApplicationId == x.Id && y.Currency == FeeCurrency.USD_CODE)
|
|
|
|
.Select(y => SqlFunc.AggregateSum(y.ApplyAmount)),
|
|
|
|
.Select(y => SqlFunc.AggregateSum(y.ApplyAmount)),
|
|
|
|
OtherAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => y.ApplicationId == x.Id && y.Currency != FeeCurrency.RMB_CODE && y.Currency != FeeCurrency.USD_CODE)
|
|
|
|
OtherAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => y.ApplicationId == x.Id && y.Currency != FeeCurrency.RMB_CODE && y.Currency != FeeCurrency.USD_CODE)
|
|
|
|
.Select(y => SqlFunc.AggregateSum(y.ApplyAmount)),
|
|
|
|
.Select(y => SqlFunc.AggregateSum(y.ApplyAmount)),
|
|
|
|
CustomerAccount = x.CustomerBank.AccountName + "/" + x.CustomerBank.Currency,
|
|
|
|
CustomerAccount = x.CustomerBank.AccountName + "/" + x.CustomerBank.Currency,
|
|
|
|
CustomerBankName = x.CustomerBank.BankName,
|
|
|
|
CustomerBankName = x.CustomerBank.BankName,
|
|
|
|
//未开票
|
|
|
|
//未开票
|
|
|
|
UnInvoiceList = SqlFunc.Subqueryable<ApplicationDetail>().InnerJoin<FeeRecord>((d, f) => d.ApplicationId == x.Id && d.RecordId == f.Id)
|
|
|
|
UnInvoiceList = SqlFunc.Subqueryable<ApplicationDetail>().InnerJoin<FeeRecord>((d, f) => d.ApplicationId == x.Id && d.RecordId == f.Id)
|
|
|
|
.GroupBy((d, f) => f.Currency).ToList((d, f) => new CurrencyAmount { Currency = f.Currency, Amount = SqlFunc.AggregateSum(f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount) }),
|
|
|
|
.GroupBy((d, f) => f.Currency).ToList((d, f) => new CurrencyAmount { Currency = f.Currency, Amount = SqlFunc.AggregateSum(f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount) }),
|
|
|
|
}, true);
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
|
|
|
|
var whereList = request.GetConditionalModels(Db);
|
|
|
|
var whereList = request.GetConditionalModels(Db);
|
|
|
|
var result = await query.Where(whereList).ToQueryPageAsync(request.PageCondition);
|
|
|
|
var result = await query.Where(whereList).ToQueryPageAsync(request.PageCondition);
|
|
|
|