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:
TradeMate Dev
2026-06-12 11:07:08 +08:00
parent a95e8b2b73
commit 79474d8480
+9
View File
@@ -6,6 +6,7 @@ from app.database import get_db
from app.services.quotation import QuotationService from app.services.quotation import QuotationService
from app.services.pdf_generator import pdf_generator from app.services.pdf_generator import pdf_generator
from app.services import export from app.services import export
from app.services.credit import CreditService
from app.api.v1.deps import get_current_user_id from app.api.v1.deps import get_current_user_id
from app.models.quotation import Quotation from app.models.quotation import Quotation
from app.models.customer import Customer from app.models.customer import Customer
@@ -35,6 +36,14 @@ async def generate_from_inquiry(
user_id: str = Depends(get_current_user_id), user_id: str = Depends(get_current_user_id),
db: AsyncSession = Depends(get_db), 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) service = QuotationService(db)
result = await service.generate_from_inquiry( result = await service.generate_from_inquiry(
user_id=user_id, user_id=user_id,