From ac07eae81e943f975866648f4f1ffe011996b4b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=B9=E6=B5=B7?= Date: Fri, 5 Sep 2025 14:11:15 +0800 Subject: [PATCH] =?UTF-8?q?TRS-ZS-721=20=E8=B5=84=E9=87=91=E5=88=92?= =?UTF-8?q?=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DBModels/ClientCashInCashOut.cs | 18 ++++- .../RealTimeClientBanlanceService.cs | 50 ++++++++++++- .../ClientCashInCashOutDataService.cs | 28 ++++++- YLErpDAL/Modules/ClientModule/EntryexitBLL.cs | 5 +- .../SettlementModule/EodClientBalanceCalc.cs | 41 +++++++++- YLErpWeb/Controllers/entryexitController.cs | 2 +- YLErpWeb/Views/entryexit/entryexitEdit.cshtml | 23 +++++- YLErpWeb/Views/entryexit/entryexitList.cshtml | 8 +- YLErpWeb/Views/entryexit/entryexitView.cshtml | 2 + .../Scripts/app/client/entryexitEdit.js | 75 +++++++++++++++++-- 10 files changed, 229 insertions(+), 23 deletions(-) diff --git a/Framework/YLErp.Core/DBModels/ClientCashInCashOut.cs b/Framework/YLErp.Core/DBModels/ClientCashInCashOut.cs index 780b0096..2529c4bf 100644 --- a/Framework/YLErp.Core/DBModels/ClientCashInCashOut.cs +++ b/Framework/YLErp.Core/DBModels/ClientCashInCashOut.cs @@ -1,4 +1,4 @@ -using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations.Schema; using YLErp.Commons; using YLErp.Helpers; @@ -205,6 +205,20 @@ namespace YLErp.DBModels /// [DisplayName("账户类型")] public string cash_type { get; set; } + + /// + /// 转出科目 + /// + [DisplayName("转出科目")] + [Column("transfer_out_account​")] + public string TransferOutAccount { get; set; } + + /// + /// 转入科目 + /// + [DisplayName("转入科目")] + [Column("transfer_in_account")] + public string TransferInAccount { get; set; } } /// /// 出入金信息 @@ -267,7 +281,7 @@ namespace YLErp.DBModels { get { - if (Direction == "出金" || Direction == "入金" || Direction == "其他收入" || Direction == "其他支出" || Direction == "应收预付金" || Direction == "实收预付金" || Direction == "实付预付金" || Direction == "实收权利金" || Direction == "实付权利金") + if (Direction == "出金" || Direction == "入金" || Direction == "其他收入" || Direction == "其他支出" || Direction == "应收预付金" || Direction == "实收预付金" || Direction == "实付预付金" || Direction == "实收权利金" || Direction == "实付权利金" || Direction == "划转") { return Direction; } diff --git a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs index b282eda1..1018feee 100644 --- a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs +++ b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs @@ -232,7 +232,6 @@ namespace YLErp.BLL.Eod //SetDebugSqlLog(); Dictionary dicIntradayTradePosition = DbContext.intraday_trade_position.Where(x => clientIds.Contains(x.ClientId)).AsEnumerable().GroupBy(p => p.ClientId).Select(p => new { p.Key, OptDate = p.Max(d => d.OptDate) }) .ToDictionary(p => p.Key, p => p.OptDate); - Dictionary dicCashInOut = DbContext.ClientCashInCashOut.Where(x => clientIds.Contains((int)x.ClientId)).AsEnumerable().GroupBy(p => (int)p.ClientId).Select(p => new { p.Key, OptDate = p.Max(d => d.OptDate) }).ToDictionary(p => p.Key, p => p.OptDate); foreach (var item in _clientBalanceDic.Values) { @@ -1067,7 +1066,7 @@ namespace YLErp.BLL.Eod from td in trade.DefaultIfEmpty() where t.HappenDate >= lastSettletDateAddOne && t.HappenDate < newValuedate && t.ValidState != "InValid" - && (t.State == ClientCashInCashOut.已结算 || t.State == ClientCashInCashOut.已确认 || (t.Direction == "出金" && ClientCashInCashOut.outCashCals.Contains(t.State))) + && (t.State == ClientCashInCashOut.已结算 || t.State == ClientCashInCashOut.已确认 || ((t.Direction == "出金"||t.Direction=="划转") && ClientCashInCashOut.outCashCals.Contains(t.State))) && clientIds.Contains(t.ClientId.Value) && t.Money != null && td.TradeType != "收益互换" @@ -1077,19 +1076,23 @@ namespace YLErp.BLL.Eod TradeId = t.TradeId ?? 0, action = t.Direction + "^" + (t.Direction == "应收" ? t.Action : ""), money = t.Money.Value, - cash_type = t.cash_type + cash_type = t.cash_type, + TransferOutAccount=t.TransferOutAccount, + TransferInAccount = t.TransferInAccount }; //获取包含的所有收益互换id列表 var allTradeIds = ClientCashQuery.Select(x => x.TradeId).ToList(); var ClientCashQuerySum = from t in ClientCashQuery - group t by new { t.ClientId, t.action, t.cash_type } into g + group t by new { t.ClientId, t.action, t.cash_type,t.TransferOutAccount,t.TransferInAccount } into g select new { g.Key.ClientId, g.Key.action, g.Key.cash_type, + g.Key.TransferOutAccount, + g.Key.TransferInAccount, moneySum = g.Sum(n => n.money), swapMoneySun = 0.0 }; @@ -1152,6 +1155,45 @@ namespace YLErp.BLL.Eod { balance.OutFundOther = data.moneySum; } + else if (data.action == "划转^") + { + if (data.TransferOutAccount == "初保账户") + { + balance.InFund -= data.moneySum; + if (data.TransferInAccount == "追保账户") + { + balance.VmInFund += data.moneySum; + } + else + { + balance.WinLoss += data.moneySum; + } + } + else if (data.TransferOutAccount == "追保账户") + { + balance.VmInFund -= data.moneySum; + if (data.TransferInAccount == "初保账户") + { + balance.InFund += data.moneySum; + } + else + { + balance.WinLoss += data.moneySum; + } + } + else + { + balance.WinLoss -= data.moneySum; + if (data.TransferInAccount == "初保账户") + { + balance.InFund += data.moneySum; + } + else + { + balance.VmInFund += data.moneySum; + } + } + } } diff --git a/YLErpDAL/Modules/ClientModule/ClientCashInCashOutDataService.cs b/YLErpDAL/Modules/ClientModule/ClientCashInCashOutDataService.cs index cb899926..ad74c2f1 100644 --- a/YLErpDAL/Modules/ClientModule/ClientCashInCashOutDataService.cs +++ b/YLErpDAL/Modules/ClientModule/ClientCashInCashOutDataService.cs @@ -602,6 +602,8 @@ namespace YLErp.Modules.ClientModule r.CurrencyCode = req.CurrencyCode; r.cash_type = req.cash_type; r.ValidState = ConsGlobal.Valid; + r.TransferOutAccount = req.TransferOutAccount; + r.TransferInAccount = req.TransferInAccount; } if (isARAP) @@ -696,7 +698,31 @@ namespace YLErp.Modules.ClientModule } #endregion - + #region 划转资金时进行验资 + if ("划转".Equals(r.Direction)) + { + var clientbalance = ClientBalanceUtility.GetClientBanlances(new List { r.ClientId.Value }, DateTime.MinValue, DateTime.Now.Date).FirstOrDefault(); + if (clientbalance == null) + { + throw new ServiceException("查询客户资金信息失败"); + } + var money = r.Money ?? 0; + money=isAddNew? money: money-(originalMoney??0); + if (r.TransferOutAccount == "初保账户" && money > clientbalance.NetFundAll) + { + throw new ServiceException("划转金额不能超过初保账户金额"); + } + if (r.TransferOutAccount == "追保账户" && money > clientbalance.VmFundSum) + { + throw new ServiceException("划转金额不能超过追保账户金额"); + } + if (r.TransferOutAccount == "已实现盈亏" && money > clientbalance.WinLoss) + { + throw new ServiceException("划转金额不能超过已实现盈亏"); + } + r.cash_type = null; + } + #endregion if (r.Direction != "出金" && r.Direction != "入金") { r.OpenBank = null; diff --git a/YLErpDAL/Modules/ClientModule/EntryexitBLL.cs b/YLErpDAL/Modules/ClientModule/EntryexitBLL.cs index f6cd93e1..bd3bba02 100644 --- a/YLErpDAL/Modules/ClientModule/EntryexitBLL.cs +++ b/YLErpDAL/Modules/ClientModule/EntryexitBLL.cs @@ -18,8 +18,9 @@ namespace YLErp.BLL /// 系统中可以操作的方向 /// public static List EntryDirection_Remove = new List { "收入", "支出" }; - public static List EntryDirection_Menu = new List { "出金", "入金", "其他收入", "其他支出" }; - public static List DirectionType = new List { "出金", "入金", "权利金支出", "权利金收入", "平仓/行权支出", "平仓/行权收入", "票息支出", "票息收入", "其他支出", "其他收入", "互换收入", "互换支出","应付预付金","预付金返息" }; + public static List EntryDirection_Menu = new List { "出金", "入金", "其他收入", "其他支出","划转" }; + public static List TransferAccount = new List { "初保账户", "追保账户", "已实现盈亏" }; + public static List DirectionType = new List { "出金", "入金", "划转", "权利金支出", "权利金收入", "平仓/行权支出", "平仓/行权收入", "票息支出", "票息收入", "其他支出", "其他收入", "互换收入", "互换支出","应付预付金","预付金返息" }; /// /// 现金交易方向 /// diff --git a/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs b/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs index 102162b0..cffec3f8 100644 --- a/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs +++ b/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using DocumentFormat.OpenXml.Drawing.Charts; +using Newtonsoft.Json; using NPOI.SS.Formula.Functions; using NPOI.SS.UserModel; using Org.BouncyCastle.Asn1.Ocsp; @@ -525,6 +526,44 @@ namespace YLErp.Modules.EodModule.SettlementModule fundObject.OtherFund.Add(clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0); } } + else if (clientEntryexit.Direction.Equals("划转")) { + if (clientEntryexit.TransferOutAccount == "初保账户") + { + AddToFund(fundObject.InFund, clientEntryexit.CurrencyCode, -clientEntryexit.Money ?? 0); + if (clientEntryexit.TransferInAccount == "追保账户") + { + AddToFund(fundObject.VmInFund, clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0); + } + else + { + WinLoss += clientEntryexit.Money ?? 0; + } + } + else if (clientEntryexit.TransferOutAccount == "追保账户") + { + AddToFund(fundObject.VmInFund, clientEntryexit.CurrencyCode, -clientEntryexit.Money ?? 0); + if (clientEntryexit.TransferInAccount == "初保账户") + { + AddToFund(fundObject.InFund, clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0); + } + else + { + WinLoss += clientEntryexit.Money ?? 0; + } + } + else + { + WinLoss -= clientEntryexit.Money ?? 0; + if (clientEntryexit.TransferInAccount == "初保账户") + { + AddToFund(fundObject.InFund, clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0); + } + else + { + AddToFund(fundObject.VmInFund, clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0); + } + } + } else { if (ClientCashInCashOut.系统操作_期权费.Equals(clientEntryexit.Action)) diff --git a/YLErpWeb/Controllers/entryexitController.cs b/YLErpWeb/Controllers/entryexitController.cs index c0b25fda..3ff952e6 100644 --- a/YLErpWeb/Controllers/entryexitController.cs +++ b/YLErpWeb/Controllers/entryexitController.cs @@ -354,7 +354,7 @@ namespace YLErp.Web.Controllers { return JsonError("找不到出入金信息"); } - if (r.Direction != "出金" && r.Direction != "入金" && r.Direction != "其他收入" && r.Direction != "其他支出") + if (r.Direction != "出金" && r.Direction != "入金" && r.Direction != "其他收入" && r.Direction != "其他支出" && r.Direction != "划转") { return JsonError("该笔交易不可以删除"); } diff --git a/YLErpWeb/Views/entryexit/entryexitEdit.cshtml b/YLErpWeb/Views/entryexit/entryexitEdit.cshtml index c1b419d0..ece835b0 100644 --- a/YLErpWeb/Views/entryexit/entryexitEdit.cshtml +++ b/YLErpWeb/Views/entryexit/entryexitEdit.cshtml @@ -110,10 +110,31 @@ +
+ + + +
+
+ + + +
+ 全部转出
@if (Model.TradeId == null || Model.TradeId == 0) @@ -130,7 +151,7 @@ -
+
@if (pageObj.changeBeforeConfirm) { diff --git a/YLErpWeb/Views/entryexit/entryexitList.cshtml b/YLErpWeb/Views/entryexit/entryexitList.cshtml index d34f3ac2..8948a6d9 100644 --- a/YLErpWeb/Views/entryexit/entryexitList.cshtml +++ b/YLErpWeb/Views/entryexit/entryexitList.cshtml @@ -52,7 +52,7 @@ TradeAction: isCompanyCash ? "@ClientCashInCashOut.人工操作_预付金" : "" }; if (!isCompanyCash) { - PostData.DirectionTypes = "出金,入金,权利金支出,权利金收入,平仓/行权支出,平仓/行权收入,票息支出,票息收入,其他支出,其他收入,互换收入,互换支出"; + // PostData.DirectionTypes = "出金,入金,权利金支出,权利金收入,平仓/行权支出,平仓/行权收入,票息支出,票息收入,其他支出,其他收入,互换收入,互换支出"; } else { PostData.InOut = "应收,应付"; } @@ -394,7 +394,7 @@ function customButton(cellValue, options, rowObject) { var imageHtml = ""; - if ((rowObject.Direction == "出金" || rowObject.Direction == "入金" || rowObject.Direction == "其他收入" || rowObject.Direction == "其他支出") && pageData.canDelete && rowObject.TradeNumber == "" && rowObject.ApprovalProcess < 1) { + if ((rowObject.Direction == "出金" || rowObject.Direction == "入金" || rowObject.Direction == "其他收入" || rowObject.Direction == "其他支出"|| rowObject.Direction == "划转") && pageData.canDelete && rowObject.TradeNumber == "" && rowObject.ApprovalProcess < 1) { imageHtml = imageHtml + ""; @@ -495,7 +495,7 @@ if (isCompanyCash) { addurl += "?isCompanyCash=1"; } - main.open("新增资金记录", addurl, { area: ['1000px', '75%'] }); + main.open("新增资金记录", addurl, { area: ['1000px', '95%'] }); } function Entryexit_remove() { @@ -505,7 +505,7 @@ function startentryexitView(id) { var srcurl = "/entryexit/entryexitView/?enid=" + id; - main.open("查看资金信息", srcurl, { area: ['1000px', '75%'] }); + main.open("查看资金信息", srcurl, { area: ['1000px', '95%'] }); } function reloadentryexit() { diff --git a/YLErpWeb/Views/entryexit/entryexitView.cshtml b/YLErpWeb/Views/entryexit/entryexitView.cshtml index 63e042ee..59492f60 100644 --- a/YLErpWeb/Views/entryexit/entryexitView.cshtml +++ b/YLErpWeb/Views/entryexit/entryexitView.cshtml @@ -67,6 +67,8 @@ @Html.MyDisplayFor(m => m.ClientName) @Html.MyDisplayFor(m => m.DirectionType) @Html.MyDisplayFor(m => m.cash_type) + @Html.MyDisplayFor(m => m.TransferOutAccount) + @Html.MyDisplayFor(m => m.TransferInAccount) @Html.MyDisplayFor(m => m.Money, (((Model.Direction == "出金" ? (-1) : 1) * Model.Money) ?? 0).ToString("N")) @Html.MyDisplayFor(m => m.CurrencyCode) @Html.MyDisplayFor(m => m.HappenDate, Utilities.ShowValidDatetime(Model.HappenDate, "yyyy-MM-dd HH:mm:ss")) diff --git a/YLErpWeb/wwwroot/Scripts/app/client/entryexitEdit.js b/YLErpWeb/wwwroot/Scripts/app/client/entryexitEdit.js index 5dd2036d..159c707e 100644 --- a/YLErpWeb/wwwroot/Scripts/app/client/entryexitEdit.js +++ b/YLErpWeb/wwwroot/Scripts/app/client/entryexitEdit.js @@ -1,4 +1,8 @@ -const cardInputMgr = (new function () { +var winloss = 0; // 已实现盈亏 +var netFund = 0; // 初保账户 +var vmFund = 0; // 追保账户 +var transferOutMoney = 0; // 转出金额 +const cardInputMgr = (new function () { var _inited = 0, _inputFlag = 0; @@ -180,7 +184,18 @@ function checkSubmitData() { else { $("#Money").val($("#Money").val().replace(',', '')); } - + let direction = $("#Direction").val(); + if (direction==="划转") { + var transfer_out_account = $("#TransferOutAccount").val(); + var transfer_in_account = $("#TransferInAccount").val(); + if (transfer_out_account === transfer_in_account) { + return main.message("转出科目与转入科目不能相同!"); + } + var money = parseFloat($("#Money").val()); + if (money <=0) { + return main.message("转出金额必须大于0!"); + } + } return cardInputMgr.checkSubmit(); } @@ -205,16 +220,30 @@ function setDirection(isInit) { !isInit && cardInputMgr.changeInputType(true); let direction = $("#Direction").val(); $(".changeInputBtn").toggleClass("hide", ["出金", "应付"].includes(direction)); - if (direction === "出金") { - $("#cash_type_container").hide(); // 隐藏资金类型 - } else { + if (direction === "入金") { $("#cash_type_container").show(); // 显示资金类型 + } else { + $("#cash_type_container").hide(); // 隐藏资金类型 + } + if (direction === "划转") { + $("#transfer_out_container").show(); + $("#transfer_in_container").show(); + $("#transferAll").show(); + } else { + $("#transfer_out_container").hide(); + $("#transfer_in_container").hide(); + $("#transferAll").hide(); } cardInputMgr.toggle(["入金", "出金"].includes(direction)); cardInputMgr.updateOptions(); } +// 全部转出 +function transferAll() { + $("#MoneyStr").val(transferOutMoney); + moneyInputMgr.onInput(); +} function setClientCash() { var clientId = $("#ClientId").val(); if (!clientId) { @@ -225,9 +254,41 @@ function setClientCash() { $("#ClientCashCNY").val(res.CNY); $("#ClientCashUSD").val(res.USD); } - }) + }); + main.post("/trade_span/GetClientLatestBalance", { clientId: clientId }).done(function (data) { + winloss = data.WinLoss; + netFund = data.NetFund; + vmFund = data.VmFundSum; + setTransferMoney(); + }); +} +function setTransferMoney() { + var clientId = $("#ClientId").val(); + if (!clientId) { + return; + } + var transfer_out_account = $("#TransferOutAccount").val(); + var transfer_in_account = $("#TransferInAccount").val(); + if (transfer_out_account === "初保账户") { + transferOutMoney = netFund; + $("#transfer_out_account_money").text("余额:" + netFund); + } + else if (transfer_out_account === "追保账户") { + transferOutMoney = vmFund; + $("#transfer_out_account_money").text("余额:" + vmFund); + } else { + transferOutMoney = winloss; + $("#transfer_out_account_money").text("余额:" + winloss); + } + if (transfer_in_account === "初保账户") { + $("#transfer_in_account_money").text("余额:" + netFund); + } + else if (transfer_in_account === "追保账户") { + $("#transfer_in_account_money").text("余额:" + vmFund); + } else { + $("#transfer_in_account_money").text("余额:" + winloss); + } } - $(function () { cardInputMgr.init();