修复(履约绑定): 后台人工绑定也必须先有客户游戏资料
- 工作台 start/confirm/代确认/强制确认入口统一校验角色和主页截图 - 仅 clean 任务强制,历史任务保持兼容 - 补充后台绑定资料校验测试
This commit is contained in:
@@ -3856,6 +3856,15 @@ class TestBindingAndCompletion(_Base):
|
||||
assert captured["job_type"] == "douyu_binding"
|
||||
assert captured["batch_id"].startswith(f"pfbind-{task.id}-")
|
||||
|
||||
def test_admin_binding_requires_game_home_profile(self):
|
||||
task = self._allocated()
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
service.ensure_customer_profile_for_binding(self.session, task_id=task.id)
|
||||
assert exc_info.value.status_code == 409
|
||||
|
||||
self.complete_customer_profile(task)
|
||||
service.ensure_customer_profile_for_binding(self.session, task_id=task.id)
|
||||
|
||||
def test_customer_start_requires_game_home_profile(self):
|
||||
task = self._allocated()
|
||||
|
||||
@@ -3876,6 +3885,9 @@ class TestBindingAndCompletion(_Base):
|
||||
)
|
||||
barrier = threading.Barrier(2)
|
||||
errors: list[BaseException] = []
|
||||
first_session = make_test_session(self.engine)
|
||||
first_admin = first_session.get(User, self.admin_id)
|
||||
assert first_admin is not None
|
||||
other_session = make_test_session(self.engine)
|
||||
other_admin = other_session.get(User, self.admin_id)
|
||||
assert other_admin is not None
|
||||
@@ -3893,12 +3905,13 @@ class TestBindingAndCompletion(_Base):
|
||||
except BaseException as exc: # noqa: BLE001 - surfaced below
|
||||
errors.append(exc)
|
||||
|
||||
first = threading.Thread(target=start, args=(self.session, self.admin))
|
||||
first = threading.Thread(target=start, args=(first_session, first_admin))
|
||||
second = threading.Thread(target=start, args=(other_session, other_admin))
|
||||
first.start()
|
||||
second.start()
|
||||
first.join(timeout=10)
|
||||
second.join(timeout=10)
|
||||
first_session.close()
|
||||
other_session.close()
|
||||
|
||||
assert not first.is_alive()
|
||||
|
||||
@@ -403,6 +403,7 @@ async def start_binding(
|
||||
db: Session = Depends(get_db),
|
||||
current: User = Depends(require_permission("platform_fulfillment:use")),
|
||||
) -> dict[str, Any]:
|
||||
service.ensure_customer_profile_for_binding(db, task_id=task_id)
|
||||
result = await service.start_binding(db, task_id=task_id, current=current)
|
||||
record_audit(
|
||||
db,
|
||||
@@ -455,6 +456,7 @@ async def confirm_binding(
|
||||
db: Session = Depends(get_db),
|
||||
current: User = Depends(require_permission("platform_fulfillment:use")),
|
||||
) -> dict[str, Any]:
|
||||
service.ensure_customer_profile_for_binding(db, task_id=task_id)
|
||||
result = await service.confirm_binding(db, task_id=task_id, current=current)
|
||||
record_audit(
|
||||
db,
|
||||
@@ -474,6 +476,7 @@ def operator_confirm_binding(
|
||||
current: User = Depends(require_permission("platform_fulfillment:use")),
|
||||
) -> dict[str, Any]:
|
||||
"""普通人工代确认:客户已扫码但没点确认,运营代为提交正常 actBind。"""
|
||||
service.ensure_customer_profile_for_binding(db, task_id=task_id)
|
||||
result = service.operator_confirm_binding_sync(
|
||||
db,
|
||||
task_id=task_id,
|
||||
@@ -498,6 +501,7 @@ def manual_confirm_binding(
|
||||
current: User = Depends(require_permission("platform_fulfillment:use")),
|
||||
) -> dict[str, Any]:
|
||||
"""运营人工确认绑定:用于客户已在别处绑定、或账号当前角色已确认的场景。"""
|
||||
service.ensure_customer_profile_for_binding(db, task_id=task_id)
|
||||
result = service.manual_confirm_binding_sync(
|
||||
db,
|
||||
task_id=task_id,
|
||||
|
||||
@@ -44,7 +44,7 @@ from .binding_status import (
|
||||
_binding_failure_raw_message,
|
||||
_customer_task_message,
|
||||
)
|
||||
from .common import _now
|
||||
from .common import FLOW_VERSION_CLEAN, _has_game_home_profile, _now
|
||||
from .outbox import _emit_order_site_binding_state
|
||||
from .repository import (
|
||||
_binding_qr_expired,
|
||||
@@ -1494,6 +1494,12 @@ def reconcile_binding_state_outbox(
|
||||
}
|
||||
|
||||
|
||||
def ensure_customer_profile_for_binding(db: Session, *, task_id: int) -> None:
|
||||
task = _load_task(db, task_id)
|
||||
if task.flow_version == FLOW_VERSION_CLEAN and not _has_game_home_profile(task):
|
||||
raise HTTPException(status_code=409, detail="请先提交游戏角色和游戏主页截图")
|
||||
|
||||
|
||||
def confirm_binding_sync(db: Session, *, task_id: int, current: User) -> dict[str, Any]:
|
||||
task = _load_task_for_update(db, task_id)
|
||||
task = _load_task(db, refresh_binding(db, task_id=task.id)["task"]["id"])
|
||||
|
||||
@@ -29,6 +29,7 @@ from .allocation import ( # noqa: F401
|
||||
from .binding import ( # noqa: F401
|
||||
confirm_binding,
|
||||
confirm_binding_sync,
|
||||
ensure_customer_profile_for_binding,
|
||||
manual_confirm_binding_sync,
|
||||
operator_confirm_binding_sync,
|
||||
reconcile_binding_observations,
|
||||
|
||||
Reference in New Issue
Block a user