v4.0.18版本提交

This commit is contained in:
2026-09-08 10:07:34 +08:00
parent 4bdb09068c
commit 23ba639e9b
46 changed files with 1922 additions and 162 deletions
@@ -30,6 +30,11 @@ import {
renderWecomTemplate,
} from './wecom-push-template.defaults';
/** 含 markdown 表格时改走 markdown_v2,群聊才能渲染表格 */
function wecomMarkdownUsesTable(content: string): boolean {
return /\|[^\n]*\|\s*\n\s*\|?\s*:?-{3,}/.test(content);
}
type PushRow = {
id: bigint;
name: string;
@@ -327,14 +332,16 @@ export class WecomMessagePushService implements OnModuleInit {
async sendMarkdownToWebhook(webhookUrl: string, content: string): Promise<boolean> {
const url = (webhookUrl || '').trim();
if (!url) return false;
const useTable = wecomMarkdownUsesTable(content);
const text = content.slice(0, useTable ? 4096 : 4000);
const payload = useTable
? { msgtype: 'markdown_v2', markdown_v2: { content: text } }
: { msgtype: 'markdown', markdown: { content: text } };
try {
const res = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
msgtype: 'markdown',
markdown: { content: content.slice(0, 4000) },
}),
body: JSON.stringify(payload),
});
const data = (await res.json().catch(() => ({}))) as {
errcode?: number;
@@ -580,20 +587,23 @@ export class WecomMessagePushService implements OnModuleInit {
},
'finance.partner_bill': {
vars: {
period: '2026-07',
period: '2026-07-27 ~ 2026-08-02',
billCount: '1',
totalAmount: '120.00',
billSummary: [
'城市:郑州',
'合伙人:郑州某某商贸-张三',
'订单笔数:8',
'核销笔数:12',
'订单佣金:¥100.00',
'核销佣金:¥20.00',
'账单:¥120.00',
'收款人:张三',
'收款账户:6222000011112222',
'收款开户行:郑州支行',
'| 郑州某某商贸-张三 | |',
'| :--- | ---: |',
'| 账期 | 2026-07-27 ~ 2026-08-02 |',
'| 订单数量 | 8 |',
'| 订单金额 | ¥1000.00 |',
'| 订单佣金 | ¥100.00 |',
'| 核销单数量 | 12 |',
'| 核销金额 | ¥200.00 |',
'| 核销佣金 | ¥20.00 |',
'| 累计金额 | ¥120.00 |',
'| 收款人 | 张三 |',
'| 收款银行账号 | 6222000011112222 |',
'| 开户行 | 郑州支行 |',
].join('\n'),
},
handlePath: '/finance/partner-bills',