# coding=utf-8
from django.core.management import BaseCommand

from api.models import SpecialSeckillService, Order


class Command(BaseCommand):
    """
    同步专题美购抽成数据, p
    """

    def handle(self, *args, **options):

        lsit_services = SpecialSeckillService.objects.filter(special_id=568)
        service_ids = []
        for item in lsit_services:
            service_ids.append(item.service.id)
        orders_list = Order.objects.filter(service_id__in=service_ids)
        for item in orders_list:
            item.discount = int(item.service.gengmei_price*0.05)
            item.save()
            print item.id

        print(u"执行完成!")
