feat(deposits): add refund rejection path with reason

This commit is contained in:
2026-07-06 09:44:43 +08:00
parent 3717531bb3
commit 6ba7213cc4
4 changed files with 146 additions and 15 deletions

View File

@@ -95,8 +95,22 @@ export class DepositsController {
async addInstallment(
@Param('id') id: string,
@Body() body: { amount: number; dueDate: string },
@Request() req: { user?: { id: number; username: string }; headers?: Record<string, string> },
) {
return this.service.addInstallment(+id, body.amount, body.dueDate);
const { ipAddress, userAgent } = extractRequestInfo(req);
const result = await this.service.addInstallment(+id, body.amount, body.dueDate);
await this.logService.log({
userId: req.user?.id,
username: req.user?.username,
module: '押金管理',
action: '新增分期',
targetId: result.id,
targetType: 'deposit-installment',
detail: `押金${id} 新增分期 ¥${result.amount}`,
ipAddress,
userAgent,
});
return result;
}
@Put('installments/:installmentId')
@@ -104,14 +118,44 @@ export class DepositsController {
async updateInstallment(
@Param('installmentId') installmentId: string,
@Body() body: { paidDate?: string; status?: string },
@Request() req: { user?: { id: number; username: string }; headers?: Record<string, string> },
) {
return this.service.updateInstallment(+installmentId, body);
const { ipAddress, userAgent } = extractRequestInfo(req);
const result = await this.service.updateInstallment(+installmentId, body);
await this.logService.log({
userId: req.user?.id,
username: req.user?.username,
module: '押金管理',
action: '更新分期',
targetId: +installmentId,
targetType: 'deposit-installment',
detail: `更新分期${installmentId}, 状态:${result.status ?? '-'}, 实付日:${result.paidDate ?? '-'}`,
ipAddress,
userAgent,
});
return result;
}
@Delete('installments/:installmentId')
@RequirePermission('deposit:delete')
async deleteInstallment(@Param('installmentId') installmentId: string) {
return this.service.deleteInstallment(+installmentId);
async deleteInstallment(
@Param('installmentId') installmentId: string,
@Request() req: { user?: { id: number; username: string }; headers?: Record<string, string> },
) {
const { ipAddress, userAgent } = extractRequestInfo(req);
const result = await this.service.deleteInstallment(+installmentId);
await this.logService.log({
userId: req.user?.id,
username: req.user?.username,
module: '押金管理',
action: '删除分期',
targetId: +installmentId,
targetType: 'deposit-installment',
detail: `删除分期${installmentId}`,
ipAddress,
userAgent,
});
return result;
}
@Put(':id/refund')
@@ -183,6 +227,29 @@ export class DepositsController {
return result;
}
@Put(':id/reject-refund')
@RequirePermission('deposit:approve')
async rejectRefund(
@Param('id') id: string,
@Body() body: { reason: string },
@Request() req: any,
) {
const { ipAddress, userAgent } = extractRequestInfo(req);
const result = await this.service.rejectRefund(+id, body.reason, req.user?.id);
await this.logService.log({
userId: req.user?.id,
username: req.user?.username,
module: '押金管理',
action: '驳回退款',
targetId: +id,
targetType: 'deposit',
detail: `驳回原因:${body.reason}`,
ipAddress,
userAgent,
});
return result;
}
@Delete(':id')
@RequirePermission('deposit:delete')
async remove(@Param('id') id: string, @Request() req: any) {