diff --git a/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/浙商证券利率债收益互换合约交易确认书模版.docx b/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/浙商证券利率债收益互换合约交易确认书模版.docx index dfec74d0..f25c6139 100644 Binary files a/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/浙商证券利率债收益互换合约交易确认书模版.docx and b/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/浙商证券利率债收益互换合约交易确认书模版.docx differ diff --git a/Plugins/YLErp.Plugins.ZheShang/DocumentGenerator/TradeConfirmationGenerator.cs b/Plugins/YLErp.Plugins.ZheShang/DocumentGenerator/TradeConfirmationGenerator.cs index 31ee782d..731dbd99 100644 --- a/Plugins/YLErp.Plugins.ZheShang/DocumentGenerator/TradeConfirmationGenerator.cs +++ b/Plugins/YLErp.Plugins.ZheShang/DocumentGenerator/TradeConfirmationGenerator.cs @@ -103,6 +103,10 @@ namespace YLErp.Plugins.ShanXi.DocumentGenerator dic["交易对手方全称"] = client.ClientType != "产品" ? client.Name : $"{client.Manager}作为管理人代表{client.Name}"; dic["主协议编号"] = client.MainProtocolCode; dic["定义文件编号"] = client.SettleFileNumber; + dic["户名"] = bank?.ClientName; + dic["银行账号"] = bank?.Card; + dic["开户行"] = bank?.Bank; + dic["大额行号"] = bank?.Payment; var count = 0; var trades = Context.Trades; @@ -112,13 +116,23 @@ namespace YLErp.Plugins.ShanXi.DocumentGenerator { var swapPositions = Context.GetSwapPositions(trade.id, true); var swapPosition = swapPositions.Where(x => x.PositionType == 1 || x.PositionType == 2).FirstOrDefault(); - var interestMargin = swapPositions.Where(x => ConsTrade.InterestModels.Contains(x.InterestMode)).FirstOrDefault(); + var interestMargins = swapPositions.Where(x => ConsTrade.InterestModels.Contains(x.InterestMode)); var initialMarginQuery = swapPositions.Where(x => x.InterestMode == 5); var additionMarginQuery = swapPositions.Where(x => x.InterestMode == 6); var underlyingCode = swapPosition?.UnderlyingCode; if (count == 0) { + var interestMargin = interestMargins.FirstOrDefault(o => o.interest_rest_days != null); + if (interestMargin == null) + { + interestMargin = interestMargins.FirstOrDefault(o => string.IsNullOrWhiteSpace(o.FloatRateUnderlyingCode)); + } + if (interestMargin == null) + { + interestMargin = interestMargins.FirstOrDefault(); + } + dic["成交日期"] = trade.TradeDate?.ToString("yyyy年M月d日"); dic["开始日期"] = trade.StartDate?.ToString("yyyy年M月d日"); dic["到期日期"] = trade.ExerciseDate?.ToString("yyyy年M月d日"); @@ -146,6 +160,7 @@ namespace YLErp.Plugins.ShanXi.DocumentGenerator dic["固定利率"] = ((interestMargin?.InterestRateDefault) ?? 0) * 100; dic["参考利率"] = ""; dic["重置频率"] = ""; + dic["计算基准"] = ""; if (posiLong) { dic["多头约定利率"] = ((double)interestRate).ToString("0.####") + "%"; @@ -162,28 +177,30 @@ namespace YLErp.Plugins.ShanXi.DocumentGenerator dic["利差%"] = ((interestMargin?.InterestRateDefault) ?? 0) * 100; dic["参考利率"] = interestMargin?.FloatRateUnderlyingCode; dic["固定利率"] = ""; - dic["重置频率"] = interestMargin?.interest_rest_days; + dic["计算基准"] = interestMargin?.FloatRateUnderlyingCode +" + " + ((interestMargin?.InterestRateDefault) ?? 0) * 100 + "%"; + dic["重置频率"] = interestMargin?.interest_rest_days + "天"; } - dic["初始预付金支付日"] = initialMarginQuery.FirstOrDefault()?.HappenDate == null ? "" : interestMargin?.HappenDate?.ToString("【yyyy】年【M】月【d】日"); + dic["初始预付金支付日"] = trade.TradeDate?.ToString("yyyy年M月d日"); dic["管理人名称"] = client.Manager; - var calculationBasis = interestMargin?.FloatRateUnderlyingCode; - if (!string.IsNullOrEmpty(calculationBasis)) - { - calculationBasis += interestRate > 0 ? " + " + ((double)interestRate).ToString("0.####") + "%" : ((double)interestRate).ToString("0.####") + "%"; - } - else - { - calculationBasis = ((double)interestRate).ToString("0.####") + "%"; - } + //var calculationBasis = interestMargin?.FloatRateUnderlyingCode; + //if (!string.IsNullOrEmpty(calculationBasis)) + //{ + // calculationBasis += interestRate > 0 ? " + " + ((double)interestRate).ToString("0.####") + "%" : ((double)interestRate).ToString("0.####") + "%"; + //} + //else + //{ + // calculationBasis = ((double)interestRate).ToString("0.####") + "%"; + //} - dic["计算基准"] = calculationBasis; + //dic["计算基准"] = calculationBasis; dic["初始保障金率"] = ((clientMarginRate?.InitMarginRate ?? 0) * 100).ToString("0.####") + "%"; dic["维持保障金率"] = ((clientMarginRate?.MaintenanceRate ?? 0) * 100).ToString("0.####") + "%"; dic["交易费率"] = dic["基本费率"]; - var initialMarginSum = initialMarginQuery.Sum(x => - x.InterestDirection == 2 ? x.InterestPrincipalFix * -1 : x.InterestPrincipalFix); - dic["期初预付金".Insert("期初预付金".Length, "2?")] = trade.StockEqvNotionalReal.ToString("0.##"); + //var initialMarginSum = initialMarginQuery.Sum(x => + // x.InterestDirection == 2 ? x.InterestPrincipalFix * -1 : x.InterestPrincipalFix); + //dic["期初预付金".Insert("期初预付金".Length, "2?")] = initialMarginSum.ToString("0.##"); + } var row = new JObject(); @@ -194,10 +211,6 @@ namespace YLErp.Plugins.ShanXi.DocumentGenerator row["开始日期"] = trade.StartDate?.ToString("【yyyy】年【M】月【d】日"); row["到期日期"] = trade.ExerciseDate?.ToString("【yyyy】年【M】月【d】日"); row["成交日期2"] = trade.TradeDate?.ToString("【yyyy】年【M】月【d】日"); - row["户名"] = bank?.ClientName; - row["银行账号"] = bank?.Card; - row["开户行"] = bank?.Bank; - row["大额行号"] = bank?.Payment; FormatToDict("期初标的交割全价", (double)((swapPosition?.PosiGrossPrice) ?? 0) * 100, row); FormatToDict("期初标的交割净价", (double)((swapPosition?.PosiNetNoFeePrice) ?? 0) * 100, row); @@ -237,6 +250,7 @@ namespace YLErp.Plugins.ShanXi.DocumentGenerator }; table1.Add(row); dic["名义本金".Insert("名义本金".Length, "2?")] = StockEqvNotionalRealSum.ToString("0.##"); + dic["期初预付金".Insert("期初预付金".Length, "2?")] = (StockEqvNotionalRealSum * clientMarginRate?.InitMarginRate)?.ToString("0.##"); } diff --git a/YLErpDAL/Modules/SwapModule/SwapTradeService.cs b/YLErpDAL/Modules/SwapModule/SwapTradeService.cs index 51f308c6..5495169a 100644 --- a/YLErpDAL/Modules/SwapModule/SwapTradeService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapTradeService.cs @@ -610,7 +610,7 @@ namespace YLErp.Modules.SwapModule } } } - else if (changeConfirmStatus) + if (changeConfirmStatus) { //删除交易确认书 TODO new TradeDocumentDataService(this).DeleteBooksAfterEditTrade(dbTrade); diff --git a/YLErpDAL/Modules/TradeModule/DealModule/TradeContractGenerateService.cs b/YLErpDAL/Modules/TradeModule/DealModule/TradeContractGenerateService.cs index 64e5e57a..d891b6bb 100644 --- a/YLErpDAL/Modules/TradeModule/DealModule/TradeContractGenerateService.cs +++ b/YLErpDAL/Modules/TradeModule/DealModule/TradeContractGenerateService.cs @@ -1,4 +1,5 @@ using BaseOUDAL; +using DocumentFormat.OpenXml.Office.Word; using System.Collections.Concurrent; using System.Drawing.Printing; using YLErp.Configuration; @@ -562,7 +563,11 @@ namespace YLErp.Modules.TradeModule.DealModule tcd.SealResult, ContractId = tcr != null ? tcr.id : 0, sp.PositionType, - t.SentMailCount + t.SentMailCount, + tcd.StampDocumentFileName, + tcr.OptDate, + tcr.OptName, + ContractDocId = tcd != null ? tcd.id : 0, }; if (req.StartDate != null && req.StartDate != DateTime.MinValue) @@ -616,9 +621,13 @@ namespace YLErp.Modules.TradeModule.DealModule tradeCount = group.Select(x => x.id).Distinct().Count(), PositionType = group.FirstOrDefault().PositionType, SentMailCount = group.FirstOrDefault().SentMailCount ?? 0, + StampDocumentFileName = group.FirstOrDefault().StampDocumentFileName, + OptDate = group.FirstOrDefault().OptDate, + OptName = group.FirstOrDefault().OptName, + ContractDocId = group.FirstOrDefault().ContractDocId }); } - result = contractList.AsQueryable().ToSearchList(req); + result = contractList.OrderBy(r => r.TradeDate).AsQueryable().ToSearchList(req); return result; } } @@ -653,6 +662,7 @@ namespace YLErp.Modules.TradeModule.DealModule public List? PositionTypes { get; set; } + } public class clientContractR @@ -689,5 +699,13 @@ namespace YLErp.Modules.TradeModule.DealModule public int SentMailCount { get; set; } + public string StampDocumentFileName { get; set; } + + public DateTime? OptDate { get; set; } + + public string OptName { get; set; } + + public int ContractDocId { get; set; } + } } diff --git a/YLErpDAL/Modules/TradeModule/TradeDocumentDataService.cs b/YLErpDAL/Modules/TradeModule/TradeDocumentDataService.cs index de26a3d8..299b01e4 100644 --- a/YLErpDAL/Modules/TradeModule/TradeDocumentDataService.cs +++ b/YLErpDAL/Modules/TradeModule/TradeDocumentDataService.cs @@ -52,7 +52,15 @@ namespace YLErp.Modules.TradeModule return 0; } - doc.ToList().ForEach(O => O.IsValid = false); + //同ContractCode的都要改变 + var docArr = doc.ToArray(); + var contractCode = docArr.FirstOrDefault().ContractCode; + var types = docArr.Select(o => o.Type).ToArray(); + var tcrs = from tcr in DbContext.trade_contract_r + where tcr.ContractCode == contractCode && types.Contains(tcr.Type) && tcr.IsValid + select tcr; + + tcrs.ToList().ForEach(O => O.IsValid = false); return DbContext.SaveChanges(); } diff --git a/YLErpWeb/Controllers/TradeConfirmBookController.cs b/YLErpWeb/Controllers/TradeConfirmBookController.cs index 4be41d79..f6b2022b 100644 --- a/YLErpWeb/Controllers/TradeConfirmBookController.cs +++ b/YLErpWeb/Controllers/TradeConfirmBookController.cs @@ -547,6 +547,15 @@ namespace YLErp.Web.Controllers /// public ActionResult confirmBookUpload(string Id, string SendMailId = "") { + //如果都是数字,进行一次编码 + if (Id.All(char.IsDigit)) + { + Id = DataProtectHelper.Encrypt(int.Parse(Id)); + } + if (!string.IsNullOrWhiteSpace(SendMailId) && SendMailId.All(char.IsDigit)) + { + SendMailId = DataProtectHelper.Encrypt(int.Parse(SendMailId)); + } ViewBag.Id = Id; ViewBag.SendMailId = SendMailId; return View(); diff --git a/YLErpWeb/wwwroot/Scripts/app/trade/tradeConfirmBookListByClient.js b/YLErpWeb/wwwroot/Scripts/app/trade/tradeConfirmBookListByClient.js index 83cd1dcc..a6e8e80a 100644 --- a/YLErpWeb/wwwroot/Scripts/app/trade/tradeConfirmBookListByClient.js +++ b/YLErpWeb/wwwroot/Scripts/app/trade/tradeConfirmBookListByClient.js @@ -30,7 +30,6 @@ const colModelGrid = (new function () { { label: '用印状态', name: 'StampStatus', width: 80, align: 'center' }, // 根据实际需要调整宽度和对齐 { label: '邮件发送结果', name: 'EmailResult', width: 100, align: 'center', formatter: function (cellValue, options, rowObject) { - console.log(cellValue); var html = ""; html += "