diff --git a/src/Cron/cron.service.ts b/src/Cron/cron.service.ts index ee8bb13..deefdab 100644 --- a/src/Cron/cron.service.ts +++ b/src/Cron/cron.service.ts @@ -11,7 +11,7 @@ export class CronService { // cron every 1 minute to check schedule date status @Cron(CronExpression.EVERY_MINUTE) async checkScheduleDateStatus() { - Logger.log('Checking schedule date status') + Logger.log('Checking schedule date status', 'checkScheduleDateStatus') const schedules = await this.prisma.scheduleDate.findMany({ where: { end: { @@ -72,7 +72,7 @@ export class CronService { // cron every 1 minute to check payment status where created_at is more than 15 minutes @Cron(CronExpression.EVERY_MINUTE) async checkPaymentStatus() { - Logger.log('Checking payment status') + Logger.log('Checking payment status', 'checkPaymentStatus') const payments = await this.prisma.payment.findMany({ where: { status: PaymentStatus.PENDING, @@ -85,5 +85,11 @@ export class CronService { `Found ${payments.length} payments to update`, 'checkPaymentStatus', ) + for (const payment of payments) { + await this.prisma.payment.update({ + where: { id: payment.id }, + data: { status: PaymentStatus.CANCELLED }, + }) + } } }