|
|
|
@ -12,6 +12,7 @@ using DS.WMS.Core.Settlement.Dtos;
|
|
|
|
|
using DS.WMS.Core.Settlement.Entity;
|
|
|
|
|
using DS.WMS.Core.Settlement.Interface;
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Settlement.Method
|
|
|
|
@ -141,17 +142,30 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
|
protected override async Task<List<SettlementDetailGroup>> GetSettlementDetails(long id)
|
|
|
|
|
{
|
|
|
|
|
var list = await TenantDb.Queryable<PaymentApplication>()
|
|
|
|
|
.InnerJoin<ApplicationDetail>((i, d1) => i.Id == d1.ApplicationId)
|
|
|
|
|
.InnerJoin<ApplicationDetail>((i, d1, d2) => d1.ApplicationId == d2.RefId)
|
|
|
|
|
.Where((i, d1, d2) => d2.ApplicationId == id &&
|
|
|
|
|
d2.Category == DetailCategory.PaidApplicationSettlement || d1.Category == DetailCategory.ChargeApplicationSettlement)
|
|
|
|
|
.InnerJoin<ApplicationDetail>((i, d1) => i.Id == d1.ApplicationId) //d1=申请明细
|
|
|
|
|
.InnerJoin<ApplicationDetail>((i, d1, d2) => d2.DetailId == d1.Id) //d2=结算明细
|
|
|
|
|
.Where((i, d1, d2) => d2.ApplicationId == id)
|
|
|
|
|
.GroupBy((i, d1, d2) => i.Id)
|
|
|
|
|
.Select((i, d1, d2) => new SettlementDetailGroup
|
|
|
|
|
{
|
|
|
|
|
SettlementAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(d3 => d3.ApplicationId == i.Id).Sum(d3 => d3.ApplyAmount),
|
|
|
|
|
Status = (int)i.Status,
|
|
|
|
|
BillNO = i.ApplicationNO,
|
|
|
|
|
PaymentDate = i.PaymentDate,
|
|
|
|
|
RMBApplyAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(x => x.ApplicationId == d2.RefId && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.ApplyAmount),
|
|
|
|
|
USDApplyAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(x => x.ApplicationId == d2.RefId && x.Currency == FeeCurrency.USD_CODE).Sum(x => x.ApplyAmount),
|
|
|
|
|
RMBStlAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(x => x.ApplicationId == i.Id && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.ApplyAmount),
|
|
|
|
|
USDStlAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(x => x.ApplicationId == i.Id && x.Currency == FeeCurrency.USD_CODE).Sum(x => x.ApplyAmount),
|
|
|
|
|
RMBStlRestAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(x => x.ApplicationId == i.Id && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.ApplyAmount - x.ProcessedAmount),
|
|
|
|
|
USDStlRestAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(x => x.ApplicationId == i.Id && x.Currency == FeeCurrency.USD_CODE).Sum(x => x.ApplyAmount - x.ProcessedAmount),
|
|
|
|
|
//ApplicationNOList = SqlFunc.Subqueryable<PaymentApplication>().Where(a => a.Id == d1.RefId.Value).ToList(a => a.ApplicationNO)
|
|
|
|
|
}, true).ToListAsync();
|
|
|
|
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
PaymentApplicationStatus status = (PaymentApplicationStatus)item.Status;
|
|
|
|
|
item.StatusText = status.GetDescription();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -186,6 +200,7 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
|
FeeType = d.FeeType,
|
|
|
|
|
Amount = d.Amount, //总金额
|
|
|
|
|
ApplyAmount = d.ApplyAmount, //已结算金额
|
|
|
|
|
SettlementAmount = d.ApplyAmount,
|
|
|
|
|
RestAmount = d.ApplyAmount - d.ProcessedAmount, //剩余结算金额
|
|
|
|
|
CustomerId = d.CustomerId,
|
|
|
|
|
CustomerName = d.CustomerName,
|
|
|
|
|