Merge branch 'main' of http://git.yiliantech.com/gitlab/otc-dev/zszq-trs
This commit is contained in:
@@ -34,7 +34,7 @@ namespace YLErp.Modules.SwapModule
|
||||
public class SwapTradeAutoService : YLBaseService
|
||||
{
|
||||
protected static IYcLogger Log = LogFactory.GetLogger(typeof(SwapTradeAutoService).FullName);
|
||||
private static string LongShortStructType = "定义文件型债券收益互换";
|
||||
private static string LongShortStructType = "普通债券类收益互换";
|
||||
public SwapTradeAutoService(OptUserInfo optUser) : base(optUser)
|
||||
{
|
||||
|
||||
@@ -450,7 +450,7 @@ namespace YLErp.Modules.SwapModule
|
||||
{
|
||||
return;
|
||||
}
|
||||
var swaptrades = DbContext.trade.Where(t => t.StructureType == "定义文件型债券收益互换"
|
||||
var swaptrades = DbContext.trade.Where(t => t.TradeType == "收益互换"
|
||||
&& t.TradeDate <= valueDate
|
||||
&& t.ValidState != ConsGlobal.InValid
|
||||
&& !ConsTrade.TradeCompleteStatus.Contains(t.TradeStatus)).ToList();
|
||||
|
||||
@@ -1556,17 +1556,9 @@ namespace YLErp.Modules.SwapModule
|
||||
throw new ServiceException("交易不存在");
|
||||
}
|
||||
bool backToBegin = td.TradeDate == valueDate;
|
||||
bool longshort = td.StructureType == ClientMarginTypeEnum.多空组合.ToString();
|
||||
var swapPositions = DbContext.swap_position.Where(x => x.SwapTradeId == tradeId && !x.Invalid).ToList();
|
||||
td.trade_extend = DbContext.trade_extend.FirstOrDefault(x => x.TradeId == td.id);
|
||||
if (longshort)
|
||||
{
|
||||
var anyTrade = DbContext.trade.FirstOrDefault(x => x.StructureType == ClientMarginTypeEnum.多空组合.ToString() && x.TradeStatus == "确认成交" && x.ValidState != ConsGlobal.InValid && x.id != tradeId && x.ClientId == td.ClientId);
|
||||
if (anyTrade != null)
|
||||
{
|
||||
throw new ServiceException($"{td.ClientName}存在存续期多空组合框架合约,不能回退");
|
||||
}
|
||||
}
|
||||
|
||||
//展期
|
||||
var swapEvent = DbContext.swap_event.Where(x => x.SwapTradeId == tradeId && x.EventType == (int)SwapEventTypeEnum.展期 && !x.Invalid && x.ValueDate <= valueDate).OrderByDescending(o => o.ValueDate).FirstOrDefault();
|
||||
var trans = DbContext.Database.BeginTransaction();
|
||||
@@ -1581,22 +1573,11 @@ namespace YLErp.Modules.SwapModule
|
||||
td.StockEqvNotional = td.OriginalStockEqvNotional ?? 0;
|
||||
td.UnWindDate = null;
|
||||
td.HasPartialUnWind = null;
|
||||
if (!longshort)
|
||||
{
|
||||
SingleTradeBackToBegin(td, swapPositions);
|
||||
}
|
||||
else
|
||||
{
|
||||
LongshortTradeBackToBegin(swapPositions);
|
||||
}
|
||||
SingleTradeBackToBegin(td, swapPositions);
|
||||
}
|
||||
else
|
||||
{
|
||||
TradeBackByDate(td, valueDate, swapPositions, longshort);
|
||||
}
|
||||
if (longshort)
|
||||
{
|
||||
new SwapFlowService(this).ResetFlows(td.ClientId, valueDate);
|
||||
TradeBackByDate(td, valueDate, swapPositions);
|
||||
}
|
||||
if (swapEvent != null)//展期
|
||||
{
|
||||
@@ -1727,7 +1708,7 @@ namespace YLErp.Modules.SwapModule
|
||||
/// </summary>
|
||||
/// <param name="td"></param>
|
||||
/// <param name="swapEvent"></param>
|
||||
private void TradeBackByDate(trade td, DateTime valueDate, List<swap_position> swapPositions, bool longshort)
|
||||
private void TradeBackByDate(trade td, DateTime valueDate, List<swap_position> swapPositions)
|
||||
{
|
||||
SwapEodPositionService eodPositionService = new SwapEodPositionService(this);
|
||||
SwapDealService swapDealService = new SwapDealService(this);
|
||||
|
||||
Reference in New Issue
Block a user