webadmin端增加商铺日志

This commit is contained in:
2026-07-07 12:12:12 +08:00
parent e25b208545
commit 6572799264
20 changed files with 919 additions and 5 deletions
@@ -7,12 +7,16 @@ import { loadAppConfig } from '@dukang/shared-types';
import { PrismaService } from '../../common/prisma/prisma.module';
import { serializeBigInt } from '../../common/decorators/current-user.decorator';
import { mapStoreCompat } from '../../common/compat/v31-compat';
import { AnalyticsService } from '../analytics/analytics.service';
@Injectable()
export class StoreService {
private readonly config = loadAppConfig();
constructor(private readonly prisma: PrismaService) {}
constructor(
private readonly prisma: PrismaService,
private readonly analyticsService: AnalyticsService,
) {}
async listOpenStores(cityCode?: string) {
const where: Record<string, unknown> = { status: 'OPEN' };
@@ -213,6 +217,16 @@ export class StoreService {
data: { status },
include: { coverResource: true },
});
this.analyticsService.trackStoreOneSafe(undefined, 'PARTNER_H5', {
storeId,
eventName: 'store_status_change',
extraJson: {
status,
previousStatus: store.status,
actor: 'PARTNER',
partnerAccountId: partnerAccountId.toString(),
},
});
return serializeBigInt(mapStoreCompat(updated));
}
@@ -267,11 +281,22 @@ export class StoreService {
async updateShopStatus(storeAccountId: bigint, status: 'OPEN' | 'PAUSED') {
const account = await this.prisma.storeAccount.findUniqueOrThrow({
where: { id: storeAccountId },
include: { store: true },
});
const previousStatus = account.store.status;
const store = await this.prisma.store.update({
where: { id: account.storeId },
data: { status },
});
this.analyticsService.trackStoreOneSafe(storeAccountId, 'SHOP_H5', {
storeId: account.storeId,
eventName: 'store_status_change',
extraJson: {
status,
previousStatus,
actor: 'STORE',
},
});
return serializeBigInt(store);
}