协商中再问按后台超时小时顺延并可强制清跟进时刻;工单与账号支持按筛选导出 Excel。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,7 +13,12 @@ from typing import Any, Callable, Optional
|
||||
|
||||
from agent.config import get_settings
|
||||
from agent.policy import inquiry_copy as copy
|
||||
from agent.policy.deal_followup import next_followup_at, pick_leaders
|
||||
from agent.policy.deal_followup import (
|
||||
DEFAULT_NEGOTIATE_HOURS,
|
||||
TIMEOUT_CODE_DEAL_NEGOTIATE,
|
||||
next_followup_at,
|
||||
pick_leaders,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -156,8 +161,14 @@ def finish_deal_outcome(
|
||||
status = (outcome or "").strip()
|
||||
extra: dict[str, Any] = {}
|
||||
summary = ""
|
||||
negotiate_hours = 0.0
|
||||
if status == "协商中":
|
||||
extra["next_followup_at"] = next_followup_at().strftime("%Y-%m-%d %H:%M:%S")
|
||||
# 小时读后台超时响应 deal_negotiate;0=不排再问;缺配置默认 48
|
||||
negotiate_hours = _negotiate_followup_hours(ledger)
|
||||
if negotiate_hours > 0:
|
||||
extra["next_followup_at"] = next_followup_at(hours=negotiate_hours).strftime(
|
||||
"%Y-%m-%d %H:%M:%S"
|
||||
)
|
||||
if status == "已成交":
|
||||
staff: list[dict[str, Any]] = []
|
||||
lister = getattr(ledger, "list_staff_by_role", None)
|
||||
@@ -242,9 +253,38 @@ def finish_deal_outcome(
|
||||
"notify_summary": summary,
|
||||
"status": status,
|
||||
"next_followup_at": str(extra.get("next_followup_at") or ""),
|
||||
"negotiate_hours": negotiate_hours,
|
||||
}
|
||||
|
||||
|
||||
def _negotiate_followup_hours(ledger: Any) -> float:
|
||||
"""
|
||||
读主账 deal_negotiate 超时小时;找不到或异常则用默认 48。
|
||||
|
||||
允许小数;负数当 0(不排再问)。不在回调线程打主账以外的慢活。
|
||||
"""
|
||||
lookup = getattr(ledger, "get_timeout_by_code", None)
|
||||
if not callable(lookup):
|
||||
return DEFAULT_NEGOTIATE_HOURS
|
||||
try:
|
||||
row = lookup(timeout_code=TIMEOUT_CODE_DEAL_NEGOTIATE) or {}
|
||||
except Exception:
|
||||
logger.exception("读协商再问小时失败,用默认 %s", DEFAULT_NEGOTIATE_HOURS)
|
||||
return DEFAULT_NEGOTIATE_HOURS
|
||||
if not row.get("found"):
|
||||
return DEFAULT_NEGOTIATE_HOURS
|
||||
raw = row.get("timeoutHours")
|
||||
if raw is None:
|
||||
raw = row.get("timeout_hours")
|
||||
try:
|
||||
hours = float(raw)
|
||||
except (TypeError, ValueError):
|
||||
return DEFAULT_NEGOTIATE_HOURS
|
||||
if hours < 0:
|
||||
return 0.0
|
||||
return hours
|
||||
|
||||
|
||||
def _transition_deal_status(
|
||||
writer: Callable[..., dict[str, Any]],
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user