feat(settlement): 门店未出账手动提现与总部审核(OPT-010)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,6 +5,7 @@ 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 { ShopPrimaryGuard } from '../../common/guards/shop-primary.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';
|
||||
@@ -59,6 +60,98 @@ export class ShopPayoutController {
|
||||
}
|
||||
}
|
||||
|
||||
@Controller('shop/withdraw')
|
||||
@UseGuards(JwtAuthGuard, ShopStoreGuard)
|
||||
export class ShopWithdrawController {
|
||||
constructor(private readonly settlementService: SettlementService) {}
|
||||
|
||||
@Get('summary')
|
||||
summary(@CurrentUser() user: AuthUser) {
|
||||
return this.settlementService.getShopWithdrawSummary(user.actorId, user.storeId!);
|
||||
}
|
||||
|
||||
@Get('requests')
|
||||
requests(
|
||||
@CurrentUser() user: AuthUser,
|
||||
@Query('page') page = '1',
|
||||
@Query('pageSize') pageSize = '20',
|
||||
@Query('status') status?: string,
|
||||
) {
|
||||
return this.settlementService.listShopWithdrawRequests(user.actorId, user.storeId!, {
|
||||
page: Number(page),
|
||||
pageSize: Number(pageSize),
|
||||
status,
|
||||
});
|
||||
}
|
||||
|
||||
@Post()
|
||||
@UseGuards(ShopPrimaryGuard)
|
||||
apply(@CurrentUser() user: AuthUser, @Body() body: { amount?: number }) {
|
||||
return this.settlementService.createStoreWithdrawRequest(user.actorId, user.storeId!, body);
|
||||
}
|
||||
}
|
||||
|
||||
@Controller('admin/store-withdrawals')
|
||||
@UseGuards(HqAuthGuard)
|
||||
export class AdminStoreWithdrawController {
|
||||
constructor(private readonly settlementService: SettlementService) {}
|
||||
|
||||
@Get('overdue-summary')
|
||||
overdueSummary() {
|
||||
return this.settlementService.getStoreWithdrawOverdueSummary();
|
||||
}
|
||||
|
||||
@Get()
|
||||
list(@Query() query: Record<string, string>) {
|
||||
return this.settlementService.listAdminStoreWithdrawals({
|
||||
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(':id')
|
||||
detail(@Param('id') id: string) {
|
||||
return this.settlementService.getAdminStoreWithdrawal(BigInt(id));
|
||||
}
|
||||
|
||||
@Post(':id/approve')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.STORE_WITHDRAW_APPROVE,
|
||||
refType: 'STORE_WITHDRAW',
|
||||
refIdParam: 'id',
|
||||
includeBody: true,
|
||||
})
|
||||
approve(
|
||||
@CurrentUser() user: AuthUser,
|
||||
@Param('id') id: string,
|
||||
@Body() body: { paymentRef?: string },
|
||||
) {
|
||||
return this.settlementService.approveStoreWithdraw(BigInt(id), user.actorId, body);
|
||||
}
|
||||
|
||||
@Post(':id/reject')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.STORE_WITHDRAW_REJECT,
|
||||
refType: 'STORE_WITHDRAW',
|
||||
refIdParam: 'id',
|
||||
includeBody: true,
|
||||
})
|
||||
reject(
|
||||
@CurrentUser() user: AuthUser,
|
||||
@Param('id') id: string,
|
||||
@Body() body: { reason?: string },
|
||||
) {
|
||||
if (!body?.reason?.trim()) {
|
||||
throw new BadRequestException('请填写驳回理由');
|
||||
}
|
||||
return this.settlementService.rejectStoreWithdraw(BigInt(id), user.actorId, body.reason);
|
||||
}
|
||||
}
|
||||
|
||||
@Controller('admin/store-payouts')
|
||||
@UseGuards(HqAuthGuard)
|
||||
export class AdminStorePayoutController {
|
||||
|
||||
Reference in New Issue
Block a user