feat(settlement): redesign factory/partner/store statement bills
CI / verify (pull_request) Has been cancelled
CI / verify (pull_request) Has been cancelled
Add WineryBill/StoreBill tables, partner review-send-confirm flow, daily/monthly cron, and admin multi-select confirm with status filters. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -43,8 +43,8 @@ export class AdminDashboardService {
|
||||
this.prisma.redeemRecord.count({ where: { createdAt: { gte: todayStart } } }),
|
||||
this.prisma.orderDelivery.count(),
|
||||
this.prisma.storePayout.count({ where: { status: 'PENDING' } }),
|
||||
this.prisma.partnerBill.count({ where: { status: 'CONFIRMED' } }),
|
||||
this.prisma.partnerBill.count({ where: { status: 'DRAFT' } }),
|
||||
this.prisma.partnerBill.count({ where: { status: 'UNPAID' } }),
|
||||
this.prisma.partnerBill.count({ where: { status: 'PENDING_REVIEW' } }),
|
||||
this.prisma.commonTicket.count({ where: { status: { in: ['PENDING', 'OPEN'] } } }),
|
||||
]);
|
||||
|
||||
|
||||
@@ -28,6 +28,11 @@ export class SettlementController {
|
||||
return this.settlementService.listPartnerBills(user.actorId);
|
||||
}
|
||||
|
||||
@Post('bills/batch-confirm')
|
||||
batchConfirm(@CurrentUser() user: AuthUser, @Body() body: { ids: string[] }) {
|
||||
return this.settlementService.batchPartnerConfirmBills(user.actorId, body.ids ?? []);
|
||||
}
|
||||
|
||||
@Post('bills/:id/confirm')
|
||||
confirm(@CurrentUser() user: AuthUser, @Param('id') id: string) {
|
||||
return this.settlementService.partnerConfirmBill(user.actorId, BigInt(id));
|
||||
@@ -126,6 +131,65 @@ export class AdminStorePayoutController {
|
||||
}
|
||||
}
|
||||
|
||||
@Controller('admin/store-bills')
|
||||
@UseGuards(HqAuthGuard)
|
||||
export class AdminStoreBillController {
|
||||
constructor(private readonly settlementService: SettlementService) {}
|
||||
|
||||
@Get()
|
||||
list(@Query() query: Record<string, string>) {
|
||||
return this.settlementService.listAdminStoreBills({
|
||||
page: query.page ? Number(query.page) : 1,
|
||||
pageSize: query.pageSize ? Number(query.pageSize) : 20,
|
||||
status: query.status,
|
||||
storeId: query.storeId,
|
||||
dateFrom: query.dateFrom,
|
||||
dateTo: query.dateTo,
|
||||
});
|
||||
}
|
||||
|
||||
@Get('export')
|
||||
export(@Query() query: Record<string, string>) {
|
||||
return this.settlementService.exportAdminStoreBills({
|
||||
status: query.status,
|
||||
storeId: query.storeId,
|
||||
dateFrom: query.dateFrom,
|
||||
dateTo: query.dateTo,
|
||||
});
|
||||
}
|
||||
|
||||
@Post('generate')
|
||||
generate() {
|
||||
return this.settlementService.generateStoreBillsForDay();
|
||||
}
|
||||
|
||||
@Post('batch-confirm')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.STORE_BILL_BATCH_CONFIRM,
|
||||
refType: 'STORE_BILL',
|
||||
batch: true,
|
||||
includeBody: true,
|
||||
})
|
||||
batchConfirm(@Body() body: { ids: string[] }) {
|
||||
return this.settlementService.batchConfirmStoreBills(body.ids ?? []);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
detail(@Param('id') id: string) {
|
||||
return this.settlementService.getAdminStoreBill(BigInt(id));
|
||||
}
|
||||
|
||||
@Post(':id/confirm')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.STORE_BILL_CONFIRM,
|
||||
refType: 'STORE_BILL',
|
||||
refIdParam: 'id',
|
||||
})
|
||||
confirm(@Param('id') id: string) {
|
||||
return this.settlementService.confirmStoreBill(BigInt(id));
|
||||
}
|
||||
}
|
||||
|
||||
@Controller('admin/partner-bills')
|
||||
@UseGuards(HqAuthGuard)
|
||||
export class AdminPartnerBillController {
|
||||
@@ -175,11 +239,43 @@ export class AdminPartnerBillController {
|
||||
});
|
||||
}
|
||||
|
||||
@Post('batch-send')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.PARTNER_BILL_BATCH_SEND,
|
||||
refType: 'PARTNER_BILL',
|
||||
batch: true,
|
||||
includeBody: true,
|
||||
})
|
||||
batchSend(@Body() body: { ids: string[] }) {
|
||||
return this.settlementService.batchSendPartnerBills(body.ids ?? []);
|
||||
}
|
||||
|
||||
@Post('batch-mark-paid')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.PARTNER_BILL_BATCH_MARK_PAID,
|
||||
refType: 'PARTNER_BILL',
|
||||
batch: true,
|
||||
includeBody: true,
|
||||
})
|
||||
batchMarkPaid(@Body() body: { ids: string[] }) {
|
||||
return this.settlementService.batchMarkPartnerBillsPaid(body.ids ?? []);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
detail(@Param('id') id: string) {
|
||||
return this.settlementService.getAdminPartnerBill(BigInt(id));
|
||||
}
|
||||
|
||||
@Post(':id/send')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.PARTNER_BILL_SEND,
|
||||
refType: 'PARTNER_BILL',
|
||||
refIdParam: 'id',
|
||||
})
|
||||
send(@Param('id') id: string) {
|
||||
return this.settlementService.sendPartnerBill(BigInt(id));
|
||||
}
|
||||
|
||||
@Post(':id/confirm')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.PARTNER_BILL_CONFIRM,
|
||||
@@ -226,20 +322,55 @@ export class AdminWineryBillController {
|
||||
return this.settlementService.listAdminWineryBills({
|
||||
page: query.page ? Number(query.page) : 1,
|
||||
pageSize: query.pageSize ? Number(query.pageSize) : 20,
|
||||
status: query.status,
|
||||
dateFrom: query.dateFrom,
|
||||
dateTo: query.dateTo,
|
||||
year: query.year ? Number(query.year) : undefined,
|
||||
month: query.month ? Number(query.month) : undefined,
|
||||
deliveryType: query.deliveryType,
|
||||
});
|
||||
}
|
||||
|
||||
@Get('export')
|
||||
export(@Query() query: Record<string, string>) {
|
||||
return this.settlementService.exportAdminWineryBills({
|
||||
status: query.status,
|
||||
dateFrom: query.dateFrom,
|
||||
dateTo: query.dateTo,
|
||||
year: query.year ? Number(query.year) : undefined,
|
||||
month: query.month ? Number(query.month) : undefined,
|
||||
deliveryType: query.deliveryType,
|
||||
});
|
||||
}
|
||||
|
||||
@Post('generate')
|
||||
generate() {
|
||||
return this.settlementService.generateWineryBillForDay();
|
||||
}
|
||||
|
||||
@Post('batch-confirm')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.WINERY_BILL_BATCH_CONFIRM,
|
||||
refType: 'WINERY_BILL',
|
||||
batch: true,
|
||||
includeBody: true,
|
||||
})
|
||||
batchConfirm(@Body() body: { ids: string[] }) {
|
||||
return this.settlementService.batchConfirmWineryBills(body.ids ?? []);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
detail(@Param('id') id: string) {
|
||||
return this.settlementService.getAdminWineryBill(BigInt(id));
|
||||
}
|
||||
|
||||
@Post(':id/confirm')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.WINERY_BILL_CONFIRM,
|
||||
refType: 'WINERY_BILL',
|
||||
refIdParam: 'id',
|
||||
})
|
||||
confirm(@Param('id') id: string) {
|
||||
return this.settlementService.confirmWineryBill(BigInt(id));
|
||||
}
|
||||
}
|
||||
|
||||
@Controller('partner/me')
|
||||
@@ -280,7 +411,6 @@ export class PartnerMeController {
|
||||
});
|
||||
}
|
||||
|
||||
// 门店类子账号若未配置权限,补齐开店/门店管理,便于开闭店与重传资料
|
||||
if (account.isPrimary !== 1) {
|
||||
const perms = Array.isArray(account.permissions) ? (account.permissions as string[]) : [];
|
||||
const hasStorePerm = perms.includes('store:create') || perms.includes('store:manage');
|
||||
|
||||
@@ -5,6 +5,7 @@ import { CityScopeModule } from '../city-scope/city-scope.module';
|
||||
import { SettlementService } from './settlement.service';
|
||||
import {
|
||||
AdminPartnerBillController,
|
||||
AdminStoreBillController,
|
||||
AdminStorePayoutController,
|
||||
AdminWineryBillController,
|
||||
PartnerMeController,
|
||||
@@ -19,6 +20,7 @@ import {
|
||||
PartnerMeController,
|
||||
ShopPayoutController,
|
||||
AdminStorePayoutController,
|
||||
AdminStoreBillController,
|
||||
AdminPartnerBillController,
|
||||
AdminWineryBillController,
|
||||
],
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user