feat(fulfillment): 接收并展示 order_site 客户主页截图
- 履约任务新增客户角色/平台/系统/主页截图/更新时间字段 - 迁移 0131 - order_site contractVersion=3 快照自动落客户资料 - 增加客户资料 integration 写入接口 - 工作台详情展示客户资料、平台角色比对和截图 - 补充客户资料保存/快照解析测试与对接文档
This commit is contained in:
@@ -38,6 +38,7 @@ from web.backend.services.automation.jobs import (
|
||||
platform_fulfillment_lease_reaper as reaper,
|
||||
)
|
||||
from web.backend.services.platform_fulfillment import account_selector, service, views
|
||||
from web.backend.services.platform_fulfillment.order_sync import _apply_customer_profile
|
||||
|
||||
NOW = datetime.now(UTC).replace(microsecond=0)
|
||||
COMMODITY = "20260120QYOOB_bag10"
|
||||
@@ -3148,6 +3149,80 @@ class TestBindingAndCompletion(_Base):
|
||||
== 0
|
||||
)
|
||||
|
||||
def test_customer_profile_snapshot_is_applied_to_task(self):
|
||||
task = self._allocated()
|
||||
_apply_customer_profile(
|
||||
task,
|
||||
{
|
||||
"customerRoleName": "小淋笨",
|
||||
"customerPlatform": "wechat",
|
||||
"customerSystem": "android",
|
||||
"homeImages": [
|
||||
{
|
||||
"url": "https://order.example.com/a.png",
|
||||
"thumbnailUrl": "https://order.example.com/a-thumb.png",
|
||||
"objectKey": "douyu-homepage-screenshot/a.png",
|
||||
}
|
||||
],
|
||||
"customerProfileUpdatedAt": "2026-11-24T12:00:00.000Z",
|
||||
},
|
||||
)
|
||||
assert task.customer_role_name == "小淋笨"
|
||||
assert task.customer_platform == "wechat"
|
||||
assert task.customer_system == "android"
|
||||
assert task.customer_home_images[0]["objectKey"].endswith("a.png")
|
||||
assert task.customer_profile_updated_at is not None
|
||||
|
||||
def test_customer_profile_with_home_image_is_saved_and_compared(self):
|
||||
task = self._allocated()
|
||||
account = self.session.get(Account, task.account_id)
|
||||
account.game_name = "小淋笨"
|
||||
account.game_channel = "微信 · 安卓(android)"
|
||||
self.session.commit()
|
||||
|
||||
detail = service.save_customer_profile(
|
||||
self.session,
|
||||
task_id=task.id,
|
||||
customer_role_name="小淋笨",
|
||||
platform="wechat",
|
||||
system="android",
|
||||
home_images=[
|
||||
{
|
||||
"url": "https://example.com/customer-home.png",
|
||||
"thumbnail_url": "https://example.com/customer-home-thumb.png",
|
||||
"object_key": "collect-material/customer-home.png",
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
self.session.refresh(task)
|
||||
profile = detail["customerProfile"]
|
||||
assert task.customer_role_name == "小淋笨"
|
||||
assert task.customer_home_images[0]["url"].endswith("customer-home.png")
|
||||
assert profile["roleMatched"] is True
|
||||
assert profile["channelMatched"] is True
|
||||
assert profile["homeImages"][0]["thumbnailUrl"].endswith("thumb.png")
|
||||
assert (
|
||||
self.session.query(PlatformFulfillmentEvent)
|
||||
.filter_by(task_id=task.id, event_type="customer_profile_saved")
|
||||
.count()
|
||||
== 1
|
||||
)
|
||||
|
||||
def test_customer_profile_requires_home_image(self):
|
||||
task = self._allocated()
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
service.save_customer_profile(
|
||||
self.session,
|
||||
task_id=task.id,
|
||||
customer_role_name="小淋笨",
|
||||
platform="wechat",
|
||||
system="android",
|
||||
home_images=[],
|
||||
)
|
||||
assert exc_info.value.status_code == 409
|
||||
assert "主页截图" in str(exc_info.value.detail)
|
||||
|
||||
def test_manual_confirm_rejects_role_not_currently_bound(self):
|
||||
task = self._allocated()
|
||||
account = self.session.get(Account, task.account_id)
|
||||
|
||||
Reference in New Issue
Block a user