从山证v2.3.0拷贝
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
using BaseOUDAL;
|
||||
using YLErp.BLL;
|
||||
using YLErp.Model;
|
||||
|
||||
namespace YLErp.Modules.ClientModule
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ClientPaymentService : ClientQueryService
|
||||
{
|
||||
public ClientPaymentService(OptUserInfo userInfo) : base(userInfo)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询client
|
||||
/// </summary>
|
||||
public SearchListResult<ClientPayment> SearchPaymentList(ClientReq req)
|
||||
{
|
||||
var needAdditionalMargin = PS.Config.ErpElement.NeedAdditionalMargin;
|
||||
//系统交易日
|
||||
var valueDate = valuedateBLL.ValueDate;
|
||||
if (!req.ValueDate.HasValue)
|
||||
{
|
||||
req.ValueDate = valueDate;
|
||||
}
|
||||
var clientPredicate = CreatePredicate(req);
|
||||
|
||||
var query = from source in DbContext.client.Where(clientPredicate)
|
||||
orderby source.id descending
|
||||
select new ClientPayment
|
||||
{
|
||||
id = source.id,
|
||||
Number = source.Number,
|
||||
Name = source.Name,
|
||||
PendingMarginCallPayment = source.PendingMarginCallPayment,
|
||||
ValueDate = req.ValueDate
|
||||
};
|
||||
|
||||
var retListResult = query.ToSearchList(req, false);
|
||||
|
||||
var clientIds = retListResult.rows.Select(n => n.id).ToArray();
|
||||
|
||||
if (clientIds.Any())
|
||||
{
|
||||
var clientBalanceList = yldb.ClientBalanceDaily.Where(o => o.BalanceDate == req.ValueDate.Value && clientIds.Contains(o.ClientId))
|
||||
.Select(n => new { n.ClientId, n.State, n.MarginBalance, n.ToDayRemainFund, n.CashDeposit, n.Margin, n.AdditionalMargin }).ToArray();
|
||||
|
||||
foreach (var item in retListResult.rows)
|
||||
{
|
||||
var clientbalance = clientBalanceList.FirstOrDefault(o => o.ClientId == item.id);
|
||||
if (clientbalance != null)
|
||||
{
|
||||
item.MarginBanlance = clientbalance.MarginBalance;
|
||||
item.ToDayRemainFund = clientbalance.ToDayRemainFund;
|
||||
item.CashDeposit = clientbalance.CashDeposit;
|
||||
item.MarginPayment = clientbalance.Margin * -1 + (needAdditionalMargin ? clientbalance.AdditionalMargin * -1 : 0);
|
||||
item.ValueDate = req.ValueDate;
|
||||
}
|
||||
}
|
||||
|
||||
var creditQuery = from c in yldb.credit
|
||||
where clientIds.Contains(c.ClientId.Value) && c.ProcessStatus == "已审批"
|
||||
&& (c.CreditStartDate == null || c.CreditStartDate <= req.ValueDate)
|
||||
&& (c.CreditDeadLine == null || c.CreditDeadLine >= req.ValueDate)
|
||||
select new { ClientId = c.ClientId.Value, c.Credit };
|
||||
var creditDic = creditQuery.ToDictionary(n => n.ClientId, m => m.Credit);
|
||||
|
||||
foreach (var clientLinq in retListResult.rows)
|
||||
{
|
||||
if (creditDic.TryGetValue(clientLinq.id, out var credit) && credit.HasValue)
|
||||
{
|
||||
clientLinq.Credit = credit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retListResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user