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

@@ -158,6 +158,21 @@ export class DepositsService {
return this.repo.save(deposit);
}
async rejectRefund(id: number, reason: string, userId: number) {
const deposit = await this.repo.findOne({ where: { id } });
if (!deposit) throw new NotFoundException('押金记录不存在');
if (!deposit.refundStatus || deposit.refundStatus === 'refunded') {
throw new BadRequestException('未找到待审批的退款申请');
}
deposit.refundStatus = null;
deposit.refundApprovedBy = userId;
deposit.refundApprovedAt = new Date();
deposit.refundRejectedReason = reason;
return this.repo.save(deposit);
}
async findPendingRefunds() {
const baseWhere = await this.scope.filter({});
return this.repo.find({