feat: 三项联动 — 计划过期提醒 + 拜访自动关闭 + 批量制定
1. 计划过期自动提醒: - scheduler.py 新增 check_overdue_plans() - 每日 9:00 检查过期计划(plan_date < today, status=计划中) - 按经理汇总 → 企微推送提醒消息 2. 拜访后自动关闭计划: - create_visit 后自动将匹配的计划标记为「已完成」 - 条件: customer_id 匹配 + status=计划中 + plan_date <= visit_date 3. 亮灯表批量制定: - 红灯/黄灯卡片右上角 ☐ 复选框 - 勾选后出现「批量制定计划」按钮 - 弹窗统一设置日期+内容 → 批量 POST Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -151,6 +151,19 @@ async def create_visit(
|
||||
customer.last_visit_manager_id = uuid.UUID(current_user["user_id"])
|
||||
db.add(customer)
|
||||
|
||||
# Auto-complete matching work plans for this customer
|
||||
from app.models.work_plan import WorkPlan
|
||||
plans_result = await db.execute(
|
||||
select(WorkPlan).where(
|
||||
WorkPlan.customer_id == data.customer_id,
|
||||
WorkPlan.status == "计划中",
|
||||
WorkPlan.plan_date <= parse_date(data.visit_date),
|
||||
)
|
||||
)
|
||||
for plan in plans_result.scalars().all():
|
||||
plan.status = "已完成"
|
||||
append_entry(plan, current_user["name"], [{"field": "status", "from": "计划中", "to": "已完成", "reason": "拜访自动完成"}])
|
||||
|
||||
# Create draft copies for companions
|
||||
for companion_id in data.companions:
|
||||
if companion_id != uuid.UUID(current_user["user_id"]):
|
||||
|
||||
Reference in New Issue
Block a user