|
|
|
@ -305,53 +305,37 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
|
public async Task<DataResult<List<PaymentApplicationDtoV2>>> GetApplicationListAsync(PageRequest<ApplicationListQuery> request)
|
|
|
|
|
{
|
|
|
|
|
var query = TenantDb.Queryable<PaymentApplication>()
|
|
|
|
|
.InnerJoinIF<ApplicationDetail>(request.OtherQueryCondition != null && request.OtherQueryCondition.PortId.HasValue,
|
|
|
|
|
(a, d) => a.Id == d.ApplicationId)
|
|
|
|
|
.InnerJoinIF<FeeRecord>(request.OtherQueryCondition != null && request.OtherQueryCondition.PortId.HasValue,
|
|
|
|
|
(a, d, f) => d.RecordId == f.Id)
|
|
|
|
|
.InnerJoinIF<SeaExport>(request.OtherQueryCondition != null && request.OtherQueryCondition.PortId.HasValue,
|
|
|
|
|
(a, d, f, s) => f.BusinessId == s.Id && (s.LoadPortId == request.OtherQueryCondition.PortId.Value || s.DischargePortId == request.OtherQueryCondition.PortId.Value))
|
|
|
|
|
.GroupByIF(request.OtherQueryCondition != null && request.OtherQueryCondition.PortId.HasValue,
|
|
|
|
|
(a, d, s) => a.Id)
|
|
|
|
|
.Select(a => new PaymentApplicationDtoV2
|
|
|
|
|
{
|
|
|
|
|
Id = a.Id,
|
|
|
|
|
ApplicationNO = a.ApplicationNO,
|
|
|
|
|
Status = a.Status,
|
|
|
|
|
CustomerId = a.CustomerId,
|
|
|
|
|
CustomerName = a.CustomerName, //结算单位
|
|
|
|
|
CustomerBankId = a.CustomerBankId,
|
|
|
|
|
CustomerBankName = a.CustomerBank.BankName, //结算对象银行
|
|
|
|
|
CustomerAccount = a.CustomerBank.Account, //结算对象账号
|
|
|
|
|
Currency = a.Currency,
|
|
|
|
|
AmountRMB = a.AmountRMB.GetValueOrDefault(), //RMB申请金额
|
|
|
|
|
AmountUSD = a.AmountUSD.GetValueOrDefault(), //USD申请金额
|
|
|
|
|
//RMB未结金额
|
|
|
|
|
UnSettledRMB = SqlFunc.Subqueryable<ApplicationDetail>().Where(d => d.Currency == FeeCurrency.RMB_CODE)
|
|
|
|
|
.Select(d => SqlFunc.AggregateSum(d.ApplyAmount - d.ProcessedAmount)),
|
|
|
|
|
//USD未结金额
|
|
|
|
|
UnSettledUSD = SqlFunc.Subqueryable<ApplicationDetail>().Where(d => d.Currency == FeeCurrency.USD_CODE)
|
|
|
|
|
.Select(d => SqlFunc.AggregateSum(d.ApplyAmount - d.ProcessedAmount)),
|
|
|
|
|
SaleDeptId = a.SaleDeptId, //所属分部
|
|
|
|
|
SettlementTypeId = a.SettlementTypeId,
|
|
|
|
|
SettlementTypeName = a.SettlementType.StlName, //结算方式
|
|
|
|
|
CreateBy = a.CreateBy, //申请人
|
|
|
|
|
CreateTime = a.CreateTime, //申请日期
|
|
|
|
|
PayAmount = 0, //审核实付金额
|
|
|
|
|
PaymentDate = a.PaymentDate, //申请支付日期
|
|
|
|
|
AuditerId = a.AuditerId,
|
|
|
|
|
AuditerName = a.AuditerName,
|
|
|
|
|
AuditTime = a.AuditTime,
|
|
|
|
|
Note = a.Note
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (request.OtherQueryCondition != null && request.OtherQueryCondition.UnsettledOnly)
|
|
|
|
|
query = query.Where(a => a.Status == PaymentApplicationStatus.AuditPassed || a.Status == PaymentApplicationStatus.PartialSettlement);
|
|
|
|
|
.InnerJoin<ApplicationDetail>((a, d) => a.Id == d.ApplicationId && d.ApplyAmount - d.ProcessedAmount != 0)
|
|
|
|
|
.InnerJoin<FeeRecord>((a, d, f) => d.RecordId == f.Id)
|
|
|
|
|
.InnerJoin<SeaExport>((a, d, f, s) => f.BusinessId == s.Id && f.BusinessType == BusinessType.OceanShippingExport)
|
|
|
|
|
.GroupBy((a, d) => a.Id);
|
|
|
|
|
|
|
|
|
|
if (request.OtherQueryCondition != null)
|
|
|
|
|
{
|
|
|
|
|
if (request.OtherQueryCondition.PortId.HasValue)
|
|
|
|
|
query = query.Where((a, d, f, s) => s.LoadPortId == request.OtherQueryCondition.PortId || s.DischargePortId == request.OtherQueryCondition.PortId);
|
|
|
|
|
|
|
|
|
|
if (request.OtherQueryCondition.UnsettledOnly)
|
|
|
|
|
query = query.Where(a => a.Status == PaymentApplicationStatus.AuditPassed || a.Status == PaymentApplicationStatus.PartialSettlement);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(a => a.Status == PaymentApplicationStatus.AuditPassed || a.Status == PaymentApplicationStatus.PartialSettlement || a.Status == PaymentApplicationStatus.SettlementCompleted);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var whereList = request.GetConditionalModels(Db);
|
|
|
|
|
var result = await query.Where(whereList).ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
var result = await query.Select(a => new PaymentApplicationDtoV2
|
|
|
|
|
{
|
|
|
|
|
AmountRMB = a.AmountRMB == null ? 0 : a.AmountRMB.Value, //RMB申请金额
|
|
|
|
|
AmountUSD = a.AmountUSD == null ? 0 : a.AmountUSD.Value, //USD申请金额
|
|
|
|
|
//RMB未结金额
|
|
|
|
|
UnSettledRMB = SqlFunc.Subqueryable<ApplicationDetail>().Where(d => d.Currency == FeeCurrency.RMB_CODE)
|
|
|
|
|
.Select(d => SqlFunc.AggregateSum(d.ApplyAmount - d.ProcessedAmount)),
|
|
|
|
|
//USD未结金额
|
|
|
|
|
UnSettledUSD = SqlFunc.Subqueryable<ApplicationDetail>().Where(d => d.Currency == FeeCurrency.USD_CODE)
|
|
|
|
|
.Select(d => SqlFunc.AggregateSum(d.ApplyAmount - d.ProcessedAmount)),
|
|
|
|
|
SettlementTypeName = a.SettlementType.StlName, //结算方式
|
|
|
|
|
}, true).MergeTable().Where(whereList).ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
|
|
|
|
|
if (result.Data.Count > 0)
|
|
|
|
|
{
|
|
|
|
|