feat(douyu): 订单台账按平台履约只读投影
- 外部单协作改名为斗鱼订单台账 - 平台来源台账单的订单号/账号/礼包/商品/积分只读 - 台账显示来源履约任务,隐藏解除/推荐账号入口 - 后端 update_order 拒绝投影字段变更 - set_account 对平台来源要求显式接管转人工 - 补充重构计划第一刀实施状态
This commit is contained in:
@@ -893,6 +893,15 @@ def create_order(
|
||||
return order
|
||||
|
||||
|
||||
PLATFORM_PROJECTED_FIELDS = {
|
||||
"order_no",
|
||||
"account_username",
|
||||
"gift_name",
|
||||
"commodity_id",
|
||||
"required_points",
|
||||
}
|
||||
|
||||
|
||||
def update_order(
|
||||
db: Session,
|
||||
current: User,
|
||||
@@ -950,6 +959,20 @@ def update_order(
|
||||
if new != old:
|
||||
changes[field] = {"old": old, "new": new}
|
||||
|
||||
if order.source_type == SOURCE_TYPE_PLATFORM_FULFILLMENT:
|
||||
# 平台来源台账单是履约任务的投影:订单号/商品/积分/账号由平台维护。
|
||||
# 账号变更只有显式“接管转人工”才允许,避免协作页静默改出两个账号。
|
||||
projected = PLATFORM_PROJECTED_FIELDS.intersection(changes)
|
||||
if "account_username" in projected and takeover_platform_lease:
|
||||
projected.discard("account_username")
|
||||
if projected:
|
||||
raise CollabError(
|
||||
"本单来自直播账号履约,订单号/商品/积分/账号由履约工作台维护;"
|
||||
"确需改账号请先走“接管并转人工”",
|
||||
status_code=409,
|
||||
code="platform_projection_readonly",
|
||||
)
|
||||
|
||||
if order.succeeded_at is not None:
|
||||
locked_changes = SUCCESS_PURCHASE_FIELDS.intersection(changes)
|
||||
if locked_changes:
|
||||
@@ -1074,6 +1097,16 @@ def set_account(
|
||||
_assert_mutable(order)
|
||||
_assert_success_account_change_allowed(current, order)
|
||||
_assert_version(order, expected_version)
|
||||
if (
|
||||
order.source_type == SOURCE_TYPE_PLATFORM_FULFILLMENT
|
||||
and not takeover_platform_lease
|
||||
):
|
||||
raise CollabError(
|
||||
"本单来自直播账号履约,账号由履约工作台维护;"
|
||||
"确需更换账号请确认“接管并转人工”",
|
||||
status_code=409,
|
||||
code="platform_projection_readonly",
|
||||
)
|
||||
account = account_by_username(db, username)
|
||||
if account is None:
|
||||
raise CollabError("斗鱼账号不存在", code="account_not_found")
|
||||
|
||||
Reference in New Issue
Block a user