feat(douyu): 增加账号角色异常状态
This commit is contained in:
@@ -81,6 +81,7 @@ STATUS_RECHARGED = "recharged"
|
||||
STATUS_SCRIPTED = "scripted"
|
||||
STATUS_DONE = "done"
|
||||
STATUS_POINTS_ERROR = "points_error"
|
||||
STATUS_ROLE_ERROR = "role_error"
|
||||
STATUS_FAILED = "failed"
|
||||
STATUS_VOID = "void"
|
||||
LEASE_PURPOSE_DOUYU_COLLAB = "douyu_collab"
|
||||
@@ -90,6 +91,7 @@ COLLAB_LEASE_STATUSES: tuple[str, ...] = (
|
||||
STATUS_RECHARGED,
|
||||
STATUS_SCRIPTED,
|
||||
STATUS_POINTS_ERROR,
|
||||
STATUS_ROLE_ERROR,
|
||||
STATUS_FAILED,
|
||||
)
|
||||
|
||||
@@ -100,6 +102,7 @@ ORDER_STATUSES: tuple[str, ...] = (
|
||||
STATUS_SCRIPTED,
|
||||
STATUS_DONE,
|
||||
STATUS_POINTS_ERROR,
|
||||
STATUS_ROLE_ERROR,
|
||||
STATUS_FAILED,
|
||||
STATUS_VOID,
|
||||
)
|
||||
@@ -111,6 +114,7 @@ ORDER_STATUS_LABELS = {
|
||||
STATUS_SCRIPTED: "已上脚本",
|
||||
STATUS_DONE: "抢购成功",
|
||||
STATUS_POINTS_ERROR: "积分异常",
|
||||
STATUS_ROLE_ERROR: "账号角色异常",
|
||||
STATUS_FAILED: "抢购失败",
|
||||
STATUS_VOID: "已作废",
|
||||
}
|
||||
@@ -1751,8 +1755,33 @@ def set_status(
|
||||
db.refresh(order)
|
||||
return order
|
||||
|
||||
if old in (STATUS_FAILED, STATUS_VOID) and not rollback:
|
||||
raise CollabError("从失败/作废状态回流程必须显式回退", code="rollback_required")
|
||||
if target == STATUS_ROLE_ERROR:
|
||||
order.status = STATUS_ROLE_ERROR
|
||||
order.updated_by = current.id
|
||||
order.version = int(order.version or 0) + 1
|
||||
record_audit(
|
||||
db,
|
||||
current,
|
||||
action="douyu:collab:role_error",
|
||||
target=_status_audit_target(order),
|
||||
detail={"from": old, "reason": _text(reason, max_length=256)},
|
||||
)
|
||||
_sync_order_lease(
|
||||
db,
|
||||
current,
|
||||
order,
|
||||
reason="douyu_collab_role_error",
|
||||
)
|
||||
if commit:
|
||||
db.commit()
|
||||
db.refresh(order)
|
||||
return order
|
||||
|
||||
if old in (STATUS_FAILED, STATUS_VOID, STATUS_ROLE_ERROR) and not rollback:
|
||||
raise CollabError(
|
||||
"从失败/角色异常/作废状态回流程必须显式回退",
|
||||
code="rollback_required",
|
||||
)
|
||||
if target not in STAGE_INDEX:
|
||||
raise CollabError("该状态不能手工切换", code="status_not_manual")
|
||||
current_index = STAGE_INDEX.get(old)
|
||||
|
||||
Reference in New Issue
Block a user