|
|
|
@ -2,8 +2,6 @@
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Enums;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.Module.Core.PageQuery;
|
|
|
|
|
using DS.WMS.Core.Application.Dtos;
|
|
|
|
|
using DS.WMS.Core.Application.Entity;
|
|
|
|
|
using DS.WMS.Core.Application.Interface;
|
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
|
@ -27,12 +25,77 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取分页列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<PaymentApplicationDto>>> GetListAsync(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
var queryList = CreateListQuery();
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
queryList = queryList.Where(whereList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return await queryList.GroupBy(x => x.Id).ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal ISugarQueryable<PaymentApplicationDto> CreateListQuery()
|
|
|
|
|
{
|
|
|
|
|
var query1 = TenantDb.Queryable<PaymentApplication>()
|
|
|
|
|
.InnerJoin<ApplicationDetail>((a, d) => a.Id == d.ApplicationId)
|
|
|
|
|
.LeftJoin<SeaExport>((a, d, s) => d.BusinessId == s.Id)
|
|
|
|
|
.Select((a, d, s) => new PaymentApplicationDto
|
|
|
|
|
{
|
|
|
|
|
Id = a.Id,
|
|
|
|
|
ApplicationNO = a.ApplicationNO,
|
|
|
|
|
CustomerId = a.CustomerId,
|
|
|
|
|
CustomerName = a.CustomerName,
|
|
|
|
|
AmountOther = a.AmountOther,
|
|
|
|
|
AmountRMB = a.AmountRMB,
|
|
|
|
|
AmountUSD = a.AmountUSD,
|
|
|
|
|
SaleDeptId = a.SaleDeptId,
|
|
|
|
|
CreateBy = a.CreateBy,
|
|
|
|
|
CreateTime = a.CreateTime,
|
|
|
|
|
Currency = a.Currency,
|
|
|
|
|
ExchangeRate = a.ExchangeRate,
|
|
|
|
|
Reason = a.Reason,
|
|
|
|
|
Status = a.Status,
|
|
|
|
|
AuditerId = a.AuditerId,
|
|
|
|
|
AuditerName = a.AuditerName,
|
|
|
|
|
AuditTime = a.AuditTime,
|
|
|
|
|
IsInvoiceReceived = a.IsInvoiceReceived,
|
|
|
|
|
Client = s.CustomerName,
|
|
|
|
|
IsPrinted = a.IsPrinted,
|
|
|
|
|
PrintTimes = a.PrintTimes,
|
|
|
|
|
InvoiceAmount = a.InvoiceAmount,
|
|
|
|
|
InvoiceDate = a.InvoiceDate,
|
|
|
|
|
InvoiceNO = a.InvoiceNO,
|
|
|
|
|
CustomerBank = a.CustomerBank,
|
|
|
|
|
SettlementType = a.SettlementType,
|
|
|
|
|
PaymentDate = a.PaymentDate,
|
|
|
|
|
Note = a.Note,
|
|
|
|
|
BillNO = s.CustomerNo, //业务编号=委托编号
|
|
|
|
|
//汇总项
|
|
|
|
|
RestAmountRMB = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.Id == d.RecordId && f.FeeStatus == FeeStatus.AuditPassed
|
|
|
|
|
&& f.Currency == RMB_CODE).Select(f => SqlFunc.AggregateSum(f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount)),
|
|
|
|
|
RestAmountUSD = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.Id == d.RecordId && f.FeeStatus == FeeStatus.AuditPassed
|
|
|
|
|
&& f.Currency == USD_CODE).Select(f => SqlFunc.AggregateSum(f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount)),
|
|
|
|
|
RestAmountOther = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.Id == d.RecordId && f.FeeStatus == FeeStatus.AuditPassed
|
|
|
|
|
&& f.Currency != RMB_CODE && f.Currency != USD_CODE).Select(f => SqlFunc.AggregateSum(f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return TenantDb.UnionAll(new List<ISugarQueryable<PaymentApplicationDto>> { query1 });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取待付费的业务列表(编辑用)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<FeeApplicationBiz>>> GetBizListAsync(PageRequest request)
|
|
|
|
|
public async Task<DataResult<List<ApplicationBiz>>> GetBizListAsync(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
var queryList = CreateBizQuery();
|
|
|
|
|
|
|
|
|
@ -63,21 +126,22 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建各项业务数据的查询并集
|
|
|
|
|
internal ISugarQueryable<FeeApplicationBiz> CreateBizQuery()
|
|
|
|
|
internal ISugarQueryable<ApplicationBiz> CreateBizQuery()
|
|
|
|
|
{
|
|
|
|
|
//海运出口
|
|
|
|
|
var query1 = TenantDb.Queryable<SeaExport>().InnerJoin<FeeRecord>((s, f) => s.Id == f.BusinessId && f.BusinessType == BusinessType.OceanShippingExport)
|
|
|
|
|
var query1 = TenantDb.Queryable<SeaExport>()
|
|
|
|
|
.InnerJoin<FeeRecord>((s, f) => s.Id == f.BusinessId && f.BusinessType == BusinessType.OceanShippingExport)
|
|
|
|
|
.Where((s, f) => f.FeeStatus == FeeStatus.AuditPassed)
|
|
|
|
|
.GroupBy((s, f) => s.Id)
|
|
|
|
|
.Select((s, f) => new FeeApplicationBiz
|
|
|
|
|
.Select((s, f) => new ApplicationBiz
|
|
|
|
|
{
|
|
|
|
|
Id = s.Id,
|
|
|
|
|
AccountDate = s.AccountDate,
|
|
|
|
|
BusinessType = BusinessType.OceanShippingExport,
|
|
|
|
|
CntrTotal = s.CntrTotal,
|
|
|
|
|
CreateBy = s.CreateBy,
|
|
|
|
|
CustomerId = s.CustomerId,
|
|
|
|
|
CustomerName = s.CustomerName,//委托单位
|
|
|
|
|
CustomerId = s.CustomerId,//费用对象
|
|
|
|
|
CustomerName = s.CustomerName,
|
|
|
|
|
DischargePort = s.DischargePort,
|
|
|
|
|
ETD = s.ETD,
|
|
|
|
|
HBLNO = s.HBLNO,
|
|
|
|
@ -85,7 +149,6 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
MBLNO = s.MBLNO,
|
|
|
|
|
OperatorId = s.OperatorId,
|
|
|
|
|
SaleDeptId = s.SaleDeptId,
|
|
|
|
|
//SaleDeptName //所属部门
|
|
|
|
|
SaleId = s.SaleId,
|
|
|
|
|
SaleName = s.Sale,//揽货人
|
|
|
|
|
Vessel = s.Vessel,//船名
|
|
|
|
@ -97,7 +160,7 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
Currency = f.Currency,
|
|
|
|
|
IsAdvancedPay = f.IsAdvancedPay,
|
|
|
|
|
IsInvoice = f.IsInvoice,
|
|
|
|
|
|
|
|
|
|
//统计项
|
|
|
|
|
UnpaidRMB = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.Id && f.FeeStatus == FeeStatus.AuditPassed &&
|
|
|
|
|
f.FeeType == FeeType.Payable && f.Currency == "CNY").Select(f => SqlFunc.AggregateSumNoNull(f.Amount.Value)),
|
|
|
|
|
UnpaidUSD = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.Id && f.FeeStatus == FeeStatus.AuditPassed &&
|
|
|
|
@ -119,7 +182,7 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
//海运进口
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return TenantDb.UnionAll(new List<ISugarQueryable<FeeApplicationBiz>> { query1 });
|
|
|
|
|
return TenantDb.UnionAll(new List<ISugarQueryable<ApplicationBiz>> { query1 });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -168,68 +231,6 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
return DataResult<FeeDto>.Success(new FeeDto(list));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取分页列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<PaymentApplicationDto>>> GetListAsync(PageRequest<PaymentApplicationListQuery> request)
|
|
|
|
|
{
|
|
|
|
|
var exp1 = Expressionable.Create<PaymentApplication>()
|
|
|
|
|
.AndIF(!request.QueryCondition.ApplicaitionNO.IsNullOrEmpty(), x => x.ApplicationNO.Contains(request.QueryCondition.ApplicaitionNO))
|
|
|
|
|
.AndIF(request.QueryCondition.CustomerId.HasValue, x => x.CustomerId == request.QueryCondition.CustomerId.Value)
|
|
|
|
|
.AndIF(request.QueryCondition.Status.HasValue, x => x.Status == request.QueryCondition.Status.Value)
|
|
|
|
|
.AndIF(request.QueryCondition.PaymentDateStart.HasValue, x => request.QueryCondition.PaymentDateStart.Value >= x.PaymentDate)
|
|
|
|
|
.AndIF(request.QueryCondition.PaymentDateEnd.HasValue, x => request.QueryCondition.PaymentDateEnd.Value <= x.PaymentDate)
|
|
|
|
|
.AndIF(request.QueryCondition.CreateBy.HasValue, x => x.CreateBy == request.QueryCondition.CreateBy.Value)
|
|
|
|
|
.ToExpression();
|
|
|
|
|
|
|
|
|
|
var result = await TenantDb.Queryable<PaymentApplication>().Where(exp1)
|
|
|
|
|
.InnerJoin<ApplicationDetail>((a, d) => a.Id == d.ApplicationId)
|
|
|
|
|
.LeftJoin<SeaExport>((a, d, s) => d.BusinessId == s.Id)
|
|
|
|
|
.WhereIF(!request.QueryCondition.BillNO.IsNullOrEmpty(), (a, d, s) => s.CustomerNo.Contains(request.QueryCondition.BillNO))
|
|
|
|
|
.Select((a, d, s) => new PaymentApplicationDto
|
|
|
|
|
{
|
|
|
|
|
Id = a.Id,
|
|
|
|
|
ApplicationNO = a.ApplicationNO,
|
|
|
|
|
CustomerId = a.CustomerId,
|
|
|
|
|
CustomerName = a.CustomerName,
|
|
|
|
|
AmountOther = a.AmountOther,
|
|
|
|
|
AmountRMB = a.AmountRMB,
|
|
|
|
|
AmountUSD = a.AmountUSD,
|
|
|
|
|
SaleDeptId = a.SaleDeptId,
|
|
|
|
|
CreateBy = a.CreateBy,
|
|
|
|
|
CreateTime = a.CreateTime,
|
|
|
|
|
Currency = a.Currency,
|
|
|
|
|
ExchangeRate = a.ExchangeRate,
|
|
|
|
|
Reason = a.Reason,
|
|
|
|
|
Status = a.Status,
|
|
|
|
|
AuditerId = a.AuditerId,
|
|
|
|
|
AuditerName = a.AuditerName,
|
|
|
|
|
AuditTime = a.AuditTime,
|
|
|
|
|
IsInvoiceReceived = a.IsInvoiceReceived,
|
|
|
|
|
Client = s.CustomerName,
|
|
|
|
|
IsPrinted = a.IsPrinted,
|
|
|
|
|
PrintTimes = a.PrintTimes,
|
|
|
|
|
InvoiceAmount = a.InvoiceAmount,
|
|
|
|
|
InvoiceDate = a.InvoiceDate,
|
|
|
|
|
InvoiceNO = a.InvoiceNO,
|
|
|
|
|
CustomerBank = a.CustomerBank,
|
|
|
|
|
SettlementType = a.SettlementType,
|
|
|
|
|
PaymentDate = a.PaymentDate,
|
|
|
|
|
Note = a.Note,
|
|
|
|
|
//汇总项
|
|
|
|
|
RestAmountRMB = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.Id == d.RecordId && f.FeeStatus == FeeStatus.AuditPassed
|
|
|
|
|
&& f.Currency == RMB_CODE).Select(f => SqlFunc.AggregateSum(f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount)),
|
|
|
|
|
RestAmountUSD = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.Id == d.RecordId && f.FeeStatus == FeeStatus.AuditPassed
|
|
|
|
|
&& f.Currency == USD_CODE).Select(f => SqlFunc.AggregateSum(f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount)),
|
|
|
|
|
RestAmountOther = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.Id == d.RecordId && f.FeeStatus == FeeStatus.AuditPassed
|
|
|
|
|
&& f.Currency != RMB_CODE && f.Currency != USD_CODE).Select(f => SqlFunc.AggregateSum(f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount))
|
|
|
|
|
}).GroupBy(a => new { a.Id }).ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取申请单详情
|
|
|
|
|
/// </summary>
|
|
|
|
|