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
+89 -5
View File
@@ -477,9 +477,7 @@ class TestDouyuCollabOrders:
include_rebindable=False,
limit=5,
)
assert [item["account_id"] for item in unbound_only["candidates"]] == [
empty.id
]
assert [item["account_id"] for item in unbound_only["candidates"]] == [empty.id]
def test_create_strict_order_uses_internal_account_and_advances(self):
order = collab.create_order(
@@ -2699,11 +2697,15 @@ class TestDouyuCollabOrders:
)
wrong_role_record = {
**exchange_record(name="冥河战士大礼包", commodity_id="20260120QYOOB_bag413"),
**exchange_record(
name="冥河战士大礼包", commodity_id="20260120QYOOB_bag413"
),
"showName": "其他角色(安卓(android)-微信)",
}
matched_record = {
**exchange_record(name="冥河战士大礼包", commodity_id="20260120QYOOB_bag413"),
**exchange_record(
name="冥河战士大礼包", commodity_id="20260120QYOOB_bag413"
),
"showName": "角色A(苹果(iOS)-微信)",
"score": "8000",
}
@@ -2733,3 +2735,85 @@ class TestDouyuCollabOrders:
)
assert result["verdict"] == collab.VERDICT_SUCCESS
assert result["order"].status == collab.STATUS_DONE
def test_collab_takeover_blocked_when_shared_lease_has_other_active_platform_task():
engine = get_test_engine()
session = make_test_session(engine)
try:
admin = User(
username="collab-shared-admin", password_hash="h", role="super_admin"
)
acc = Account(
username="collab-shared-acc",
password="p",
email="collab-shared@example.com",
email_password="ep",
status="active",
ck_check_status="valid",
cookie="PHPSESSID=x",
elite_opened=True,
points=5000,
gold_balance=1000,
)
session.add_all([admin, acc])
session.flush()
lease = AccountLease(
account_id=acc.id,
holder_user_id=admin.id,
scope="elite",
purpose="platform_fulfillment",
batch_id="pf:1",
status="active",
)
session.add(lease)
session.flush()
t1 = PlatformFulfillmentTask(
source_system="order_site",
source_order_id="cs-1",
source_order_item_id="cs-1",
platform_order_id="CS-1",
internal_sku_key="sku-1",
commodity_id="cid-1",
account_id=acc.id,
lease_id=lease.id,
execution_status="bound",
binding_status="bound",
exchange_status="eligible",
)
t2 = PlatformFulfillmentTask(
source_system="order_site",
source_order_id="cs-2",
source_order_item_id="cs-2",
platform_order_id="CS-2",
internal_sku_key="sku-2",
commodity_id="cid-2",
account_id=acc.id,
lease_id=lease.id,
execution_status="bound",
binding_status="bound",
exchange_status="eligible",
)
session.add_all([t1, t2])
session.flush()
lease.batch_id = f"pf:{t1.id}"
session.commit()
with pytest.raises(collab.CollabError) as excinfo:
collab.create_order(
session,
admin,
order_no="DY-SHARED-BLOCKED",
shop="店铺A",
account_username="collab-shared-acc",
gift_name="礼包A",
required_points=100,
home_images=["collab/home-shared.png"],
takeover_platform_lease=True,
client=FakeClient(),
)
assert excinfo.value.code == "account_lease_conflict"
assert lease.status == "active"
assert lease.purpose == "platform_fulfillment"
finally:
session.close()