# -*- coding: UTF-8 -*-

import os
import sys

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gaia.settings")
import django
django.setup()

from api.models import *
import datetime


def scan_seckill(seckill_id):
    f = open('/tmp/stock_%s.txt' % (datetime.datetime.now().strftime('%Y%m%d%H%M')), 'w')
    #seckill = Special.objects.get(id=seckill_id)
    for sss in SpecialSeckillService.objects.filter(special__id__in=seckill_id):
        line = '%s %s %s %s' % (sss.special.id, sss.service.id, sss.stock, sss.service.sell_num_limit)
        f.write("%s\n" % (line))

    f.close()


if __name__ == '__main__':
    #seckill_id = 570
    seckill_ids = [593, 594, 595, 596, 597, 598, 599, 600]
    scan_seckill(seckill_ids)
