发布(0.4.6): 修复预售兑换记录判定与详情展示并新增工作台强制发放

This commit is contained in:
yml
2026-11-27 14:50:45 +08:00
parent 5006367217
commit e25e35994d
22 changed files with 1118 additions and 38 deletions
+22 -1
View File
@@ -19,6 +19,7 @@ from .binding_ownership import (
BINDING_TASK_TYPES,
WORKBENCH_GOODS_MUTATION_TYPES,
active_fulfillment_binding_task_id,
workbench_force_goods_inspection,
workbench_task_occupation_error,
)
from .douyu_binding import resolve_douyu_binding
@@ -359,6 +360,7 @@ def create_douyu_planned_tasks(
enqueue_execution: bool = True,
recharge_channel: str = "",
recharge_amount: int | None = None,
force_occupied: bool = False,
) -> tuple[str, int]:
"""创建斗鱼任务记录,等待后台执行器消费。"""
if task_type not in SUPPORTED_DOUYU_TASK_TYPES:
@@ -371,6 +373,13 @@ 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)
allow_force_goods = (
bool(force_occupied)
and platform_task_id is None
and handbook_scope == "elite"
and task_type in WORKBENCH_GOODS_MUTATION_TYPES
)
forced_payloads: dict[int, dict] = {}
if (
platform_task_id is None
and handbook_scope == "elite"
@@ -384,9 +393,18 @@ def create_douyu_planned_tasks(
handbook_scope=handbook_scope,
platform_task_id=platform_task_id,
allow_auto_link=True,
force_occupied=allow_force_goods,
)
if occupation_error:
raise DouyuLeaseConflictError(occupation_error)
if allow_force_goods:
inspection = workbench_force_goods_inspection(db, account)
if inspection["occupied"]:
forced_payloads[int(account.id)] = {
"force_occupied": True,
"force_expected_role": inspection["account_role"],
"force_platform_task_id": inspection["platform_task_id"],
}
if (
task_type in {"refresh_esports_goods", "refresh_xpd_goods"}
and accounts
@@ -412,6 +430,9 @@ def create_douyu_planned_tasks(
db,
account.id,
)
account_payload = dict(payload)
if int(account.id) in forced_payloads:
account_payload.update(forced_payloads[int(account.id)])
task = DouyuTask(
batch_id=batch_id,
account_id=account.id,
@@ -420,7 +441,7 @@ def create_douyu_planned_tasks(
handbook_scope=handbook_scope,
status="planned",
message="任务已创建,等待执行",
result={"payload": payload} if payload else None,
result={"payload": account_payload} if account_payload else None,
created_by=created_by,
platform_task_id=linked_platform_task_id,
recharge_channel=recharge_channel,