From 94ab27d5e694572e892bfeb78deb25e1409abd91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=B9=E6=B5=B7?= Date: Mon, 21 Apr 2025 11:06:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E7=9B=98=E6=94=B9=E5=9B=9E=E5=8F=8C?= =?UTF-8?q?=E5=80=8D=E8=B4=B9=E7=94=A8=EF=BC=8C=E9=BB=91=E5=90=8D=E5=8D=95?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=9B=B4=E6=8E=A5=E9=80=9A=E7=9F=A5=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF=E4=B8=8D=E5=8F=AF=E4=B8=8B=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ClientModule/ClientBlackService.cs | 21 +++++++++++++++++-- .../SwapModule/SwapEodPositionService.cs | 6 +++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/YLErpDAL/Modules/ClientModule/ClientBlackService.cs b/YLErpDAL/Modules/ClientModule/ClientBlackService.cs index 5c5e085a..894dec2a 100644 --- a/YLErpDAL/Modules/ClientModule/ClientBlackService.cs +++ b/YLErpDAL/Modules/ClientModule/ClientBlackService.cs @@ -1,6 +1,10 @@ using BaseOUDAL; +using Microsoft.Extensions.DependencyInjection; +using Org.BouncyCastle.Crypto.Tls; using Qdp.Foundation.Utilities; using System.Data; +using YieldChain.Commons; +using YLErp.Abstract; using YLErp.Commons; using YLErp.Model; using YLErp.Models.Tag; @@ -14,9 +18,10 @@ namespace YLErp.Modules.ClientModule /// public class ClientBlackService : ClientBaseService { + private IKafkaProduce _kafkaProduce; public ClientBlackService(OptUserInfo userInfo) : base(userInfo) { - + _kafkaProduce = YLServiceLocator.ServiceProvider.GetService(); } /// @@ -188,6 +193,8 @@ namespace YLErp.Modules.ClientModule throw new ServiceException(msg); } } + // 在外部定义列表来保存需要通知的客户对 + var clientsToNotify = new List<(Client oldClient, Client newClient)>(); foreach (var item in list) { if (string.IsNullOrWhiteSpace(item.Name)) @@ -205,6 +212,7 @@ namespace YLErp.Modules.ClientModule var dt = DateTime.Now; if (clientexistence.ProcessStatus == "已开户") { + var oldClient= clientexistence.Clone(); clientexistence.ProcessOrderId = -4; clientexistence.ProcessStatus = "已休眠"; clientexistence.OptId = UserId; @@ -221,6 +229,11 @@ namespace YLErp.Modules.ClientModule OptName = UserName, OptDate = dt }); + // 如果原有状态是已开户,添加到通知列表 + if (oldClient != null) + { + clientsToNotify.Add((oldClient, clientexistence)); + } } ///日志记录 DbContext.ClientAuditLog.Add(new ClientAuditLog @@ -242,7 +255,11 @@ namespace YLErp.Modules.ClientModule } DbContext.client_black.AddRange(list); DbContext.SaveChanges(); - + // 发送Kafka消息 + foreach (var (oldClient, newClient) in clientsToNotify) + { + new ClientKafkaService(_kafkaProduce).Send(newClient, oldClient); + } var importHasTagClientNames = list.Where(p => p.Tags != null && p.Tags.Count > 0).Select(p => p.Name).Distinct().ToList(); if (importHasTagClientNames != null && importHasTagClientNames.Count > 0) { diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs index 6a7f52aa..f07f15f8 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs @@ -1151,7 +1151,7 @@ namespace YLErp.Modules.SwapModule curretEod.PosiMtmPnL = (curretEod.UnderlyingPrice - curretEod.PosiGrossPrice) * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio * directionRatio; curretEod.TdPosiDividend = 0; curretEod.PosiDividendSum = eod.PosiDividendSum + curretEod.TdPosiDividend; - curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum+ curretEod.PosiFeePending; + curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum+ curretEod.VTradingFee; curretEod.TdCloseFee = 0; curretEod.TdCloseQty = 0; curretEod.TdCloseMtmPnl = 0; @@ -1215,7 +1215,7 @@ namespace YLErp.Modules.SwapModule curretEod.UnderlyingMarketValue = curretEod.UnderlyingPrice * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio; curretEod.PosiMtmPnL = (curretEod.UnderlyingPrice - curretEod.PosiGrossPrice) * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio * directionRatio; curretEod.PosiDividendSum = eod.PosiDividendSum + curretEod.TdPosiDividend; - curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum + curretEod.PosiFeePending; + curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum + curretEod.VTradingFee; curretEod.RealizedMtmPnL = eod.RealizedMtmPnL + curretEod.TdCloseMtmPnl; curretEod.RealizedDividend = eod.RealizedDividend + curretEod.TdCloseDividend; curretEod.RealizedFee = eod.RealizedFee + curretEod.TdCloseFee; @@ -1356,7 +1356,7 @@ namespace YLErp.Modules.SwapModule curretEod.TdCloseDividend = curretEod.TdPosiDividend; curretEod.UnderlyingMarketValue = curretEod.UnderlyingPrice * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio; curretEod.PosiMtmPnL = (curretEod.UnderlyingPrice - curretEod.PosiGrossPrice) * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio * directionRatio; - curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum + curretEod.PosiFeePending; + curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum + curretEod.VTradingFee; curretEod.RealizedMtmPnL = curretEod.TdCloseMtmPnl; curretEod.RealizedDividend = curretEod.TdCloseDividend; curretEod.RealizedFee = curretEod.TdCloseFee;