fix: 修复变量名冲突错误 CS0136

This commit is contained in:
claw_bot 2026-03-10 03:57:59 +00:00
parent a23937eac8
commit 1a529387e7

View File

@ -375,19 +375,19 @@ public class PortfolioService : IPortfolioService
if (request.type?.ToLower() == "sell") if (request.type?.ToLower() == "sell")
{ {
// 校验是否有该持仓 // 校验是否有该持仓
var position = _db.Queryable<Position>() var existingPosition = _db.Queryable<Position>()
.Where(pos => pos.PortfolioId == request.portfolioId && pos.StockCode == request.stockCode) .Where(pos => pos.PortfolioId == request.portfolioId && pos.StockCode == request.stockCode)
.First(); .First();
if (position == null) if (existingPosition == null)
{ {
throw new Exception($"该组合中不存在标的 {request.stockCode},无法卖出"); 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} 份");
} }
} }