#! /usr/bin/env python
# -*- coding: utf-8 -*-
# __author__: vv
# Date: 2019/10/15

from gm_types.gaia import DOCTOR_SECKILL_APPLY_STATUS


from api.models import DoctorSeckillApply
from django.core.management import BaseCommand


class Command(BaseCommand):

    def handle(self, *args, **options):
        docsecapps = DoctorSeckillApply.objects.filter(status=DOCTOR_SECKILL_APPLY_STATUS.PASS)
        total = docsecapps.count()
        print("total: ", total)
        for docsecapp in docsecapps:
            docsecapp.left_stock = docsecapp.stock
            docsecapp.save()
            print("left-------------------", total)
            total -= 1
        print("done!")