落地私聊空运询价与TMS报价回填,按后台模板出单。

查到价后把币种、单位、数量、单价、备注写入报价单,避免销售只看到光秃秃的金额。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-14 20:25:35 +08:00
co-authored by Cursor
parent cea3a6e51e
commit 99da1faf30
78 changed files with 8838 additions and 321 deletions
+17 -3
View File
@@ -157,6 +157,7 @@ class PostgresMessageStore:
touser: str,
content: str,
dedupe_key: str = "",
payload: Optional[dict[str, Any]] = None,
) -> tuple[bool, str]:
if not touser or not content:
return False, "invalid_outbox"
@@ -167,9 +168,15 @@ class PostgresMessageStore:
"""
INSERT INTO agent_outbox (
id, dedupe_key, touser, content, payload, state
) VALUES (%s, %s, %s, %s, '{}'::jsonb, 'pending')
) VALUES (%s, %s, %s, %s, %s::jsonb, 'pending')
""",
(item_id, dedupe_key or "", touser, content),
(
item_id,
dedupe_key or "",
touser,
content,
json.dumps(dict(payload or {}), ensure_ascii=False),
),
)
conn.commit()
self._outbox_event.set()
@@ -209,7 +216,7 @@ class PostgresMessageStore:
FROM cte
WHERE o.id = cte.id
RETURNING o.id, o.touser, o.content, o.attempts, o.last_error,
o.created_at, o.dedupe_key, o.claimed_at
o.created_at, o.dedupe_key, o.claimed_at, o.payload
""",
(str(timeout), self._worker_id),
).fetchone()
@@ -221,6 +228,12 @@ class PostgresMessageStore:
created_ts = created.timestamp() if hasattr(created, "timestamp") else time.time()
claimed = row[7]
claimed_ts = claimed.timestamp() if hasattr(claimed, "timestamp") else time.time()
raw_payload = row[8] if len(row) > 8 else {}
if isinstance(raw_payload, str):
try:
raw_payload = json.loads(raw_payload)
except json.JSONDecodeError:
raw_payload = {}
return OutboxItem(
id=str(row[0]),
touser=str(row[1]),
@@ -231,6 +244,7 @@ class PostgresMessageStore:
last_error=str(row[4] or ""),
created_at=created_ts,
dedupe_key=str(row[6] or ""),
payload=dict(raw_payload or {}),
)
def complete_outbound(