implement payment cron job
This commit is contained in:
@@ -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 },
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user