feat(accounts): 统一可换绑时间并加本地 7 天锁
- 新增官方时间、本地 bind_ok、7 天锁到期、检查时间和来源字段 - role_change_available_at 改为官方时间与本地锁取较晚者 - 绑定成功和官方探测统一写有效时间 - 分配过滤增加最近 elite bind_ok 的数据库兜底 - 迁移 0129 从 account_events 回填历史账号 - 补充字段/回填过滤测试和生命周期文档
This commit is contained in:
@@ -285,6 +285,33 @@ def role_change_available_at(
|
||||
return None
|
||||
|
||||
|
||||
#: 本地规则:同一斗鱼账号 7 天内只能绑定一个精英角色。
|
||||
ROLE_BIND_LOCK = timedelta(days=7)
|
||||
|
||||
|
||||
def role_bind_lock_until(last_bind_ok_at: datetime | None) -> datetime | None:
|
||||
if last_bind_ok_at is None:
|
||||
return None
|
||||
return last_bind_ok_at + ROLE_BIND_LOCK
|
||||
|
||||
|
||||
def effective_role_change_available_at(
|
||||
*,
|
||||
official_at: datetime | None,
|
||||
last_bind_ok_at: datetime | None,
|
||||
) -> datetime | None:
|
||||
"""官方可换绑时间与本地 7 天锁取较晚者。
|
||||
|
||||
分配/人工选号只看这个结果;官方时间早于本地锁时,本地锁优先。
|
||||
"""
|
||||
candidates = [
|
||||
value
|
||||
for value in (official_at, role_bind_lock_until(last_bind_ok_at))
|
||||
if value is not None
|
||||
]
|
||||
return max(candidates) if candidates else None
|
||||
|
||||
|
||||
BindCooldownKind = Literal["platform", "customer"]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user