diff --git a/YLErpDAL/Modules/SwapModule/SwapFlowService.cs b/YLErpDAL/Modules/SwapModule/SwapFlowService.cs index 430a5e53..ba2eb4b1 100644 --- a/YLErpDAL/Modules/SwapModule/SwapFlowService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapFlowService.cs @@ -9,6 +9,7 @@ using YLErp.DBModels; using YLErp.Helpers; using YLErp.Model; using YLErp.Model.Enum; +using YLErp.Modules.EodModule; using YLErp.Modules.SwapModule.Dto; using YLErp.Office; using YLErp.QdpModule; @@ -79,8 +80,13 @@ namespace YLErp.Modules.SwapModule /// public bool AddOrUpdateFRdata(Double price, DateTime dateTime) { - string beforedate = ""; var frdata = DbContext.eod_commodity_future_price.Where(a => a.ValueDate == dateTime && a.UnderlyingCode == "FR007").FirstOrDefault(); + var frUnderlying = DbContext.underlying_manager.FirstOrDefault(a => a.UnderlyingCode == "FR007"); + if (frUnderlying == null) + { + throw new ServiceException("找不到FR007的标的"); + } + if (frdata == null) { frdata = new eod_commodity_future_price(); @@ -91,28 +97,17 @@ namespace YLErp.Modules.SwapModule frdata.ValueDate = dateTime; frdata.HighPrice = 0; frdata.LowPrice = 0; - beforedate = JsonHelper.Serialize(frdata); } else { //新增 - var newestdata = DbContext.eod_commodity_future_price.OrderByDescending(a => a.ValueDate).FirstOrDefault(); - if (newestdata == null) - { - var underlyingCode = DbContext.underlying_manager.Where(a => a.UnderlyingCode == "FR007").FirstOrDefault(); - if (underlyingCode == null) - { - throw new ServiceException("找不到FR007的标的"); - } - newestdata = new eod_commodity_future_price(); - newestdata.UnderlyingId = underlyingCode.id; - } frdata.ValueDate = dateTime; frdata.UnderlyingCode = "FR007"; - frdata.UnderlyingId = newestdata.UnderlyingId; + frdata.UnderlyingId = frUnderlying.id; frdata.DataSource = EodPriceBase.人工; DbContext.Add(frdata); } + frdata.UnderlyingId = EodPriceService.ResolveUnderlyingIdForCode(frdata.UnderlyingCode, frdata.UnderlyingId ?? 0, frUnderlying.id); frdata.ClosePrice = Math.Round(price, 4); frdata.SettlePrice = Math.Round(price, 4); frdata.ReferencePrice = Math.Round(price, 4);