4bdb09068c
C 端门店列表拼接省市区县地址;门店多银行账户与默认打款账户;子账号独立 sa_ 关联码及统计维度;同步 v4.0.18 开发文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
94 lines
3.0 KiB
TypeScript
94 lines
3.0 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, Post, Put, UseGuards } from '@nestjs/common';
|
|
import { IsNotEmpty, IsOptional, IsString, MaxLength } from 'class-validator';
|
|
import { JwtAuthGuard, AuthUser } from '../../common/guards/jwt-auth.guard';
|
|
import { ShopStoreGuard } from '../../common/guards/shop-store.guard';
|
|
import { ShopPrimaryGuard } from '../../common/guards/shop-primary.guard';
|
|
import { HqAuthGuard } from '../../common/guards/hq-auth.guard';
|
|
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
|
import { StoreBankService } from './store-bank.service';
|
|
|
|
class StoreBankDto {
|
|
@IsString()
|
|
@IsNotEmpty({ message: '请填写收款人' })
|
|
@MaxLength(64)
|
|
bankAccountName!: string;
|
|
|
|
@IsString()
|
|
@IsNotEmpty({ message: '请填写银行账号' })
|
|
@MaxLength(32)
|
|
bankAccountNo!: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(128)
|
|
bankBranch?: string;
|
|
}
|
|
|
|
/** 门店端:主账号管理本店收款账户(子账号只读) */
|
|
@Controller('shop/store/bank-accounts')
|
|
@UseGuards(JwtAuthGuard, ShopStoreGuard)
|
|
export class ShopStoreBankController {
|
|
constructor(private readonly storeBankService: StoreBankService) {}
|
|
|
|
@Get()
|
|
list(@CurrentUser() user: AuthUser) {
|
|
return this.storeBankService.list(user.storeId!);
|
|
}
|
|
|
|
@Post()
|
|
@UseGuards(ShopPrimaryGuard)
|
|
create(@CurrentUser() user: AuthUser, @Body() dto: StoreBankDto) {
|
|
return this.storeBankService.create(user.storeId!, dto);
|
|
}
|
|
|
|
@Put(':id')
|
|
@UseGuards(ShopPrimaryGuard)
|
|
update(@CurrentUser() user: AuthUser, @Param('id') id: string, @Body() dto: StoreBankDto) {
|
|
return this.storeBankService.update(user.storeId!, BigInt(id), dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@UseGuards(ShopPrimaryGuard)
|
|
remove(@CurrentUser() user: AuthUser, @Param('id') id: string) {
|
|
return this.storeBankService.remove(user.storeId!, BigInt(id));
|
|
}
|
|
|
|
@Post(':id/default')
|
|
@UseGuards(ShopPrimaryGuard)
|
|
setDefault(@CurrentUser() user: AuthUser, @Param('id') id: string) {
|
|
return this.storeBankService.setDefault(user.storeId!, BigInt(id));
|
|
}
|
|
}
|
|
|
|
/** 总部端:管理指定门店的收款账户 */
|
|
@Controller('admin/stores/:storeId/bank-accounts')
|
|
@UseGuards(HqAuthGuard)
|
|
export class AdminStoreBankController {
|
|
constructor(private readonly storeBankService: StoreBankService) {}
|
|
|
|
@Get()
|
|
list(@Param('storeId') storeId: string) {
|
|
return this.storeBankService.list(BigInt(storeId));
|
|
}
|
|
|
|
@Post()
|
|
create(@Param('storeId') storeId: string, @Body() dto: StoreBankDto) {
|
|
return this.storeBankService.create(BigInt(storeId), dto);
|
|
}
|
|
|
|
@Put(':id')
|
|
update(@Param('storeId') storeId: string, @Param('id') id: string, @Body() dto: StoreBankDto) {
|
|
return this.storeBankService.update(BigInt(storeId), BigInt(id), dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
remove(@Param('storeId') storeId: string, @Param('id') id: string) {
|
|
return this.storeBankService.remove(BigInt(storeId), BigInt(id));
|
|
}
|
|
|
|
@Post(':id/default')
|
|
setDefault(@Param('storeId') storeId: string, @Param('id') id: string) {
|
|
return this.storeBankService.setDefault(BigInt(storeId), BigInt(id));
|
|
}
|
|
}
|