From 3c545f18ff09209007817fb9d7871663f9614b56 Mon Sep 17 00:00:00 2001 From: DaxPay Dev Date: Thu, 9 Jul 2026 17:31:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(notify):=20=E7=AE=A1=E7=90=86=E7=AB=AF?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=B8=8E=E5=8F=91=E9=80=81=E8=AE=B0=E5=BD=95=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 单菜单 Tabs 管理模板配置与发送记录,权限合并为 wechat-config; 三方平台微信公众号文案同步支持模板通知。 --- .../src/api/system/notify/wechat.api.ts | 101 +++++++++ apps/daxpay-admin/src/constants/perm-codes.ts | 13 +- .../locales/langs/en-US/system/notify.json | 31 ++- .../langs/en-US/system/thirdPlatform.json | 6 +- .../locales/langs/zh-CN/system/notify.json | 31 ++- .../langs/zh-CN/system/thirdPlatform.json | 6 +- .../notify/wechat/WechatNotifyConfig.vue | 129 +++++++++++ .../notify/wechat/WechatNotifyRecord.vue | 211 ++++++++++++++++++ .../src/views/system/notify/wechat/index.vue | 33 +++ 9 files changed, 545 insertions(+), 16 deletions(-) create mode 100644 apps/daxpay-admin/src/api/system/notify/wechat.api.ts create mode 100644 apps/daxpay-admin/src/views/system/notify/wechat/WechatNotifyConfig.vue create mode 100644 apps/daxpay-admin/src/views/system/notify/wechat/WechatNotifyRecord.vue create mode 100644 apps/daxpay-admin/src/views/system/notify/wechat/index.vue diff --git a/apps/daxpay-admin/src/api/system/notify/wechat.api.ts b/apps/daxpay-admin/src/api/system/notify/wechat.api.ts new file mode 100644 index 000000000..b7b5a4bb6 --- /dev/null +++ b/apps/daxpay-admin/src/api/system/notify/wechat.api.ts @@ -0,0 +1,101 @@ +import type { BaseEntity, PageResult, Result } from '#/types/web'; + +import { defHttp } from '#/api/request'; + +/** + * 微信消息通知配置 API + * 仅管理场景模板 Id(存 system_platform_config / wechat_notify); + * 公众号 AppId/AppSecret 在三方平台管理(加密配置 wechat_mp_auth) + */ +export const WechatConfigApi = { + /** 查询配置 */ + find(): Promise> { + return defHttp.get({ url: '/notify/wechat/config/find' }); + }, + /** 更新配置 */ + update(data: WechatConfigParam): Promise> { + return defHttp.post({ url: '/notify/wechat/config/update', data }); + }, +}; + +/** + * 微信通知记录 API + */ +export const WechatMessageApi = { + /** 分页查询 */ + page(params: any): Promise>> { + return defHttp.get({ url: '/notify/wechat/message/page', params }); + }, + /** 记录详情 */ + findById(id: string): Promise> { + return defHttp.get({ url: '/notify/wechat/message/get', params: { id } }); + }, + /** 重发失败消息 */ + resend(id: string): Promise> { + return defHttp.post({ url: '/notify/wechat/message/resend', params: { id } }); + }, + /** 测试发送(发给当前登录用户, 验证三方平台凭据+绑定+模板链路) */ + testSend(): Promise> { + return defHttp.post({ url: '/notify/wechat/message/test-send' }); + }, +}; + +/** + * 微信消息通知配置参数(编辑) + */ +export interface WechatConfigParam { + /** 交易通知模板Id */ + tradeTemplateId?: string; + /** 操作通知模板Id */ + operateTemplateId?: string; +} + +/** + * 微信消息通知配置结果(平台非加密配置, 无 BaseEntity 字段) + */ +export interface WechatConfigResult { + tradeTemplateId?: string; + operateTemplateId?: string; +} + +/** + * 微信消息记录 + */ +export interface WechatMessageRecord extends BaseEntity { + /** 接收平台用户ID */ + userId?: string; + /** 消息类型(template/uniform) */ + messageType?: string; + /** 接收者 OpenId */ + openId?: string; + /** 模板ID */ + templateId?: string; + /** 模板数据(JSON) */ + templateData?: string; + /** 跳转链接 */ + url?: string; + /** 发送状态(success/failed/sending) */ + status?: string; + /** 微信消息ID */ + msgId?: string; + /** 错误码 */ + errorCode?: string; + /** 错误信息 */ + errorMsg?: string; + /** 发送时间 */ + sendTime?: string; + /** 业务场景(trade/operate) */ + scene?: string; + /** 使用的 AppId */ + wxAppId?: string; +} + +/** + * 消息发送结果 + */ +export interface MessageSendResult { + success?: boolean; + msgId?: string; + errorCode?: string; + errorMsg?: string; +} diff --git a/apps/daxpay-admin/src/constants/perm-codes.ts b/apps/daxpay-admin/src/constants/perm-codes.ts index b3c9d42f7..ae29d433a 100644 --- a/apps/daxpay-admin/src/constants/perm-codes.ts +++ b/apps/daxpay-admin/src/constants/perm-codes.ts @@ -254,15 +254,12 @@ export const PermCodes = { MANAGE: 'system:notify:notice:manage', PUBLISH: 'system:notify:notice:publish', }, - /** 公众号配置 menuCode=system:notify:wechat-config */ - WechatConfig: { + /** 微信消息通知 menuCode=system:notify:wechat-config(配置 + 发送记录 Tabs) */ + WechatNotify: { MANAGE: 'system:notify:wechat-config:manage', - }, - /** 微信通知记录 menuCode=system:notify:wechat-message */ - WechatMessage: { - VIEW: 'system:notify:wechat-message:view', - RESEND: 'system:notify:wechat-message:resend', - TEST: 'system:notify:wechat-message:test', + VIEW: 'system:notify:wechat-config:view', + RESEND: 'system:notify:wechat-config:resend', + TEST: 'system:notify:wechat-config:test', }, /** 存储文件 menuCode=system:file:platform */ FilePlatform: { diff --git a/apps/daxpay-admin/src/locales/langs/en-US/system/notify.json b/apps/daxpay-admin/src/locales/langs/en-US/system/notify.json index 13efe08a6..6f6d63fe4 100644 --- a/apps/daxpay-admin/src/locales/langs/en-US/system/notify.json +++ b/apps/daxpay-admin/src/locales/langs/en-US/system/notify.json @@ -43,5 +43,34 @@ "isTopRequired": "Please confirm whether to pin", "effectiveTimeHelp": "If set, the notice becomes visible after this time. Leave empty to show it immediately after publishing.", "expireTimeHelp": "If set, the notice is hidden after this time. Leave empty to keep it permanently.", - "confirmCloseContent": "Content has been modified. Discard changes and close?" + "confirmCloseContent": "Content has been modified. Discard changes and close?", + "wechatConfigTitle": "WeChat Message Notification", + "wechatConfigDesc": "Configure WeChat official account template data for each business scene. AppId/AppSecret are managed under Third-party Platform → WeChat Official Account.", + "wechatTabConfig": "Notification Config", + "wechatTabRecord": "Send Records", + "tradeTemplateId": "Trade Notice Template ID", + "operateTemplateId": "Operation Notice Template ID", + "testSend": "Test Send", + "confirmTestSend": "A test notification will be sent to the current user (requires MP credentials in Third-party Platform and the user bound to this official account). Continue?", + "testSendSuccess": "Test message sent. Please check it in WeChat.", + "testSendFail": "Send failed: {msg}", + "wechatMessageType": "Message Type", + "userId": "User ID", + "sendStatus": "Send Status", + "openId": "OpenId", + "templateIdField": "Template ID", + "sendTime": "Send Time", + "scene": "Scene", + "errorMsgField": "Error Message", + "msgIdField": "WeChat Msg ID", + "resend": "Resend", + "confirmResend": "Resend this message?", + "statusFilterPlaceholder": "Select send status", + "statusSending": "Sending", + "statusSuccess": "Success", + "statusFailed": "Failed", + "typeTemplate": "OA Template", + "typeUniform": "Mini Program Uniform", + "sceneTrade": "Trade Notice", + "sceneOperate": "Operation Notice" } diff --git a/apps/daxpay-admin/src/locales/langs/en-US/system/thirdPlatform.json b/apps/daxpay-admin/src/locales/langs/en-US/system/thirdPlatform.json index 50f2152c1..d42e50d68 100644 --- a/apps/daxpay-admin/src/locales/langs/en-US/system/thirdPlatform.json +++ b/apps/daxpay-admin/src/locales/langs/en-US/system/thirdPlatform.json @@ -52,10 +52,10 @@ }, "wechatMp": { "tabTitle": "WeChat Official Account Config", - "tabDescription": "WeChat MP H5 OAuth credentials for WeChat login", + "tabDescription": "WeChat MP credentials for login and template notifications", "title": "WeChat Official Account Auth Configuration", - "description": "Manage WeChat MP H5 web authorization credentials (appId/appSecret) to get user openId.", - "usageTip": "This configuration serves WeChat MP H5 web authorization to get user openId.", + "description": "Manage WeChat MP credentials (appId/appSecret) for H5 OAuth openId and notification-center template messages.", + "usageTip": "This configuration serves: 1) WeChat MP H5 OAuth login; 2) Notification-center template message sending.", "confirmSaveContent": "Are you sure to save the WeChat Official Account configuration?", "section": { "credential": "Credential Configuration" diff --git a/apps/daxpay-admin/src/locales/langs/zh-CN/system/notify.json b/apps/daxpay-admin/src/locales/langs/zh-CN/system/notify.json index 96b75a635..94948f591 100644 --- a/apps/daxpay-admin/src/locales/langs/zh-CN/system/notify.json +++ b/apps/daxpay-admin/src/locales/langs/zh-CN/system/notify.json @@ -43,5 +43,34 @@ "isTopRequired": "请确认是否置顶", "effectiveTimeHelp": "设置后公告在该时间后才对用户可见,不填则发布后立即可见", "expireTimeHelp": "设置后公告在该时间后不再可见,不填则永久有效", - "confirmCloseContent": "正文内容已修改,确认放弃修改并关闭吗?" + "confirmCloseContent": "正文内容已修改,确认放弃修改并关闭吗?", + "wechatConfigTitle": "微信消息通知", + "wechatConfigDesc": "配置各业务场景公众号模板数据。AppId/AppSecret 请在「三方平台管理 → 微信公众号」配置。", + "wechatTabConfig": "通知配置", + "wechatTabRecord": "发送记录", + "tradeTemplateId": "交易通知模板Id", + "operateTemplateId": "操作通知模板Id", + "testSend": "测试发送", + "confirmTestSend": "将向当前登录用户发送一条测试通知(需已在三方平台配置公众号凭据, 且当前用户已绑定该公众号), 确认发送吗?", + "testSendSuccess": "测试消息已发送, 请在微信公众号查看", + "testSendFail": "发送失败: {msg}", + "wechatMessageType": "消息类型", + "userId": "用户ID", + "sendStatus": "发送状态", + "openId": "OpenId", + "templateIdField": "模板ID", + "sendTime": "发送时间", + "scene": "业务场景", + "errorMsgField": "错误信息", + "msgIdField": "微信消息ID", + "resend": "重发", + "confirmResend": "确认重发该消息吗?", + "statusFilterPlaceholder": "请选择发送状态", + "statusSending": "发送中", + "statusSuccess": "成功", + "statusFailed": "失败", + "typeTemplate": "公众号模板", + "typeUniform": "小程序统一消息", + "sceneTrade": "交易通知", + "sceneOperate": "操作通知" } diff --git a/apps/daxpay-admin/src/locales/langs/zh-CN/system/thirdPlatform.json b/apps/daxpay-admin/src/locales/langs/zh-CN/system/thirdPlatform.json index 3eb6c34cb..000a3db6c 100644 --- a/apps/daxpay-admin/src/locales/langs/zh-CN/system/thirdPlatform.json +++ b/apps/daxpay-admin/src/locales/langs/zh-CN/system/thirdPlatform.json @@ -52,10 +52,10 @@ }, "wechatMp": { "tabTitle": "微信公众号配置", - "tabDescription": "公众号 H5 网页授权凭据, 服务于微信登录", + "tabDescription": "公众号凭据, 服务于微信登录与模版通知", "title": "微信公众号认证配置", - "description": "管理微信公众号网页授权凭据(appId/appSecret), 用于公众号 H5 授权获取用户 openId。", - "usageTip": "本配置服务于公众号 H5 网页授权, 用于获取用户 openId。", + "description": "管理微信公众号凭据(appId/appSecret), 用于公众号 H5 授权获取用户 openId, 以及通知中心模版消息发送。", + "usageTip": "本配置同时服务于: 1) 公众号 H5 网页授权登录; 2) 通知中心模版消息发送。", "confirmSaveContent": "确定要保存微信公众号配置吗?", "section": { "credential": "凭据配置" diff --git a/apps/daxpay-admin/src/views/system/notify/wechat/WechatNotifyConfig.vue b/apps/daxpay-admin/src/views/system/notify/wechat/WechatNotifyConfig.vue new file mode 100644 index 000000000..5baf04722 --- /dev/null +++ b/apps/daxpay-admin/src/views/system/notify/wechat/WechatNotifyConfig.vue @@ -0,0 +1,129 @@ + + + diff --git a/apps/daxpay-admin/src/views/system/notify/wechat/WechatNotifyRecord.vue b/apps/daxpay-admin/src/views/system/notify/wechat/WechatNotifyRecord.vue new file mode 100644 index 000000000..ed07215b8 --- /dev/null +++ b/apps/daxpay-admin/src/views/system/notify/wechat/WechatNotifyRecord.vue @@ -0,0 +1,211 @@ + + + diff --git a/apps/daxpay-admin/src/views/system/notify/wechat/index.vue b/apps/daxpay-admin/src/views/system/notify/wechat/index.vue new file mode 100644 index 000000000..73fb877b1 --- /dev/null +++ b/apps/daxpay-admin/src/views/system/notify/wechat/index.vue @@ -0,0 +1,33 @@ + + +