feat: 安全应用采购规格解析结果 (#257)
This commit is contained in:
@@ -255,7 +255,15 @@ class PurchaseReconcileService:
|
||||
normalized_confirmed_options = {
|
||||
str(key): str(value) for key, value in confirmed_options.items()
|
||||
}
|
||||
if normalized_confirmed_options != requested_options:
|
||||
resolution = snapshot.get("spec_resolution")
|
||||
resolution = resolution if isinstance(resolution, Mapping) else {}
|
||||
applied_options = resolution.get("applied_options")
|
||||
effective_options = (
|
||||
{str(key): str(value) for key, value in applied_options.items()}
|
||||
if isinstance(applied_options, Mapping)
|
||||
else requested_options
|
||||
)
|
||||
if normalized_confirmed_options != effective_options:
|
||||
raise ValueError("采购运行确认规格与任务不一致")
|
||||
if (
|
||||
isinstance(confirmed_quantity, bool)
|
||||
@@ -291,6 +299,8 @@ class PurchaseReconcileService:
|
||||
irreversible_action_at=str(run.irreversible_action_at),
|
||||
order_submitted_at=order_submitted_at,
|
||||
reconcile_started_at=_utc_now_iso(),
|
||||
original_options=requested_options,
|
||||
spec_resolution=dict(resolution),
|
||||
)
|
||||
|
||||
def _result_data(
|
||||
@@ -306,7 +316,7 @@ class PurchaseReconcileService:
|
||||
"purchase": {
|
||||
"mode": "live",
|
||||
"requested": {
|
||||
"options": dict(query.options),
|
||||
"options": dict(query.original_options or query.options),
|
||||
"quantity": query.quantity,
|
||||
"max_price_cent": task.price_cent,
|
||||
},
|
||||
@@ -324,6 +334,9 @@ class PurchaseReconcileService:
|
||||
"ordered_at": candidate.ordered_at,
|
||||
"ordered_at_raw": candidate.ordered_at_raw,
|
||||
"match_status": "matched",
|
||||
"spec_resolution": dict(query.spec_resolution)
|
||||
if query.spec_resolution
|
||||
else None,
|
||||
},
|
||||
"captured_at": _utc_now_iso(),
|
||||
"source": {
|
||||
|
||||
Reference in New Issue
Block a user