fix: 等待微信返回后再只读核单 (#124)

This commit is contained in:
chengma
2026-08-10 19:58:57 +08:00
parent 0f5d38b08f
commit 4999aa70e4
4 changed files with 274 additions and 27 deletions
+14 -4
View File
@@ -133,7 +133,10 @@ class PurchaseReconcileService:
return self._save_manual_review(
task, run, "ambiguous", diagnostics
)
match_status = "not_found" if not candidates else "unknown"
read_failed = bool(diagnostics.get("error_code"))
match_status = (
"unknown" if read_failed or candidates else "not_found"
)
return self._save_manual_review(task, run, match_status, diagnostics)
def _read_candidates(
@@ -153,9 +156,13 @@ class PurchaseReconcileService:
):
raise TypeError("采购核对候选数据无效")
except Exception as exc:
error_code = str(
getattr(exc, "code", "RECONCILE_READ_FAILED")
or "RECONCILE_READ_FAILED"
)
scan = PurchaseReconcileScan(
diagnostics={
"error_code": "RECONCILE_READ_FAILED",
"error_code": error_code,
"error_message": str(exc)[:300],
}
)
@@ -181,13 +188,16 @@ class PurchaseReconcileService:
dict(diagnostics),
)
messages = {
"not_found": "未找到符合时间范围的订单",
"not_found": "未找到符合条件的订单",
"ambiguous": "找到多个完全匹配的未付款订单",
"unknown": "订单字段不完整、不一致或读取失败",
}
message = messages[match_status]
if match_status == "unknown" and diagnostics.get("error_message"):
message = f"订单读取失败:{str(diagnostics['error_message'])[:200]}"
return PurchaseReconcileOutcome(
"manual_review",
f"任务 {task.remote_task_id} {messages[match_status]};需人工处理,绝不重新下单",
f"任务 {task.remote_task_id} {message};需人工处理,绝不重新下单",
task.remote_task_id,
)