feat(contract-payment): 采购合同付款预警
This commit is contained in:
1 parent
5aa431cc8e
commit
03e5e88e27
113 files changed
+11381
-2991
No files matched your search
@@ -186,12 +186,30 @@ def send_wecom_event_message(
|
||||
jump_path: str = '/workspace',
|
||||
jump_params: dict | None = None,
|
||||
jump_url: str | None = None,
|
||||
wecom_userid: str | None = None,
|
||||
) -> dict:
|
||||
"""
|
||||
发送企微事件 textcard;可选 jump_url 覆盖默认跳转(如密码重置外链)。
|
||||
|
||||
核心逻辑:默认使用 `user.wecom_userid`;合同付款第二、三轮可传入 OA HrmResource.id
|
||||
作为 wecom_userid,因为该 id 同时是企业微信 userid。
|
||||
Args:
|
||||
event_type: 通知事件开关名。
|
||||
user: 审计关联的系统用户,可为收件人在 HXOPS 中的映射账号。
|
||||
title: 卡片标题。
|
||||
content: 卡片正文。
|
||||
jump_path: 站内跳转路径。
|
||||
jump_params: 跳转查询参数。
|
||||
jump_url: 若传入则覆盖默认拼接的跳转地址。
|
||||
wecom_userid: 可选,显式指定企微 touser;空则回退 user.wecom_userid。
|
||||
Returns:
|
||||
含 ok / trace_id 的发送结果字典。
|
||||
"""
|
||||
trace_id = uuid.uuid4().hex
|
||||
audit = _create_audit(event_type, user, title, content, trace_id)
|
||||
target_userid = str(wecom_userid or (user.wecom_userid if user else "") or "").strip()
|
||||
if target_userid:
|
||||
audit.wecom_userid = target_userid
|
||||
|
||||
if not current_app.config.get('WECOM_NOTIFY_ENABLED', True):
|
||||
audit.error_code = 'NOTIFY_DISABLED'
|
||||
@@ -203,7 +221,7 @@ def send_wecom_event_message(
|
||||
audit.error_message = f'event {event_type} disabled'
|
||||
return {'ok': False, 'trace_id': trace_id, 'reason': 'event_disabled'}
|
||||
|
||||
if not user or not user.wecom_userid:
|
||||
if not target_userid:
|
||||
audit.error_code = 'WECOM_USER_UNBOUND'
|
||||
audit.error_message = 'user has no wecom_userid'
|
||||
return {'ok': False, 'trace_id': trace_id, 'reason': 'user_unbound'}
|
||||
@@ -214,7 +232,7 @@ def send_wecom_event_message(
|
||||
else:
|
||||
final_jump_url = _build_jump_url(jump_path, trace_id, jump_params)
|
||||
audit.jump_url = final_jump_url
|
||||
data = send_wecom_textcard_message(user.wecom_userid, title, content, final_jump_url)
|
||||
data = send_wecom_textcard_message(target_userid, title, content, final_jump_url)
|
||||
if data.get('errcode') == 0:
|
||||
audit.status = 'sent'
|
||||
return {'ok': True, 'trace_id': trace_id}
|
||||
|
||||
Reference in new issue
Block a user