v4.0.19版本提交

This commit is contained in:
2026-09-10 09:56:50 +08:00
parent 5d0beb5733
commit 1867e7ea55
23 changed files with 420 additions and 41 deletions
@@ -152,7 +152,7 @@ export const SYSTEM_CONFIG_FIELDS: SystemConfigFieldMeta[] = [
group: G.wechat_mini,
type: 'string',
requiresRestart: false,
placeholder: '4.0.4',
placeholder: '4.0.19',
description: 'semver 格式(可带或不带 v);客户端低于此版本时提示更新',
},
{
@@ -483,6 +483,7 @@ export class WecomMessagePushService implements OnModuleInit {
userName: '好客用户',
userPhone: '13800008000',
userRemark: '大客户',
userSource: '推广码 · 秋季品鉴',
phoneMasked: '13800008000',
},
handlePath: '/orders?orderNo=DK202608200001',
@@ -0,0 +1,20 @@
import { describe, expect, it } from 'vitest';
import { WECOM_PUSH_TEMPLATE_DEFAULTS, WECOM_PUSH_TEMPLATE_LEGACY_BODIES } from './wecom-push-template.defaults';
describe('wecom-push-template.defaults', () => {
it('order.paid 默认正文在备注下含用户来源', () => {
const paid = WECOM_PUSH_TEMPLATE_DEFAULTS.find((t) => t.eventKey === 'order.paid');
expect(paid?.body).toContain('备注:{{userRemark}}');
expect(paid?.body).toContain('用户来源:{{userSource}}');
expect(paid?.body.indexOf('备注:{{userRemark}}') ?? -1).toBeLessThan(
paid?.body.indexOf('用户来源:{{userSource}}') ?? -1,
);
});
it('上一版含备注的默认文案列入 legacy 以便启动升级', () => {
const legacy = WECOM_PUSH_TEMPLATE_LEGACY_BODIES['order.paid'] ?? [];
expect(legacy.some((body) => body.includes('备注:{{userRemark}}') && !body.includes('用户来源'))).toBe(
true,
);
});
});
@@ -22,6 +22,7 @@ export const WECOM_PUSH_TEMPLATE_DEFAULTS: WecomTemplateDefault[] = [
'收货:{{receiverInfo}}',
'用户:{{userName}} {{userPhone}}',
'备注:{{userRemark}}',
'用户来源:{{userSource}}',
'时间:{{time}}',
'[{{handleLabel}}]({{handleUrl}})',
].join('\n'),
@@ -227,6 +228,19 @@ export const WECOM_PUSH_TEMPLATE_LEGACY_BODIES: Partial<Record<WecomTemplateEven
'时间:{{time}}',
'[{{handleLabel}}]({{handleUrl}})',
].join('\n'),
[
'**订单支付成功**',
'订单号:{{orderNo}}',
'实付:¥{{payAmount}}',
'城市:{{cityName}}',
'商品:{{skuSummary}}',
'物流:{{deliveryLabel}}',
'收货:{{receiverInfo}}',
'用户:{{userName}} {{userPhone}}',
'备注:{{userRemark}}',
'时间:{{time}}',
'[{{handleLabel}}]({{handleUrl}})',
].join('\n'),
],
'redeem.success': [
[
@@ -28,7 +28,7 @@ export class HealthController {
return {
status,
service: 'dukang-api',
version: 'prev1',
version: '4.0.19',
checks: { db, redis },
};
}
@@ -16,7 +16,7 @@ import {
validateMinPurchase,
validateShippingAddress,
} from '@dukang/domain';
import { loadAppConfig, ClientApp, WECHAT_AUTH_REQUIRED } from '@dukang/shared-types';
import { loadAppConfig, ClientApp, WECHAT_AUTH_REQUIRED, formatUserSourceLine } from '@dukang/shared-types';
import { PrismaService } from '../../common/prisma/prisma.module';
import { serializeBigInt } from '../../common/decorators/current-user.decorator';
import { AnalyticsService } from '../analytics/analytics.service';
@@ -521,7 +521,7 @@ export class TradeService {
where: { id: orderId },
include: {
city: { select: { name: true } },
user: { select: { phone: true, nickname: true, hqRemark: true } },
user: { select: { phone: true, nickname: true, hqRemark: true, sourceType: true, sourceLabel: true } },
},
});
if (!order) return;
@@ -554,6 +554,7 @@ export class TradeService {
const userName = order.user?.nickname?.trim() || '—';
const userPhone = (order.user?.phone || '').trim() || '—';
const userRemark = (order.user?.hqRemark || '').trim() || '—';
const userSource = formatUserSourceLine(order.user?.sourceType, order.user?.sourceLabel);
void this.wecomPush.dispatchEvent(
'order.paid',
{
@@ -566,6 +567,7 @@ export class TradeService {
userName,
userPhone,
userRemark,
userSource,
phoneMasked: userPhone,
},
{ handlePath: `/orders?orderNo=${encodeURIComponent(order.orderNo)}` },