fix(h5-partner): resolve merge conflicts for auth and sub-accounts

Merge partner session model (AuthGate, ensureSession, WeChat OAuth in Context) with sub-account routing, admin partner-account tree CRUD, upload lock, and partner staff flows.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-10 11:24:48 +08:00
20 changed files with 378 additions and 264 deletions
@@ -10,13 +10,11 @@ export class CreatePartnerStaffDto {
@IsNotEmpty()
name: string;
/** 未传时服务端默认 INTERNAL */
@IsOptional()
@IsString()
@IsIn(Object.values(PartnerStaffRole))
staffRole: string;
@IsString()
@IsNotEmpty()
code: string;
staffRole?: string;
}
export class UpdatePartnerStaffDto {
@@ -3,18 +3,14 @@ import {
Injectable,
NotFoundException,
} from '@nestjs/common';
import { PartnerStaffRole, SmsScene } from '@dukang/shared-types';
import { PartnerStaffRole } from '@dukang/shared-types';
import { PrismaService } from '../../common/prisma/prisma.module';
import { serializeBigInt } from '../../common/decorators/current-user.decorator';
import { AuthService } from './auth.service';
import { CreatePartnerStaffDto, UpdatePartnerStaffDto } from './dto/partner-staff.dto';
@Injectable()
export class PartnerStaffService {
constructor(
private readonly prisma: PrismaService,
private readonly authService: AuthService,
) {}
constructor(private readonly prisma: PrismaService) {}
async listStaff(parentAccountId: bigint) {
const rows = await this.prisma.partnerAccount.findMany({
@@ -40,8 +36,6 @@ export class PartnerStaffService {
const existing = await this.prisma.partnerAccount.findUnique({ where: { phone } });
if (existing) throw new BadRequestException('该手机号已被使用');
await this.authService.verifySmsCode(phone, dto.code, SmsScene.PARTNER_STAFF_ADD);
const name = dto.name.trim();
if (!name) throw new BadRequestException('请填写真实姓名');
@@ -50,7 +44,7 @@ export class PartnerStaffService {
partnerId: parent.partnerId,
phone,
name,
staffRole: dto.staffRole as PartnerStaffRole,
staffRole: (dto.staffRole as PartnerStaffRole | undefined) ?? PartnerStaffRole.INTERNAL,
isPrimary: 0,
parentAccountId: parent.id,
status: 'DISABLED',
@@ -78,6 +78,9 @@ export class AdminPartnersService {
if (query.phone) where.phone = { contains: query.phone };
if (query.partnerId) where.partnerId = BigInt(query.partnerId);
if (query.status) where.status = query.status as Prisma.EnumAccountStatusFilter['equals'];
if (query.isPrimary === '0' || query.isPrimary === '1') {
where.isPrimary = Number(query.isPrimary);
}
const [items, total] = await Promise.all([
this.prisma.partnerAccount.findMany({
@@ -87,6 +90,7 @@ export class AdminPartnersService {
take: pageSize,
include: {
partner: { select: { id: true, companyName: true } },
parent: { select: { id: true, name: true, phone: true } },
},
}),
this.prisma.partnerAccount.count({ where }),
@@ -152,6 +156,7 @@ export class AdminPartnersService {
address: true,
},
},
parent: { select: { id: true, name: true, phone: true } },
},
});
if (!account) throw new NotFoundException('开城合伙人账号不存在');
@@ -123,6 +123,10 @@ export class AdminPartnerAccountsQueryDto extends PaginationQueryDto {
@IsOptional()
@IsString()
status?: string;
@IsOptional()
@IsString()
isPrimary?: string;
}
export class AdminBenefitCouponsQueryDto extends PaginationQueryDto {