From 1a529387e77907f4b9727332a0ebfd0e71c858ff Mon Sep 17 00:00:00 2001 From: claw_bot Date: Tue, 10 Mar 2026 03:57:59 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=90=8D=E5=86=B2=E7=AA=81=E9=94=99=E8=AF=AF=20CS0136?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AssetManager.Services/PortfolioService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AssetManager.Services/PortfolioService.cs b/AssetManager.Services/PortfolioService.cs index 3ce4f24..84a88d3 100644 --- a/AssetManager.Services/PortfolioService.cs +++ b/AssetManager.Services/PortfolioService.cs @@ -375,19 +375,19 @@ public class PortfolioService : IPortfolioService if (request.type?.ToLower() == "sell") { // 校验是否有该持仓 - var position = _db.Queryable() + var existingPosition = _db.Queryable() .Where(pos => pos.PortfolioId == request.portfolioId && pos.StockCode == request.stockCode) .First(); - if (position == null) + if (existingPosition == null) { throw new Exception($"该组合中不存在标的 {request.stockCode},无法卖出"); } // 校验卖出数量不超过持仓数量 - if (request.amount > (double)position.Shares) + if (request.amount > (double)existingPosition.Shares) { - throw new Exception($"卖出数量不能超过持仓数量,当前持仓 {position.Shares} 份"); + throw new Exception($"卖出数量不能超过持仓数量,当前持仓 {existingPosition.Shares} 份"); } }