模版消息
这篇解决什么
微信私有模版如何同步到本地、发送走哪条接口。读完能对上 mp_message_template,不要去改系统邮件模版或小程序订阅消息。
默认端口 48080。先接入账号、有粉丝,见 公众号接入、公众号粉丝。
示意图:列表是微信模版的本地镜像。发送直接打微信,不写 mp_message。
从哪改
| 名称 | 说明 | 仓库路径 |
|---|---|---|
| 模版 | @RequestMapping("/mp/message-template") | ruoyi-office/yudao-module-mp/yudao-module-mp-server/.../controller/admin/message/MpMessageTemplateController.java |
| 同步 | POST /sync | mp:message-template:sync |
| 发送 | POST /send | mp:message-template:send |
| 删除 | DELETE /delete | 先删微信再删库 |
| 模版表 | mp_message_template | MpMessageTemplateDO |
| 管理端 | 列表、发送表单 | ruoyi-office-vben/apps/web-antd/src/views/mp/messageTemplate/ |
sync 调 getAllPrivateTemplate(),按 templateId 增改删本地行。send 组 WxMpTemplateMessage 后 sendTemplateMsg。代码明确不落 mp_message,因为微信会再推一条事件。
客户默认包 dump/latest 的 system_menu 没有「模版消息」叶子,也没有 mp:message-template:* 按钮行。页面和接口已在工程里。UniApp menu.json 有回退入口。要从 PC 侧栏进,需自己补菜单或走路由 /mp/message-template。
字段
| 名称 | 说明 | 仓库路径 |
|---|---|---|
templateId | 微信模版编号 | MpMessageTemplateDO |
title / content / example | 标题、正文、示例 | 同上 |
primaryIndustry / deputyIndustry | 一级、二级行业 | 同上 |
accountId / appId | 归属账号 | 同上 |
这不是 系统通知 的 system_notify_template,也不是邮件模版。会员小程序订阅消息在 member 模块,按批另写。
侧栏可能没有入口
默认静态数据停在消息发送权限 2129,下一号是邮箱管理。角色里搜不到「模版消息」是种子问题,不是模块没编译。
先在微信后台加模版
本地不能手搓行业模版。先在公众号后台选用,再点同步。删本地行会同时删微信私有模版。
按本仓库 DO 生成的 ER。一行对应一个微信 templateId。
配置与操作
客户 dump 没有「模版消息」叶子。页面在 views/mp/messageTemplate/,直开路由 /mp/message-template。先选账号,再 POST /sync 拉微信私有模版;本地不能手搓行业模版。发送 POST /send 填粉丝 userId 和 data JSON,可选落地页 url 或小程序。
发送不写 mp_message(微信会再推事件)。删本地行会同时删微信私有模版。这不是站内信 system_notify_template,也不是小程序订阅消息。开启见 公众号功能设计。

本系统截图:账号管理。模版消息没有侧栏入口,先有账号再同步微信私有模版。
