修复(履约与分配): 封堵工作台换绑、预售共号与分配中心越权占用
This commit is contained in:
@@ -6306,3 +6306,100 @@ class TestBindingAndCompletion(_Base):
|
||||
.count()
|
||||
== 1
|
||||
)
|
||||
|
||||
def test_workbench_blocks_rebind_and_goods_on_bound_or_collab_accounts(self):
|
||||
"""已绑定履约单与预售台账占用期间,禁止工作台无归属绑码/换绑,且履约期禁兑换。"""
|
||||
from web.backend.models import DouyuExternalOrder
|
||||
from web.backend.services.douyu_service import (
|
||||
DouyuLeaseConflictError,
|
||||
create_douyu_planned_tasks,
|
||||
)
|
||||
|
||||
task = self._allocated()
|
||||
task.binding_status = "bound"
|
||||
task.execution_status = "bound"
|
||||
self.session.commit()
|
||||
|
||||
for blocked_type in (
|
||||
"get_bind_qr",
|
||||
"confirm_bind",
|
||||
"lock_goods",
|
||||
"pay_locked_order",
|
||||
"exchange_goods",
|
||||
):
|
||||
with pytest.raises(DouyuLeaseConflictError):
|
||||
create_douyu_planned_tasks(
|
||||
self.session,
|
||||
[task.account_id],
|
||||
blocked_type,
|
||||
"elite",
|
||||
self.admin_id,
|
||||
enqueue_execution=False,
|
||||
)
|
||||
|
||||
# 只读查询仍允许从工作台发起
|
||||
_, query_count = create_douyu_planned_tasks(
|
||||
self.session,
|
||||
[task.account_id],
|
||||
"query_points",
|
||||
"elite",
|
||||
self.admin_id,
|
||||
enqueue_execution=False,
|
||||
)
|
||||
assert query_count == 1
|
||||
|
||||
collab_account = Account(
|
||||
username="collab-occupied-acc",
|
||||
password="pw",
|
||||
email="collab@example.com",
|
||||
email_password="epw",
|
||||
cookie="acf_uid=9090; acf_nickname=collab",
|
||||
status="active",
|
||||
)
|
||||
self.session.add(collab_account)
|
||||
self.session.flush()
|
||||
collab_lease = AccountLease(
|
||||
account_id=collab_account.id,
|
||||
holder_user_id=self.admin_id,
|
||||
scope="elite",
|
||||
purpose="douyu_collab",
|
||||
batch_id=f"collab:{collab_account.id}",
|
||||
status="active",
|
||||
)
|
||||
self.session.add(collab_lease)
|
||||
self.session.add(
|
||||
DouyuExternalOrder(
|
||||
order_no="DY-WORKBENCH-BLOCK-1",
|
||||
shop="店铺A",
|
||||
owner_id=self.admin_id,
|
||||
account_id=collab_account.id,
|
||||
account_username=collab_account.username,
|
||||
gift_name="礼包A",
|
||||
bind_game_role="原绑定角色",
|
||||
status="to_recharge",
|
||||
created_by=self.admin_id,
|
||||
)
|
||||
)
|
||||
self.session.commit()
|
||||
|
||||
for blocked_bind_type in ("get_bind_qr", "confirm_bind"):
|
||||
with pytest.raises(DouyuLeaseConflictError):
|
||||
create_douyu_planned_tasks(
|
||||
self.session,
|
||||
[collab_account.id],
|
||||
blocked_bind_type,
|
||||
"elite",
|
||||
self.admin_id,
|
||||
enqueue_execution=False,
|
||||
)
|
||||
|
||||
# 预售台账账号仍可由人工从工作台查积分或做兑换,不被绑定拦截误伤
|
||||
_, collab_query_count = create_douyu_planned_tasks(
|
||||
self.session,
|
||||
[collab_account.id],
|
||||
"query_points",
|
||||
"elite",
|
||||
self.admin_id,
|
||||
enqueue_execution=False,
|
||||
)
|
||||
assert collab_query_count == 1
|
||||
|
||||
Reference in New Issue
Block a user