From fb5a5d0ab4d2195c591e885b832152080f18812b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=90=8D=E9=94=90?= <1565842059@qq.com> Date: Fri, 7 Aug 2026 19:44:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(swap):=20=E4=BF=AE=E5=A4=8DFR007=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=B7=BB=E5=8A=A0=E6=97=B6=E7=9A=84=E6=A0=87=E7=9A=84?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E5=92=8C=E5=85=B3=E8=81=94=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加对FR007标的存在的验证检查 - 移除冗余的新增数据查询逻辑 - 直接使用查找到的标的ID进行关联 - 集成EodPriceService中的标的ID解析逻辑 - 统一数据源设置为人工来源 --- .../Modules/SwapModule/SwapFlowService.cs | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) 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);