fix(fulfillment): 支持先分配后补角色或撞锁时的同角色自动合并改挂

This commit is contained in:
yml
2026-11-28 16:17:04 +08:00
parent 82f2cc21ac
commit f23ef42e67
5 changed files with 667 additions and 93 deletions
@@ -90,8 +90,12 @@ def save_customer_profile(
images.append(
{
"url": url[:2048],
"thumbnailUrl": str(item.get("thumbnail_url") or item.get("thumbnailUrl") or url)[:2048],
"objectKey": str(item.get("object_key") or item.get("objectKey") or "")[:512],
"thumbnailUrl": str(
item.get("thumbnail_url") or item.get("thumbnailUrl") or url
)[:2048],
"objectKey": str(item.get("object_key") or item.get("objectKey") or "")[
:512
],
}
)
if not images:
@@ -115,6 +119,17 @@ def save_customer_profile(
"homeImageCount": len(images),
},
)
if task.account_id and task.customer_role_name:
from .allocation import try_reallocate_task_to_same_role
try_reallocate_task_to_same_role(
db,
task=task,
current=_integration_actor(db),
role_name=task.customer_role_name,
trigger="customer_profile_saved",
commit=False,
)
if commit:
db.commit()
return customer_binding_out(db, task.id)
@@ -135,10 +150,11 @@ async def customer_start_binding(
raise HTTPException(status_code=409, detail="请先提交游戏角色和游戏主页截图")
if not task.account_id or not task.lease_id:
if (
task.execution_status == "manual_required"
and task.issue_code in {"binding_failed", "lease_expired", "role_changed"}
):
if task.execution_status == "manual_required" and task.issue_code in {
"binding_failed",
"lease_expired",
"role_changed",
}:
from .allocation import prepare_manual_allocation
prepare_manual_allocation(
@@ -218,7 +234,9 @@ def update_customer_profile_by_operator(
if task.execution_status in {"completed", "cancelled"}:
raise HTTPException(status_code=409, detail="订单已结束,不能修改客户资料")
if task.binding_status == "bound":
raise HTTPException(status_code=409, detail="角色已绑定确认,不能直接修改客户资料")
raise HTTPException(
status_code=409, detail="角色已绑定确认,不能直接修改客户资料"
)
if task.binding_status == "confirming":
raise HTTPException(status_code=409, detail="正在确认绑定中,请稍后再试")
@@ -293,6 +311,17 @@ def update_customer_profile_by_operator(
},
)
_emit_order_site_binding_state(db, task.id)
if task.execution_status != "manual_required" and task.binding_status != "bound":
from .allocation import try_reallocate_task_to_same_role
try_reallocate_task_to_same_role(
db,
task=task,
current=current,
role_name=new_role,
trigger="operator_profile_updated",
commit=False,
)
db.commit()
if reopened and task.execution_status == "ready":
from .auto_allocator import wake_auto_allocator