# -*- coding: utf-8 -*- # !/usr/bin/env python import os,sys PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..') sys.path.insert(0, PROJECT_ROOT) os.environ.update({"DJANGO_SETTINGS_MODULE": "configs.production"}) import django django.setup() from apps.web.dealer.models import Dealer from apps.web.device.models import Device from apps.web.device.models import Group agentBlackList = ['15888766630','13966711825'] dealerBlackList = ['13827102928','18674568321','13930448219','15854515805'] #黑名单中的关闭掉 # agentIds = [str(agent.id) for agent in Agent.objects.filter(username__in = agentBlackList)] # dealerIds = [dealer for dealer in Dealer.objects.filter(agentId__in = agentIds)] dealerIds = [dealer for dealer in Dealer.objects.filter(username = '15854515805')] # dealerIds2 = [dealer for dealer in Dealer.objects.filter(username__in = dealerBlackList)] # dealerIds.extend(dealerIds2) groupIds = [str(_.id) for _ in Group.objects.filter(ownerId__in = dealerIds)] for groupId in groupIds: group = Group.get_group(groupId) if not group.get('beforeChargeUnpay',False): continue Group.update_group(groupId,beforeChargeUnpay = False) dealers = [dealer for dealer in Dealer.objects.all().only('id','username')] count = 0 dealerIds = [] for dealer in dealers: if dealer.username in blackList: continue devCount = Device.objects.filter(ownerId = str(dealer.id)).count() if devCount > 10: continue dealerIds.append(str(dealer.id)) print 'dealer id num',len(dealerIds) groupIds = [str(_.id) for _ in Group.objects.filter(ownerId__in = dealerIds)] for groupId in groupIds: group = Group.get_group(groupId) if not group.get('beforeChargeUnpay',False): continue Group.update_group(groupId,beforeChargeUnpay = False) print 'finished'