From b1d2ad0756e3b9807373dc2a5e8cbf1b7d74c93d Mon Sep 17 00:00:00 2001 From: tengyufan <1532636164@qq.com> Date: Fri, 7 Aug 2026 16:46:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20EQD-6718=20=E6=94=B6=E7=9B=8A=E4=BA=92?= =?UTF-8?q?=E6=8D=A2=E6=B5=AE=E5=8A=A8=E7=AB=AF=E5=A4=9A=E7=A9=BA=E6=96=B9?= =?UTF-8?q?=E5=90=91=E5=85=BC=E5=AE=B9=E5=8E=86=E5=8F=B2=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 配置开启时,查看交易、审批查看、交易平仓、收益结算和平仓详情按浮动收支方向与原多空方向组合展示多空方向 - 兼容历史支付数据:支付多头展示为空头,支付空头展示为多头,收取方向保持原多空展示 - 新增浮动端方向组合及相关页面覆盖专项测试 --- YLErpWeb/Views/SwapTrade2/CloseDetial.cshtml | 22 +++++++-- YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml | 9 +++- YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml | 9 +++- YLErpWeb/Views/SwapTrade2/TradeView.cshtml | 17 +++++-- .../floatingIncomeDirectionDisplay.test.js | 47 +++++++++++++++++++ 5 files changed, 95 insertions(+), 9 deletions(-) create mode 100644 YLErpWeb/fe-tests/floatingIncomeDirectionDisplay.test.js diff --git a/YLErpWeb/Views/SwapTrade2/CloseDetial.cshtml b/YLErpWeb/Views/SwapTrade2/CloseDetial.cshtml index 3a641898..0283ee83 100644 --- a/YLErpWeb/Views/SwapTrade2/CloseDetial.cshtml +++ b/YLErpWeb/Views/SwapTrade2/CloseDetial.cshtml @@ -2,6 +2,16 @@ @{ ViewBag.Title = "交易 | 提前终止详情"; Layout = "~/Views/Shared/_InfoLayout.cshtml"; + bool hideFloatingIncomeDirection = PS.Config.ErpElement.SwapFloatingIncomeReceiveOnlyMode; + string FloatingPositionTypeText(int posiDirection, int positionType) + { + if (hideFloatingIncomeDirection) + { + return posiDirection == positionType ? "多头" : "空头"; + } + + return positionType == (int)PositionTypeFlag.Long ? "多头" : "空头"; + } } @section CSS{ @@ -69,7 +79,10 @@ - + @if (!hideFloatingIncomeDirection) + { + + } @@ -84,8 +97,11 @@ { var fbgclass = item.PosiDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay"; - - + @if (!hideFloatingIncomeDirection) + { + + } + diff --git a/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml b/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml index c6e7df28..2eedf7ce 100644 --- a/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml +++ b/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml @@ -163,7 +163,14 @@ } } } - + } } - + @if (isBond) { @@ -1046,7 +1055,7 @@ { } - + @if (isBond) { diff --git a/YLErpWeb/fe-tests/floatingIncomeDirectionDisplay.test.js b/YLErpWeb/fe-tests/floatingIncomeDirectionDisplay.test.js new file mode 100644 index 00000000..187daf64 --- /dev/null +++ b/YLErpWeb/fe-tests/floatingIncomeDirectionDisplay.test.js @@ -0,0 +1,47 @@ +const fs = require('fs'); +const path = require('path'); + +function read(relativePath) { + return fs.readFileSync(path.join(__dirname, '..', relativePath), 'utf8'); +} + +function floatingPositionTypeText(posiDirection, positionType) { + return posiDirection === positionType ? '多头' : '空头'; +} + +describe('收益互换浮动端多空方向展示', () => { + test.each([ + [1, 1, '多头'], + [1, 2, '空头'], + [2, 1, '空头'], + [2, 2, '多头'] + ])('收支方向=%i,多空方向=%i时展示%s', (posiDirection, positionType, expected) => { + expect(floatingPositionTypeText(posiDirection, positionType)).toBe(expected); + }); + + test('查看交易的初始持仓、实时持仓、平仓和互换记录均使用计算后的方向', () => { + const source = read('Views/SwapTrade2/TradeView.cshtml'); + + expect(source).toContain('FloatingPositionTypeText(item.PosiDirection, item.PositionType)'); + expect(source.match(/FloatingPositionTypeText\(item\.PosiDirection, item\.PositionType\)/g)).toHaveLength(2); + expect(source.match(/FloatingPositionTypeText\(closeFloat\.PayDirection, closeFloat\.PositionType\)/g)).toHaveLength(2); + }); + + test.each([ + 'Views/SwapTrade2/SwapUnwind.cshtml', + 'Views/SwapTrade2/SwapIncome.cshtml' + ])('%s按收支方向和多空方向计算展示值', relativePath => { + const source = read(relativePath); + + expect(source).toContain('floatPosition.PayDirection==floatPosition.PositionType?"多头":"空头"'); + expect(source).toContain('floatPosition.PositionType==1?"多头":"空头"'); + }); + + test('平仓详情隐藏浮动收支方向并计算多空展示值', () => { + const source = read('Views/SwapTrade2/CloseDetial.cshtml'); + + expect(source).toContain('bool hideFloatingIncomeDirection = PS.Config.ErpElement.SwapFloatingIncomeReceiveOnlyMode;'); + expect(source).toContain('FloatingPositionTypeText(item.PosiDirection, item.PositionType)'); + expect(source).toMatch(/@if \(!hideFloatingIncomeDirection\)[\s\S]*
收支方向收支方向多空方向 标的代码 期初标的价格
@((SwapDirectionEnum)item.PosiDirection)@(item.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头")@((SwapDirectionEnum)item.PosiDirection)@FloatingPositionTypeText(item.PosiDirection, item.PositionType) @item.UnderlyingCode @(item.PosiNetPrice.OtcFormatMoney(true, 4)) @(item.PosiGrossPrice.OtcFormatMoney(true, 4)){{floatPosition.PayDirection==1?"收取":"支付"}} - {{floatPosition.PositionType==1?"多头":"空头"}} + @if (hideFloatingIncomeDirection) + { + {{floatPosition.PayDirection==floatPosition.PositionType?"多头":"空头"}} + } + else + { + {{floatPosition.PositionType==1?"多头":"空头"}} + } {{floatPosition.UnderlyingCode}} diff --git a/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml b/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml index 26a8f625..3ef08042 100644 --- a/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml +++ b/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml @@ -202,7 +202,14 @@ {{floatPosition.PayDirection==1?"收取":"支付"}} - {{floatPosition.PositionType==1?"多头":"空头"}} + @if (hideFloatingIncomeDirection) + { + {{floatPosition.PayDirection==floatPosition.PositionType?"多头":"空头"}} + } + else + { + {{floatPosition.PositionType==1?"多头":"空头"}} + } {{floatPosition.UnderlyingCode}} diff --git a/YLErpWeb/Views/SwapTrade2/TradeView.cshtml b/YLErpWeb/Views/SwapTrade2/TradeView.cshtml index 24f94de3..1f3efd57 100644 --- a/YLErpWeb/Views/SwapTrade2/TradeView.cshtml +++ b/YLErpWeb/Views/SwapTrade2/TradeView.cshtml @@ -31,6 +31,15 @@ var realPositions = trade.swap_positions.Where(x => x.PosiDirection > 0 && !x.IsInitial).ToList(); var sr = trade.trade_extend.ExtendObj.SettlementRules; bool hideFloatingIncomeDirection = PS.Config.ErpElement.SwapFloatingIncomeReceiveOnlyMode; + string FloatingPositionTypeText(int posiDirection, int positionType) + { + if (hideFloatingIncomeDirection) + { + return posiDirection == positionType ? "多头" : "空头"; + } + + return positionType == (int)PositionTypeFlag.Long ? "多头" : "空头"; + } string SwapPriceData(decimal? value) => value?.ToString(CultureInfo.InvariantCulture) ?? string.Empty; string SwapCommonData(object value) => value == null ? string.Empty : Convert.ToString(value, CultureInfo.InvariantCulture); } @@ -408,7 +417,7 @@ { @((SwapDirectionEnum)item.PosiDirection)@(item.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头")@FloatingPositionTypeText(item.PosiDirection, item.PositionType) @item.UnderlyingCode @@ -633,7 +642,7 @@ - @(item.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头") + @FloatingPositionTypeText(item.PosiDirection, item.PositionType) @item.UnderlyingCode @@ -844,7 +853,7 @@ { @((SwapDirectionEnum)closeFloat.PayDirection)@(closeFloat.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头")@FloatingPositionTypeText(closeFloat.PayDirection, closeFloat.PositionType) @closeFloat.UnderlyingCode@((SwapDirectionEnum)closeFloat.PayDirection)@(closeFloat.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头")@FloatingPositionTypeText(closeFloat.PayDirection, closeFloat.PositionType) @closeFloat.UnderlyingCode收支方向<\/td>/); + }); +});