update bank expiration logic
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import datetime
|
||||
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from .enum import BankType, PaymentStatus
|
||||
@@ -23,19 +24,28 @@ class BankManager(models.Manager):
|
||||
return self.get_queryset().active()
|
||||
|
||||
def update_expire_records(self):
|
||||
now = timezone.now()
|
||||
cutoff = now - datetime.timedelta(minutes=15)
|
||||
|
||||
count = (
|
||||
self.active()
|
||||
.filter(
|
||||
status=PaymentStatus.RETURN_FROM_BANK,
|
||||
update_at__lte=datetime.datetime.now() - datetime.timedelta(minutes=15),
|
||||
update_at__lte=cutoff,
|
||||
)
|
||||
.update(status=PaymentStatus.EXPIRE_VERIFY_PAYMENT)
|
||||
)
|
||||
|
||||
count = count + self.active().filter(
|
||||
status=PaymentStatus.REDIRECT_TO_BANK,
|
||||
update_at__lt=datetime.datetime.now() - datetime.timedelta(minutes=15),
|
||||
update_at__lt=cutoff,
|
||||
).update(status=PaymentStatus.EXPIRE_GATEWAY_TOKEN)
|
||||
|
||||
count = count + self.active().filter(
|
||||
status=PaymentStatus.WAITING,
|
||||
update_at__lt=cutoff,
|
||||
).update(status=PaymentStatus.EXPIRE_GATEWAY_TOKEN)
|
||||
|
||||
return count
|
||||
|
||||
def filter_return_from_bank(self):
|
||||
|
||||
Reference in New Issue
Block a user