|
|
|
@ -147,7 +147,8 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<BizPaymentApplication>>> GetBizListAsync(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
var query = CreateBizQuery(request.GetConditionalModels(Db));
|
|
|
|
|
var conditions = request.GetConditionalModels(Db);
|
|
|
|
|
var query = CreateBizQuery(conditions);
|
|
|
|
|
var result = await query.ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
|
|
|
|
|
if (result.Data.Count > 0)
|
|
|
|
@ -160,8 +161,54 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
//关联机构名称
|
|
|
|
|
var orgIds = result.Data.Select(x => x.SaleDeptId).Distinct();
|
|
|
|
|
var orgs = await Db.Queryable<SysOrg>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.OrgName }).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var ids1 = result.Data.Select(x => x.Id);
|
|
|
|
|
var ids2 = result.Data.Select(x => x.BusinessType).Distinct();
|
|
|
|
|
var fees = await TenantDb.Queryable<FeeRecord>().Where(x => ids1.Contains(x.BusinessId) && ids2.Contains(x.BusinessType) && x.FeeStatus == FeeStatus.AuditPassed)
|
|
|
|
|
.Where(conditions).Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.BusinessId,
|
|
|
|
|
x.BusinessType,
|
|
|
|
|
x.CustomerId,
|
|
|
|
|
x.FeeType,
|
|
|
|
|
x.Amount,
|
|
|
|
|
x.InvoiceAmount,
|
|
|
|
|
x.OrderInvoiceAmount,
|
|
|
|
|
x.OrderInvSettlementAmount,
|
|
|
|
|
x.SettlementAmount,
|
|
|
|
|
x.OrderAmount,
|
|
|
|
|
x.OrderSettlementAmount,
|
|
|
|
|
x.Currency,
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
foreach (var item in result.Data)
|
|
|
|
|
{
|
|
|
|
|
//--------统计项--------
|
|
|
|
|
item.UnpaidRMB = fees.Where(f => f.BusinessId == item.Id && f.BusinessType == item.BusinessType &&
|
|
|
|
|
f.CustomerId == item.CustomerId && f.FeeType == FeeType.Payable && f.Currency == FeeCurrency.RMB_CODE)
|
|
|
|
|
.Sum(f => f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount);
|
|
|
|
|
item.UnpaidUSD = fees.Where(f => f.BusinessId == item.Id && f.BusinessType == item.BusinessType &&
|
|
|
|
|
f.CustomerId == item.CustomerId && f.FeeType == FeeType.Payable && f.Currency == FeeCurrency.USD_CODE)
|
|
|
|
|
.Sum(f => f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount);
|
|
|
|
|
item.UnpaidOther = fees.Where(f => f.BusinessId == item.Id && f.BusinessType == item.BusinessType &&
|
|
|
|
|
f.CustomerId == item.CustomerId && f.FeeType == FeeType.Payable && f.Currency != FeeCurrency.RMB_CODE && f.Currency != FeeCurrency.USD_CODE)
|
|
|
|
|
.Sum(f => f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount);
|
|
|
|
|
|
|
|
|
|
item.UnreceivedRMB = fees.Where(f => f.BusinessId == item.Id && f.BusinessType == item.BusinessType &&
|
|
|
|
|
f.CustomerId == item.CustomerId && f.FeeType == FeeType.Receivable && f.Currency == FeeCurrency.RMB_CODE)
|
|
|
|
|
.Sum(f => f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount);
|
|
|
|
|
item.UnreceivedUSD = fees.Where(f => f.BusinessId == item.Id && f.BusinessType == item.BusinessType &&
|
|
|
|
|
f.CustomerId == item.CustomerId && f.FeeType == FeeType.Receivable && f.Currency == FeeCurrency.USD_CODE)
|
|
|
|
|
.Sum(f => f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount);
|
|
|
|
|
item.UnreceivedOther = fees.Where(f => f.BusinessId == item.Id && f.BusinessType == item.BusinessType &&
|
|
|
|
|
f.CustomerId == item.CustomerId && f.FeeType == FeeType.Receivable && f.Currency != FeeCurrency.RMB_CODE && f.Currency != FeeCurrency.USD_CODE)
|
|
|
|
|
.Sum(f => f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount);
|
|
|
|
|
|
|
|
|
|
item.UnpaidRMBInv = fees.Where(f => f.BusinessId == item.Id && f.BusinessType == item.BusinessType && f.CustomerId == item.CustomerId && f.Currency == FeeCurrency.RMB_CODE)
|
|
|
|
|
.Sum(f => f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount);
|
|
|
|
|
item.UnpaidUSDInv = fees.Where(f => f.BusinessId == item.Id && f.BusinessType == item.BusinessType && f.CustomerId == item.CustomerId && f.Currency == FeeCurrency.USD_CODE)
|
|
|
|
|
.Sum(f => f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount);
|
|
|
|
|
|
|
|
|
|
item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
|
|
|
|
|
|
|
|
|
|
if (item.OperatorId.HasValue)
|
|
|
|
@ -203,26 +250,7 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
SaleName = s.Sale, //揽货人
|
|
|
|
|
Vessel = s.Vessel, //船名
|
|
|
|
|
Voyage = s.Voyage, //航次
|
|
|
|
|
StlName = s.StlName, //结算方式
|
|
|
|
|
//--------统计项--------
|
|
|
|
|
UnpaidRMB = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId && f.FeeStatus == FeeStatus.AuditPassed &&
|
|
|
|
|
f.FeeType == FeeType.Payable && f.Currency == FeeCurrency.RMB_CODE).Sum(f => f.Amount),
|
|
|
|
|
UnpaidUSD = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId && f.FeeStatus == FeeStatus.AuditPassed &&
|
|
|
|
|
f.FeeType == FeeType.Payable && f.Currency == FeeCurrency.USD_CODE).Sum(f => f.Amount),
|
|
|
|
|
UnpaidOther = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId && f.FeeStatus == FeeStatus.AuditPassed &&
|
|
|
|
|
f.FeeType == FeeType.Payable && f.Currency != FeeCurrency.USD_CODE && f.Currency != FeeCurrency.RMB_CODE).Sum(f => f.Amount),
|
|
|
|
|
|
|
|
|
|
UnreceivedRMB = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId && f.FeeStatus == FeeStatus.AuditPassed &&
|
|
|
|
|
f.FeeType == FeeType.Receivable && f.Currency == FeeCurrency.RMB_CODE).Sum(f => f.Amount),
|
|
|
|
|
UnreceivedUSD = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId && f.FeeStatus == FeeStatus.AuditPassed &&
|
|
|
|
|
f.FeeType == FeeType.Receivable && f.Currency == FeeCurrency.USD_CODE).Sum(f => f.Amount),
|
|
|
|
|
UnreceivedOther = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId && f.FeeStatus == FeeStatus.AuditPassed &&
|
|
|
|
|
f.FeeType == FeeType.Receivable && f.Currency != FeeCurrency.USD_CODE && f.Currency != FeeCurrency.RMB_CODE).Sum(f => f.Amount),
|
|
|
|
|
|
|
|
|
|
UnpaidRMBInv = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId && f.FeeStatus == FeeStatus.AuditPassed &&
|
|
|
|
|
f.FeeType == FeeType.Payable && f.Currency == FeeCurrency.RMB_CODE).Sum(f => f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount),
|
|
|
|
|
UnpaidUSDInv = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId && f.FeeStatus == FeeStatus.AuditPassed &&
|
|
|
|
|
f.FeeType == FeeType.Payable && f.Currency == FeeCurrency.USD_CODE).Sum(f => f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount)
|
|
|
|
|
StlName = s.StlName //结算方式
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|