feat: quotation credit deduction + production restart
- Quotation generate-from-inquiry deducts 2 credits - Backend restarted and verified API endpoints work - Credit seed data committed to database - All credit APIs returning correct data
This commit is contained in:
@@ -6,6 +6,7 @@ from app.database import get_db
|
||||
from app.services.quotation import QuotationService
|
||||
from app.services.pdf_generator import pdf_generator
|
||||
from app.services import export
|
||||
from app.services.credit import CreditService
|
||||
from app.api.v1.deps import get_current_user_id
|
||||
from app.models.quotation import Quotation
|
||||
from app.models.customer import Customer
|
||||
@@ -35,6 +36,14 @@ async def generate_from_inquiry(
|
||||
user_id: str = Depends(get_current_user_id),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
credit_svc = CreditService(db)
|
||||
ok, balance = await credit_svc.deduct(user_id, "quotation")
|
||||
if not ok:
|
||||
raise HTTPException(
|
||||
status_code=402,
|
||||
detail=f"次数不足 (剩余 {balance:.1f}, 需要 2)"
|
||||
)
|
||||
|
||||
service = QuotationService(db)
|
||||
result = await service.generate_from_inquiry(
|
||||
user_id=user_id,
|
||||
|
||||
Reference in New Issue
Block a user