修复(履约与分配): 封堵工作台换绑、预售共号与分配中心越权占用

This commit is contained in:
yml
2026-11-27 13:42:28 +08:00
parent 9100991cb1
commit 5006367217
13 changed files with 1031 additions and 34 deletions
+26 -1
View File
@@ -15,7 +15,12 @@ from core.douyu.cookie_utils import cookie_value
from ..models import Account, DouyuConfig, DouyuTask
from . import account_query_filters as account_filters
from .account_events_service import CATEGORY_ACTIVITY, EVENT_TASK_STARTED, emit_bulk
from .binding_ownership import BINDING_TASK_TYPES, active_fulfillment_binding_task_id
from .binding_ownership import (
BINDING_TASK_TYPES,
WORKBENCH_GOODS_MUTATION_TYPES,
active_fulfillment_binding_task_id,
workbench_task_occupation_error,
)
from .douyu_binding import resolve_douyu_binding
LOGIN_ATTEMPT_IN_FLIGHT_STATUSES = account_filters.LOGIN_ATTEMPT_IN_FLIGHT_STATUSES
@@ -168,6 +173,10 @@ class DouyuActivePaymentError(ValueError):
"""同一账号已有未结束的充值任务。"""
class DouyuLeaseConflictError(ValueError):
"""账号当前被履约订单或预售台账占用,禁止从工作台发起冲突操作。"""
class DouyuTaskBackpressureError(ValueError):
"""全局活跃斗鱼任务超过安全上限。"""
@@ -362,6 +371,22 @@ def create_douyu_planned_tasks(
accounts = visible_douyu_task_accounts(db, account_ids)
_ensure_active_task_budget(db, len(accounts))
_lock_payment_accounts(db, accounts, task_type)
if (
platform_task_id is None
and handbook_scope == "elite"
and task_type in (BINDING_TASK_TYPES | WORKBENCH_GOODS_MUTATION_TYPES)
):
for account in accounts:
occupation_error = workbench_task_occupation_error(
db,
account,
task_type=task_type,
handbook_scope=handbook_scope,
platform_task_id=platform_task_id,
allow_auto_link=True,
)
if occupation_error:
raise DouyuLeaseConflictError(occupation_error)
if (
task_type in {"refresh_esports_goods", "refresh_xpd_goods"}
and accounts