feat(fulfillment): 支持选号优先级、三皮肤联合资格捆绑与同角色共享租约

This commit is contained in:
yml
2026-11-28 11:26:24 +08:00
parent ef226c9041
commit 20314a2f1d
24 changed files with 2504 additions and 495 deletions
+29 -4
View File
@@ -87,10 +87,7 @@ def _collab_order_expected_role(
explicit = str(incoming_role or order.bind_game_role or "").strip()
if explicit:
return explicit
if (
order.source_type == SOURCE_TYPE_PLATFORM_FULFILLMENT
and order.source_task_id
):
if order.source_type == SOURCE_TYPE_PLATFORM_FULFILLMENT and order.source_task_id:
task = db.get(PlatformFulfillmentTask, int(order.source_task_id))
if task is not None and task.customer_role_name:
return str(task.customer_role_name or "").strip()
@@ -235,6 +232,34 @@ def _takeover_platform_lease_for_collab(
status_code=409,
code="account_lease_conflict",
)
all_lease_tasks = (
db.query(PlatformFulfillmentTask)
.filter(
PlatformFulfillmentTask.lease_id == int(lease.id),
PlatformFulfillmentTask.execution_status != "cancelled",
)
.with_for_update()
.all()
)
active_siblings = [
item
for item in all_lease_tasks
if int(item.id) != int(platform_task.id)
and item.execution_status not in {"completed", "cancelled"}
]
if active_siblings:
sibling_ids = ", ".join(f"#{item.id}" for item in active_siblings)
raise CollabError(
f"该账号同时被同角色其他进行中履约任务({sibling_ids})共享占用,暂不能直接接管",
status_code=409,
code="account_lease_conflict",
)
for item in all_lease_tasks:
if (
int(item.id) != int(platform_task.id)
and item.execution_status == "completed"
):
item.lease_id = None
blocking = (
db.query(DouyuTask)
.filter(