|
|
@ -177,7 +177,7 @@ 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<SettlementDetailDto>>> GetDetailsAsync(PageRequest<long> request)
|
|
|
|
public async Task<DataResult<List<SettlementDetailDto>>> GetDetailsAsync(PageRequest<long> request)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var list = await TenantDb.Queryable<ApplicationDetail>()
|
|
|
|
var list = await TenantDb.Queryable<ApplicationDetail>()
|
|
|
|
.InnerJoin<ApplicationDetail>((d, pd) => d.DetailId == pd.Id)
|
|
|
|
.InnerJoin<ApplicationDetail>((d, pd) => d.DetailId == pd.Id)
|
|
|
@ -251,8 +251,10 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
var query = TenantDb.Queryable<PaymentApplication>()
|
|
|
|
var query = TenantDb.Queryable<PaymentApplication>()
|
|
|
|
.InnerJoinIF<ApplicationDetail>(request.OtherQueryCondition != null && request.OtherQueryCondition.PortId.HasValue,
|
|
|
|
.InnerJoinIF<ApplicationDetail>(request.OtherQueryCondition != null && request.OtherQueryCondition.PortId.HasValue,
|
|
|
|
(a, d) => a.Id == d.ApplicationId)
|
|
|
|
(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,
|
|
|
|
.InnerJoinIF<SeaExport>(request.OtherQueryCondition != null && request.OtherQueryCondition.PortId.HasValue,
|
|
|
|
(a, d, s) => s.Id == d.BusinessId && (s.LoadPortId == request.OtherQueryCondition.PortId.Value || s.DischargePortId == request.OtherQueryCondition.PortId.Value))
|
|
|
|
(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,
|
|
|
|
.GroupByIF(request.OtherQueryCondition != null && request.OtherQueryCondition.PortId.HasValue,
|
|
|
|
(a, d, s) => a.Id)
|
|
|
|
(a, d, s) => a.Id)
|
|
|
|
.Select(a => new PaymentApplicationDtoV2
|
|
|
|
.Select(a => new PaymentApplicationDtoV2
|
|
|
@ -323,15 +325,15 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task<DataResult<List<PaymentApplicationDetailDto>>> GetApplicationDetailsAsync(long id)
|
|
|
|
public async Task<DataResult<List<PaymentApplicationDetailDto>>> GetApplicationDetailsAsync(long id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var details = await TenantDb.Queryable<ApplicationDetail>().Where(d => d.ApplicationId == id && d.Category == FeeCategory.PaidApplication && (d.ApplyAmount - d.ProcessedAmount) != 0)
|
|
|
|
var details = await TenantDb.Queryable<ApplicationDetail>().Where(d => d.ApplicationId == id && d.Category == DetailCategory.PaidApplication && (d.ApplyAmount - d.ProcessedAmount) != 0)
|
|
|
|
.LeftJoin<FeeRecord>((d, f) => d.RecordId == f.Id)
|
|
|
|
.LeftJoin<FeeRecord>((d, f) => d.RecordId == f.Id)
|
|
|
|
.LeftJoin<BusinessFeeStatus>((d, f, b) => f.BusinessId == b.BusinessId && f.BusinessType == b.BusinessType)
|
|
|
|
.LeftJoin<BusinessFeeStatus>((d, f, b) => f.BusinessId == b.BusinessId && f.BusinessType == b.BusinessType)
|
|
|
|
.Select((d, f, b) => new PaymentApplicationDetailDto
|
|
|
|
.Select((d, f, b) => new PaymentApplicationDetailDto
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = d.Id,
|
|
|
|
Id = d.Id,
|
|
|
|
ApplicationId = d.ApplicationId,
|
|
|
|
ApplicationId = d.ApplicationId,
|
|
|
|
BusinessId = d.BusinessId,
|
|
|
|
BusinessId = f.BusinessId,
|
|
|
|
BusinessType = d.BusinessType,
|
|
|
|
BusinessType = f.BusinessType,
|
|
|
|
RecordId = d.RecordId,
|
|
|
|
RecordId = d.RecordId,
|
|
|
|
FeeName = d.FeeName,
|
|
|
|
FeeName = d.FeeName,
|
|
|
|
FeeType = d.FeeType, //收付
|
|
|
|
FeeType = d.FeeType, //收付
|
|
|
@ -358,7 +360,7 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task<DataResult<List<PaymentApplicationDetailDto>>> GetApplicationDetailsAsync(long[] ids)
|
|
|
|
public async Task<DataResult<List<PaymentApplicationDetailDto>>> GetApplicationDetailsAsync(long[] ids)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var details = await TenantDb.Queryable<ApplicationDetail>().Where(d => ids.Contains(d.Id) && d.Category == FeeCategory.PaidApplicationSettlement)
|
|
|
|
var details = await TenantDb.Queryable<ApplicationDetail>().Where(d => ids.Contains(d.Id) && d.Category == DetailCategory.PaidApplicationSettlement)
|
|
|
|
.LeftJoin<FeeRecord>((d, f) => d.RecordId == f.Id)
|
|
|
|
.LeftJoin<FeeRecord>((d, f) => d.RecordId == f.Id)
|
|
|
|
.LeftJoin<BusinessFeeStatus>((d, f, b) => f.BusinessId == b.BusinessId && f.BusinessType == b.BusinessType)
|
|
|
|
.LeftJoin<BusinessFeeStatus>((d, f, b) => f.BusinessId == b.BusinessId && f.BusinessType == b.BusinessType)
|
|
|
|
.LeftJoin<PaymentApplication>((d, f, b, p) => d.ApplicationId == p.Id)
|
|
|
|
.LeftJoin<PaymentApplication>((d, f, b, p) => d.ApplicationId == p.Id)
|
|
|
@ -366,8 +368,8 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = d.Id,
|
|
|
|
Id = d.Id,
|
|
|
|
ApplicationId = d.ApplicationId,
|
|
|
|
ApplicationId = d.ApplicationId,
|
|
|
|
BusinessId = d.BusinessId,
|
|
|
|
BusinessId = f.BusinessId,
|
|
|
|
BusinessType = d.BusinessType,
|
|
|
|
BusinessType = f.BusinessType,
|
|
|
|
RecordId = d.RecordId,
|
|
|
|
RecordId = d.RecordId,
|
|
|
|
FeeName = d.FeeName,
|
|
|
|
FeeName = d.FeeName,
|
|
|
|
FeeType = d.FeeType, //收付
|
|
|
|
FeeType = d.FeeType, //收付
|
|
|
@ -461,7 +463,7 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
|
|
|
|
|
|
|
|
//获取剩余待结算金额
|
|
|
|
//获取剩余待结算金额
|
|
|
|
var ids2 = settlement.Details.Select(x => x.DetailId);
|
|
|
|
var ids2 = settlement.Details.Select(x => x.DetailId);
|
|
|
|
var appDetails = await TenantDb.Queryable<ApplicationDetail>().Where(x => ids2.Contains(x.Id) && x.Category == FeeCategory.PaidApplication)
|
|
|
|
var appDetails = await TenantDb.Queryable<ApplicationDetail>().Where(x => ids2.Contains(x.Id) && x.Category == DetailCategory.PaidApplication)
|
|
|
|
.Select(x => new
|
|
|
|
.Select(x => new
|
|
|
|
{
|
|
|
|
{
|
|
|
|
x.Id,
|
|
|
|
x.Id,
|
|
|
@ -492,7 +494,7 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
detail.Category = FeeCategory.PaidFreeSettlement;
|
|
|
|
detail.Category = DetailCategory.PaidFreeSettlement;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return sb.Length > 0 ? DataResult.Failed(sb.ToString()) : DataResult.Success;
|
|
|
|
return sb.Length > 0 ? DataResult.Failed(sb.ToString()) : DataResult.Success;
|
|
|
@ -518,15 +520,15 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//回写付费申请的状态
|
|
|
|
//回写付费申请的状态
|
|
|
|
var ids = settlement.Details.Select(x => x.DetailId);
|
|
|
|
var ids = settlement.Details.Select(x => x.DetailId);
|
|
|
|
var appIds = await TenantDb.Queryable<ApplicationDetail>().Where(x => ids.Contains(x.Id) && x.Category == FeeCategory.PaidApplication)
|
|
|
|
var appIds = await TenantDb.Queryable<ApplicationDetail>().Where(x => ids.Contains(x.Id) && x.Category == DetailCategory.PaidApplication)
|
|
|
|
.Select(x => x.ApplicationId).ToListAsync();
|
|
|
|
.Select(x => x.ApplicationId).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
var details = await TenantDb.Queryable<ApplicationDetail>().Where(x => appIds.Contains(x.ApplicationId) && x.Category == FeeCategory.PaidApplication).GroupBy(x => x.ApplicationId).Select(x => new
|
|
|
|
var details = await TenantDb.Queryable<ApplicationDetail>().Where(x => appIds.Contains(x.ApplicationId) && x.Category == DetailCategory.PaidApplication).GroupBy(x => x.ApplicationId).Select(x => new
|
|
|
|
{
|
|
|
|
{
|
|
|
|
x.ApplicationId,
|
|
|
|
x.ApplicationId,
|
|
|
|
Count = SqlFunc.AggregateCount(x.Id),
|
|
|
|
Count = SqlFunc.AggregateCount(x.Id),
|
|
|
|
ProcessedCount = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => y.ApplicationId == x.ApplicationId &&
|
|
|
|
ProcessedCount = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => y.ApplicationId == x.ApplicationId &&
|
|
|
|
y.Category == FeeCategory.PaidApplication && y.OriginalAmount - y.OriginalProcessedAmount == 0).Count()
|
|
|
|
y.Category == DetailCategory.PaidApplication && y.OriginalAmount - y.OriginalProcessedAmount == 0).Count()
|
|
|
|
}).ToListAsync();
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
List<PaymentApplication> applications = [];
|
|
|
|
List<PaymentApplication> applications = [];
|
|
|
@ -572,7 +574,7 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var items = list.SelectMany(x => x.Details);
|
|
|
|
var items = list.SelectMany(x => x.Details);
|
|
|
|
var ids = items.Select(x => x.DetailId);
|
|
|
|
var ids = items.Select(x => x.DetailId);
|
|
|
|
var details = TenantDb.Queryable<ApplicationDetail>().Where(x => ids.Contains(x.Id) && x.Category == FeeCategory.PaidApplication)
|
|
|
|
var details = TenantDb.Queryable<ApplicationDetail>().Where(x => ids.Contains(x.Id) && x.Category == DetailCategory.PaidApplication)
|
|
|
|
.Select(x => new ApplicationDetail
|
|
|
|
.Select(x => new ApplicationDetail
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = x.Id,
|
|
|
|
Id = x.Id,
|
|
|
|