feat;提交管理端和城市合伙人端

This commit is contained in:
ljy
2026-07-05 23:48:20 +08:00
parent fecfc61ec5
commit 569becedaa
73 changed files with 10150 additions and 80 deletions
@@ -268,6 +268,48 @@ export class AuthService {
});
}
async loginHqWechat(code: string, clientApp: ClientApp, platform: 'h5' | 'mini' = 'h5') {
this.assertWechatEnabled();
const session =
platform === 'mini'
? await this.wechatProvider.code2Session(code)
: await this.wechatProvider.oauth2AccessToken(code);
let account = await this.prisma.hqAccount.findFirst({
where: { wxOpenId: session.openId },
});
if (!account && this.wechatProvider.isMock()) {
// preV1 Mock:无绑定微信时回落到演示超管账号
account = await this.prisma.hqAccount.findFirst({
where: { status: 'ACTIVE' },
orderBy: [{ adminRole: 'asc' }, { id: 'asc' }],
});
}
if (!account) {
throw new BadRequestException('首次登录请使用手机验证码,登录后将自动关联微信');
}
if (account.status !== 'ACTIVE') throw new BadRequestException('账号已停用');
account = await this.prisma.hqAccount.update({
where: { id: account.id },
data: {
wxOpenId: session.openId,
wxUnionId: session.unionId ?? account.wxUnionId,
lastLoginAt: new Date(),
},
});
return this.issueToken('HQ', account.id, clientApp, false, undefined, undefined, undefined, undefined, {
id: account.id.toString(),
phone: account.phone,
name: account.name,
adminRole: account.adminRole,
status: account.status,
});
}
async getMe(actorType: string, actorId: bigint) {
if (actorType === 'USER') {
const user = await this.assertActiveUser(actorId);
@@ -555,6 +597,15 @@ export class AuthService {
include: { partner: true },
});
if (!account && this.wechatProvider.isMock()) {
// preV1 Mock:无绑定微信时回落到演示主账号,方便一键授权登录
account = await this.prisma.partnerAccount.findFirst({
where: { status: 'ACTIVE' },
orderBy: [{ isPrimary: 'desc' }, { id: 'asc' }],
include: { partner: true },
});
}
if (!account) {
throw new BadRequestException('首次登录请使用手机验证码,登录后将自动关联微信');
}