feat(training): 出国规则培训完成推送企微通知!

This commit is contained in:
runny committed 2026-09-16 13:16:43 +08:00
1 parent 258098ea7b
commit 77851288f7
8 files changed
+60 -5

No files matched your search

+1 -1
View File
@@ -552,7 +552,7 @@ class Config:
WECOM_PUBLIC_BASE_URL = os.getenv('WECOM_PUBLIC_BASE_URL')
WECOM_NOTIFY_ENABLED = os.getenv('WECOM_NOTIFY_ENABLED', 'true').lower() == 'true'
WECOM_NOTIFY_BASE_URL = os.getenv('WECOM_NOTIFY_BASE_URL')
WECOM_NOTIFY_EVENTS = os.getenv('WECOM_NOTIFY_EVENTS', 'task_completed,schedule_completed,password_reset,contract_payment_warning,training_lean_overdue,training_lean_task_initial,training_lean_targeted_reminder')
WECOM_NOTIFY_EVENTS = os.getenv('WECOM_NOTIFY_EVENTS', 'task_completed,schedule_completed,password_reset,contract_payment_warning,training_lean_overdue,training_lean_task_initial,training_lean_targeted_reminder,training_overseas_thailand_guidelines')
# 精益培训企微提醒卡片跳转的员工培训聊天页 agent id(前端路由 /chat/<id>,默认 27=员工培训)。
# 注意:默认值必须指向 content_profile=training 的培训 agent;历史默认 16 实为「通用入口」,
# 会导致卡片落地非培训 agent、前端精益页签深链不消费([FIX] 2026-09-11)。
+13
View File
@@ -21,6 +21,7 @@ from app.core.errors import ValidationError
from app.extensions import db
from app.models import Agent, TrainingRecord, User
from app.services.training_config_service import get_published_config
from app.services.wecom_notify import send_wecom_event_message
TRAINING_STAGES = {"video", "summary", "exam", "result"}
TRAINING_TYPES = {"onboarding", "safety"}
@@ -609,6 +610,18 @@ def upsert_user_training_record(user: User, payload: dict[str, Any]) -> Training
record.started_at = datetime.utcnow()
db.session.commit()
if stage == "result" and _is_overseas_regulations_training(training_type):
try:
send_wecom_event_message(
event_type="training_overseas_thailand_guidelines",
user=user,
title="中国员工出差泰国的行为准则",
content="中国员工出差泰国的行为准则",
jump_path="/workspace",
)
db.session.commit()
except Exception:
db.session.rollback()
return record