锁仓操作增加锁仓价位确认弹窗

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
fish
2026-07-27 10:09:35 +08:00
parent abc436514a
commit eb096d915d
2 changed files with 58 additions and 7 deletions
+23 -3
View File
@@ -80,6 +80,7 @@ def add_position(
round_id: int,
open_price: int = Form(...),
amp_threshold: int = Form(...),
lock_price: str = Form(""),
hands: int = Form(1),
db: Session = Depends(get_db),
):
@@ -87,12 +88,12 @@ def add_position(
if not r or r.status != "active":
return RedirectResponse("/positions/?error=轮次不存在或已结束", status_code=303)
lock_price = open_price + amp_threshold
final_lock = int(lock_price) if lock_price else open_price + amp_threshold
p = Position(
round_id=r.id,
open_price=open_price,
amp_threshold=amp_threshold,
lock_price=lock_price,
lock_price=final_lock,
hands=hands,
opened_at=date.today(),
)
@@ -102,9 +103,15 @@ def add_position(
@router.post("/{position_id}/lock")
def lock_position(position_id: int, db: Session = Depends(get_db)):
def lock_position(
position_id: int,
lock_price: str = Form(""),
db: Session = Depends(get_db),
):
p = db.query(Position).filter(Position.id == position_id).first()
if p and p.locked_count < p.hands:
if lock_price:
p.lock_price = int(lock_price)
p.locked_count += 1
db.commit()
return RedirectResponse("/positions/", status_code=303)
@@ -119,6 +126,19 @@ def unlock_position(position_id: int, db: Session = Depends(get_db)):
return RedirectResponse("/positions/", status_code=303)
@router.post("/{position_id}/update-lock-price")
def update_lock_price(
position_id: int,
lock_price: int = Form(...),
db: Session = Depends(get_db),
):
p = db.query(Position).filter(Position.id == position_id).first()
if p and p.locked_count == 0:
p.lock_price = lock_price
db.commit()
return RedirectResponse("/positions/", status_code=303)
@router.post("/{round_id}/close")
def close_round(
request: Request,