#coding=utf-8

import datetime
import re

import tablib

from libs.utils import strfdate
from libs import utils
from django.db.models import Q, Sum
from .models import *

class OrderUpdate():
    @staticmethod
    def update_status():
        now_date = timezone.now().date()
        Order.objects.filter(
            Q(status=Order.DEFAULT),
            Q(
                Q(activity__enabled=False)|
                Q(activity__delete=True)|
                Q(activity__end_date__lt=now_date)
            )
        ).update(status=Order.FAIL)