|
|
@ -13,6 +13,7 @@ using DS.WMS.Core.Settlement.Entity;
|
|
|
|
using DS.WMS.Core.Settlement.Interface;
|
|
|
|
using DS.WMS.Core.Settlement.Interface;
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
using SqlSugar;
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
using static iText.StyledXmlParser.Jsoup.Select.Evaluator;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Settlement.Method
|
|
|
|
namespace DS.WMS.Core.Settlement.Method
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -107,6 +108,10 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
model.SettlementDetails = await GetSettlementDetails(id);
|
|
|
|
model.SettlementDetails = await GetSettlementDetails(id);
|
|
|
|
if (model.SettlementDetails.Count > 0)
|
|
|
|
if (model.SettlementDetails.Count > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
var ids = model.SettlementDetails.Select(x => x.Id);
|
|
|
|
|
|
|
|
var appList = await TenantDb.Queryable<PaymentApplication>().Where(x => ids.Contains(x.Id))
|
|
|
|
|
|
|
|
.Select(x => new PaymentApplication { Id = x.Id, ApplicationNO = x.ApplicationNO }).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
//关联用户名称
|
|
|
|
//关联用户名称
|
|
|
|
var userIds = model.SettlementDetails.Select(x => x.CreateBy).Distinct();
|
|
|
|
var userIds = model.SettlementDetails.Select(x => x.CreateBy).Distinct();
|
|
|
|
var users = await Db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
|
|
|
|
var users = await Db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
|
|
|
@ -114,6 +119,7 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
foreach (var item in model.SettlementDetails)
|
|
|
|
foreach (var item in model.SettlementDetails)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
|
|
|
|
item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
|
|
|
|
|
|
|
|
item.ApplicationNOList = appList.Where(x => x.Id == item.Id).Select(x => x.ApplicationNO).ToList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -137,83 +143,10 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
.Select((i, d1, d2) => new SettlementDetailGroup
|
|
|
|
.Select((i, d1, d2) => new SettlementDetailGroup
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SettlementAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(d3 => d3.ApplicationId == i.Id).Sum(d3 => d3.ApplyAmount),
|
|
|
|
SettlementAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(d3 => d3.ApplicationId == i.Id).Sum(d3 => d3.ApplyAmount),
|
|
|
|
ApplicationNOList = SqlFunc.Subqueryable<PaymentApplication>().Where(a => a.Id == d1.RefId).ToList(a => a.ApplicationNO)
|
|
|
|
//ApplicationNOList = SqlFunc.Subqueryable<PaymentApplication>().Where(a => a.Id == d1.RefId.Value).ToList(a => a.ApplicationNO)
|
|
|
|
}, true).ToListAsync();
|
|
|
|
}, true).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
|
|
|
|
|
|
|
|
|
//var list = await TenantDb.Queryable<ApplicationDetail>()
|
|
|
|
|
|
|
|
// .InnerJoin<ApplicationDetail>((d, pd) => d.DetailId == pd.Id)
|
|
|
|
|
|
|
|
// .InnerJoin<PaymentApplication>((d, pd, pa) => pd.ApplicationId == pa.Id)
|
|
|
|
|
|
|
|
// .Where(d => d.ApplicationId == id)
|
|
|
|
|
|
|
|
// .Select((d, pd, pa) => new
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// d.Id,
|
|
|
|
|
|
|
|
// d.ApplicationId,
|
|
|
|
|
|
|
|
// d.ApplyAmount,
|
|
|
|
|
|
|
|
// d.Currency,
|
|
|
|
|
|
|
|
// d.OriginalCurrency,
|
|
|
|
|
|
|
|
// d.OriginalAmount,
|
|
|
|
|
|
|
|
// pa.ApplicationNO,
|
|
|
|
|
|
|
|
// pa.Status,
|
|
|
|
|
|
|
|
// pa.CreateTime,
|
|
|
|
|
|
|
|
// pa.CreateBy,
|
|
|
|
|
|
|
|
// pa.PaymentDate,
|
|
|
|
|
|
|
|
// pa.Note
|
|
|
|
|
|
|
|
// }).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var details = new List<SettlementDetailDto>();
|
|
|
|
|
|
|
|
//if (list.Count == 0)
|
|
|
|
|
|
|
|
// return details;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var gp = list.GroupBy(d => d.ApplicationId);
|
|
|
|
|
|
|
|
//var uids = list.Select(x => x.CreateBy).Distinct();
|
|
|
|
|
|
|
|
//var users = await Db.Queryable<SysUser>().Where(x => uids.Contains(x.Id)).Select(x => new
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// x.Id,
|
|
|
|
|
|
|
|
// x.UserName
|
|
|
|
|
|
|
|
//}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//foreach (var g in gp)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// var firstItem = g.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var dto = new SettlementDetailDto
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// ApplicationId = g.Key,
|
|
|
|
|
|
|
|
// //Ids = g.Select(x => x.Id),
|
|
|
|
|
|
|
|
// RMBApplyAmount = g.Where(x => x.OriginalCurrency == FeeCurrency.RMB_CODE).Sum(x => x.ApplyAmount),
|
|
|
|
|
|
|
|
// USDApplyAmount = g.Where(x => x.OriginalCurrency == FeeCurrency.USD_CODE).Sum(x => x.ApplyAmount),
|
|
|
|
|
|
|
|
// ApplicationNO = firstItem.ApplicationNO,
|
|
|
|
|
|
|
|
// Status = (int)firstItem.Status,
|
|
|
|
|
|
|
|
// StatusText = firstItem.Status.GetDescription(),
|
|
|
|
|
|
|
|
// CreateTime = firstItem?.CreateTime,
|
|
|
|
|
|
|
|
// CreateBy = firstItem?.CreateBy,
|
|
|
|
|
|
|
|
// CreateByName = users.Find(x => x.Id == firstItem?.CreateBy)?.UserName,
|
|
|
|
|
|
|
|
// PaymentDate = firstItem?.PaymentDate,
|
|
|
|
|
|
|
|
// Note = firstItem?.Note
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //包含多个币别
|
|
|
|
|
|
|
|
// if (g.GroupBy(x => x.OriginalCurrency).Select(x => x.Key).Count() > 1)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// //原始币别=不等于结算单币别的首个币别(参考DS7)
|
|
|
|
|
|
|
|
// dto.OriginalCurrency = g.Select(x => x.OriginalCurrency).FirstOrDefault();
|
|
|
|
|
|
|
|
// //原始金额=当前结算单的币别合计
|
|
|
|
|
|
|
|
// dto.OriginalAmount = g.Sum(x => x.ApplyAmount);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// dto.OriginalCurrency = firstItem?.OriginalCurrency;
|
|
|
|
|
|
|
|
// dto.OriginalAmount = g.Where(x => x.OriginalCurrency == dto.OriginalCurrency).Sum(x => x.ApplyAmount);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //结算金额=原申请的原始币别合计
|
|
|
|
|
|
|
|
// dto.SettlementAmount = g.Where(x => x.OriginalCurrency == dto.OriginalCurrency).Sum(x => x.ApplyAmount);
|
|
|
|
|
|
|
|
// details.Add(dto);
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//return details;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|