feat: 完善真实采购订单核对与恢复 (#100)
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Mapping, Optional
|
||||
from typing import Mapping, Sequence
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -15,33 +15,42 @@ class PurchaseReconcileQuery:
|
||||
goods_id: str
|
||||
options: Mapping[str, str]
|
||||
quantity: int
|
||||
unit_price_cent: int
|
||||
total_price_cent: int
|
||||
irreversible_action_at: str
|
||||
reconcile_started_at: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class PurchaseReconcileObservation:
|
||||
"""只读核对看到的结果。"""
|
||||
class PurchaseOrderCandidate:
|
||||
"""订单列表中一个不含个人信息的只读候选。"""
|
||||
|
||||
match_status: str
|
||||
order_no: Optional[str] = None
|
||||
ordered_at: Optional[str] = None
|
||||
order_no: str = ""
|
||||
goods_id: str = ""
|
||||
options: Mapping[str, str] = field(default_factory=dict)
|
||||
quantity: int = 0
|
||||
total_price_cent: int = 0
|
||||
ordered_at: str = ""
|
||||
ordered_at_raw: str = ""
|
||||
payment_status: str = ""
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class PurchaseReconcileScan:
|
||||
"""一次只读扫描结果;diagnostics 只能包含计数和错误摘要。"""
|
||||
|
||||
candidates: Sequence[PurchaseOrderCandidate] = field(default_factory=tuple)
|
||||
diagnostics: Mapping[str, object] = field(default_factory=dict)
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
if self.match_status not in {
|
||||
"matched", "not_found", "ambiguous", "unknown"
|
||||
}:
|
||||
raise ValueError("采购核对结果无效")
|
||||
|
||||
|
||||
class PddPurchaseReconcileAdapter(ABC):
|
||||
"""已进入不可逆阶段后使用的只读订单核对会话。"""
|
||||
|
||||
@abstractmethod
|
||||
def read_order_match(
|
||||
def read_order_candidates(
|
||||
self, query: PurchaseReconcileQuery
|
||||
) -> PurchaseReconcileObservation:
|
||||
"""读取并核对订单候选;不得点击下单或付款。"""
|
||||
) -> PurchaseReconcileScan:
|
||||
"""只读扫描订单候选;不得提交、取消或付款。"""
|
||||
|
||||
@abstractmethod
|
||||
def close(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user