From 6f49335fcdd4d70de9ba3986a7a44cf32d65463c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Sat, 28 Feb 2026 11:55:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_hr_attendance/models/hr_attendance.py | 2 + .../views/property_lease_contract.xml | 2 +- yuthon_wechat/models/wecom_apps.py | 37 +++++++++++++------ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/yuthon_hr_attendance/models/hr_attendance.py b/yuthon_hr_attendance/models/hr_attendance.py index 26ecad4a3..8d7e92267 100644 --- a/yuthon_hr_attendance/models/hr_attendance.py +++ b/yuthon_hr_attendance/models/hr_attendance.py @@ -347,10 +347,12 @@ class HrAttendance(models.Model): user_id=emp.wecom_userid, title=f'【{title}】', description='考勤异常请尽快处理', + exception_alerts = True, url=url, btntxt="查看详情") self.sudo().env["wecom.apps"].sync_send_message_textcard(category='att', user_id='18562027762', title='【考勤异常提醒】', + exception_alerts=True, description='考勤异常请尽快处理', url=url, btntxt="查看详情") diff --git a/yuthon_property_approval/views/property_lease_contract.xml b/yuthon_property_approval/views/property_lease_contract.xml index 9d920685c..25bf20363 100644 --- a/yuthon_property_approval/views/property_lease_contract.xml +++ b/yuthon_property_approval/views/property_lease_contract.xml @@ -530,7 +530,7 @@ - + diff --git a/yuthon_wechat/models/wecom_apps.py b/yuthon_wechat/models/wecom_apps.py index 79b0bc154..4dcf56707 100644 --- a/yuthon_wechat/models/wecom_apps.py +++ b/yuthon_wechat/models/wecom_apps.py @@ -111,7 +111,7 @@ class WeComApps(models.Model): _logger.info(f"------------------------获取msg_id:{msg_id}tokenID:{token}当前url{url}-------------------------------") requests.post(url=url, data=json.dumps(data)) - def sync_send_message_textcard(self, content_item='', touser='', category='default', user_id=None, title="", description="", url="", btntxt="详情"): + def sync_send_message_textcard(self, content_item='', touser='', category='default', user_id=None, title="", description="", url="", btntxt="详情", exception_alerts = False): """ touser 否 成员ID列表(消息接收者,多个接收者用‘|’分隔,最多支持1000个)。特殊情况:指定为@all,则向关注该企业应用的全部成员发送 toparty 否 部门ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为@all时忽略本参数 @@ -175,17 +175,30 @@ class WeComApps(models.Model): }, } elif category == 'att': - data = { - "touser": user_id, - "msgtype": "miniprogram_notice", - "miniprogram_notice": { - "appid": "wxda530cb253dec90d", - "page": "pages/clock_in/clock_in", - "title": "打卡提醒", - "description": description, - "content_item": content_item - }, - } + if exception_alerts == True: + data = { + 'touser': user_id, + 'msgtype': 'textcard', + 'agentid': wecom_app.agent_id, + "textcard": { + "title": title, + "description": description, + "url": url, + "btntxt": btntxt + }, + } + else: + data = { + "touser": user_id, + "msgtype": "miniprogram_notice", + "miniprogram_notice": { + "appid": "wxda530cb253dec90d", + "page": "pages/clock_in/clock_in", + "title": "打卡提醒", + "description": description, + "content_item": content_item + }, + } else: data = { 'touser': touser,