feat(douyu): 查询工作台增加宝典状态与到期时间 (v0.4.28)

This commit is contained in:
yml
2026-11-30 18:25:20 +08:00
parent a3529c54a2
commit ecb987fff0
8 changed files with 168 additions and 19 deletions
+26
View File
@@ -1303,6 +1303,27 @@ def _csv_safe_cell(value: Any) -> Any:
return value
def _elite_status_label(account: Account, now_seconds: int) -> str:
expire_time = int(account.elite_expire_time or 0)
if expire_time > 0 and expire_time <= now_seconds:
return "已过期"
if account.elite_opened is True:
return "已开通"
if account.elite_opened is False:
return "未开通"
return "未查询"
def _format_shanghai_unix_seconds(value: int | None) -> str:
if value is None or int(value) <= 0:
return ""
return (
datetime.fromtimestamp(int(value), tz=UTC)
.astimezone(_SHANGHAI_TZ)
.strftime("%Y-%m-%d %H:%M:%S")
)
@router.post("/query-workbench/lookup")
def lookup_query_workbench_accounts(
req: DouyuQueryWorkbenchLookupRequest,
@@ -1559,6 +1580,7 @@ def export_query_workbench_csv(
ordered_accounts = [rows_by_id[aid] for aid in requested_ids if aid in rows_by_id]
now = datetime.now(UTC)
now_seconds = int(now.timestamp())
output = io.StringIO()
writer = csv.writer(output)
writer.writerow(
@@ -1575,6 +1597,8 @@ def export_query_workbench_csv(
"兑换余额",
"积分",
"积分到期时间",
"宝典状态",
"宝典到期时间",
"绑定状态",
"绑定角色",
"绑定渠道",
@@ -1644,6 +1668,8 @@ def export_query_workbench_csv(
acc.exchange_balance if acc.exchange_balance is not None else "",
acc.points if acc.points is not None else "",
_format_shanghai_dt(acc.points_expire_at),
_elite_status_label(acc, now_seconds),
_format_shanghai_unix_seconds(acc.elite_expire_time),
bind_label,
acc.game_name or "",
acc.game_channel or "",