27 lines
1.2 KiB
Python
27 lines
1.2 KiB
Python
"""证面总量更正与流水查询,不提供直接修改余额入口。"""
|
|
from fastapi import HTTPException
|
|
from app.models.pl_quota_models import PlCertQtyLog
|
|
from app.schemas.pl.quota_usage import UsageRequest
|
|
from app.services.pl_quota_cert_service import _get_row, _row_to_dict
|
|
from app.services.pl_quota_usage_service import execute_usage
|
|
from app.services.pl_quota_attachments import authorize_attachment
|
|
|
|
|
|
def adjust_total(db, user, kind, cert_id, body):
|
|
_get_row(db, user, kind, cert_id)
|
|
for url in filter(None, body.evidence_urls.split(',')):
|
|
authorize_attachment(db, user, url.strip())
|
|
request = UsageRequest(action='total_adjust', cert_type=kind, cert_id=cert_id,
|
|
**body.model_dump())
|
|
try:
|
|
return execute_usage(db, user, request)
|
|
except ValueError as error:
|
|
raise HTTPException(409, str(error)) from error
|
|
|
|
|
|
def list_logs(db, user, kind, cert_id):
|
|
_get_row(db, user, kind, cert_id)
|
|
rows = db.query(PlCertQtyLog).filter_by(tenant_no=user.tenant_no, cert_type=kind,
|
|
cert_id=cert_id, del_flag=0).order_by(PlCertQtyLog.create_time.desc()).all()
|
|
return [_row_to_dict(row) for row in rows]
|