feat(admin): HQ手机号编辑、合伙人子账号日志与子账号H5体验
支持 HQ 账户改手机号(格式校验)、合伙人日志包含子账号且子账号不显示主账号信息;改手机号时清除微信绑定。合伙人 H5 子账号页签与我的页、录入门店底部按钮及上传失败提示。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Body, Controller, Get, Param, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { BadRequestException, Body, Controller, Get, Param, Post, Put, Query, UseGuards } from '@nestjs/common';
|
||||
import { IsOptional, IsString } from 'class-validator';
|
||||
import { SettlementService } from './settlement.service';
|
||||
import { JwtAuthGuard, AuthUser } from '../../common/guards/jwt-auth.guard';
|
||||
import { PartnerPrimaryGuard } from '../../common/guards/partner-primary.guard';
|
||||
@@ -9,6 +10,12 @@ import { HqOperation } from '../../common/hq-operation/hq-operation.decorator';
|
||||
import { HqOperationAction } from '../../common/hq-operation/hq-operation.constants';
|
||||
import { PrismaService } from '../../common/prisma/prisma.module';
|
||||
|
||||
class UpdatePartnerMeDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
name?: string;
|
||||
}
|
||||
|
||||
@Controller('partner/settlement')
|
||||
@UseGuards(JwtAuthGuard, PartnerPrimaryGuard)
|
||||
export class SettlementController {
|
||||
@@ -156,8 +163,26 @@ export class PartnerMeController {
|
||||
|
||||
@Get()
|
||||
async me(@CurrentUser() user: AuthUser) {
|
||||
return this.buildPartnerMe(user.actorId);
|
||||
}
|
||||
|
||||
@Put()
|
||||
async update(@CurrentUser() user: AuthUser, @Body() dto: UpdatePartnerMeDto) {
|
||||
if (dto.name !== undefined && !dto.name.trim()) {
|
||||
throw new BadRequestException('姓名不能为空');
|
||||
}
|
||||
if (dto.name !== undefined) {
|
||||
await this.prisma.partnerAccount.update({
|
||||
where: { id: user.actorId },
|
||||
data: { name: dto.name.trim() },
|
||||
});
|
||||
}
|
||||
return this.buildPartnerMe(user.actorId);
|
||||
}
|
||||
|
||||
private async buildPartnerMe(actorId: bigint) {
|
||||
const account = await this.prisma.partnerAccount.findUniqueOrThrow({
|
||||
where: { id: user.actorId },
|
||||
where: { id: actorId },
|
||||
});
|
||||
let primary = account;
|
||||
if (account.isPrimary !== 1 && account.parentAccountId) {
|
||||
|
||||
Reference in New Issue
Block a user