feat(promo): generate WeChat mini-program codes on create

Use getwxacodeunlimit with activity id as scene, upload PNG to OSS qrcode/, and show in HQ admin.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-23 00:21:10 +08:00
parent 0418370c31
commit bca1d8afea
11 changed files with 162 additions and 34 deletions
@@ -1,9 +1,11 @@
import { createHash } from 'crypto';
import { Injectable, NotImplementedException } from '@nestjs/common';
import * as QRCode from 'qrcode';
import type {
IWechatProvider,
WechatCodeSession,
WechatOAuthSession,
WechatWxaCodeUnlimitedInput,
} from './wechat.interface';
/**
@@ -81,4 +83,15 @@ export class WechatMockProvider implements IWechatProvider {
parsePayNotification(): never {
throw new NotImplementedException('FEATURE_DISABLED');
}
/** Mock:用普通二维码 PNG 占位,内容含 scene,便于本地联调上传 OSS */
async getWxaCodeUnlimited(input: WechatWxaCodeUnlimitedInput): Promise<Buffer> {
const scene = (input.scene ?? '').trim() || 'mock';
return QRCode.toBuffer(`mock-wxa://promo?scene=${encodeURIComponent(scene)}`, {
width: input.width ?? 430,
margin: 1,
type: 'png',
color: { dark: '#1f1a17', light: '#ffffff' },
});
}
}