From 78c0bb3b2fc32b7a2128203eda0bac8334760b99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=94=A6=E9=BA=9F=20=E7=8E=8B?= Date: Tue, 14 Apr 2026 18:21:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E7=9B=8A=E4=BA=92=E6=8D=A2=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E9=80=89=E6=8B=A9=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=BB=93=E5=90=88=20swap=5Fposition=20=E7=9A=84=20PosiDirectio?= =?UTF-8?q?n=EF=BC=88=E6=94=B6=E6=94=AF=E6=96=B9=E5=90=91=EF=BC=89?= =?UTF-8?q?=E4=B8=8E=20PositionType=EF=BC=88=E5=A4=9A=E7=A9=BA=E6=96=B9?= =?UTF-8?q?=E5=90=91=EF=BC=89=E5=85=B1=E5=90=8C=E5=88=A4=E6=96=AD=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=9C=8B=E5=A4=9A/=E7=9C=8B=E7=A9=BA=E6=96=B9?= =?UTF-8?q?=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TradeConfirmationGenerator.cs | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Plugins/YLErp.Plugins.GuoLian/DocumentGenerator/TradeConfirmationGenerator.cs b/Plugins/YLErp.Plugins.GuoLian/DocumentGenerator/TradeConfirmationGenerator.cs index a77ce1ba..6d659813 100644 --- a/Plugins/YLErp.Plugins.GuoLian/DocumentGenerator/TradeConfirmationGenerator.cs +++ b/Plugins/YLErp.Plugins.GuoLian/DocumentGenerator/TradeConfirmationGenerator.cs @@ -22,7 +22,8 @@ namespace YLErp.Plugins.GuoLian.DocumentGenerator /// /// 获取模板文件路径 /// 收益互换模板选择逻辑: - /// 1. 客户看多/看空:通过持仓方向判断(PositionType: 1=多头/看多,2=空头/看空) + /// 1. 客户看多/看空:根据 swap_position 的 PosiDirection(收支方向)和 PositionType(多空方向) + /// 组合出我方方向,再取反得到客户方向。 /// 2. 标的类型: /// - 债券ETF:.SH后缀且511开头,或.SZ后缀且59开头 /// - 现券:其他 @@ -54,22 +55,31 @@ namespace YLErp.Plugins.GuoLian.DocumentGenerator var trade = Context.Trade; var underlying = Context.GetTradeUnderlying(); - // 判断看多/看空方向(通过持仓方向判断:PositionType: 1=多头/看多,2=空头/看空) + // 判断客户看多/看空方向: + // 先根据 PosiDirection(收支方向)和 PositionType(多空方向)组合出我方方向,再取反得到客户方向。 var swapPosition = Context.GetSwapPositions(trade.id, true) .Where(x => x.PositionType == (int)PositionTypeFlag.Long || x.PositionType == (int)PositionTypeFlag.Short) .FirstOrDefault(); - bool isLong = swapPosition?.PositionType == (int)PositionTypeFlag.Long; + + bool isCustomerLong = false; + if (swapPosition != null) + { + bool isOurLong = swapPosition.PosiDirection == (int)SwapDirectionEnum.支付 + ? swapPosition.PositionType == (int)PositionTypeFlag.Short // 支付端:我方方向与 PositionType 相反 + : swapPosition.PositionType == (int)PositionTypeFlag.Long; // 收取端:我方方向与 PositionType 相同 + isCustomerLong = !isOurLong; + } // 判断标的类型(债券ETF vs 现券) bool isEtf = IsBondEtf(underlying?.UnderlyingCode ?? string.Empty); // 选择对应模板(使用客户提供的原始文件名) string templateName; - if (isLong && !isEtf) + if (isCustomerLong && !isEtf) templateName = "国联民生-收益互换交易确认书-境内模板-【客户看多】-【现券】-清洁版.docx"; - else if (isLong && isEtf) + else if (isCustomerLong && isEtf) templateName = "国联民生-收益互换交易确认书-境内模板-【客户看多】-【债券ETF】-清洁版.docx"; - else if (!isLong && !isEtf) + else if (!isCustomerLong && !isEtf) templateName = "国联民生-收益互换交易确认书-境内模板-【客户看空】-【现券】-清洁版.docx"; else templateName = "国联民生-收益互换交易确认书-境内模板-【客户看空】-【债券ETF】-清洁版.docx";