优化(斗鱼预售台账): 统一命名并同步客户主页图
同步履约客户游戏主页截图,兼容 order_site 绝对 URL 与 objectKey;统一预售台账用户可见文案和保护标签;移除 CK 检测与重登前端页面入口。
This commit is contained in:
@@ -119,6 +119,7 @@ def test_protection_membership_uses_active_fulfillment_relationships(db):
|
||||
assert snapshot.group_account_ids["collab_bound"] == frozenset(
|
||||
{shared.id, collab_only.id}
|
||||
)
|
||||
assert snapshot.groups["collab_bound"]["label"] == "预售台账绑定账号"
|
||||
assert snapshot.monitored_ids == frozenset(
|
||||
{shared.id, presale_only.id, collab_only.id}
|
||||
)
|
||||
|
||||
@@ -20,6 +20,7 @@ from tests.support.db import make_test_session
|
||||
from web.backend.models import FileAsset
|
||||
from web.backend.services.file_service import (
|
||||
FileUploadError,
|
||||
build_file_url,
|
||||
build_object_key,
|
||||
generate_image_variants,
|
||||
get_stored_object,
|
||||
@@ -105,6 +106,15 @@ class TestContentTypeAndScene:
|
||||
assert re.fullmatch(r"collab/\d{4}/\d{2}/\d{2}/[0-9a-f]{24}\.png", key)
|
||||
assert build_object_key("collab", "image/png", "a.png") != key
|
||||
|
||||
def test_file_url_keeps_external_customer_image_url(self):
|
||||
url = "https://order-site.example/files/home.png"
|
||||
|
||||
assert build_file_url(url) == url
|
||||
assert build_file_url(url, "thumb") == url
|
||||
assert build_file_url("collab/2026/11/26/home.png") == (
|
||||
"/api/files/object?key=collab%2F2026%2F11%2F26%2Fhome.png"
|
||||
)
|
||||
|
||||
|
||||
class TestImageVariants:
|
||||
def test_png_source_keeps_alpha_and_outputs_webp(self):
|
||||
|
||||
@@ -136,7 +136,7 @@ def test_run_lease_ck_refresh_calls_login_for_selected_accounts(db, monkeypatch)
|
||||
|
||||
|
||||
def test_select_due_lease_accounts_also_covers_presale_and_collab_protection(db):
|
||||
"""P1 到期前刷新不仅看生效租约,也覆盖预售与协作单绑定的履约保护账号。"""
|
||||
"""P1 到期前刷新不仅看生效租约,也覆盖预售与预售台账绑定的履约保护账号。"""
|
||||
from web.backend.models import DouyuExternalOrder, PlatformFulfillmentTask
|
||||
|
||||
now = datetime.now(UTC).replace(microsecond=0)
|
||||
|
||||
@@ -682,6 +682,7 @@ class TestFulfillmentCollabSync(_Base):
|
||||
|
||||
def test_manual_sync_creates_projected_collab_order(self):
|
||||
task = self._task_with_account()
|
||||
self.complete_customer_profile(task)
|
||||
mapping = self.session.query(PlatformCommodityMapping).one()
|
||||
mapping.goods_name = "套装-兔兔白日梦(斗鱼)"
|
||||
self.session.add(
|
||||
@@ -730,6 +731,7 @@ class TestFulfillmentCollabSync(_Base):
|
||||
assert order.required_points == 1280
|
||||
assert order.account_id == task.account_id
|
||||
assert order.account_username == "collab-sync-account"
|
||||
assert order.home_images == ["https://example.com/game-home.png"]
|
||||
assert order.bind_game_role == "已确认角色"
|
||||
assert order.bind_game_channel == "微信 / 苹果(iOS)"
|
||||
assert order.status == collab.STATUS_INCOMPLETE
|
||||
@@ -738,6 +740,8 @@ class TestFulfillmentCollabSync(_Base):
|
||||
).model_dump()
|
||||
assert payload["source_task_id"] == task.id
|
||||
assert payload["source_platform_order_id"] == task.platform_order_id
|
||||
assert payload["home_image_urls"] == ["https://example.com/game-home.png"]
|
||||
assert payload["home_image_thumb_urls"] == ["https://example.com/game-home.png"]
|
||||
assert (
|
||||
self.session.query(AccountEvent)
|
||||
.filter(AccountEvent.event_type == "collab_synced")
|
||||
@@ -768,6 +772,25 @@ class TestFulfillmentCollabSync(_Base):
|
||||
assert synced.account_id == account.id
|
||||
assert synced.account_username == account.username
|
||||
|
||||
def test_manual_sync_backfills_customer_home_images(self):
|
||||
task = self._task_with_account()
|
||||
order, _ = collab.sync_platform_fulfillment_order(
|
||||
self.session,
|
||||
self.admin,
|
||||
task,
|
||||
)
|
||||
assert not order.home_images
|
||||
|
||||
self.complete_customer_profile(task)
|
||||
synced, action = collab.sync_platform_fulfillment_order(
|
||||
self.session,
|
||||
self.admin,
|
||||
task,
|
||||
)
|
||||
|
||||
assert action == "updated"
|
||||
assert synced.home_images == ["https://example.com/game-home.png"]
|
||||
|
||||
def test_manual_sync_is_idempotent_and_preserves_human_fields(self):
|
||||
task = self._task_with_account()
|
||||
order, _ = collab.sync_platform_fulfillment_order(
|
||||
@@ -3011,7 +3034,7 @@ class TestBindingAndCompletion(_Base):
|
||||
assert task.execution_status == "manual_required"
|
||||
assert task.issue_code == "customer_role_bound_elsewhere"
|
||||
assert "role-lock-holder" in task.last_error
|
||||
assert "协作单" in task.last_error
|
||||
assert "预售台账" in task.last_error
|
||||
assert event.detail_json["roleLockAccountId"] == lock_account.id
|
||||
assert event.detail_json["roleLockAccountName"] == "role-lock-holder"
|
||||
assert event.detail_json["roleLockLeasePurpose"] == "douyu_collab"
|
||||
@@ -4418,7 +4441,7 @@ class TestBindingAndCompletion(_Base):
|
||||
)
|
||||
|
||||
assert exc_info.value.status_code == 409
|
||||
assert "外部协作单已在人工处理" in str(exc_info.value.detail)
|
||||
assert "关联预售单已在人工处理" in str(exc_info.value.detail)
|
||||
|
||||
def test_restore_rejects_terminal_source_order(self, monkeypatch):
|
||||
task = self.task()
|
||||
@@ -4559,7 +4582,7 @@ class TestBindingAndCompletion(_Base):
|
||||
self.session,
|
||||
task_id=task.id,
|
||||
current=self.admin,
|
||||
reason="以外部协作单的人工处理为准",
|
||||
reason="以斗鱼预售台账的人工处理为准",
|
||||
)
|
||||
|
||||
self.session.refresh(task)
|
||||
|
||||
Reference in New Issue
Block a user