refactor(longshort): 全量移除多空组合(StructType)子系统死代码(无入口/无存量,按需求重写优于维护)

This commit is contained in:
hjhan
2026-08-13 09:50:25 +08:00
parent a86b496f87
commit af1b4fd27f
12 changed files with 1 additions and 845 deletions
@@ -1536,11 +1536,6 @@ namespace YLErp.Modules.SystemModule
Text = SwapTypeEnum..ToString(),
Value = SwapTypeEnum..ToString()
},
new SelectItem
{
Text = SwapTypeEnum..ToString(),
Value = SwapTypeEnum..ToString()
}
};
}
@@ -351,36 +351,6 @@ namespace YLErp.Web.Controllers
return View(model);
}
/// <summary>
/// 收益互换 多空组合平仓
/// </summary>
/// <param name="enid"></param>
/// <returns></returns>
public ActionResult SwapLongShortUnwind(string enid, bool isUseApproval = false)
{
var intid = DecryptInt(enid);
var model = new SwapDealService(CurUser).InitLongShortUnwind(intid, SwapEventTypeEnum.);
ViewBag.isUseApproval = isUseApproval;
var hasProcess = new SwapDealService(CurUser).HasTradeProcess();
//需要审批或者复核的交易都会显示行权审核提交按钮
ViewBag.IsShowReCheckClose = (valuedateBLL.SystemDate.CloseReCheck == 1) || (valuedateBLL.SystemDate.CloseReApprove == 1 && hasProcess);
return View(model);
}
/// <summary>
/// 收益互换 多空组合互换
/// </summary>
/// <param name="enid"></param>
/// <returns></returns>
public ActionResult SwapLongShortSwap(string enid, bool isUseApproval = false)
{
var intid = DecryptInt(enid);
var model = new SwapDealService(CurUser).InitLongShortUnwind(intid, SwapEventTypeEnum.);
ViewBag.isUseApproval = isUseApproval;
var hasProcess = new SwapDealService(CurUser).HasTradeProcess();
//需要审批或者复核的交易都会显示行权审核提交按钮
ViewBag.IsShowReCheckClose = (valuedateBLL.SystemDate.CloseReCheck == 1) || (valuedateBLL.SystemDate.CloseReApprove == 1 && hasProcess);
return View(model);
}
/// <summary>
/// 操作历史
/// </summary>
/// <param name="enid"></param>
@@ -456,26 +426,6 @@ namespace YLErp.Web.Controllers
return JsonSuccess("平仓成功");
}
/// <summary>
///多空组合 平仓
/// </summary>
/// <param name="swap_Deal"></param>
/// <returns></returns>
public JsonResult SwapLongShortUnwindJson(UnwindData unwindData)
{
new SwapDealService(CurUser).SwapLongShortUnwind(unwindData);
return JsonSuccess("平仓成功");
}
/// <summary>
///多空组合 互换
/// </summary>
/// <param name="swap_Deal"></param>
/// <returns></returns>
public JsonResult SwapLongShortJson(UnwindData unwindData)
{
new SwapDealService(CurUser).SwapLongShort(unwindData);
return JsonSuccess("互换成功");
}
/// <summary>
/// 互换
/// </summary>
/// <param name="swap_Deal"></param>
@@ -1,126 +0,0 @@
@model UnwindData
@{
ViewBag.Title = "交易 | 收益结算";
Layout = "~/Views/Shared/_InfoLayout.cshtml";
bool isUseApproval = ViewBag.isUseApproval;
bool isShowReCheckClose = ViewBag.IsShowReCheckClose;
}
@section CSS{
<link rel="stylesheet" href="~/Style/Css/unwindSwapTrade.css?v=@(HtmlUtil.JsVersion)" />
}
@section JS
{
<script>
var model = @Json.Serialize(Model);
model.StartDate = model.StartDate ? model.StartDate.substr(0, 10) : "";
model.ValueDate = model.ValueDate ? model.ValueDate.substr(0, 10) : "";
var isUseApproval = "@isUseApproval" == "True";
var g_isShowReCheckClose = "@isShowReCheckClose" == "True";
</script>
<script src="~/front/calendar?v=@(HtmlUtil.JsVersion)"></script>
<script src="~/Scripts/fast/fastVue.components.js?v=@HtmlUtil.JsVersion"></script>
<script src="~/front/swappriceprecision?v=@(HtmlUtil.JsVersion)"></script>
<script src="~/Scripts/app/swaptrade/swapPricePrecisionHelper.js?v=@HtmlUtil.JsVersion"></script>
<script src="~/Scripts/app/swaptrade/swapLongShort.js?v=@HtmlUtil.JsVersion"></script>
}
<div class="pb-3" id="vueDiv">
<div class="yc-panel">
<div id="commomArea" class="row" style="height:140px">
<div class="form-group col-md-4">
<label class="formlabel">成交名义本金</label>
<input class="text-box" :value="formatAmount(deal.NotionalValue)" readonly="readonly" type="text" />
</div>
<div class="form-group col-md-4">
<label class="formlabel">持仓名义本金</label>
<input class="text-box" :value="formatAmount(deal.PosiNotionalValue)" readonly="readonly" type="text" />
</div>
<div class="form-group col-md-4">
<label class="formlabel">起始日期</label>
<input class="text-box" id="startDate" readonly="readonly" type="text" v-model="deal.StartDate" />
</div>
<div class="form-group col-md-4">
<label class="formlabel">收益结算日期</label>
<vue-datepicker :maxdate="maxUnwindDate" :mindate="minStartDate" :holiday="1" v-model="deal.ValueDate" v-on:input="setValueDate" />
</div>
<div class="form-group col-md-4">
<label class="formlabel">年化天数</label>
<input class="text-box" v-model="deal.AnnualDays" readonly="readonly" type="text" />
</div>
<div class="form-group col-md-4">
<label class="formlabel">平仓总额</label>
<input class="text-box" :value="formatAmount(deal.SwapCloseAmount)" readonly="readonly" type="text" />
</div>
</div>
</div>
<div class="yc-panel">
<div class="row no-gutters" style="display:block;">
<div class="titleDiv">
<div class="titleHead"></div>
<div class="titleLabel"><label>预付金/预付金</label></div>
</div>
<div style="margin: 5px 0 0 12px">
<table class="table table-bordered ratetable" style="width:750px;">
<tbody>
<tr>
<td width="116px">收支方向</td>
<td>利息金额</td>
<td>其他费用</td>
<td>预付金/预付金平仓盈亏</td>
</tr>
<tr v-for="item in marginList">
<td :class="item.InterestDirection==1?'swapget':'swappay'">{{item.InterestDirection==1?"收取":"支付"}}</td>
<td>
<vue-number-input v-model="item.InterestAmount" v-bind:format="inputFormatEqvNotional" v-on:input="changeInterestAmount(item)"></vue-number-input>
</td>
<td>
<vue-number-input v-model="item.InterestFee" v-bind:format="inputFormatEqvNotional" v-on:input="changeInterestAmount(item)"></vue-number-input>
</td>
<td>{{formatAmount(item.InterestClosePnL)}}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row no-gutters" style="display:block;">
<div class="titleDiv">
<div class="titleHead"></div>
<div class="titleLabel"><label>利息端</label></div>
</div>
<div style="margin: 5px 0 0 12px">
<table class="table table-bordered">
<tbody>
<tr>
<td>收支方向</td>
<td>利息金额</td>
<td>其他费用</td>
<td>利息端平仓盈亏</td>
</tr>
<tr v-for="item in interestList">
<td :class="item.InterestDirection==1?'swapget':'swappay'">{{item.InterestDirection==1?"收取":"支付"}}</td>
<td>
<vue-number-input v-model="item.InterestAmount" v-bind:format="inputFormatEqvNotional" v-on:input="changeInterestAmount(item)"></vue-number-input>
</td>
<td>
<vue-number-input v-model="item.InterestFee" v-bind:format="inputFormatEqvNotional" v-on:input="changeInterestAmount(item)"></vue-number-input>
</td>
<td>{{formatAmount(item.InterestClosePnL)}}</td>
</tr>
</tbody>
</table>
</div>
<div>
@if (isUseApproval)
{
<button class="btn btn-default swapclose" type="button" v-on:click="submitApproval('reject');">拒绝</button>
<button class="btn btn-primary swapsave" type="button" v-on:click="submitApproval('pass')">审批通过</button>
}
else
{
<button class="btn btn-default swapclose" type="button" onclick="layer.closeMe();">取消</button>
<button class="btn btn-primary swapsave" type="button" v-on:click="incomeTrade">{{getSumbitText()}}</button>
}
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
@@ -1,138 +0,0 @@
@model UnwindData
@{
ViewBag.Title = "交易 | 交易平仓";
Layout = "~/Views/Shared/_InfoLayout.cshtml";
bool isUseApproval = ViewBag.isUseApproval;
bool isShowReCheckClose = ViewBag.IsShowReCheckClose;
}
@section CSS{
<link rel="stylesheet" href="~/Style/Css/unwindSwapTrade.css?v=@(HtmlUtil.JsVersion)" />
}
@section JS
{
<script>
var model = @Json.Serialize(Model);
model.StartDate = model.StartDate ? model.StartDate.substr(0, 10) : "";
model.ValueDate = model.ValueDate ? model.ValueDate.substr(0, 10) : "";
model.PayDate = model.PayDate ? model.PayDate.substr(0, 10) : "";
var isUseApproval = "@isUseApproval" == "True";
var g_isShowReCheckClose = "@isShowReCheckClose" == "True";
</script>
<script src="~/front/calendar?v=@(HtmlUtil.JsVersion)"></script>
<script src="~/Scripts/fast/fastVue.components.js?v=@HtmlUtil.JsVersion"></script>
<script src="~/front/swappriceprecision?v=@(HtmlUtil.JsVersion)"></script>
<script src="~/Scripts/app/swaptrade/swapPricePrecisionHelper.js?v=@HtmlUtil.JsVersion"></script>
<script src="~/Scripts/app/swaptrade/unwindLongShort.js?v=@HtmlUtil.JsVersion"></script>
}
<div class="pb-3" id="vueDiv">
<div class="yc-panel">
<div id="commomArea" class="row" style="height:140px">
<div class="form-group col-md-3">
<label class="formlabel">成交名义本金</label>
<input class="text-box" :value="formatAmount(deal.NotionalValue)" readonly="readonly" type="text" />
</div>
<div class="form-group col-md-3">
<label class="formlabel">持仓名义本金</label>
<input class="text-box" :value="formatAmount(deal.PosiNotionalValue)" readonly="readonly" type="text" />
</div>
<div class="form-group col-md-3">
<label class="formlabel">成交数量</label>
<input class="text-box" :value="formatQuantity(deal.NotionalQty)" readonly="readonly" type="text" />
</div>
<div class="form-group col-md-3">
<label class="formlabel">持仓数量</label>
<input class="text-box" :value="formatQuantity(deal.PositionQty)" readonly="readonly" type="text" />
</div>
<div class="form-group col-md-3">
<label class="formlabel">起始日期</label>
<input class="text-box" id="startDate" readonly="readonly" type="text" v-model="deal.StartDate" />
</div>
<div class="form-group col-md-3">
<label class="formlabel">平仓日期</label>
<input class="text-box" id="DealDate" readonly="readonly" type="text" v-model="deal.ValueDate" />
</div>
<div class="form-group col-md-3">
<label class="formlabel">支付日期</label>
<vue-datepicker :mindate="minStartDate" :holiday="1" v-model="deal.PayDate" />
</div>
<div class="form-group col-md-3">
<label class="formlabel">年化天数</label>
<input class="text-box" v-model="deal.AnnualDays" readonly="readonly" type="text" />
</div>
<div class="form-group col-md-3">
<label class="formlabel">平仓总额</label>
<input class="text-box" :value="formatAmount(deal.SwapCloseAmount)" readonly="readonly" type="text" />
</div>
</div>
</div>
<div class="yc-panel">
<div class="row no-gutters" style="display:block;">
<div class="titleDiv">
<div class="titleHead"></div>
<div class="titleLabel"><label>预付金/预付金</label></div>
</div>
<div style="margin: 5px 0 0 12px">
<table class="table table-bordered ratetable" style="width:700px;">
<tbody>
<tr>
<td width="116px">收支方向</td>
<td>资金类别</td>
<td>应返还本金</td>
<td>利息金额</td>
<td>预付金/预付金平仓盈亏</td>
</tr>
<tr v-for="item in marginList">
<td :class="item.InterestDirection==1?'swapget':'swappay'">{{item.InterestDirection==1?"收取":"支付"}}</td>
<td>{{item.InterestModeStr}}</td>
<td>
<vue-number-input v-model="item.InterestPrincipal" v-bind:format="inputFormatEqvNotional" v-on:input="changeInterestAmount(item)"></vue-number-input>
</td>
<td>
<vue-number-input v-model="item.InterestAmount" v-bind:format="inputFormatEqvNotional" v-on:input="changeInterestAmount(item)"></vue-number-input>
</td>
<td>{{formatAmount(item.InterestClosePnL)}}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row no-gutters" style="display:block;">
<div class="titleDiv">
<div class="titleHead"></div>
<div class="titleLabel"><label>利息端</label></div>
</div>
<div style="margin: 5px 0 0 12px">
<table class="table table-bordered" style="width:750px;">
<tbody>
<tr>
<td>收支方向</td>
<td>利息金额</td>
<td>利息端平仓盈亏</td>
</tr>
<tr v-for="item in interestList">
<td :class="item.InterestDirection==1?'swapget':'swappay'">{{item.InterestDirection==1?"收取":"支付"}}</td>
<td>
<vue-number-input v-model="item.InterestAmount" v-bind:format="inputFormatEqvNotional" v-on:input="changeInterestAmount(item)"></vue-number-input>
</td>
<td>{{formatAmount(item.InterestClosePnL)}}</td>
</tr>
</tbody>
</table>
</div>
<div>
@if (isUseApproval)
{
<button class="btn btn-default swapclose" type="button" v-on:click="submitApproval('reject');">拒绝</button>
<button class="btn btn-primary swapsave" type="button" v-on:click="submitApproval('pass')">审批通过</button>
}
else
{
<button class="btn btn-default swapclose" type="button" onclick="layer.closeMe();">取消</button>
<button class="btn btn-primary swapsave" type="button" v-on:click="closeTrade">{{getSumbitText()}}</button>
}
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
-8
View File
@@ -141,10 +141,6 @@
{
@MyControls.Btn("平仓", string.Format("unWindSwapTrade('{0}')", tradeModel.EncryptId))
}
if (longShort && !hasPosition && tradeModel.CanSwapTradeUnwind() && CurUser.交易管理_交易平仓)
{
@MyControls.Btn("平仓", string.Format("unWindSwapLongShort('{0}')", tradeModel.EncryptId))
}
if (tradeModel.CanSwapTradeUnwind() && CurUser.交易管理_收益互换)
{
@MyControls.Btn("展期信息", string.Format("extensionTime('{0}')", tradeModel.EncryptId))
@@ -153,10 +149,6 @@
{
@MyControls.Btn("收益结算", string.Format("unWindSwap('{0}')", tradeModel.EncryptId))
}
if (longShort && hasPosition && tradeModel.CanSwapTradeUnwind() && CurUser.交易管理_收益互换)
{
@MyControls.Btn("收益结算", string.Format("unWindLongShortSwap('{0}')", tradeModel.EncryptId))
}
@if (CurUser.交易管理_交易续作)
{
@MyControls.Btn("续作", string.Format("renewTrade('{0}')", tradeModel.EncryptId))
@@ -43,43 +43,5 @@
"SwapMarginRebatePnl": 200,
"SwapMarginAmount": 40000
}
},
{
"id": "LONGSHORT_UNWIND",
"desc": "多空组合平仓(unwindLongShort):从0起,不含浮动盈亏(FloatPnlSum=0)",
"eventType": 4,
"deal": { "CloseQty": 0 },
"floatPosition": { "FloatPnlSum": 0, "PositionType": 1, "PayDirection": 1, "TradingFee": 0 },
"interestList": [],
"marginList": [
{ "InterestClosePnL": 150, "InterestDirection": 1, "InterestPrincipal": 20000 }
],
"expected": {
"SwapCloseAmount": 150,
"SwapRealizedPnL": 150,
"SwapMarginRebatePnl": 150,
"SwapMarginAmount": -20000
}
},
{
"id": "LONGSHORT_SWAP",
"desc": "多空组合互换(swapLongShort)SwapMarginAmount 用裸 InterestPrincipal(无符号) —— 已知差异",
"eventType": 5,
"deal": { "CloseQty": 0 },
"floatPosition": { "FloatPnlSum": 0, "PositionType": 1, "PayDirection": 1, "TradingFee": 0 },
"interestList": [],
"marginList": [
{ "InterestClosePnL": 100, "InterestDirection": 1, "InterestPrincipal": 18000 }
],
"expected": {
"SwapCloseAmount": 100,
"SwapRealizedPnL": 100,
"SwapMarginRebatePnl": 100,
"SwapMarginAmount": 18000
},
"knownDiscrepancies": {
"SwapMarginAmount": 36000
}
}
]
} ]
}
@@ -163,8 +163,6 @@ describe('swap price precision common wiring', () => {
edit: read('wwwroot/Scripts/app/swaptrade/swapTradeEdit.js'),
income: read('wwwroot/Scripts/app/swaptrade/incomeSwapTrade.js'),
unwind: read('wwwroot/Scripts/app/swaptrade/unwindSwapTrade.js'),
longShort: read('wwwroot/Scripts/app/swaptrade/swapLongShort.js'),
unwindLongShort: read('wwwroot/Scripts/app/swaptrade/unwindLongShort.js'),
view: read('wwwroot/Scripts/app/swaptrade/swapTradeView.js'),
flow: read('wwwroot/Scripts/app/swaptrade/SwapflowList.js'),
helper: precisionHelperSrc
@@ -2000,9 +2000,6 @@ const subView = (function (jqGridMgr) {
if (tradeType === "收益互换") {
srcurl = "/swaptrade2/SwapUnwind/?enid=" + encryptId;
if (StructureType=="多空组合") {
srcurl = "/swaptrade2/SwapLongShortUnwind/?enid=" + encryptId;
}
area = ["1300px", "720px"];
}
if (tradeType.indexOf("远期") >= 0) {
@@ -1,228 +0,0 @@
//otcformat禁止千分位分组
window.otcformat.options.disableGrouping = true;
const inputFormatEqvNotional = swapPricePrecision.getCommonInputFormat('amount', { append: '' });
const swapInstrumentType = (model.FlowEvents || []).find(item => item && item.UnderlyingInstrumentType)?.UnderlyingInstrumentType || model.UnderlyingInstrumentType || '';
const formatSwapAmount = value => swapPricePrecision.normalizeCommon('amount', value);
const formatSwapQuantity = value => swapPricePrecision.normalizeCommon('quantity', value, swapInstrumentType);
let ValueDate = model.ValueDate;
const vue = new Vue({
el: '#vueDiv',
data: {
deal: model,
interestList: [],
marginList: [],
},
computed: {
maxUnwindDate() {
return ValueDate;
},
minStartDate() {
return this.deal.StartDate;
}
},
created() {
this.initDeal();
this.setValueDate();
},
methods: {
formatAmount(value) {
return swapPricePrecision.formatCommon('amount', value);
},
formatQuantity(value) {
return swapPricePrecision.formatCommon('quantity', value, swapInstrumentType);
},
initDeal() {
this.interestList = model.FlowEvents.filter((item) => {
return item.InterestMode == 1 || item.InterestMode == 2 || item.InterestMode == 9;
});
this.marginList = model.FlowEvents.filter((item) => {
return item.InterestMode == 5 || item.InterestMode == 6;
});
},
setValueDate(e) {//修改平仓日期
if (e) {
this.deal.ValueDate = e;
this.deal.UnwindDate = e;
}
if (!isUseApproval) {
this.getInterestList();
} else {
this.dataFormat();
}
},
dataFormat() {
this.deal.NotionalValue = formatSwapAmount(this.deal.NotionalValue);
this.deal.PosiNotionalValue = formatSwapAmount(this.deal.PosiNotionalValue);
this.deal.NotionalQty = formatSwapQuantity(this.deal.NotionalQty);
this.deal.PositionQty = formatSwapQuantity(this.deal.PositionQty);
this.deal.SwapCloseAmount = formatSwapAmount(this.deal.SwapCloseAmount);
this.interestList.forEach(x => {
//x.Principal = formatSwapAmount(x.Principal);
//x.Rate = otcformat.fixed6(x.Rate);
x.InterestFee = formatSwapAmount(x.InterestFee);
x.InterestAmount = formatSwapAmount(x.InterestAmount);
x.InterestClosePnL = formatSwapAmount(x.InterestClosePnL);
//x.InterestStartDate = x.InterestStartDate ? x.InterestStartDate.substr(0, 10) : "";
//x.InterestEndDate = x.InterestEndDate ? x.InterestEndDate.substr(0, 10) : "";
});
this.marginList.forEach(x => {
x.InterestFee = formatSwapAmount(x.InterestFee);
x.InterestAmount = formatSwapAmount(x.InterestAmount);
x.InterestClosePnL = formatSwapAmount(x.InterestClosePnL);
});
},
changeInterestAmount(item) {//修改利息金额
let interestRatio = item.InterestDirection == 1 ? 1 : -1;
item.InterestClosePnL = formatSwapAmount(parseFloat(item.InterestAmount) * interestRatio + parseFloat(item.InterestFee));
this.calcCloseAmount();
},
calcCloseAmount() {//计算平仓总额=浮动收取+利息收取-浮动支付-利息支付
let thisObj = this;
thisObj.deal.SwapCloseAmount = 0;
thisObj.deal.SwapRealizedPnL = 0;
thisObj.deal.SwapMarginRebatePnl = 0;
thisObj.deal.SwapMarginAmount = 0;
this.interestList.forEach(x => {
/*let interestRatio = x.InterestDirection == 1 ? 1 : -1;*/
let interestAmount = parseFloat(x.InterestClosePnL);
thisObj.deal.SwapCloseAmount = parseFloat(thisObj.deal.SwapCloseAmount) + interestAmount;
thisObj.deal.SwapRealizedPnL = parseFloat(thisObj.deal.SwapRealizedPnL) + interestAmount;
});
this.marginList.forEach(x => {
let interestAmount = parseFloat(x.InterestClosePnL);
thisObj.deal.SwapCloseAmount = parseFloat(thisObj.deal.SwapCloseAmount) + interestAmount;
thisObj.deal.SwapMarginRebatePnl = parseFloat(thisObj.deal.SwapMarginRebatePnl) + interestAmount;
thisObj.deal.SwapRealizedPnL = parseFloat(thisObj.deal.SwapRealizedPnL) + interestAmount;
thisObj.deal.SwapMarginAmount = parseFloat(thisObj.deal.SwapMarginAmount) + parseFloat(x.InterestPrincipal);
});
thisObj.deal.SwapCloseAmount = formatSwapAmount(thisObj.deal.SwapCloseAmount);
thisObj.deal.SwapRealizedPnL = formatSwapAmount(thisObj.deal.SwapRealizedPnL);
thisObj.deal.SwapMarginRebatePnl = formatSwapAmount(thisObj.deal.SwapMarginRebatePnl);
thisObj.deal.SwapMarginAmount = formatSwapAmount(thisObj.deal.SwapMarginAmount);
},
getInterestList() {//根据平仓日期获取利息腿信息
var thisObj = this;
var postData = { valueDate: thisObj.deal.ValueDate, unwindDate: thisObj.deal.UnwindDate, tradeId: thisObj.deal.SwapTradeId, closePercent: 1, eventType: 3 }
main.post("/swaptrade2/GetUnwindInterestList", postData, { async: true }).done(function (resp) {
thisObj.interestList = resp.obj.filter((item) => {
return item.InterestMode == 1 || item.InterestMode == 2 || item.InterestMode == 9;
});
thisObj.marginList = resp.obj.filter((item) => {
return item.InterestMode == 5 || item.InterestMode == 6;
});
thisObj.calcCloseAmount();
thisObj.dataFormat();
});
},
incomeTrade() {//互换
var thisObj = this;
if (main.isEmpty(thisObj.deal.ValueDate)) {
main.message("请输入平仓日期");
return;
}
let reqObj = _.cloneDeep(thisObj.deal);
let marginCloneList = _.cloneDeep(thisObj.marginList);
reqObj.FlowEvents = _.cloneDeep(thisObj.interestList);
marginCloneList.forEach((item) => {
reqObj.FlowEvents.push(item);
})
var postData = { unwindData: reqObj };
var msg = "确认提交收益结算?";
var postUrl = "/swaptrade2/SwapLongShortJson";
if (g_isShowReCheckClose) {
msg = "确认提交收益结算审核?";
postUrl = "/swaptrade2/ApplyUnwind";
postData.eventType = 3;//互换3,平仓2
}
main.confirm(msg,
function () {
//重新计算百分比
var thisObj2 = thisObj;
main.post(postUrl, { unwindData: reqObj }).done(function (res) {
if (res.success) {
thisObj2.closetrade_cashWindow();
}
else {
try {
thisObj2.closetrade_cashWindow();
} catch (e) {
}
}
});
});
},
getSumbitText: function () {
return g_isShowReCheckClose ? "审核提交" : "保存";
},
submitApproval(status) {
var pop = '';
if (status === 'pass') {
pop = "确认通过审批?";
}
if (status === 'reject') {
pop = "确认拒绝?";
}
var confirmFunc = function (additionalProcessing) {
var pData = { tradeId: trade.id, status: status, text: "" };
if (!main.isEmpty(additionalProcessing)) {
pData.additionalProcessing = additionalProcessing;
}
var thisObj2 = thisObj;
main.post("/processtradelog/UpdateTradeProcessLog", pData).done(
function (data) {
if (data.obj && data.obj.proccessType == "AdditionalProcessing") {
if (data.obj.type == "LackOfMoney") {
var htmlContent = `<div style="padding:10px">${data.obj.message}</div>`;
var lackMoneyConfirmLayer = main.open2("提示",
htmlContent,
{
area: ["430px", "175px"],
btn: ['交易特批', '取消'],
yes: function (index, layero) {
var layerIndex = lackMoneyConfirmLayer;
main.confirm("客户资金或授信不足,强制成交会导致本机构产生风险!要继续审批通过?", function () {
layer.close(layerIndex);
confirmFunc("LackOfMoney");
});
},
cancel: function (index, layero) {
if (window.parent && window.parent.reloadtrade) {
thisObj2.closetrade_cashWindow();
}
(parent || window).layer.closeAll();
}
});
}
return;
}
(parent || window).main.message(data.msg);
try { thisObj2.closetrade_cashWindow(); }
catch (e) { }
if (parent) {
parent.layer.closeAll();
}
});
}
main.confirm(pop, confirmFunc);
},
closetrade_cashWindow: function () {
layer.closeMe('reloadData');
},
closeCurrentWindow: function () {
try {
if (window.parent && window.parent.reload) window.parent.reload();
} catch (e) {
}
try {
var layer = window.parent.layer;
layer.close(layer.getFrameIndex(window.name));
} catch (e) {
}
}
},
components: {
'vue-datepicker': FastVue.vueDatePicker(),
'vue-number-input': FastVue.vueNumberInput(),
}
});
@@ -330,46 +330,6 @@ function unWindSwap(id) {
}
});
}
function unWindSwapLongShort(id) {
var title = "交易平仓";
var srcurl = "/swaptrade2/SwapLongShortUnwind/?enid=" + id;
main.post("/swaptrade2/CheckEodTrade?enid=" + id).done(function (res) {
if (res.success) {
main.open(title,
srcurl,
{
area: ["1300px", "780px"],
end: function () {
if (window.parent && window.parent.reloadtrade) {
window.parent.reloadtrade();
}
}
});
} else {
main.message(res.message);
}
});
}
function unWindLongShortSwap(id) {
var title = "期间互换";
var srcurl = "/swaptrade2/SwapLongShortSwap/?enid=" + id;
main.post("/swaptrade2/CheckEodTrade?enid=" + id).done(function (res) {
if (res.success) {
main.open(title,
srcurl,
{
area: ["1300px", "780px"],
end: function () {
if (window.parent && window.parent.reloadtrade) {
window.parent.reloadtrade();
}
}
});
} else {
main.message(res.message);
}
});
}
function extensionTime(id) {
var title = "展期信息";
var srcurl = "/swaptrade2/ExtensionTime/?enid=" + id;
@@ -1,197 +0,0 @@
//otcformat禁止千分位分组
window.otcformat.options.disableGrouping = true;
const inputFormatEqvNotional = swapPricePrecision.getCommonInputFormat('amount', { append: '' });
const swapInstrumentType = (model.FlowEvents || []).find(item => item && item.UnderlyingInstrumentType)?.UnderlyingInstrumentType || model.UnderlyingInstrumentType || '';
const formatSwapAmount = value => swapPricePrecision.normalizeCommon('amount', value);
const formatSwapQuantity = value => swapPricePrecision.normalizeCommon('quantity', value, swapInstrumentType);
let dealDate = model.DealDate;
const vue = new Vue({
el: '#vueDiv',
data: {
deal: model,
interestList: [],
marginList: [],
oriClosePercent: model.ClosePercent
},
computed: {
minStartDate() {
return dealDate;
}
},
created() {
this.initDeal();
this.calcCloseAmount();
this.dataFormat();
},
methods: {
formatAmount(value) {
return swapPricePrecision.formatCommon('amount', value);
},
formatQuantity(value) {
return swapPricePrecision.formatCommon('quantity', value, swapInstrumentType);
},
initDeal() {
this.interestList = model.FlowEvents.filter((item) => {
return item.InterestMode == 1 || item.InterestMode == 2 || item.InterestMode == 9;
});
this.marginList = model.FlowEvents.filter((item) => {
return item.InterestMode == 5 || item.InterestMode == 6;
});
},
dataFormat() {
this.deal.NotionalValue = formatSwapAmount(this.deal.NotionalValue);
this.deal.PosiNotionalValue = formatSwapAmount(this.deal.PosiNotionalValue);
this.deal.NotionalQty = formatSwapQuantity(this.deal.NotionalQty);
this.deal.SwapCloseAmount = formatSwapAmount(this.deal.SwapCloseAmount);
this.deal.PositionQty = formatSwapQuantity(this.deal.PositionQty);
this.interestList.forEach(x => {
//x.Principal = formatSwapAmount(x.Principal);
//x.Rate = otcformat.fixed6(x.Rate);
x.InterestAmount = formatSwapAmount(x.InterestAmount);
x.InterestClosePnL = formatSwapAmount(x.InterestClosePnL);
//x.InterestStartDate = x.InterestStartDate ? x.InterestStartDate.substr(0, 10) : "";
//x.InterestEndDate = x.InterestEndDate ? x.InterestEndDate.substr(0, 10) : "";
});
this.marginList.forEach(x => {
x.InterestAmount = formatSwapAmount(x.InterestAmount);
x.InterestClosePnL = formatSwapAmount(x.InterestClosePnL);
});
},
changeInterestAmount(item) {//修改利息金额
let interestRatio = item.InterestDirection == 1 ? 1 : -1;
item.InterestClosePnL = formatSwapAmount(parseFloat(item.InterestAmount) * interestRatio+ parseFloat(item.InterestFee));
this.calcCloseAmount();
},
calcCloseAmount() {//计算平仓总额=浮动收取+利息收取-浮动支付-利息支付
let thisObj = this;
thisObj.deal.SwapCloseAmount = 0;
thisObj.deal.SwapRealizedPnL = 0;
thisObj.deal.SwapMarginRebatePnl = 0;
thisObj.deal.SwapMarginAmount = 0;
this.interestList.forEach(x => {
/*let interestRatio = x.InterestDirection == 1 ? 1 : -1;*/
let interestAmount = parseFloat(x.InterestClosePnL);
thisObj.deal.SwapCloseAmount = parseFloat(thisObj.deal.SwapCloseAmount) + interestAmount;
thisObj.deal.SwapRealizedPnL = parseFloat(thisObj.deal.SwapRealizedPnL) + interestAmount;
});
this.marginList.forEach(x => {
let interestAmount = parseFloat(x.InterestClosePnL);
let interestRatio = x.InterestDirection == 1 ? -1 : 1;
thisObj.deal.SwapCloseAmount = parseFloat(thisObj.deal.SwapCloseAmount) + interestAmount;
thisObj.deal.SwapMarginRebatePnl = parseFloat(thisObj.deal.SwapMarginRebatePnl) + interestAmount;
thisObj.deal.SwapRealizedPnL = parseFloat(thisObj.deal.SwapRealizedPnL) + interestAmount;
thisObj.deal.SwapMarginAmount = parseFloat(thisObj.deal.SwapMarginAmount) + parseFloat(x.InterestPrincipal) * interestRatio;
});
thisObj.deal.SwapCloseAmount = formatSwapAmount(thisObj.deal.SwapCloseAmount);
thisObj.deal.SwapRealizedPnL = formatSwapAmount(thisObj.deal.SwapRealizedPnL);
thisObj.deal.SwapMarginRebatePnl = formatSwapAmount(thisObj.deal.SwapMarginRebatePnl);
thisObj.deal.SwapMarginAmount = formatSwapAmount(thisObj.deal.SwapMarginAmount);
},
closeTrade() {//平仓
var thisObj = this;
let reqObj = _.cloneDeep(thisObj.deal);
let marginCloneList = _.cloneDeep(thisObj.marginList);
reqObj.FlowEvents = _.cloneDeep(thisObj.interestList);
marginCloneList.forEach((item) => {
reqObj.FlowEvents.push(item);
})
var postData = { unwindData: reqObj };
var msg = "确认提交平仓?";
var postUrl = "/swaptrade2/SwapLongShortUnwindJson";
if (g_isShowReCheckClose) {
msg = "确认提交平仓审核?";
postUrl = "/swaptrade2/ApplyUnwind";
postData.eventType = 2;//互换3,平仓2
}
main.confirm(msg,
function () {
//重新计算百分比
var thisObj2 = thisObj;
main.post(postUrl, postData).done(function (res) {
if (res.success) {
thisObj2.closetrade_cashWindow();
}
else {
try {
thisObj2.closetrade_cashWindow();
} catch (e) {
}
}
});
});
},
getSumbitText: function () {
return g_isShowReCheckClose ? "审核提交" : "保存";
},
submitApproval(status) {
var pop = '';
if (status === 'pass') {
pop = "确认通过审批?";
}
if (status === 'reject') {
pop = "确认拒绝?";
}
let thisObj = this;
var confirmFunc = function (additionalProcessing) {
var pData = { tradeId: thisObj.deal.SwapTradeId, status: status, text: "" };
if (!main.isEmpty(additionalProcessing)) {
pData.additionalProcessing = additionalProcessing;
}
var thisObj2 = thisObj;
main.post("/processtradelog/UpdateTradeProcessLog", pData).done(
function (data) {
if (data.obj && data.obj.proccessType == "AdditionalProcessing") {
if (data.obj.type == "LackOfMoney") {
var htmlContent = `<div style="padding:10px">${data.obj.message}</div>`;
var lackMoneyConfirmLayer = main.open2("提示",
htmlContent,
{
area: ["430px", "175px"],
btn: ['交易特批', '取消'],
yes: function (index, layero) {
var layerIndex = lackMoneyConfirmLayer;
main.confirm("客户资金或授信不足,强制成交会导致本机构产生风险!要继续审批通过?", function () {
layer.close(layerIndex);
confirmFunc("LackOfMoney");
});
},
cancel: function (index, layero) {
if (window.parent && window.parent.reloadtrade) {
thisObj2.closetrade_cashWindow();
}
(parent || window).layer.closeAll();
}
});
}
return;
}
(parent || window).main.message(data.msg);
try { thisObj2.closetrade_cashWindow(); }
catch (e) { }
if (parent) {
parent.layer.closeAll();
}
});
}
main.confirm(pop, confirmFunc);
},
closetrade_cashWindow: function () {
layer.closeMe('reloadData');
},
closeCurrentWindow: function () {
try {
if (window.parent && window.parent.reload) window.parent.reload();
} catch (e) {
}
try {
var layer = window.parent.layer;
layer.close(layer.getFrameIndex(window.name));
} catch (e) {
}
}
},
components: {
'vue-datepicker': FastVue.vueDatePicker(),
'vue-number-input': FastVue.vueNumberInput(),
}
});
@@ -731,9 +731,6 @@ function passorreinfo(eid, tradeType, status, isGroup, StructureType) {
else if (tradeType === "收益互换") {
weight = "95%";
url = "/swaptrade2/SwapUnwind/?enid=" + eid + "&isUseApproval=" + true;
if (StructureType == "多空组合") {
url = "/swaptrade2/SwapLongShortUnwind/?enid=" + eid + "&isUseApproval=" + true;
}
height = "800px";
}
else {
@@ -744,9 +741,6 @@ function passorreinfo(eid, tradeType, status, isGroup, StructureType) {
weight = "95%";
title = "互换审批";
url = "/swaptrade2/SwapIncome/?enid=" + eid + "&isUseApproval=" + true;
if (StructureType == "多空组合") {
url = "/swaptrade2/SwapLongShortSwap/?enid=" + eid + "&isUseApproval=" + true;
}
height = "800px";
}
else if (status === "行权待复核") {
@@ -883,9 +877,6 @@ function unWindSelect(id, tradeType, isReCheck, StructureType) {
});
} else if (tradeType == "收益互换") {
var url = "/swaptrade2/SwapUnwind/?enid=" + id + "&isUseApproval=" + true;;
if (StructureType == "多空组合") {
url = "/swaptrade2/SwapLongShortUnwind/?enid=" + id + "&isUseApproval=" + true;;
}
main.open(title, url, {
area: ["1300px", "720px"],
end: function () {