门店账户多账号

This commit is contained in:
2026-07-12 12:24:34 +08:00
parent 06b1cb22e0
commit 54a15d6da7
39 changed files with 1962 additions and 311 deletions
@@ -2,6 +2,7 @@ import { Body, Controller, Get, Param, Post, Query, UseGuards } from '@nestjs/co
import { SettlementService } from './settlement.service';
import { JwtAuthGuard, AuthUser } from '../../common/guards/jwt-auth.guard';
import { PartnerPrimaryGuard } from '../../common/guards/partner-primary.guard';
import { ShopStoreGuard } from '../../common/guards/shop-store.guard';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import { HqAuthGuard } from '../../common/guards/hq-auth.guard';
import { HqOperation } from '../../common/hq-operation/hq-operation.decorator';
@@ -20,7 +21,7 @@ export class SettlementController {
}
@Controller('shop/payouts')
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, ShopStoreGuard)
export class ShopPayoutController {
constructor(private readonly settlementService: SettlementService) {}
@@ -30,7 +31,12 @@ export class ShopPayoutController {
@Query('page') page = '1',
@Query('pageSize') pageSize = '20',
) {
return this.settlementService.listShopPayouts(user.actorId, Number(page), Number(pageSize));
return this.settlementService.listShopPayouts(
user.actorId,
user.storeId!,
Number(page),
Number(pageSize),
);
}
}
@@ -54,11 +54,11 @@ export class SettlementService {
return serializeBigInt(payout);
}
async listShopPayouts(storeAccountId: bigint, page = 1, pageSize = 20) {
const account = await this.prisma.storeAccount.findUniqueOrThrow({
where: { id: storeAccountId },
async listShopPayouts(storeAccountId: bigint, storeId: bigint, page = 1, pageSize = 20) {
await this.prisma.storeAccountStore.findUniqueOrThrow({
where: { storeAccountId_storeId: { storeAccountId, storeId } },
});
const where = { storeId: account.storeId };
const where = { storeId };
const [items, total] = await Promise.all([
this.prisma.storePayout.findMany({
where,