fix(douyu): 按到期时间修正精英宝典状态
This commit is contained in:
@@ -13,6 +13,10 @@ from core.douyu import DouyuActivityClient, DouyuActivityError
|
||||
from ..models import Account, DouyuTask
|
||||
from .account_events_service import EVENT_ELITE_OPENED, EVENT_ESPORTS_OPENED, emit
|
||||
from .douyu_activity_query import query_csrf, query_elite_user_info, query_points
|
||||
from .douyu_elite_status import (
|
||||
elite_is_currently_open,
|
||||
normalize_elite_expire_time,
|
||||
)
|
||||
from .douyu_runner_core import DOUYU_PAYMENT_POLL_INTERVAL, DOUYU_PAYMENT_POLL_SECONDS
|
||||
from .douyu_service import account_uid, update_account_profile_from_cookie
|
||||
|
||||
@@ -77,14 +81,15 @@ class ManualMixin:
|
||||
) -> dict:
|
||||
"""查询精英宝典开通状态(manualType/expireTime)并写回账号。
|
||||
|
||||
积分区分不了「开通后积分花完」和「从未开通」,manualType 才是权威口径:
|
||||
0=未开通,>=1=已开通。
|
||||
积分区分不了「开通后积分花完」和「从未开通」。manualType >= 1
|
||||
表示开通过,expireTime 决定当前是否仍有效;已到期必须按未开通处理。
|
||||
"""
|
||||
result = query_elite_user_info(client, manual_id=manual_id, rid=rid)
|
||||
manual_type = self._to_int(result.get("manual_type")) or 0
|
||||
manual_score = self._to_int(result.get("manual_score"))
|
||||
expire_time = self._to_int(result.get("expire_time")) or 0
|
||||
opened = manual_type >= 1
|
||||
expire_time = normalize_elite_expire_time(result.get("expire_time")) or 0
|
||||
opened = elite_is_currently_open(manual_type, expire_time)
|
||||
expired = manual_type >= 1 and not opened
|
||||
account.elite_opened = opened
|
||||
account.elite_expire_time = expire_time or None
|
||||
if manual_score is not None:
|
||||
@@ -95,6 +100,7 @@ class ManualMixin:
|
||||
"elite_manual_score": manual_score,
|
||||
"elite_expire_time": expire_time,
|
||||
"elite_opened": opened,
|
||||
"elite_expired": expired,
|
||||
"elite_user_info": result,
|
||||
"points": manual_score,
|
||||
}
|
||||
@@ -115,7 +121,11 @@ class ManualMixin:
|
||||
rid=str(config.get("rid") or ""),
|
||||
)
|
||||
account.updated_at = datetime.now(UTC)
|
||||
state = "已开通" if result["elite_opened"] else "未开通"
|
||||
state = (
|
||||
"已过期"
|
||||
if result["elite_expired"]
|
||||
else ("已开通" if result["elite_opened"] else "未开通")
|
||||
)
|
||||
expire_text = self._format_expire_text(result["elite_expire_time"])
|
||||
points = result["elite_manual_score"]
|
||||
self._mark_task(
|
||||
|
||||
Reference in New Issue
Block a user