@@ -1,6 +1,7 @@
|
||||
import {
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
Logger,
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
import { Prisma } from '@prisma/client';
|
||||
@@ -13,14 +14,18 @@ import {
|
||||
import { PrismaService } from '../../common/prisma/prisma.module';
|
||||
import { serializeBigInt } from '../../common/decorators/current-user.decorator';
|
||||
import { StoreService } from './store.service';
|
||||
import { WecomMessagePushService } from '../../integrations/wecom/wecom-message-push.service';
|
||||
|
||||
type PackageInput = Record<string, unknown>;
|
||||
|
||||
@Injectable()
|
||||
export class StorePackageService {
|
||||
private readonly logger = new Logger(StorePackageService.name);
|
||||
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly storeService: StoreService,
|
||||
private readonly wecomPush: WecomMessagePushService,
|
||||
) {}
|
||||
|
||||
normalizePackages(raw: unknown): StorePackageItemDto[] {
|
||||
@@ -181,6 +186,34 @@ export class StorePackageService {
|
||||
submitterId,
|
||||
},
|
||||
});
|
||||
|
||||
const store = await this.prisma.store.findUnique({
|
||||
where: { id: storeId },
|
||||
select: { name: true, cityName: true },
|
||||
});
|
||||
const now = new Date().toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' });
|
||||
const submitterLabel = submitterType === 'PARTNER' ? '合伙人' : '门店';
|
||||
void this.wecomPush
|
||||
.dispatchMarkdown(
|
||||
'store.package_audit_pending',
|
||||
[
|
||||
'**套餐变更待审核**',
|
||||
`门店:${store?.name ?? storeId}`,
|
||||
store?.cityName ? `城市:${store.cityName}` : null,
|
||||
`提交端:${submitterLabel}`,
|
||||
`套餐条数:${packages.length}`,
|
||||
`时间:${now}`,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('\n'),
|
||||
{ applyMention: false },
|
||||
)
|
||||
.catch((e) =>
|
||||
this.logger.warn(
|
||||
`store.package_audit_pending wecom push failed: ${e instanceof Error ? e.message : String(e)}`,
|
||||
),
|
||||
);
|
||||
|
||||
return serializeBigInt({
|
||||
id: req.id.toString(),
|
||||
status: req.status,
|
||||
|
||||
Reference in New Issue
Block a user