From c49f93dcd978e3df8809ffffed44aa868b95618e Mon Sep 17 00:00:00 2001 From: wwwwwwwww <526125649@qq.com> Date: Mon, 6 Jul 2026 18:35:41 +0800 Subject: [PATCH] 1 --- video-gen-api/app/api/v1/team.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/video-gen-api/app/api/v1/team.py b/video-gen-api/app/api/v1/team.py index 6bf2fe53..12e1f8fb 100644 --- a/video-gen-api/app/api/v1/team.py +++ b/video-gen-api/app/api/v1/team.py @@ -347,7 +347,13 @@ async def export_team_credit_records( # 生成 CSV(兼容 Excel 打开) import csv import io - from datetime import datetime + + def _format_dt(val): + if val is None: + return "-" + if isinstance(val, datetime): + return val.strftime("%Y-%m-%d %H:%M:%S") + return str(val) output = io.StringIO() writer = csv.writer(output) @@ -360,12 +366,12 @@ async def export_team_credit_records( item.get("amount", 0), item.get("balance_after", 0), item.get("description") or "-", - datetime.fromisoformat(item.get("created_at") or "-").strftime("%Y-%m-%d %H:%M:%S"), + _format_dt(item.get("created_at")), ]) from starlette.responses import StreamingResponse output.seek(0) - filename = f"team_credits_{team.id}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" + filename = f"团队积分_{team.name}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" return StreamingResponse( iter([output.getvalue()]), media_type="text/csv; charset=utf-8-sig",