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} 份"); } }