feat: 实现受控真实下单安全边界 (#99)
This commit is contained in:
@@ -62,6 +62,7 @@ class NewClaimedTask:
|
||||
remote_task_id: str
|
||||
task_type: TaskType
|
||||
goods_url: str
|
||||
execution_mode: str = "dry_run"
|
||||
goods_id: Optional[str] = None
|
||||
title: Optional[str] = None
|
||||
target_color: Optional[str] = None
|
||||
@@ -79,6 +80,13 @@ class NewClaimedTask:
|
||||
raise ValueError("remote_task_id 不能为空")
|
||||
if not self.goods_url.strip():
|
||||
raise ValueError("goods_url 不能为空")
|
||||
if self.execution_mode not in {"dry_run", "live"}:
|
||||
raise ValueError("execution_mode 只允许 dry_run 或 live")
|
||||
if (
|
||||
self.task_type is not TaskType.PURCHASE
|
||||
and self.execution_mode != "dry_run"
|
||||
):
|
||||
raise ValueError("只有采购任务允许 execution_mode=live")
|
||||
if self.price_cent is not None and self.price_cent < 0:
|
||||
raise ValueError("price_cent 不能小于 0")
|
||||
if self.quantity is not None and self.quantity <= 0:
|
||||
@@ -141,6 +149,7 @@ class TaskDetail:
|
||||
finished_at: Optional[str]
|
||||
created_at: str
|
||||
updated_at: str
|
||||
execution_mode: str = "dry_run"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
||||
Reference in New Issue
Block a user