Commit ab76ac94 by sunqi02

feat: 更新课程推荐链接,优化推送消息内容生成逻辑

1 parent e3853e3a
......@@ -9,7 +9,7 @@ IM_API_KEY=
# 课程推荐(course-recommend skill)
COURSE_DATABASE_URL=mysql://<MYSQL_USER>:<PASSWORD>@<HOST>:3307/dj_smartcarlife
COURSE_BASE_URL=http://localhost:5173
COURSE_BASE_URL=http://lessonjump.test.glsx.com.cn/
# 检索接口(query)
QUERY_URL=http://192.168.1.71:8104/wiki/query/json
......
from __future__ import annotations
import logging
import os
import time
from datetime import datetime
......@@ -22,6 +23,14 @@ from app.customer_info.service import CustomerInfoService
logger = logging.getLogger(__name__)
_COURSE_BASE_URL = os.environ.get("COURSE_BASE_URL", "").rstrip("/")
def _push_content(record) -> str:
"""生成推送消息内容,包含填写链接。"""
url = f"{_COURSE_BASE_URL}/save?group_id={record.group_id}"
return f"【系统提醒】您还未绑定手机号,请点击下方链接完成绑定:\n\n{url}\n"
def _build_services():
db = SessionLocal()
......@@ -90,9 +99,8 @@ def _run_sync_customer_group_phones(service: CustomerInfoService) -> int:
"""执行同步 + 同步触发推送。"""
affected = service.sync_from_customer_groups()
candidates = service.get_push_candidates(mode="sync")
content = "【系统推送】推送信息填写链接"
for record in candidates:
if _do_push(record, content):
if _do_push(record, _push_content(record)):
service.mark_pushed(record)
logger.info("同步触发推送: candidates=%s", len(candidates))
return affected
......@@ -101,9 +109,8 @@ def _run_sync_customer_group_phones(service: CustomerInfoService) -> int:
def _run_daily_phone_push(service: CustomerInfoService) -> int:
"""执行每日 9 点推送。"""
candidates = service.get_push_candidates(mode="daily")
content = "【系统推送】推送信息填写链接"
for record in candidates:
if _do_push(record, content):
if _do_push(record, _push_content(record)):
service.mark_pushed(record)
logger.info("每日推送: pushed=%s", len(candidates))
return len(candidates)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!